11 #include <linux/kernel.h>
12 #include <linux/module.h>
20 #include <linux/slab.h>
33 int intensity = bd->
props.brightness;
41 if (pwmbl->
pdata->pwm_active_low)
42 pwm_duty = pwmbl->
pdata->pwm_duty_min + intensity;
44 pwm_duty = pwmbl->
pdata->pwm_duty_max - intensity;
46 if (pwm_duty > pwmbl->
pdata->pwm_duty_max)
47 pwm_duty = pwmbl->
pdata->pwm_duty_max;
48 if (pwm_duty < pwmbl->
pdata->pwm_duty_min)
49 pwm_duty = pwmbl->
pdata->pwm_duty_min;
54 0 ^ pwmbl->
pdata->on_active_low);
63 1 ^ pwmbl->
pdata->on_active_low);
75 if (pwmbl->
pdata->pwm_active_low) {
77 pwmbl->
pdata->pwm_duty_min;
79 intensity = pwmbl->
pdata->pwm_duty_max -
86 static int atmel_pwm_bl_init_pwm(
struct atmel_pwm_bl *pwmbl)
88 unsigned long pwm_rate = pwmbl->
pwmc.mck;
90 (pwmbl->
pdata->pwm_frequency *
91 pwmbl->
pdata->pwm_compare_max)) - 1;
98 prescale = fls(prescale);
102 pwm_channel_writel(&pwmbl->
pwmc,
PWM_CMR, prescale);
104 pwmbl->
pdata->pwm_duty_min +
105 pwmbl->
bldev->props.brightness);
107 pwmbl->
pdata->pwm_compare_max);
109 dev_info(&pwmbl->
pdev->dev,
"Atmel PWM backlight driver "
110 "(%lu Hz)\n", pwmbl->
pwmc.mck /
111 pwmbl->
pdata->pwm_compare_max /
118 .get_brightness = atmel_pwm_bl_get_intensity,
119 .update_status = atmel_pwm_bl_set_intensity,
137 pdata = pdev->
dev.platform_data;
159 "gpio_atmel_pwm_bl");
176 &atmel_pwm_bl_ops, &props);
178 retval = PTR_ERR(bldev);
184 platform_set_drvdata(pdev, pwmbl);
188 bldev->
props.brightness = bldev->
props.max_brightness / 2;
190 retval = atmel_pwm_bl_init_pwm(pwmbl);
192 goto err_free_bl_dev;
194 atmel_pwm_bl_set_intensity(bldev);
199 platform_set_drvdata(pdev,
NULL);
209 struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev);
216 platform_set_drvdata(pdev,
NULL);
223 .name =
"atmel-pwm-bl",
226 .remove =
__exit_p(atmel_pwm_bl_remove),
229 static int __init atmel_pwm_bl_init(
void)
235 static void __exit atmel_pwm_bl_exit(
void)