memory: ti-ddrss: Add MR4 temperature-driven refresh rate driver
RFC PATCH 6/22 memory: ti-ddrss: Add MR4 temperature-driven refresh rate driver
From: Santhosh Kumar K <[email protected]>
Add a driver to monitor LPDDR4 temperature via the MR4 register and adjust DDR refresh timing (tRAS_MAX, tREF) in the kernel on every TUF interrupt following JEDEC recommendations. Exposes refresh_status (RO) and auto_adjust (RW) sysfs attributes.
--- drivers/memory/Kconfig | 19 ++ drivers/memory/Makefile | 1 + drivers/memory/ti-ddrss-mr4.c | 322 ++++++++++++++++++++++++++++++++++ 3 files changed, 342 insertions(+) create mode 100644 drivers/memory/ti-ddrss-mr4.c
drivers/memory/Kconfig +19 -0
@@ -231,6 +231,25 @@ config STM32_OMM - chip select selection override. - the time between 2 transactions in multiplexed mode. +config K3_DDR_MR4 + tristate "Texas Instruments K3 DDR MR4 refresh rate driver" + depends on ARCH_K3 || COMPILE_TEST + depends on MFD_TI_DDRSS + help + Say Y here to enable automatic DDR refresh rate adjustment for TI K3 + SoCs (AM62x, AM62Ax, AM62Px, AM64x, J721E, J7200, J721S2, J784S4). + + On every TUF interrupt the driver reads the MR4 temperature sensor, + takes the maximum across all channels, and updates tRAS_MAX and tREF + for all three Frequency Set Points. The auto_adjust sysfs attribute + allows userspace to disable kernel adjustment and observe the MR4 + state via refresh_status. + + This extends the LPDDR MR4 derating pattern from drivers/memory/emif.c + (LPDDR2) to LPDDR4 on Cadence controllers. + + To compile as a module: the module will be called ti-ddrss-mr4. + source "drivers/memory/samsung/Kconfig" source "drivers/memory/tegra/Kconfig"
drivers/memory/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_SAMSUNG_MC) += samsung/ obj-$(CONFIG_TEGRA_MC) += tegra/ obj-$(CONFIG_TI_EMIF_SRAM) += ti-emif-sram.o obj-$(CONFIG_FPGA_DFL_EMIF) += dfl-emif.o +obj-$(CONFIG_K3_DDR_MR4) += ti-ddrss-mr4.o ti-emif-sram-objs := ti-emif-pm.o ti-emif-sram-pm.o
drivers/memory/ti-ddrss-mr4.c new file +322 -0
322 lines not on this page · raw message
Signature · 1 line
2.34.1
Hello,
drivers/memory/ti-ddrss-mr4.c line 12
Quoted 2 lines · MANNURU VENKATESWARLU
drivers/memory/ti-ddrss-mr4.c new file +2
-0+#include <linux/mfd/ti-ddrss.h> +#include <linux/mod_devicetable.h>
Please drop this header. platform_device_id is provided by <linux/platform_device.h>, so the explicit include isn't needed.
The mod_devicetable.h header will go away soon.
drivers/memory/ti-ddrss-mr4.c line 307
Quoted 7 lines
drivers/memory/ti-ddrss-mr4.c new file +6
-0+#include <linux/module.h> +#include <linux/platform_device.h> +static const struct platform_device_id k3_ddr_mr4_id[] = { + {"ti-ddrss-mr4" ,0 }, + {} +};
Please make this:
static const struct platform_device_id k3_ddr_mr4_id[] = {
{ .name = "ti-ddrss-mr4" },
{ }
};drivers/memory/ti-ddrss-mr4.c line 316
Quoted 9 lines
drivers/memory/ti-ddrss-mr4.c new file +9
-0+MODULE_DEVICE_TABLE (platform, k3_ddr_mr4_id); + +static struct platform_driver k3_ddr_mr4_driver = { + .driver = { + .name ="ti-ddrss-mr4" , + .dev_groups = k3_ddr_mr4_groups, + }, + .probe = k3_ddr_mr4_probe, + .id_table = k3_ddr_mr4_id,
I'm not a fan of aligned =. These tend to diverge over time. And sometimes they are not even aligned from the start ... If you ask me, just use a single space before the =.
Best regards
Uwe
Hi Uwe,
Thank you for the review.
Quoted 9 lines · Uwe Kleine-König
Hello,
drivers/memory/ti-ddrss-mr4.c line 12
Quoted 2 lines · MANNURU VENKATESWARLU
drivers/memory/ti-ddrss-mr4.c new file +2
-0+#include <linux/mfd/ti-ddrss.h> +#include <linux/mod_devicetable.h> Please drop this header.
platform_device_idis provided by <linux/platform_device.h>, so the explicit include isn't needed.The
mod_devicetable.hheader will go away soon.
Understood, will remove this.
Quoted 10 lines
drivers/memory/ti-ddrss-mr4.c line 307
Quoted 8 lines
drivers/memory/ti-ddrss-mr4.c new file +6
-0+#include <linux/module.h> +#include <linux/platform_device.h> +static const struct platform_device_id k3_ddr_mr4_id[] = { + {"ti-ddrss-mr4" ,0 }, + {} +};Please make this:
Quoted 4 lines
static const struct platform_device_id k3_ddr_mr4_id[] = {
{ .name = "ti-ddrss-mr4" },
{ }
};Okay, will make this.
Quoted 4 lines
Quoted 4 lines
drivers/memory/ti-ddrss-mr4.c new file +4
-0+MODULE_DEVICE_TABLE (platform, k3_ddr_mr4_id); + +static struct platform_driver k3_ddr_mr4_driver = { + .driver = {
Quoted 8 lines
drivers/memory/ti-ddrss-mr4.c line 316
Quoted 5 lines
drivers/memory/ti-ddrss-mr4.c new file +5
-0+ .name = "ti-ddrss-mr4", + .dev_groups = k3_ddr_mr4_groups, + }, + .probe = k3_ddr_mr4_probe, + .id_table = k3_ddr_mr4_id,I'm not a fan of aligned
=. These tend to diverge over time. And sometimes they are not even aligned from the start ... If you ask me, just use a single space before the=.
Agreed, will use a single space before = throughout
Quoted 3 lines
Best regards
Uwe
Thanks,
VENKEY