aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorSifan Naeem <sifan.naeem@imgtec.com>2015-02-04 11:48:14 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-08 06:55:48 -0400
commitcc4e8c3dc95369c08615a4151bce8506b00356d9 (patch)
tree3598bea9e7a1604142165c8b407f118fb0b36a8b /drivers/media/rc
parenta2bbf5d05918a3156e9854a7144a8b2806badb53 (diff)
[media] rc: img-ir: Add and enable sys clock for img-ir
Gets a handle to the system clock, already described in the binding document, and calls the appropriate common clock framework functions to mark it prepared/enabled, the common clock framework initially enables the clock and doesn't disable it at least until the device/driver is removed. It's important the systen clock is enabled before register interface is accessed by the driver. The system clock to IR is needed for the driver to communicate with the IR hardware via MMIO accesses on the system bus, so it must not be disabled during use or the driver will malfunction. Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com> Acked-by: James Hogan <james.hogan@imgtec.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/img-ir/img-ir-core.c29
-rw-r--r--drivers/media/rc/img-ir/img-ir.h2
2 files changed, 27 insertions, 4 deletions
diff --git a/drivers/media/rc/img-ir/img-ir-core.c b/drivers/media/rc/img-ir/img-ir-core.c
index 77c78de4f5bf..a10d66600ce4 100644
--- a/drivers/media/rc/img-ir/img-ir-core.c
+++ b/drivers/media/rc/img-ir/img-ir-core.c
@@ -110,16 +110,32 @@ static int img_ir_probe(struct platform_device *pdev)
110 priv->clk = devm_clk_get(&pdev->dev, "core"); 110 priv->clk = devm_clk_get(&pdev->dev, "core");
111 if (IS_ERR(priv->clk)) 111 if (IS_ERR(priv->clk))
112 dev_warn(&pdev->dev, "cannot get core clock resource\n"); 112 dev_warn(&pdev->dev, "cannot get core clock resource\n");
113
114 /* Get sys clock */
115 priv->sys_clk = devm_clk_get(&pdev->dev, "sys");
116 if (IS_ERR(priv->sys_clk))
117 dev_warn(&pdev->dev, "cannot get sys clock resource\n");
113 /* 118 /*
114 * The driver doesn't need to know about the system ("sys") or power 119 * Enabling the system clock before the register interface is
115 * modulation ("mod") clocks yet 120 * accessed. ISR shouldn't get called with Sys Clock disabled,
121 * hence exiting probe with an error.
116 */ 122 */
123 if (!IS_ERR(priv->sys_clk)) {
124 error = clk_prepare_enable(priv->sys_clk);
125 if (error) {
126 dev_err(&pdev->dev, "cannot enable sys clock\n");
127 return error;
128 }
129 }
117 130
118 /* Set up raw & hw decoder */ 131 /* Set up raw & hw decoder */
119 error = img_ir_probe_raw(priv); 132 error = img_ir_probe_raw(priv);
120 error2 = img_ir_probe_hw(priv); 133 error2 = img_ir_probe_hw(priv);
121 if (error && error2) 134 if (error && error2) {
122 return (error == -ENODEV) ? error2 : error; 135 if (error == -ENODEV)
136 error = error2;
137 goto err_probe;
138 }
123 139
124 /* Get the IRQ */ 140 /* Get the IRQ */
125 priv->irq = irq; 141 priv->irq = irq;
@@ -139,6 +155,9 @@ static int img_ir_probe(struct platform_device *pdev)
139err_irq: 155err_irq:
140 img_ir_remove_hw(priv); 156 img_ir_remove_hw(priv);
141 img_ir_remove_raw(priv); 157 img_ir_remove_raw(priv);
158err_probe:
159 if (!IS_ERR(priv->sys_clk))
160 clk_disable_unprepare(priv->sys_clk);
142 return error; 161 return error;
143} 162}
144 163
@@ -152,6 +171,8 @@ static int img_ir_remove(struct platform_device *pdev)
152 171
153 if (!IS_ERR(priv->clk)) 172 if (!IS_ERR(priv->clk))
154 clk_disable_unprepare(priv->clk); 173 clk_disable_unprepare(priv->clk);
174 if (!IS_ERR(priv->sys_clk))
175 clk_disable_unprepare(priv->sys_clk);
155 return 0; 176 return 0;
156} 177}
157 178
diff --git a/drivers/media/rc/img-ir/img-ir.h b/drivers/media/rc/img-ir/img-ir.h
index 2ddf56083182..f1387c016d3d 100644
--- a/drivers/media/rc/img-ir/img-ir.h
+++ b/drivers/media/rc/img-ir/img-ir.h
@@ -138,6 +138,7 @@ struct clk;
138 * @dev: Platform device. 138 * @dev: Platform device.
139 * @irq: IRQ number. 139 * @irq: IRQ number.
140 * @clk: Input clock. 140 * @clk: Input clock.
141 * @sys_clk: System clock.
141 * @reg_base: Iomem base address of IR register block. 142 * @reg_base: Iomem base address of IR register block.
142 * @lock: Protects IR registers and variables in this struct. 143 * @lock: Protects IR registers and variables in this struct.
143 * @raw: Driver data for raw decoder. 144 * @raw: Driver data for raw decoder.
@@ -147,6 +148,7 @@ struct img_ir_priv {
147 struct device *dev; 148 struct device *dev;
148 int irq; 149 int irq;
149 struct clk *clk; 150 struct clk *clk;
151 struct clk *sys_clk;
150 void __iomem *reg_base; 152 void __iomem *reg_base;
151 spinlock_t lock; 153 spinlock_t lock;
152 154