ARM: DT: Add DT entry for PWMs and Backlight
Ajay Nandakumar [Tue, 29 Oct 2013 14:21:21 +0000 (19:21 +0530)]
Add DT entry for PWM controller and Backlight for NVIDIA's
Tegra 114,124 SoCs.It has 4 PWM controllers.

Bug 1256106

Change-Id: Ia927d3231db1a07490b5027c1f23d8e736173f30
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>
Reviewed-on: http://git-master/r/299035
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>

35 files changed:
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
arch/arm/boot/dts/tegra114-dalmore.dts
arch/arm/boot/dts/tegra114-macallan.dts
arch/arm/boot/dts/tegra114-pluto.dts
arch/arm/boot/dts/tegra114-roth.dts
arch/arm/boot/dts/tegra114.dtsi
arch/arm/boot/dts/tegra124-ardbeg.dts
arch/arm/boot/dts/tegra124-bonaire.dts
arch/arm/boot/dts/tegra124-bonaire_sim.dts
arch/arm/boot/dts/tegra124-laguna.dts
arch/arm/boot/dts/tegra124-loki.dts
arch/arm/boot/dts/tegra124-soc.dtsi
arch/arm/boot/dts/tegra124-tn8.dts
arch/arm/boot/dts/tegra124-vcm30_t124.dts
arch/arm/mach-tegra/board-ardbeg.c
arch/arm/mach-tegra/board-bonaire-panel.c
arch/arm/mach-tegra/board-bonaire.c
arch/arm/mach-tegra/board-dalmore.c
arch/arm/mach-tegra/board-loki.c
arch/arm/mach-tegra/board-macallan.c
arch/arm/mach-tegra/board-pismo.c
arch/arm/mach-tegra/board-pluto.c
arch/arm/mach-tegra/board-roth-panel.c
arch/arm/mach-tegra/board-roth.c
arch/arm/mach-tegra/board-vcm30_t124.c
arch/arm/mach-tegra/panel-a-1080p-11-6.c
arch/arm/mach-tegra/panel-a-1080p-14-0.c
arch/arm/mach-tegra/panel-a-edp-1080p-14-0.c
arch/arm/mach-tegra/panel-c-lvds-1366-14.c
arch/arm/mach-tegra/panel-j-1440-810-5-8.c
arch/arm/mach-tegra/panel-j-720p-4-7.c
arch/arm/mach-tegra/panel-l-720p-5-loki.c
arch/arm/mach-tegra/panel-p-wuxga-10-1.c
arch/arm/mach-tegra/panel-s-wqxga-10-1.c
drivers/video/backlight/pwm_bl.c

index 1e4fc72..ae7b689 100644 (file)
@@ -11,13 +11,23 @@ Required properties:
   - default-brightness-level: the default brightness level (index into the
       array defined by the "brightness-levels" property)
 
+   The following fields are mutually exclusive  with "brightness-levels"
+   and "default-brightness-level".It is used in case where levels are
+   not available on the backlight device and the device can interpolate
+   values.In this case the minium value that is considered is 0.
+
+  - max-brightness: the maximum brighness value that is allowed by the
+       backlight device.
+  - default-brightness: the default brighness value that is allowed by the
+       backlight device.
+
 Optional properties:
   - pwm-names: a list of names for the PWM devices specified in the
                "pwms" property (see PWM binding[0])
 
 [0]: Documentation/devicetree/bindings/pwm/pwm.txt
 
-Example:
+Examples:
 
        backlight {
                compatible = "pwm-backlight";
@@ -26,3 +36,10 @@ Example:
                brightness-levels = <0 4 8 16 32 64 128 255>;
                default-brightness-level = <6>;
        };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
index 5dc5b14..1286291 100644 (file)
                };
        };
 
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
+
        pinmux {
                pinctrl-names = "default";
                pinctrl-0 = <&state_default>;
index 44707e7..30100aa 100644 (file)
                };
        };
 
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
+
        pinmux {
                pinctrl-names = "default";
                pinctrl-0 = <&state_default>;
index 161f1e4..7a18b2e 100644 (file)
                };
        };
 
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
+
        pinmux {
                pinctrl-names = "default";
                pinctrl-0 = <&state_default>;
index dbeb7cc..8436eb7 100644 (file)
                };
        };
 
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 40000>;
+               max-brightness = <255>;
+               default-brightness = <77>;
+       };
+
        pmc {
                status = "okay";
                nvidia,invert-interrupt;
index 3067aef..a25c62b 100644 (file)
                reg = <0x7000a000 0x100>;
                #pwm-cells = <2>;
                clocks = <&tegra_car 17>;
-               status = "disabled";
        };
 
        i2c1: i2c@7000c000 {
index 8ed179d..d942372 100644 (file)
                pout-gpio = <&gpio 190 0>;
                tout-gpio = <&gpio 112 0>;
        };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
 };
