19 #include <linux/kernel.h>
20 #include <linux/module.h>
29 static const unsigned int jz4740_pwm_gpio_list[
NUM_PWM] = {
52 unsigned int gpio = jz4740_pwm_gpio_list[pwm->
hwpwm];
64 dev_err(chip->
dev,
"Failed to request GPIO#%u for PWM: %d\n",
71 jz4740_timer_start(pwm->
hwpwm);
78 unsigned int gpio = jz4740_pwm_gpio_list[pwm->
hwpwm];
80 jz4740_timer_set_ctrl(pwm->
hwpwm, 0);
85 jz4740_timer_stop(pwm->
hwpwm);
93 jz4740_timer_set_ctrl(pwm->
hwpwm, ctrl);
94 jz4740_timer_enable(pwm->
hwpwm);
104 jz4740_timer_disable(pwm->
hwpwm);
105 jz4740_timer_set_ctrl(pwm->
hwpwm, ctrl);
109 int duty_ns,
int period_ns)
112 unsigned long long tmp;
113 unsigned long period, duty;
114 unsigned int prescaler = 0;
122 while (period > 0xffff && prescaler < 6) {
130 tmp = (
unsigned long long)period * duty_ns;
137 is_enabled = jz4740_timer_is_enabled(pwm->
hwpwm);
139 jz4740_pwm_disable(chip, pwm);
141 jz4740_timer_set_count(pwm->
hwpwm, 0);
142 jz4740_timer_set_duty(pwm->
hwpwm, duty);
143 jz4740_timer_set_period(pwm->
hwpwm, period);
148 jz4740_timer_set_ctrl(pwm->
hwpwm, ctrl);
151 jz4740_pwm_enable(chip, pwm);
156 static const struct pwm_ops jz4740_pwm_ops = {
157 .request = jz4740_pwm_request,
158 .free = jz4740_pwm_free,
159 .config = jz4740_pwm_config,
160 .enable = jz4740_pwm_enable,
161 .disable = jz4740_pwm_disable,
175 if (IS_ERR(jz4740->
clk))
176 return PTR_ERR(jz4740->
clk);
179 jz4740->
chip.ops = &jz4740_pwm_ops;
181 jz4740->
chip.base = -1;
189 platform_set_drvdata(pdev, jz4740);
210 .name =
"jz4740-pwm",
213 .probe = jz4740_pwm_probe,