aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Chen <jason.chen@linaro.org>2011-12-05 18:12:27 +0800
committerJason Chen <jason.chen@linaro.org>2011-12-06 12:46:19 +0800
commit77f159f51d629d460a5599686025592063b5d5dc (patch)
treec9cb77a7d4e668eefffe38d1979987804c717c7d
parentfed4146772f14e9c84330c3f7e364d3f450c9db2 (diff)
downloadlinux-linaro-77f159f51d629d460a5599686025592063b5d5dc.tar.gz
imx6q-sabrelite: add pwm and pwm-bl dt support
Signed-off-by: Jason Chen <jason.chen@linaro.org>
-rw-r--r--arch/arm/boot/dts/imx6q-sabrelite.dts14
-rw-r--r--arch/arm/boot/dts/imx6q.dtsi12
-rw-r--r--arch/arm/mach-imx/clock-imx6q.c8
-rw-r--r--arch/arm/plat-mxc/pwm.c9
-rw-r--r--drivers/video/backlight/pwm_bl.c40
5 files changed, 73 insertions, 10 deletions
diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts
index cab2909c571..7c017cdda83 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -74,6 +74,20 @@
};
};
+ backlight {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "simple-bus";
+
+ pwm_bl {
+ compatible = "pwm-bl";
+ pwm-parent = <&pwm4>;
+ max_brightness = <255>;
+ dft_brightness = <128>;
+ pwm_period_ns = <50000>;
+ };
+ };
+
displays {
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index dc393c1e75f..d8d646e6d01 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -211,22 +211,26 @@
reg = <0x0207c000 0x4000>;
};
- pwm@02080000 { /* PWM1 */
+ pwm1: pwm@02080000 { /* PWM1 */
+ compatible = "fsl,imx6q-pwm";
reg = <0x02080000 0x4000>;
interrupts = <0 83 0x04>;
};
- pwm@02084000 { /* PWM2 */
+ pwm2: pwm@02084000 { /* PWM2 */
+ compatible = "fsl,imx6q-pwm";
reg = <0x02084000 0x4000>;
interrupts = <0 84 0x04>;
};
- pwm@02088000 { /* PWM3 */
+ pwm3: pwm@02088000 { /* PWM3 */
+ compatible = "fsl,imx6q-pwm";
reg = <0x02088000 0x4000>;
interrupts = <0 85 0x04>;
};
- pwm@0208c000 { /* PWM4 */
+ pwm4: pwm@0208c000 { /* PWM4 */
+ compatible = "fsl,imx6q-pwm";
reg = <0x0208c000 0x4000>;
interrupts = <0 86 0x04>;
};
diff --git a/arch/arm/mach-imx/clock-imx6q.c b/arch/arm/mach-imx/clock-imx6q.c
index f952b45d31d..0dc408552ea 100644
--- a/arch/arm/mach-imx/clock-imx6q.c
+++ b/arch/arm/mach-imx/clock-imx6q.c
@@ -1904,10 +1904,10 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(NULL, "iim_clk", iim_clk),
_REGISTER_CLOCK(NULL, "mlb_clk", mlb_clk),
_REGISTER_CLOCK(NULL, "openvg_axi_clk", openvg_axi_clk),
- _REGISTER_CLOCK(NULL, "pwm1_clk", pwm1_clk),
- _REGISTER_CLOCK(NULL, "pwm2_clk", pwm2_clk),
- _REGISTER_CLOCK(NULL, "pwm3_clk", pwm3_clk),
- _REGISTER_CLOCK(NULL, "pwm4_clk", pwm4_clk),
+ _REGISTER_CLOCK("2080000.pwm", NULL, pwm1_clk),
+ _REGISTER_CLOCK("2084000.pwm", NULL, pwm2_clk),
+ _REGISTER_CLOCK("2088000.pwm", NULL, pwm3_clk),
+ _REGISTER_CLOCK("208c000.pwm", NULL, pwm4_clk),
_REGISTER_CLOCK(NULL, "gpmi_io_clk", gpmi_io_clk),
_REGISTER_CLOCK(NULL, "usboh3_clk", usboh3_clk),
_REGISTER_CLOCK(NULL, "sata_clk", sata_clk),
diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
index 2b8c0c3c0bb..6b78490c632 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/arch/arm/plat-mxc/pwm.c
@@ -157,6 +157,9 @@ struct pwm_device *pwm_request(int pwm_id, const char *label)
if (pwm->pwm_id == pwm_id) {
found = 1;
break;
+ } else if ((int)pwm->pdev->dev.of_node == pwm_id) {
+ found = 1;
+ break;
}
}
@@ -274,9 +277,15 @@ static int __devexit mxc_pwm_remove(struct platform_device *pdev)
return 0;
}
+static const struct of_device_id mxc_pwm_dt_ids[] = {
+ { .compatible = "fsl,imx6q-pwm", },
+ { /* sentinel */ }
+};
+
static struct platform_driver mxc_pwm_driver = {
.driver = {
.name = "mxc_pwm",
+ .of_match_table = mxc_pwm_dt_ids,
},
.probe = mxc_pwm_probe,
.remove = __devexit_p(mxc_pwm_remove),
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 8b5b2a4124c..63ca212818a 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -83,6 +83,33 @@ static const struct backlight_ops pwm_backlight_ops = {
.check_fb = pwm_backlight_check_fb,
};
+struct platform_pwm_backlight_data of_data;
+static int of_get_pwm_data(struct platform_device *pdev,
+ struct platform_pwm_backlight_data *data)
+{
+ const __be32 *parp;
+ struct device_node *pwm_np, *np = pdev->dev.of_node;
+
+ if (!np)
+ return -EINVAL;
+
+ parp = of_get_property(np, "pwm-parent", NULL);
+ if (parp == NULL)
+ return -EINVAL;
+ of_node_put(np);
+
+ pwm_np = of_find_node_by_phandle(be32_to_cpup(parp));
+ if (pwm_np)
+ of_node_put(pwm_np);
+ data->pwm_id = (int)pwm_np;
+
+ of_property_read_u32(np, "max_brightness", &data->max_brightness);
+ of_property_read_u32(np, "dft_brightness", &data->dft_brightness);
+ of_property_read_u32(np, "pwm_period_ns", &data->pwm_period_ns);
+
+ return 0;
+}
+
static int pwm_backlight_probe(struct platform_device *pdev)
{
struct backlight_properties props;
@@ -92,8 +119,11 @@ static int pwm_backlight_probe(struct platform_device *pdev)
int ret;
if (!data) {
- dev_err(&pdev->dev, "failed to find platform data\n");
- return -EINVAL;
+ data = pdev->dev.platform_data = &of_data;
+ if (of_get_pwm_data(pdev, data) < 0) {
+ dev_err(&pdev->dev, "failed to find platform data\n");
+ return -EINVAL;
+ }
}
if (data->init) {
@@ -196,10 +226,16 @@ static int pwm_backlight_resume(struct platform_device *pdev)
#define pwm_backlight_resume NULL
#endif
+static const struct of_device_id pwm_bl_dt_ids[] = {
+ { .compatible = "pwm-bl", },
+ { /* sentinel */ }
+};
+
static struct platform_driver pwm_backlight_driver = {
.driver = {
.name = "pwm-backlight",
.owner = THIS_MODULE,
+ .of_match_table = pwm_bl_dt_ids,
},
.probe = pwm_backlight_probe,
.remove = pwm_backlight_remove,