aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-tiecap.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-19 11:19:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-19 11:19:07 -0500
commit74779e22261172ea728b989310f6ecc991b57d62 (patch)
treea6c71e02bf6cefc9e0d261dd1ab11f4a7433ed92 /drivers/pwm/pwm-tiecap.c
parent5031a2a7c12b837a0913c4139ebeb6bbff5e1aa5 (diff)
parent20e8ac3eea4dcfeea6ebeae57cd2c739fa48da11 (diff)
Merge tag 'for-3.8-rc1' of git://gitorious.org/linux-pwm/linux-pwm
Pull pwm changes from Thierry Reding: "A new driver has been added for the SPEAr platform and the TWL4030/6030 driver has been replaced by two drivers that control the regular PWMs and the PWM driven LEDs provided by the chips. The vt8500, tiecap, tiehrpwm, i.MX, LPC32xx and Samsung drivers have all been improved and the device tree bindings now support the PWM signal polarity." Fix up trivial conflicts due to __devinit/exit removal. * tag 'for-3.8-rc1' of git://gitorious.org/linux-pwm/linux-pwm: (21 commits) pwm: samsung: add missing s3c->pwm_id assignment pwm: lpc32xx: Set the chip base for dynamic allocation pwm: lpc32xx: Properly disable the clock on device removal pwm: lpc32xx: Fix the PWM polarity pwm: i.MX: eliminate build warning pwm: Export of_pwm_xlate_with_flags() pwm: Remove pwm-twl6030 driver pwm: New driver to support PWM driven LEDs on TWL4030/6030 series of PMICs pwm: New driver to support PWMs on TWL4030/6030 series of PMICs pwm: pwm-tiehrpwm: pinctrl support pwm: tiehrpwm: Add device-tree binding pwm: pwm-tiehrpwm: Adding TBCLK gating support. pwm: pwm-tiecap: pinctrl support pwm: tiecap: Add device-tree binding pwm: Add TI PWM subsystem driver pwm: Device tree support for PWM polarity pwm: vt8500: Ensure PWM clock is enabled during pwm_config pwm: vt8500: Fix build error pwm: spear: Staticize spear_pwm_config() pwm: Add SPEAr PWM chip driver support ...
Diffstat (limited to 'drivers/pwm/pwm-tiecap.c')
-rw-r--r--drivers/pwm/pwm-tiecap.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 87c091b245cc..5cf016dd9822 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -25,6 +25,10 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/pm_runtime.h> 26#include <linux/pm_runtime.h>
27#include <linux/pwm.h> 27#include <linux/pwm.h>
28#include <linux/of_device.h>
29#include <linux/pinctrl/consumer.h>
30
31#include "pwm-tipwmss.h"
28 32
29/* ECAP registers and bits definitions */ 33/* ECAP registers and bits definitions */
30#define CAP1 0x08 34#define CAP1 0x08
@@ -184,12 +188,24 @@ static const struct pwm_ops ecap_pwm_ops = {
184 .owner = THIS_MODULE, 188 .owner = THIS_MODULE,
185}; 189};
186 190
191static const struct of_device_id ecap_of_match[] = {
192 { .compatible = "ti,am33xx-ecap" },
193 {},
194};
195MODULE_DEVICE_TABLE(of, ecap_of_match);
196
187static int ecap_pwm_probe(struct platform_device *pdev) 197static int ecap_pwm_probe(struct platform_device *pdev)
188{ 198{
189 int ret; 199 int ret;
190 struct resource *r; 200 struct resource *r;
191 struct clk *clk; 201 struct clk *clk;
192 struct ecap_pwm_chip *pc; 202 struct ecap_pwm_chip *pc;
203 u16 status;
204 struct pinctrl *pinctrl;
205
206 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
207 if (IS_ERR(pinctrl))
208 dev_warn(&pdev->dev, "unable to select pin group\n");
193 209
194 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); 210 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
195 if (!pc) { 211 if (!pc) {
@@ -211,6 +227,8 @@ static int ecap_pwm_probe(struct platform_device *pdev)
211 227
212 pc->chip.dev = &pdev->dev; 228 pc->chip.dev = &pdev->dev;
213 pc->chip.ops = &ecap_pwm_ops; 229 pc->chip.ops = &ecap_pwm_ops;
230 pc->chip.of_xlate = of_pwm_xlate_with_flags;
231 pc->chip.of_pwm_n_cells = 3;
214 pc->chip.base = -1; 232 pc->chip.base = -1;
215 pc->chip.npwm = 1; 233 pc->chip.npwm = 1;
216 234
@@ -231,14 +249,40 @@ static int ecap_pwm_probe(struct platform_device *pdev)
231 } 249 }
232 250
233 pm_runtime_enable(&pdev->dev); 251 pm_runtime_enable(&pdev->dev);
252 pm_runtime_get_sync(&pdev->dev);
253
254 status = pwmss_submodule_state_change(pdev->dev.parent,
255 PWMSS_ECAPCLK_EN);
256 if (!(status & PWMSS_ECAPCLK_EN_ACK)) {
257 dev_err(&pdev->dev, "PWMSS config space clock enable failed\n");
258 ret = -EINVAL;
259 goto pwmss_clk_failure;
260 }
261
262 pm_runtime_put_sync(&pdev->dev);
263
234 platform_set_drvdata(pdev, pc); 264 platform_set_drvdata(pdev, pc);
235 return 0; 265 return 0;
266
267pwmss_clk_failure:
268 pm_runtime_put_sync(&pdev->dev);
269 pm_runtime_disable(&pdev->dev);
270 pwmchip_remove(&pc->chip);
271 return ret;
236} 272}
237 273
238static int ecap_pwm_remove(struct platform_device *pdev) 274static int ecap_pwm_remove(struct platform_device *pdev)
239{ 275{
240 struct ecap_pwm_chip *pc = platform_get_drvdata(pdev); 276 struct ecap_pwm_chip *pc = platform_get_drvdata(pdev);
241 277
278 pm_runtime_get_sync(&pdev->dev);
279 /*
280 * Due to hardware misbehaviour, acknowledge of the stop_req
281 * is missing. Hence checking of the status bit skipped.
282 */
283 pwmss_submodule_state_change(pdev->dev.parent, PWMSS_ECAPCLK_STOP_REQ);
284 pm_runtime_put_sync(&pdev->dev);
285
242 pm_runtime_put_sync(&pdev->dev); 286 pm_runtime_put_sync(&pdev->dev);
243 pm_runtime_disable(&pdev->dev); 287 pm_runtime_disable(&pdev->dev);
244 return pwmchip_remove(&pc->chip); 288 return pwmchip_remove(&pc->chip);
@@ -246,7 +290,9 @@ static int ecap_pwm_remove(struct platform_device *pdev)
246 290
247static struct platform_driver ecap_pwm_driver = { 291static struct platform_driver ecap_pwm_driver = {
248 .driver = { 292 .driver = {
249 .name = "ecap", 293 .name = "ecap",
294 .owner = THIS_MODULE,
295 .of_match_table = ecap_of_match,
250 }, 296 },
251 .probe = ecap_pwm_probe, 297 .probe = ecap_pwm_probe,
252 .remove = ecap_pwm_remove, 298 .remove = ecap_pwm_remove,