[media] media: st-rc: Add reset support
authorSrinivas Kandagatla <srinivas.kandagatla@st.com>
Tue, 14 Jan 2014 11:04:21 +0000 (08:04 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 15 Jan 2014 13:45:22 +0000 (11:45 -0200)
Some of the SOCs hold the IRB IP in softreset state by default.
For this IP to work driver needs to bring it out of softreset.
This patch adds support to reset the IP via reset framework.

Without this patch the driver can not work with SoCs which holds the IP
in softreset.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/rc/st_rc.c

index 65120c2d47ad1d34c3a6018b242cf6e0e4c74d0c..8f0cddb9e8f2f4ce0076a9f7a4d4ba0cada0d7b4 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 #include <media/rc-core.h>
 #include <linux/pinctrl/consumer.h>
 
@@ -28,6 +29,7 @@ struct st_rc_device {
        int                             sample_mult;
        int                             sample_div;
        bool                            rxuhfmode;
+       struct  reset_control           *rstc;
 };
 
 /* Registers */
@@ -161,6 +163,10 @@ static void st_rc_hardware_init(struct st_rc_device *dev)
        unsigned int rx_max_symbol_per = MAX_SYMB_TIME;
        unsigned int rx_sampling_freq_div;
 
+       /* Enable the IP */
+       if (dev->rstc)
+               reset_control_deassert(dev->rstc);
+
        clk_prepare_enable(dev->sys_clock);
        baseclock = clk_get_rate(dev->sys_clock);
 
@@ -271,6 +277,11 @@ static int st_rc_probe(struct platform_device *pdev)
        else
                rc_dev->rx_base = rc_dev->base;
 
+
+       rc_dev->rstc = reset_control_get(dev, NULL);
+       if (IS_ERR(rc_dev->rstc))
+               rc_dev->rstc = NULL;
+
        rc_dev->dev = dev;
        platform_set_drvdata(pdev, rc_dev);
        st_rc_hardware_init(rc_dev);
@@ -338,6 +349,8 @@ static int st_rc_suspend(struct device *dev)
                writel(0x00, rc_dev->rx_base + IRB_RX_EN);
                writel(0x00, rc_dev->rx_base + IRB_RX_INT_EN);
                clk_disable_unprepare(rc_dev->sys_clock);
+               if (rc_dev->rstc)
+                       reset_control_assert(rc_dev->rstc);
        }
 
        return 0;