]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
usb: UniPhier: support OF configuration
authorMasahiro Yamada <yamada.m@jp.panasonic.com>
Wed, 26 Nov 2014 09:34:01 +0000 (18:34 +0900)
committerMasahiro Yamada <yamada.m@jp.panasonic.com>
Thu, 27 Nov 2014 17:21:01 +0000 (02:21 +0900)
If CONFIG_OF_CONTROL is defined, search device tree nodes that are
compatible with "panasonic,uniphier-ehci" and take the base address
from their "reg" property.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Marek Vasut <marex@denx.de>
arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c
arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c
arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c
arch/arm/dts/uniphier-ph1-ld4-ref.dts
arch/arm/dts/uniphier-ph1-ld4.dtsi
arch/arm/dts/uniphier-ph1-pro4-ref.dts
arch/arm/dts/uniphier-ph1-pro4.dtsi
arch/arm/dts/uniphier-ph1-sld8-ref.dts
arch/arm/dts/uniphier-ph1-sld8.dtsi
drivers/usb/host/ehci-uniphier.c

index 62f5b0148dc0b61cc637208a7d8f30473a8f0395..9d51299308764fb02d94c3d7e668d31a122e02ae 100644 (file)
@@ -14,7 +14,6 @@ SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
 SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
 SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
 
-/* USB : TODO for Masahiro Yamada: move base address to Device Tree */
 struct uniphier_ehci_platform_data uniphier_ehci_platdata[] = {
        {
                .base = 0x5a800100,
index 1843d0469f6e775c0da6f3bf2f7a6ec9f59543ef..31ee2a210002d2c67759191b515e105d90ed8cd8 100644 (file)
@@ -14,7 +14,6 @@ SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
 SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
 SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
 
-/* USB : TODO for Masahiro Yamada: move base address to Device Tree */
 struct uniphier_ehci_platform_data uniphier_ehci_platdata[] = {
        {
                .base = 0x5a800100,
index 72ec599f69b905dd029c73519ccd2abf2679a8a7..ea0691dd67b9f06ca21d8dbb0ac85fa1df549aad 100644 (file)
@@ -14,7 +14,6 @@ SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
 SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
 SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
 
-/* USB : TODO for Masahiro Yamada: move base address to Device Tree */
 struct uniphier_ehci_platform_data uniphier_ehci_platdata[] = {
        {
                .base = 0x5a800100,
index 20b05831432923fa96a079adcf60c37cf5105173..f01189c99339bd699553837445d394859ba2df50 100644 (file)
 &uart1 {
        status = "okay";
 };
+
+&usb0 {
+      status = "okay";
+};
+
+&usb1 {
+      status = "okay";
+};
index c1c2c62b7991c2c7d45db93305d8a531ee3b95e3..80074c50b5b9a51405e8dff805f61ba877362ea5 100644 (file)
                        reg = <0x54006b00 0x20>;
                        clock-frequency = <36864000>;
                };
+
+               usb0: usb@5a800100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a800100 0x100>;
+               };
+
+               usb1: usb@5a810100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a810100 0x100>;
+               };
+
+               usb2: usb@5a820100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a820100 0x100>;
+               };
        };
 };
index b42c9c8098c7c796b1201e68409b482b96cf75dc..52fa81fae15e6ce6eaa70e675d8091edce155428 100644 (file)
 &uart1 {
        status = "okay";
 };
+
+&usb0 {
+      status = "okay";
+};
+
+&usb1 {
+      status = "okay";
+};
index b53fbc5161c520730b39a37c4235dc9aed20c3ce..dd84269d1ade467c95ba95c986cae194b40e52d5 100644 (file)
                        reg = <0x54006b00 0x20>;
                        clock-frequency = <73728000>;
                };
+
+               usb0: usb@5a800100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a800100 0x100>;
+               };
+
+               usb1: usb@5a810100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a810100 0x100>;
+               };
        };
 };
index 6f898a3a9678f36a17ed6b05e84932ba402dd3b8..ac73aad928e7c3ce5f7459262bb31c090c848991 100644 (file)
 &uart1 {
        status = "okay";
 };
+
+&usb0 {
+      status = "okay";
+};
+
+&usb1 {
+      status = "okay";
+};
index 9a8da5e4423cb1bceeca798b0d0c0f1865bd1029..43a39f5a4c546c917ded9b8f8b90772660eb570c 100644 (file)
                        reg = <0x54006b00 0x20>;
                        clock-frequency = <80000000>;
                };
+
+               usb0: usb@5a800100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a800100 0x100>;
+               };
+
+               usb1: usb@5a810100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a810100 0x100>;
+               };
+
+               usb2: usb@5a820100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a820100 0x100>;
+               };
        };
 };
index 77f6c9d9d141b99f80cd1da6bd6368042f1e1d61..32a43752790d72ee1c7d0d18730c255d7a191dd7 100644 (file)
@@ -6,10 +6,43 @@
  */
 
 #include <common.h>
+#include <linux/err.h>
 #include <usb.h>
 #include <asm/arch/ehci-uniphier.h>
 #include "ehci.h"
 
+#ifdef CONFIG_OF_CONTROL
+#include <fdtdec.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+#define FDT            gd->fdt_blob
+#define COMPAT         "panasonic,uniphier-ehci"
+
+static int get_uniphier_ehci_base(int index, struct ehci_hccr **base)
+{
+       int offset;
+
+       for (offset = fdt_node_offset_by_compatible(FDT, 0, COMPAT);
+            offset >= 0;
+            offset = fdt_node_offset_by_compatible(FDT, offset, COMPAT)) {
+               if (index == 0) {
+                       *base = (struct ehci_hccr *)
+                                       fdtdec_get_addr(FDT, offset, "reg");
+                       return 0;
+               }
+               index--;
+       }
+
+       return -ENODEV; /* not found */
+}
+#else
+static int get_uniphier_ehci_base(int index, struct ehci_hccr **base)
+{
+       *base = (struct ehci_hccr *)uniphier_ehci_platdata[index].base;
+       return 0;
+}
+#endif
+
 /*
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
 int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
                  struct ehci_hcor **hcor)
 {
+       int ret;
        struct ehci_hccr *cr;
        struct ehci_hcor *or;
 
        uniphier_ehci_reset(index, 0);
 
-       cr = (struct ehci_hccr *)(uniphier_ehci_platdata[index].base);
+       ret = get_uniphier_ehci_base(index, &cr);
+       if (ret < 0)
+               return ret;
        or = (void *)cr + HC_LENGTH(ehci_readl(&cr->cr_capbase));
 
        *hccr = cr;