video: ARM CLCD: use panel device node for getting backlight and mode
[linux-2.6-block.git] / drivers / video / fbdev / amba-clcd.c
index ec2671d98abcccb5f3afa6bfd68158a14557ce6e..0fab92c628280359ec79023b545ff893c12a2d6c 100644 (file)
  *
  *  ARM PrimeCell PL110 Color LCD Controller
  */
-#include <linux/dma-mapping.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/slab.h>
+#include <linux/amba/bus.h>
+#include <linux/amba/clcd.h>
+#include <linux/backlight.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
-#include <linux/mm.h>
+#include <linux/dma-mapping.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/list.h>
-#include <linux/amba/bus.h>
-#include <linux/amba/clcd.h>
-#include <linux/bitops.h>
-#include <linux/clk.h>
-#include <linux/hardirq.h>
-#include <linux/of.h>
+#include <linux/mm.h>
+#include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_graph.h>
-#include <linux/backlight.h>
+#include <linux/slab.h>
+#include <linux/string.h>
 #include <video/display_timing.h>
 #include <video/of_display_timing.h>
 #include <video/videomode.h>
@@ -629,16 +624,11 @@ static int clcdfb_snprintf_mode(char *buf, int size, struct fb_videomode *mode)
                        mode->refresh);
 }
 
-static int clcdfb_of_get_backlight(struct device_node *endpoint,
+static int clcdfb_of_get_backlight(struct device_node *panel,
                                   struct clcd_panel *clcd_panel)
 {
-       struct device_node *panel;
        struct device_node *backlight;
 
-       panel = of_graph_get_remote_port_parent(endpoint);
-       if (!panel)
-               return -ENODEV;
-
        /* Look up the optional backlight phandle */
        backlight = of_parse_phandle(panel, "backlight", 0);
        if (backlight) {
@@ -651,19 +641,14 @@ static int clcdfb_of_get_backlight(struct device_node *endpoint,
        return 0;
 }
 
-static int clcdfb_of_get_mode(struct device *dev, struct device_node *endpoint,
-               struct clcd_panel *clcd_panel)
+static int clcdfb_of_get_mode(struct device *dev, struct device_node *panel,
+                             struct clcd_panel *clcd_panel)
 {
        int err;
-       struct device_node *panel;
        struct fb_videomode *mode;
        char *name;
        int len;
 
-       panel = of_graph_get_remote_port_parent(endpoint);
-       if (!panel)
-               return -ENODEV;
-
        /* Only directly connected DPI panels supported for now */
        if (of_device_is_compatible(panel, "panel-dpi"))
                err = clcdfb_of_get_dpi_panel_mode(panel, clcd_panel);
@@ -769,7 +754,7 @@ static int clcdfb_of_init_tft_panel(struct clcd_fb *fb, u32 r0, u32 g0, u32 b0)
 
 static int clcdfb_of_init_display(struct clcd_fb *fb)
 {
-       struct device_node *endpoint;
+       struct device_node *endpoint, *panel;
        int err;
        unsigned int bpp;
        u32 max_bandwidth;
@@ -786,17 +771,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
        if (!endpoint)
                return -ENODEV;
 
+       panel = of_graph_get_remote_port_parent(endpoint);
+       if (!panel)
+               return -ENODEV;
+
        if (fb->vendor->init_panel) {
-               err = fb->vendor->init_panel(fb, endpoint);
+               err = fb->vendor->init_panel(fb, panel);
                if (err)
                        return err;
        }
 
-       err = clcdfb_of_get_backlight(endpoint, fb->panel);
+       err = clcdfb_of_get_backlight(panel, fb->panel);
        if (err)
                return err;
 
-       err = clcdfb_of_get_mode(&fb->dev->dev, endpoint, fb->panel);
+       err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel);
        if (err)
                return err;