14 #include <linux/module.h>
15 #include <linux/kernel.h>
17 #include <linux/slab.h>
23 #include <asm/div64.h>
25 #define HAS_SECONDARY_PWM 0x10
26 #define PWM_ID_BASE(d) ((d) & 0xf)
43 #define PWMCR_SD (1 << 6)
44 #define PWMDCR_FD (1 << 10)
65 int duty_ns,
int period_ns)
73 offset = pwm->
hwpwm ? 0x10 : 0;
80 if (period_cycles < 1)
82 prescale = (period_cycles - 1) / 1024;
83 pv = period_cycles / (prescale + 1) - 1;
88 if (duty_ns == period_ns)
91 dc = (pv + 1) * duty_ns / period_ns;
96 rc = clk_prepare_enable(pc->
clk);
104 clk_disable_unprepare(pc->
clk);
114 rc = clk_prepare_enable(pc->
clk);
126 clk_disable_unprepare(pc->
clk);
131 static struct pwm_ops pxa_pwm_ops = {
132 .config = pxa_pwm_config,
133 .enable = pxa_pwm_enable,
134 .disable = pxa_pwm_disable,
147 dev_err(&pdev->
dev,
"failed to allocate memory\n");
152 if (IS_ERR(pwm->
clk))
153 return PTR_ERR(pwm->
clk);
158 pwm->
chip.ops = &pxa_pwm_ops;
164 dev_err(&pdev->
dev,
"no memory resource defined\n");
174 dev_err(&pdev->
dev,
"pwmchip_add() failed: %d\n", ret);
178 platform_set_drvdata(pdev, pwm);
186 chip = platform_get_drvdata(pdev);
195 .name =
"pxa25x-pwm",
200 .id_table = pwm_id_table,
203 static int __init pwm_init(
void)
209 static void __exit pwm_exit(
void)