wkup_m3_ipc: Add support for toggling VTT regulator
authorDave Gerlach <d-gerlach@ti.com>
Fri, 2 Nov 2018 10:29:06 +0000 (15:59 +0530)
committerTero Kristo <t-kristo@ti.com>
Tue, 6 Nov 2018 13:06:17 +0000 (15:06 +0200)
Some boards (currently AM335x EVM-SK) provides s/w control via
GPIO to toggle VTT regulator to reduce power consumption in low
power state.

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.

Add support for toggling VTT regulator using DT properties.
Actual toggling happens in CM3 Firmware. The enable option & the GPIO
pin used is collected in A8 Core and then sent to CM3 using IPC
registers.

Note:
Here it is assumed that VTT Toggle will be done using a pin on GPIO-0
Instance. The reason is GPIO-0 is in wakeup domain.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt
drivers/soc/ti/wkup_m3_ipc.c
include/linux/wkup_m3_ipc.h

index 401550487ed6f69f036a810dd6e01edcef745b87..4cdbb60fd0d0bace26aed3155b7dcf942545275b 100644 (file)
@@ -55,3 +55,37 @@ Example:
                        ...
                };
        };
                        ...
                };
        };
+
+Support for VTT Toggle
+==================================
+In order to enable the support for VTT toggle during Suspend/Resume
+sequence needed by some boards (like AM335x EVM-SK & AM437x GP EVM),
+the below DT properties are required. It is possible to toggle VTT
+using one of two methods depending on the SoC being used, either
+GPIO0 toggle (AM335x and AM437x), or any GPIO with DS_PAD_CONFIG
+bits in the control module (AM437x only).
+
+VTT Toggle using GPIO0
+----------------------------------
+Supported by: AM335x and AM437x
+Used on: AM335x EVM-SK
+
+Optional properties:
+- ti,needs-vtt-toggle: Indicates that the boards requires VTT toggling
+                       during suspend/resume.
+- ti,vtt-gpio-pin:     Specifies the GPIO0 pin used for VTT toggle.
+
+Important Note:
+- Here it is assumed that VTT Toggle will be done using a pin on GPIO-0 Instance.
+  It will not work on any other GPIO using the above properties, regardless of
+  which part is being used.
+
+Example:
+       wkup_m3_ipc: wkup_m3_ipc@1324 {
+               compatible = "ti,am3352-wkup-m3-ipc";
+               ...
+               ...
+               ti,needs-vtt-toggle;
+               ti,vtt-gpio-pin = <7>;
+               ...
+       };
index f5cb8c0af09f3ab8ade4443ada270bf1f1eefa92..5a9c1f5042207f84390f4cdeebae538896b1a99c 100644 (file)
 #define M3_FW_VERSION_MASK             0xffff
 #define M3_WAKE_SRC_MASK               0xff
 
 #define M3_FW_VERSION_MASK             0xffff
 #define M3_WAKE_SRC_MASK               0xff
 
+#define IPC_MEM_TYPE_SHIFT             (0x0)
+#define IPC_MEM_TYPE_MASK              (0x7 << 0)
+#define IPC_VTT_STAT_SHIFT             (0x3)
+#define IPC_VTT_STAT_MASK              (0x1 << 3)
+#define IPC_VTT_GPIO_PIN_SHIFT         (0x4)
+#define IPC_VTT_GPIO_PIN_MASK          (0x3f << 4)
+
 #define M3_STATE_UNKNOWN               0
 #define M3_STATE_RESET                 1
 #define M3_STATE_INITED                        2
 #define M3_STATE_UNKNOWN               0
 #define M3_STATE_RESET                 1
 #define M3_STATE_INITED                        2
@@ -222,6 +229,12 @@ static int wkup_m3_is_available(struct wkup_m3_ipc *m3_ipc)
                (m3_ipc->state != M3_STATE_UNKNOWN));
 }
 
                (m3_ipc->state != M3_STATE_UNKNOWN));
 }
 
+static void wkup_m3_set_vtt_gpio(struct wkup_m3_ipc *m3_ipc, int gpio)
+{
+       m3_ipc->vtt_conf = (1 << IPC_VTT_STAT_SHIFT) |
+                           (gpio << IPC_VTT_GPIO_PIN_SHIFT);
+}
+
 /* Public functions */
 /**
  * wkup_m3_set_mem_type - Pass wkup_m3 which type of memory is in use
 /* Public functions */
 /**
  * wkup_m3_set_mem_type - Pass wkup_m3 which type of memory is in use
@@ -297,7 +310,8 @@ static int wkup_m3_prepare_low_power(struct wkup_m3_ipc *m3_ipc, int state)
        /* Program each required IPC register then write defaults to others */
        wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->resume_addr, 0);
        wkup_m3_ctrl_ipc_write(m3_ipc, m3_power_state, 1);
        /* Program each required IPC register then write defaults to others */
        wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->resume_addr, 0);
        wkup_m3_ctrl_ipc_write(m3_ipc, m3_power_state, 1);
-       wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type, 4);
+       wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type |
+                              m3_ipc->vtt_conf, 4);
 
        wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 2);
        wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 3);
 
        wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 2);
        wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 3);
@@ -433,12 +447,13 @@ static void wkup_m3_rproc_boot_thread(struct wkup_m3_ipc *m3_ipc)
 static int wkup_m3_ipc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
 static int wkup_m3_ipc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       int irq, ret;
+       int irq, ret, temp;
        phandle rproc_phandle;
        struct rproc *m3_rproc;
        struct resource *res;
        struct task_struct *task;
        struct wkup_m3_ipc *m3_ipc;
        phandle rproc_phandle;
        struct rproc *m3_rproc;
        struct resource *res;
        struct task_struct *task;
        struct wkup_m3_ipc *m3_ipc;
+       struct device_node *np = dev->of_node;
 
        m3_ipc = devm_kzalloc(dev, sizeof(*m3_ipc), GFP_KERNEL);
        if (!m3_ipc)
 
        m3_ipc = devm_kzalloc(dev, sizeof(*m3_ipc), GFP_KERNEL);
        if (!m3_ipc)
@@ -498,6 +513,14 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
 
        m3_ipc->ops = &ipc_ops;
 
 
        m3_ipc->ops = &ipc_ops;
 
+       if (of_find_property(np, "ti,needs-vtt-toggle", NULL) &&
+           !(of_property_read_u32(np, "ti,vtt-gpio-pin", &temp))) {
+               if (temp >= 0 && temp <= 31)
+                       wkup_m3_set_vtt_gpio(m3_ipc, temp);
+               else
+                       dev_warn(dev, "Invalid VTT GPIO(%d) pin\n", temp);
+       }
+
        /*
         * Wait for firmware loading completion in a thread so we
         * can boot the wkup_m3 as soon as it's ready without holding
        /*
         * Wait for firmware loading completion in a thread so we
         * can boot the wkup_m3 as soon as it's ready without holding
index e497e621dbb7f6e793f3e2e1230ab1da16daeb66..682efbb7d401e50e232d1d5098c8afe619ce9c5b 100644 (file)
@@ -33,6 +33,7 @@ struct wkup_m3_ipc {
 
        int mem_type;
        unsigned long resume_addr;
 
        int mem_type;
        unsigned long resume_addr;
+       int vtt_conf;
        int state;
 
        struct completion sync_complete;
        int state;
 
        struct completion sync_complete;