index 50098f7..ebc01dc 100644 (file)
                device_type = "memory";
                reg = <0x80000000 0x20000000>;
        };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 2 5000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
 };
index 5e4b57b..4383048 100644 (file)
                device_type = "memory";
                reg = <0x80000000 0x20000000>;
        };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
 };
index 2d24324..00ae376 100644 (file)
                nvidia,core-power-req-active-high;
                nvidia,sys-clock-req-active-high;
        };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
 };
index 5ae9d8e..2f60467 100644 (file)
                nvidia,core-power-req-active-high;
                nvidia,sys-clock-req-active-high;
        };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 40000>;
+               max-brightness = <255>;
+               default-brightness = <77>;
+       };
 };
index 53d4b2d..26920eb 100644 (file)
                #clock-cells = <1>;
        };
 
+       pwm: pwm {
+               compatible = "nvidia,tegra124-pwm", "nvidia,tegra20-pwm";
+               reg = <0x7000a000 0x100>;
+               #pwm-cells = <2>;
+               clocks = <&tegra_car 17>;
+       };
+
        apbdma: dma@60020000 {
                compatible = "nvidia,tegra124-apbdma";
                reg = <0x60020000 0x1400>;
index d97c4fa..b1c7449 100644 (file)
 
 /include/ "tegra124-tn8-generic.dtsi"
 
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
 };
 
index cfbbe11..c2ff8a5 100644 (file)
                        status = "okay";
                };
        };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&pwm 1 1000000>;
+               max-brightness = <255>;
+               default-brightness = <224>;
+       };
 };
index 0ebad4e..3754964 100644 (file)
@@ -940,6 +940,10 @@ static struct of_dev_auxdata ardbeg_auxdata_lookup[] __initdata = {
                                NULL),
        OF_DEV_AUXDATA("nvidia,tegra124-i2c", 0x7000d100, "tegra12-i2c.5",
                                NULL),
