spi: s3c64xx: Add LPD powermode and update idle status register
authorYoungmin Nam <youngmin.nam@samsung.com>
Fri, 24 Apr 2015 08:24:51 +0000 (17:24 +0900)
committermyung-su.cha <myung-su.cha@samsung.com>
Wed, 9 May 2018 12:14:45 +0000 (21:14 +0900)
This patch adds LPD powermode and updates idle status register
when clock/power of IP is en/disabled to check LPD condition.

Change-Id: I6aeb2ede54181bddbfd92bfac1f6d493a95ee54d
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
drivers/spi/spi-s3c64xx.c
include/linux/platform_data/spi-s3c64xx.h

index b6e7be0e3cdb37b532406516e5044f83aa8f5bf2..9e33f09cf2bbce398a3880ec13a0f0ec520d5dfc 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/gpio.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <mach/exynos-powermode.h>
 
 #include <linux/platform_data/spi-s3c64xx.h>
 #include <mach/exynos-fimc-is.h>
@@ -1598,6 +1599,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
        sdd->sfr_start = mem_res->start;
        sdd->is_probed = 0;
        sdd->ops = NULL;
+
+       sdd->idle_ip_index = exynos_get_idle_ip_index(dev_name(&pdev->dev));
+
        if (pdev->dev.of_node) {
                ret = of_alias_get_id(pdev->dev.of_node, "spi");
                if (ret < 0) {
@@ -1701,6 +1705,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
                }
        }
 #else
+       exynos_update_ip_idle_status(sdd->idle_ip_index, 0);
+
        if (clk_prepare_enable(sdd->clk)) {
                dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
                ret = -EBUSY;
@@ -1808,6 +1814,8 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
 
        clk_disable_unprepare(sdd->clk);
 
+       exynos_update_ip_idle_status(sdd->idle_ip_index, 1);
+
        platform_set_drvdata(pdev, NULL);
        spi_master_put(master);
 
@@ -1834,6 +1842,7 @@ static int s3c64xx_spi_suspend_operation(struct device *dev)
                /* Disable the clock */
                clk_disable_unprepare(sdd->src_clk);
                clk_disable_unprepare(sdd->clk);
+               exynos_update_ip_idle_status(sdd->idle_ip_index, 1);
        }
 #endif
        sdd->cur_speed = 0; /* Output Clock is stopped */
@@ -1850,6 +1859,7 @@ static int s3c64xx_spi_resume_operation(struct device *dev)
 
        if (sci->domain == DOMAIN_TOP) {
                /* Enable the clock */
+               exynos_update_ip_idle_status(sdd->idle_ip_index, 0);
                clk_prepare_enable(sdd->src_clk);
                clk_prepare_enable(sdd->clk);
 
@@ -1865,6 +1875,7 @@ static int s3c64xx_spi_resume_operation(struct device *dev)
                /* Disable the clock */
                clk_disable_unprepare(sdd->src_clk);
                clk_disable_unprepare(sdd->clk);
+               exynos_update_ip_idle_status(sdd->idle_ip_index, 1);
 #endif
        }
 
@@ -1976,6 +1987,8 @@ static int s3c64xx_spi_runtime_suspend(struct device *dev)
        if (__clk_get_enable_count(sdd->src_clk))
                clk_disable_unprepare(sdd->src_clk);
 
+       exynos_update_ip_idle_status(sdd->idle_ip_index, 1);
+
        /* Free DMA channels */
        if (sci->dma_mode == DMA_MODE && sdd->is_probed && sdd->ops != NULL) {
        #ifdef CONFIG_ARM64
@@ -2013,12 +2026,14 @@ static int s3c64xx_spi_runtime_resume(struct device *dev)
        }
 
        if (sci->domain == DOMAIN_TOP) {
+               exynos_update_ip_idle_status(sdd->idle_ip_index, 0);
                clk_prepare_enable(sdd->src_clk);
                clk_prepare_enable(sdd->clk);
        }
 
 #if defined(CONFIG_VIDEO_EXYNOS_FIMC_IS) || defined(CONFIG_VIDEO_EXYNOS_FIMC_IS2)
        else if (sci->domain == DOMAIN_CAM1 || sci->domain == DOMAIN_ISP) {
+               exynos_update_ip_idle_status(sdd->idle_ip_index, 0);
                clk_prepare_enable(sdd->src_clk);
                clk_prepare_enable(sdd->clk);
 
index 40a8c15c0ed0899800787eb2bf7f5a062c60ce84..b21aaee63188eabd4ade8d8af66f8d1732cac0f7 100644 (file)
@@ -144,6 +144,7 @@ struct s3c64xx_spi_driver_data {
 
        int is_probed;
        int spi_clkoff_time;
+       int idle_ip_index;
 };
 
 /**