Skip to content

Commit f226041

Browse files
dgerlachnmenon
authored andcommitted
soc: ti: wkup_m3_ipc: Add support for toggling VTT regulator
Some boards like the AM335x EVM-SK and AM437x GP EVM provide software control via a GPIO pin to toggle the DDR VTT regulator to reduce power consumption in low power states. The VTT regulator should be disabled after enabling self-refresh on suspend, and should be enabled before disabling self-refresh on resume. This is to allow proper self-refresh entry/exit commands to be transmitted to the memory. The "ti,vtt-gpio-pin" device tree property in the wkup_m3_ipc node specifies which GPIO pin to use. This property is communicated to the Wakeup Cortex M3 co-processor where the actual toggling of the GPIO pin happens in CM3 firmware [1]. Please note that the GPIO pin must be on the GPIO0 module as that module is in the wakeup power domain. [1] https://git.ti.com/cgit/processor-firmware/ti-amx3-cm3-pm-firmware/tree/src/pm_services/ddr.c?h=08.02.00.006#n190 Signed-off-by: Dave Gerlach <d-gerlach@ti.com> Signed-off-by: Keerthy <j-keerthy@ti.com> [dfustini: remove the unnecessary "ti,needs-vtt-toggle" property] Signed-off-by: Drew Fustini <dfustini@baylibre.com> Signed-off-by: Nishanth Menon <nm@ti.com> Link: https://lore.kernel.org/r/20220409211215.2529387-3-dfustini@baylibre.com
1 parent 12eeb74 commit f226041

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

drivers/soc/ti/wkup_m3_ipc.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
#define M3_FW_VERSION_MASK 0xffff
4141
#define M3_WAKE_SRC_MASK 0xff
4242

43+
#define IPC_MEM_TYPE_SHIFT (0x0)
44+
#define IPC_MEM_TYPE_MASK (0x7 << 0)
45+
#define IPC_VTT_STAT_SHIFT (0x3)
46+
#define IPC_VTT_STAT_MASK (0x1 << 3)
47+
#define IPC_VTT_GPIO_PIN_SHIFT (0x4)
48+
#define IPC_VTT_GPIO_PIN_MASK (0x3f << 4)
49+
4350
#define M3_STATE_UNKNOWN 0
4451
#define M3_STATE_RESET 1
4552
#define M3_STATE_INITED 2
@@ -215,6 +222,12 @@ static int wkup_m3_is_available(struct wkup_m3_ipc *m3_ipc)
215222
(m3_ipc->state != M3_STATE_UNKNOWN));
216223
}
217224

225+
static void wkup_m3_set_vtt_gpio(struct wkup_m3_ipc *m3_ipc, int gpio)
226+
{
227+
m3_ipc->vtt_conf = (1 << IPC_VTT_STAT_SHIFT) |
228+
(gpio << IPC_VTT_GPIO_PIN_SHIFT);
229+
}
230+
218231
/* Public functions */
219232
/**
220233
* wkup_m3_set_mem_type - Pass wkup_m3 which type of memory is in use
@@ -294,7 +307,8 @@ static int wkup_m3_prepare_low_power(struct wkup_m3_ipc *m3_ipc, int state)
294307
/* Program each required IPC register then write defaults to others */
295308
wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->resume_addr, 0);
296309
wkup_m3_ctrl_ipc_write(m3_ipc, m3_power_state, 1);
297-
wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type, 4);
310+
wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type |
311+
m3_ipc->vtt_conf, 4);
298312

299313
wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 2);
300314
wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 3);
@@ -433,12 +447,13 @@ static int wkup_m3_rproc_boot_thread(void *arg)
433447
static int wkup_m3_ipc_probe(struct platform_device *pdev)
434448
{
435449
struct device *dev = &pdev->dev;
436-
int irq, ret;
450+
int irq, ret, temp;
437451
phandle rproc_phandle;
438452
struct rproc *m3_rproc;
439453
struct resource *res;
440454
struct task_struct *task;
441455
struct wkup_m3_ipc *m3_ipc;
456+
struct device_node *np = dev->of_node;
442457

443458
m3_ipc = devm_kzalloc(dev, sizeof(*m3_ipc), GFP_KERNEL);
444459
if (!m3_ipc)
@@ -494,6 +509,13 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
494509

495510
m3_ipc->ops = &ipc_ops;
496511

512+
if (!of_property_read_u32(np, "ti,vtt-gpio-pin", &temp)) {
513+
if (temp >= 0 && temp <= 31)
514+
wkup_m3_set_vtt_gpio(m3_ipc, temp);
515+
else
516+
dev_warn(dev, "Invalid VTT GPIO(%d) pin\n", temp);
517+
}
518+
497519
/*
498520
* Wait for firmware loading completion in a thread so we
499521
* can boot the wkup_m3 as soon as it's ready without holding

include/linux/wkup_m3_ipc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct wkup_m3_ipc {
3333

3434
int mem_type;
3535
unsigned long resume_addr;
36+
int vtt_conf;
3637
int state;
3738

3839
struct completion sync_complete;

0 commit comments

Comments
 (0)