@@ -5,6 +5,7 @@
menuconfig GENERIC_PWM
tristate "PWM Support"
depends on SYSFS
+ select HAVE_PWM
help
This enables PWM support through the generic PWM API.
If unsure, say N.
@@ -17,12 +17,12 @@
#include <linux/fb.h>
#include <linux/backlight.h>
#include <linux/err.h>
-#include <linux/pwm.h>
+#include <linux/pwm/pwm.h>
#include <linux/pwm_backlight.h>
#include <linux/slab.h>
struct pwm_bl_data {
- struct pwm_device *pwm;
+ struct pwm_channel *pwm;
struct device *dev;
unsigned int period;
int (*notify)(struct device *,
@@ -45,11 +45,13 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
brightness = pb->notify(pb->dev, brightness);
if (brightness == 0) {
- pwm_config(pb->pwm, 0, pb->period);
- pwm_disable(pb->pwm);
+ pwm_set_period_ns(pb->pwm, pb->period);
+ pwm_set_duty_ns(pb->pwm, 0);
+ pwm_stop(pb->pwm);
} else {
- pwm_config(pb->pwm, brightness * pb->period / max, pb->period);
- pwm_enable(pb->pwm);
+ pwm_set_period_ns(pb->pwm, pb->period);
+ pwm_set_duty_ns(pb->pwm, brightness * pb->period / max);
+ pwm_start(pb->pwm);
}
return 0;
}
@@ -94,7 +96,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->notify = data->notify;
pb->dev = &pdev->dev;
- pb->pwm = pwm_request(data->pwm_id, "backlight");
+ pb->pwm = pwm_request(data->pwm_id, data->ch, "backlight");
if (IS_ERR(pb->pwm)) {
dev_err(&pdev->dev, "unable to request PWM for backlight\n");
ret = PTR_ERR(pb->pwm);
@@ -119,7 +121,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
return 0;
err_bl:
- pwm_free(pb->pwm);
+ pwm_release(pb->pwm);
err_pwm:
kfree(pb);
err_alloc:
@@ -135,9 +137,9 @@ static int pwm_backlight_remove(struct platform_device *pdev)
struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
backlight_device_unregister(bl);
- pwm_config(pb->pwm, 0, pb->period);
- pwm_disable(pb->pwm);
- pwm_free(pb->pwm);
+ pwm_set_duty_ns(pb->pwm, 0);
+ pwm_stop(pb->pwm);
+ pwm_release(pb->pwm);
kfree(pb);
if (data->exit)
data->exit(&pdev->dev);
@@ -153,8 +155,8 @@ static int pwm_backlight_suspend(struct platform_device *pdev,
if (pb->notify)
pb->notify(pb->dev, 0);
- pwm_config(pb->pwm, 0, pb->period);
- pwm_disable(pb->pwm);
+ pwm_set_duty_ns(pb->pwm, 0);
+ pwm_stop(pb->pwm);
return 0;
}
@@ -5,7 +5,8 @@
#define __LINUX_PWM_BACKLIGHT_H
struct platform_pwm_backlight_data {
- int pwm_id;
+ const char *pwm_id;
+ int ch;
unsigned int max_brightness;
unsigned int dft_brightness;
unsigned int pwm_period_ns;