Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=31e8d4603ecaeb02424c9669e252ab835354a36e
Commit:     31e8d4603ecaeb02424c9669e252ab835354a36e
Parent:     47473e31585032e5c048eeec50e0f9165890230a
Author:     Grant Likely <[EMAIL PROTECTED]>
AuthorDate: Thu Oct 4 10:48:37 2007 -0600
Committer:  Grant Likely <[EMAIL PROTECTED]>
CommitDate: Tue Oct 9 18:12:02 2007 -0600

    [POWERPC] XilinxFB: add of_platform bus binding
    
    Adds the of_platform bus binding to the xilinxfb driver.  Needed to
    use framebuffer devices described in the OF device tree (used by
    arch/powerpc).
    
    Signed-off-by: Grant Likely <[EMAIL PROTECTED]>
    Acked-by: Andrei Konovalov <[EMAIL PROTECTED]>
---
 drivers/video/xilinxfb.c |  107 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 98 insertions(+), 9 deletions(-)

diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index e482bb5..dbb23a9 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -6,9 +6,12 @@
  * Author: MontaVista Software, Inc.
  *         [EMAIL PROTECTED]
  *
- * 2002-2007 (c) MontaVista Software, Inc.  This file is licensed under the
- * terms of the GNU General Public License version 2.  This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
+ * 2002-2007 (c) MontaVista Software, Inc.
+ * 2007 (c) Secret Lab Technologies, Ltd.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
  */
 
 /*
@@ -29,7 +32,10 @@
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
-
+#if defined(CONFIG_OF)
+#include <linux/of_device.h>
+#include <linux/of_platform.h>
+#endif
 #include <asm/io.h>
 #include <linux/xilinxfb.h>
 
@@ -384,20 +390,103 @@ static struct platform_driver xilinxfb_platform_driver = 
{
        },
 };
 
+/* ---------------------------------------------------------------------
+ * OF bus binding
+ */
+
+#if defined(CONFIG_OF)
+static int __devinit
+xilinxfb_of_probe(struct of_device *op, const struct of_device_id *match)
+{
+       struct resource res;
+       const u32 *prop;
+       int width = 0, height = 0, rotate = 0;
+       int size, rc;
+
+       dev_dbg(&op->dev, "xilinxfb_of_probe(%p, %p)\n", op, match);
+
+       rc = of_address_to_resource(op->node, 0, &res);
+       if (rc) {
+               dev_err(&op->dev, "invalid address\n");
+               return rc;
+       }
+
+       prop = of_get_property(op->node, "display-number", &size);
+       if ((prop) && (size >= sizeof(u32)*2)) {
+               width = prop[0];
+               height = prop[1];
+       }
+
+       if (of_find_property(op->node, "rotate-display", NULL))
+               rotate = 1;
+
+       return xilinxfb_assign(&op->dev, res.start, width, height, rotate);
+}
+
+static int __devexit xilinxfb_of_remove(struct of_device *op)
+{
+       return xilinxfb_release(&op->dev);
+}
+
+/* Match table for of_platform binding */
+static struct of_device_id __devinit xilinxfb_of_match[] = {
+       { .compatible = "xilinx,ml300-fb", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, xilinxfb_of_match);
+
+static struct of_platform_driver xilinxfb_of_driver = {
+       .owner = THIS_MODULE,
+       .name = DRIVER_NAME,
+       .match_table = xilinxfb_of_match,
+       .probe = xilinxfb_of_probe,
+       .remove = __devexit_p(xilinxfb_of_remove),
+       .driver = {
+               .name = DRIVER_NAME,
+       },
+};
+
+/* Registration helpers to keep the number of #ifdefs to a minimum */
+static inline int __init xilinxfb_of_register(void)
+{
+       pr_debug("xilinxfb: calling of_register_platform_driver()\n");
+       return of_register_platform_driver(&xilinxfb_of_driver);
+}
+
+static inline void __exit xilinxfb_of_unregister(void)
+{
+       of_unregister_platform_driver(&xilinxfb_of_driver);
+}
+#else /* CONFIG_OF */
+/* CONFIG_OF not enabled; do nothing helpers */
+static inline int __init xilinxfb_of_register(void) { return 0; }
+static inline void __exit xilinxfb_of_unregister(void) { }
+#endif /* CONFIG_OF */
+
+/* ---------------------------------------------------------------------
+ * Module setup and teardown
+ */
+
 static int __init
 xilinxfb_init(void)
 {
-       /*
-        * No kernel boot options used,
-        * so we just need to register the driver
-        */
-       return platform_driver_register(&xilinxfb_platform_driver);
+       int rc;
+       rc = xilinxfb_of_register();
+       if (rc)
+               return rc;
+
+       rc = platform_driver_register(&xilinxfb_platform_driver);
+       if (rc)
+               xilinxfb_of_unregister();
+
+       return rc;
 }
 
 static void __exit
 xilinxfb_cleanup(void)
 {
        platform_driver_unregister(&xilinxfb_platform_driver);
+       xilinxfb_of_unregister();
 }
 
 module_init(xilinxfb_init);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to