+       OF_DEV_AUXDATA("nvidia,tegra124-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index 712c141..6cd1e1f 100644 (file)
@@ -758,6 +758,9 @@ static struct platform_device bonaire_nvmap_device = {
 
 static struct platform_device *bonaire_gfx_devices[] __initdata = {
        &bonaire_nvmap_device,
+};
+
+static struct platform_device *bonaire_backlight_devices[] __initdata = {
        &tegra_pwfm_device,
        &bonaire_backlight_device,
 };
@@ -796,6 +799,12 @@ int __init bonaire_panel_init(void)
        err = platform_add_devices(bonaire_gfx_devices,
                                   ARRAY_SIZE(bonaire_gfx_devices));
 
+       if (!of_have_populated_dt()) {
+               /* if error then appened the error */
+               err = platform_add_devices(bonaire_backlight_devices,
+                       ARRAY_SIZE(bonaire_backlight_devices));
+       }
+
 #ifdef CONFIG_TEGRA_GRHOST
        phost1x = bonaire_host1x_init();
        if (!phost1x)
index ee50e44..05031c5 100644 (file)
@@ -616,6 +616,10 @@ struct of_dev_auxdata tegra_bonaire_auxdata_lookup[] __initdata = {
        OF_DEV_AUXDATA("nvidia,tegra124-vi", TEGRA_VI_BASE, "vi", NULL),
        OF_DEV_AUXDATA("nvidia,tegra124-isp", TEGRA_ISP_BASE, "isp", NULL),
        OF_DEV_AUXDATA("nvidia,tegra124-tsec", TEGRA_TSEC_BASE, "tsec", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra124-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index aae3b04..eadfce5 100644 (file)
@@ -744,6 +744,10 @@ struct of_dev_auxdata dalmore_auxdata_lookup[] __initdata = {
                                NULL),
        OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006200, "serial-tegra.2",
                                NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index d304218..9ba061a 100644 (file)
@@ -726,6 +726,10 @@ struct of_dev_auxdata loki_auxdata_lookup[] __initdata = {
                                NULL),
        OF_DEV_AUXDATA("nvidia,tegra124-i2c", 0x7000d100, "tegra12-i2c.5",
                                NULL),
+       OF_DEV_AUXDATA("nvidia,tegra124-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index f46a41f..dc1fd12 100644 (file)
@@ -626,6 +626,10 @@ struct of_dev_auxdata macallan_auxdata_lookup[] __initdata = {
                                NULL),
        OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
                                NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index 7fe9ddf..b692178 100644 (file)
@@ -729,6 +729,10 @@ struct of_dev_auxdata pismo_auxdata_lookup[] __initdata = {
        OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi", NULL),
        OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp", NULL),
        OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index abd2694..aef182b 100644 (file)
@@ -1310,6 +1310,10 @@ struct of_dev_auxdata pluto_auxdata_lookup[] __initdata = {
                                NULL),
        OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006200, "serial-tegra.2",
                                NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index 3c702c2..696a3cf 100644 (file)
@@ -1004,11 +1004,13 @@ int __init roth_panel_init(int board_id)
                return err;
 
 #if IS_EXTERNAL_PWM
-       err = platform_add_devices(roth_bl_device,
+       if (!of_have_populated_dt()) {
+               err = platform_add_devices(roth_bl_device,
                                ARRAY_SIZE(roth_bl_device));
-       if (err) {
-               pr_err("disp1 bl device registration failed");
-               return err;
+               if (err) {
+                       pr_err("disp1 bl dev registration failed");
+                       return err;
+               }
        }
 #endif
 
index eff5a02..2c6e333 100644 (file)
@@ -708,6 +708,10 @@ struct of_dev_auxdata roth_auxdata_lookup[] __initdata = {
        OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi", NULL),
        OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp", NULL),
        OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra114-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index 24e15f1..653d5b2 100644 (file)
@@ -481,6 +481,10 @@ struct of_dev_auxdata vcm30_t124_auxdata_lookup[] __initdata = {
                                NULL),
        OF_DEV_AUXDATA("nvidia,tegra124-ahub", 0x70300000,
                                "tegra30-ahub-apbif", NULL),
+       OF_DEV_AUXDATA("nvidia,tegra124-pwm", TEGRA_PWFM_BASE, "tegra-pwm",
+                               NULL),
+       OF_DEV_AUXDATA("pwm-backlight", NULL, "pwm-backlight",
+                               NULL),
        {}
 };
 #endif
index 2d58496..d0b31c9 100644 (file)
@@ -403,11 +403,14 @@ static struct platform_device __maybe_unused
 static int  __init dsi_a_1080p_11_6_register_bl_dev(void)
 {
        int err = 0;
-       err = platform_add_devices(dsi_a_1080p_11_6_bl_devices,
-                               ARRAY_SIZE(dsi_a_1080p_11_6_bl_devices));
-       if (err) {
-               pr_err("disp1 bl device registration failed");
-               return err;
+       if (!of_have_populated_dt()) {
+               err =
+               platform_add_devices(dsi_a_1080p_11_6_bl_devices,
+                       ARRAY_SIZE(dsi_a_1080p_11_6_bl_devices));
+               if (err) {
+                       pr_err("disp1 bl device registration failed");
+                       return err;
+               }
        }
        return err;
 }
index 023133f..90a31a2 100644 (file)
@@ -400,7 +400,7 @@ static struct platform_device __maybe_unused
        &dsi_a_1080p_14_0_bl_device,
 };
 
-static int  __init dsi_a_1080p_14_0_register_bl_dev(void)
+static int  __init __dsi_a_1080p_14_0_register_bl_dev(void)
 {
        int err = 0;
        err = platform_add_devices(dsi_a_1080p_14_0_bl_devices,
@@ -412,6 +412,14 @@ static int  __init dsi_a_1080p_14_0_register_bl_dev(void)
        return err;
 }
 
+static int  __init dsi_a_1080p_14_0_register_bl_dev(void)
+{
+       int err = 0;
+       if (!of_have_populated_dt())
+               err = __dsi_a_1080p_14_0_register_bl_dev();
+       return err;
+}
+
 static void dsi_a_1080p_14_0_set_disp_device(
        struct platform_device *laguna_display_device)
 {
index 1935794..db1f667 100644 (file)
@@ -312,7 +312,7 @@ static struct platform_device __maybe_unused
        &edp_a_1080p_14_0_bl_device,
 };
 
-static int  __init edp_a_1080p_14_0_register_bl_dev(void)
+static int  __init __edp_a_1080p_14_0_register_bl_dev(void)
 {
        int err = 0;
        err = platform_add_devices(edp_a_1080p_14_0_bl_devices,
@@ -324,6 +324,14 @@ static int  __init edp_a_1080p_14_0_register_bl_dev(void)
        return err;
 }
 
+static int  __init edp_a_1080p_14_0_register_bl_dev(void)
+{
+       int err = 0;
+       if (!of_have_populated_dt())
+               err = __edp_a_1080p_14_0_register_bl_dev();
+       return err;
+}
+
 static void edp_a_1080p_14_0_set_disp_device(
        struct platform_device *laguna_display_device)
 {
index b77b5b5..11fc757 100644 (file)
@@ -329,7 +329,7 @@ static struct platform_device __maybe_unused
        &lvds_c_1366_14_bl_device,
 };
 
-static int  __init lvds_c_1366_14_register_bl_dev(void)
+static int  __init __lvds_c_1366_14_register_bl_dev(void)
 {
        int err = 0;
        err = platform_add_devices(lvds_c_1366_14_bl_devices,
@@ -341,6 +341,14 @@ static int  __init lvds_c_1366_14_register_bl_dev(void)
        return err;
 }
 
+static int  __init lvds_c_1366_14_register_bl_dev(void)
+{
+       int err = 0;
+       if (!of_have_populated_dt())
+               err = __lvds_c_1366_14_register_bl_dev();
+       return 0;
+}
+
 static void lvds_c_1366_14_set_disp_device(
        struct platform_device *laguna_display_device)
 {
index 7130df0..708e268 100644 (file)
@@ -479,16 +479,19 @@ static int dsi_j_1440_810_5_8_register_bl_dev(void)
 {
        int err = 0;
 
-       err = platform_device_register(&tegra_pwfm_device);
-       if (err) {
-               pr_err("disp1 pwm device registration failed");
-               return err;
-       }
+       if (!of_have_populated_dt()) {
+               err = platform_device_register(&tegra_pwfm_device);
+               if (err) {
+                       pr_err("disp1 pwm device registration failed");
+                       return err;
+               }
 
-       err = platform_device_register(&dsi_j_1440_810_5_8_bl_device);
-       if (err) {
-               pr_err("disp1 bl device registration failed");
-               return err;
+               err = platform_device_register
+                               (&dsi_j_1440_810_5_8_bl_device);
+               if (err) {
+                       pr_err("disp1 bl device registration failed");
+                       return err;
+               }
        }
 
        err = gpio_request(dsi_j_1440_810_5_8_pdata.dsi_panel_bl_pwm_gpio,
index bec074d..7839c3b 100644 (file)
@@ -135,16 +135,18 @@ static struct tegra_dsi_out dsi_j_720p_4_7_pdata;
 static int dsi_j_720p_4_7_register_bl_dev(void)
 {
        int err = 0;
-       err = platform_device_register(&tegra_pwfm_device);
-       if (err) {
-               pr_err("disp1 pwm device registration failed");
-               return err;
-       }
+       if (!of_have_populated_dt()) {
+               err = platform_device_register(&tegra_pwfm_device);
+               if (err) {
+                       pr_err("disp1 pwm device registration failed");
+                       return err;
+               }
 
-       err = platform_device_register(&dsi_j_720p_4_7_bl_device);
-       if (err) {
-               pr_err("disp1 bl device registration failed");
-               return err;
+               err = platform_device_register(&dsi_j_720p_4_7_bl_device);
+               if (err) {
+                       pr_err("disp1 bl device registration failed");
+                       return err;
+               }
        }
 
        err = gpio_request(dsi_j_720p_4_7_pdata.dsi_panel_bl_pwm_gpio,
index e2c276c..7df7df8 100644 (file)
@@ -579,16 +579,19 @@ static int dsi_l_720p_5_loki_register_bl_dev(void)
 {
        int err = 0;
 
-       err = platform_device_register(&tegra_pwfm_device);
-       if (err) {
-               pr_err("disp1 pwm device registration failed");
-               return err;
-       }
+       if (!of_have_populated_dt()) {
+               err = platform_device_register(&tegra_pwfm_device);
+               if (err) {
+                       pr_err("disp1 pwm device registration failed");
+                       return err;
+               }
 
-       err = platform_device_register(&dsi_l_720p_5_loki_bl_device);
-       if (err) {
-               pr_err("disp1 bl device registration failed");
-               return err;
+               err = platform_device_register(
+                                       &dsi_l_720p_5_loki_bl_device);
+               if (err) {
+                       pr_err("disp1 bl device registration failed");
+                       return err;
+               }
        }
 
        err = gpio_request(dsi_l_720p_5_loki_pdata.dsi_panel_bl_pwm_gpio,
index 7cf6556..7ee0fc1 100644 (file)
@@ -619,7 +619,7 @@ static unsigned int dsi_p_tn8_edp_brightness[] = {
        255, 227, 199, 171, 143, 115, 87, 59, 31, 0
 };
 
-static int  __init dsi_p_wuxga_10_1_register_bl_dev(void)
+static int  __init __dsi_p_wuxga_10_1_register_bl_dev(void)
 {
        int err = 0;
        struct board_info board_info;
@@ -648,6 +648,14 @@ static int  __init dsi_p_wuxga_10_1_register_bl_dev(void)
        return err;
 }
 
+static int  __init dsi_p_wuxga_10_1_register_bl_dev(void)
+{
+       int err = 0;
+       if (!of_have_populated_dt())
+               err = __dsi_p_wuxga_10_1_register_bl_dev();
+       return err;
+}
+
 static void dsi_p_wuxga_10_1_set_disp_device(
        struct platform_device *display_device)
 {
index 7b8b087..af7307b 100644 (file)
@@ -690,7 +690,7 @@ static unsigned int dsi_s_tn8_edp_brightness[] = {
        255, 227, 199, 171, 143, 115, 87, 59, 31, 0
 };
 
-static int __init dsi_s_wqxga_10_1_register_bl_dev(void)
+static int __init __dsi_s_wqxga_10_1_register_bl_dev(void)
 {
        int err = 0;
        struct board_info board_info;
@@ -719,6 +719,14 @@ static int __init dsi_s_wqxga_10_1_register_bl_dev(void)
        return err;
 }
 
+static int __init dsi_s_wqxga_10_1_register_bl_dev(void)
+{
+       int err = 0;
+       if (!of_have_populated_dt())
+               err = __dsi_s_wqxga_10_1_register_bl_dev();
+       return err;
+}
+
 static void dsi_s_wqxga_10_1_set_disp_device(
        struct platform_device *dalmore_display_device)
 {
index e4c6d27..0eab4df 100644 (file)
@@ -150,29 +150,17 @@ static const struct backlight_ops pwm_backlight_ops = {
 };
 
 #ifdef CONFIG_OF
-static int pwm_backlight_parse_dt(struct device *dev,
-                                 struct platform_pwm_backlight_data *data)
+static int parse_level_brightness_dt(struct device *dev,
+                                 struct platform_pwm_backlight_data *data,
+                                 int max_brightness)
 {
        struct device_node *node = dev->of_node;
-       struct property *prop;
-       int length;
-       u32 value;
-       int ret;
-
-       if (!node)
-               return -ENODEV;
-
-       memset(data, 0, sizeof(*data));
-
-       /* determine the number of brightness levels */
-       prop = of_find_property(node, "brightness-levels", &length);
-       if (!prop)
-               return -EINVAL;
-
-       data->max_brightness = length / sizeof(u32);
+       data->max_brightness = max_brightness;
 
        /* read brightness levels from DT property */
        if (data->max_brightness > 0) {
+               u32 value;
+               int ret;
                size_t size = sizeof(*data->levels) * data->max_brightness;
 
                data->levels = devm_kzalloc(dev, size, GFP_KERNEL);
@@ -200,13 +188,55 @@ static int pwm_backlight_parse_dt(struct device *dev,
                data->max_brightness--;
        }
 
+       return 0;
+}
+
+static int parse_interpole_brightness_dt(struct device *dev,
+                                 struct platform_pwm_backlight_data *data)
+{
+       int ret = 0;
+       struct device_node *node = dev->of_node;
+
+       ret = of_property_read_u32(node, "max-brightness",
+                                       &data->max_brightness);
+       if (ret < 0)
+               goto end;
+
+       ret = of_property_read_u32(node, "default-brightness",
+                                       &data->dft_brightness);
+       if (ret < 0)
+               goto end;
+end:
+       return ret;
+}
+
+static int pwm_backlight_parse_dt(struct device *dev,
+                                 struct platform_pwm_backlight_data *data)
+{
+       struct device_node *node = dev->of_node;
+       struct property *prop;
+       int length;
+
+       if (!node)
+               return -ENODEV;
+
+       memset(data, 0, sizeof(*data));
+
        /*
         * TODO: Most users of this driver use a number of GPIOs to control
         *       backlight power. Support for specifying these needs to be
         *       added.
         */
 
-       return 0;
+       /* determine the number of brightness levels if available else
+        * use the interpolation method to get the maximum brightness
+        * that can be set*/
+       prop = of_find_property(node, "brightness-levels", &length);
+       if (prop)
+               return parse_level_brightness_dt(dev,
+                                       data, length / sizeof(u32));
+       else
+               return parse_interpole_brightness_dt(dev, data);
 }
 
 static struct of_device_id pwm_backlight_of_match[] = {