Merge tag 'lsk-v3.10-15.05-android' into develop-3.10
[firefly-linux-kernel-4.4.55.git] / drivers / mailbox / scpi_protocol.c
index 78885289123f7fd6055130455c6a60696767c243..d906906fdbd71dc66f8705703281adf2a0e06f25 100644 (file)
@@ -41,6 +41,7 @@
        ((((cmd) & CMD_ID_MASK) << CMD_ID_SHIFT) |                      \
        (((sender) & CMD_SENDER_ID_MASK) << CMD_SENDER_ID_SHIFT) |      \
        (((txsz) & CMD_DATA_SIZE_MASK) << CMD_DATA_SIZE_SHIFT))
+#define SCPI_CMD_DEFAULT_TIMEOUT_MS  1000
 
 #define MAX_DVFS_DOMAINS       3
 #define MAX_DVFS_OPPS          8
@@ -51,6 +52,7 @@ struct scpi_data_buf {
        int client_id;
        struct rockchip_mbox_msg *data;
        struct completion complete;
+       int timeout_ms;
 };
 
 static int high_priority_cmds[] = {
@@ -112,6 +114,7 @@ static int send_scpi_cmd(struct scpi_data_buf *scpi_buf, bool high_priority)
        struct rockchip_mbox_msg *data = scpi_buf->data;
        u32 status;
        int ret;
+       int timeout = msecs_to_jiffies(scpi_buf->timeout_ms);
 
        if (!the_scpi_device) {
                pr_err("Scpi initializes unsuccessfully\n");
@@ -134,8 +137,7 @@ static int send_scpi_cmd(struct scpi_data_buf *scpi_buf, bool high_priority)
                goto free_channel;
        }
 
-       ret = wait_for_completion_timeout(&scpi_buf->complete,
-                                         msecs_to_jiffies(1000));
+       ret = wait_for_completion_timeout(&scpi_buf->complete, timeout);
        if (ret == 0) {
                status = SCPI_ERR_TIMEOUT;
                goto free_channel;
@@ -159,6 +161,7 @@ do {                                                \
        pdata->rx_size = sizeof(_rx_buf);       \
        scpi_buf.client_id = _client_id;        \
        scpi_buf.data = pdata;                  \
+       scpi_buf.timeout_ms = SCPI_CMD_DEFAULT_TIMEOUT_MS; \
 } while (0)
 
 static int scpi_execute_cmd(struct scpi_data_buf *scpi_buf)
@@ -400,13 +403,51 @@ static int scpi_get_version(u32 old, u32 *ver)
        return ret;
 }
 
-int scpi_ddr_init(u32 dram_speed_bin, u32 freq)
+int scpi_sys_set_mcu_state_suspend(void)
+{
+       struct scpi_data_buf sdata;
+       struct rockchip_mbox_msg mdata;
+       struct __packed1 {
+               u32 status;
+       } tx_buf;
+       struct __packed2 {
+               u32 status;
+       } rx_buf;
+
+       tx_buf.status = 0;
+       SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_SYS,
+                       SCPI_SYS_SET_MCU_STATE_SUSPEND, tx_buf, rx_buf);
+       return scpi_execute_cmd(&sdata);
+}
+EXPORT_SYMBOL_GPL(scpi_sys_set_mcu_state_suspend);
+
+int scpi_sys_set_mcu_state_resume(void)
+{
+       struct scpi_data_buf sdata;
+       struct rockchip_mbox_msg mdata;
+       struct __packed1 {
+               u32 status;
+       } tx_buf;
+       struct __packed2 {
+               u32 status;
+       } rx_buf;
+
+       tx_buf.status = 0;
+
+       SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_SYS,
+                       SCPI_SYS_SET_MCU_STATE_RESUME, tx_buf, rx_buf);
+       return scpi_execute_cmd(&sdata);
+}
+EXPORT_SYMBOL_GPL(scpi_sys_set_mcu_state_resume);
+
+int scpi_ddr_init(u32 dram_speed_bin, u32 freq, u32 lcdc_type)
 {
        struct scpi_data_buf sdata;
        struct rockchip_mbox_msg mdata;
        struct __packed1 {
                u32 dram_speed_bin;
                u32 freq;
+               u32 lcdc_type;
        } tx_buf;
        struct __packed2 {
                u32 status;
@@ -414,6 +455,7 @@ int scpi_ddr_init(u32 dram_speed_bin, u32 freq)
 
        tx_buf.dram_speed_bin = (u32)dram_speed_bin;
        tx_buf.freq = (u32)freq;
+       tx_buf.lcdc_type = (u32)lcdc_type;
 
        SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_DDR,
                        SCPI_DDR_INIT, tx_buf, rx_buf);