[U-Boot] [PATCH v4 1/3] EHCI: Exynos: Add fdt support

From: Rajeshwari Shinde rajeshwari.s@samsung.com
Adding fdt support to ehci-exynos in order to parse register base addresses from the device node.
Signed-off-by: Vivek Gautam gautam.vivek@samsung.com Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com ---
Changes in v4: - Rebased on top of u-boot-samsung/master.
Changes in v3: - Using macros for error no. - Using a common function exynos_usb_parse_dt() to parse all DT related data. - Using a global structure "exynos_ehci" to store register base addresses and thereby using it.
Changes in v2: - Removed checkpatch errors.
drivers/usb/host/ehci-exynos.c | 92 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 9f0ed06..3ca4c5c 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -21,13 +21,71 @@ */
#include <common.h> +#include <fdtdec.h> +#include <libfdt.h> +#include <malloc.h> #include <usb.h> #include <asm/arch/cpu.h> #include <asm/arch/ehci.h> #include <asm/arch/system.h> #include <asm/arch/power.h> +#include <asm-generic/errno.h> +#include <linux/compat.h> #include "ehci.h"
+/* Declare global data pointer */ +DECLARE_GLOBAL_DATA_PTR; + +/** + * Contains pointers to register base addresses + * for the usb controller. + */ +struct exynos_ehci { + struct exynos_usb_phy *usb; + unsigned int *hcd; +}; + +static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos) +{ + unsigned int node; + int depth; + + node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS_EHCI); + if (node <= 0) { + debug("EHCI: Can't get device node for ehci\n"); + return -ENODEV; + } + + /* + * Get the base address for EHCI controller from the device node + */ + exynos->hcd = (unsigned int *)fdtdec_get_addr(blob, node, "reg"); + if (exynos->hcd == NULL) { + debug("Can't get the EHCI register address\n"); + return -ENXIO; + } + + depth = 0; + node = fdtdec_next_compatible_subnode(blob, node, + COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth); + if (node <= 0) { + debug("EHCI: Can't get device node for usb-phy controller\n"); + return -ENODEV; + } + + /* + * Get the base address for usbphy from the device node + */ + exynos->usb = (struct exynos_usb_phy *)fdtdec_get_addr(blob, node, + "reg"); + if (exynos->usb == NULL) { + debug("Can't get the usbphy register address\n"); + return -ENXIO; + } + + return 0; +} + /* Setup the EHCI host controller. */ static void setup_usb_phy(struct exynos_usb_phy *usb) { @@ -86,12 +144,20 @@ static void reset_usb_phy(struct exynos_usb_phy *usb) */ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { - struct exynos_usb_phy *usb; + struct exynos_ehci *exynos = NULL; + + exynos = (struct exynos_ehci *) + kzalloc(sizeof(struct exynos_ehci), GFP_KERNEL); + if (!exynos) { + debug("failed to allocate exynos ehci context\n"); + return -ENOMEM; + }
- usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy(); - setup_usb_phy(usb); + exynos_usb_parse_dt(gd->fdt_blob, exynos);
- *hccr = (struct ehci_hccr *)samsung_get_base_usb_ehci(); + setup_usb_phy(exynos->usb); + + *hccr = (struct ehci_hccr *)(exynos->hcd); *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
@@ -99,6 +165,8 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
+ kfree(exynos); + return 0; }
@@ -108,10 +176,20 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) */ int ehci_hcd_stop(int index) { - struct exynos_usb_phy *usb; + struct exynos_ehci *exynos = NULL; + + exynos = (struct exynos_ehci *) + kzalloc(sizeof(struct exynos_ehci), GFP_KERNEL); + if (!exynos) { + debug("failed to allocate exynos ehci context\n"); + return -ENOMEM; + } + + exynos_usb_parse_dt(gd->fdt_blob, exynos); + + reset_usb_phy(exynos->usb);
- usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy(); - reset_usb_phy(usb); + kfree(exynos);
return 0; }

From: Rajeshwari Shinde rajeshwari.s@samsung.com
This patch adds the device node required for USB
Signed-off-by: Vivek Gautam gautam.vivek@samsung.com ---
Changes in v4: - Rebased on top of u-boot-samsung/master.
Changes in v3: - Using a sub-node under ehci node for phy which provides "compatible" and "reg" information.
Changes in v2: - None.
arch/arm/dts/exynos5250.dtsi | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi index 1008797..ed8c8dd 100644 --- a/arch/arm/dts/exynos5250.dtsi +++ b/arch/arm/dts/exynos5250.dtsi @@ -138,4 +138,17 @@ reg = <0x131b0000 0x30>; interrupts = <0 130 0>; }; + + ehci@12110000 { + compatible = "samsung,exynos-ehci"; + reg = <0x12110000 0x100>; + #address-cells = <1>; + #size-cells = <1>; + + phy { + compatible = "samsung,exynos-usb-phy"; + reg = <0x12130000 0x100>; + }; + }; + };

On 08/01/13 18:35, Vivek Gautam wrote:
From: Rajeshwari Shinde rajeshwari.s@samsung.com
This patch adds the device node required for USB
Signed-off-by: Vivek Gautam gautam.vivek@samsung.com
Changes in v4: - Rebased on top of u-boot-samsung/master.
Changes in v3: - Using a sub-node under ehci node for phy which provides "compatible" and "reg" information.
Changes in v2: - None.
arch/arm/dts/exynos5250.dtsi | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
applied to u-boot-samsung.
Thanks, Minkyu Kang.

From: Rajeshwari Shinde rajeshwari.s@samsung.com
Add required compatible information for USB
Signed-off-by: Vivek Gautam gautam.vivek@samsung.com Acked-by: Simon Glass sjg@chromium.org ---
Changes in v4: - Rebased on top of u-boot-samsung/master.
Changes in v3: - Added compatible string for USB PHY controller.
Changes in v2: - None.
include/fdtdec.h | 2 ++ lib/fdtdec.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index ce10bf4..0d3417b 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -76,6 +76,8 @@ enum fdt_compat_id { COMPAT_SAMSUNG_EXYNOS5_SOUND, /* Exynos Sound */ COMPAT_WOLFSON_WM8994_CODEC, /* Wolfson WM8994 Sound Codec */ COMPAT_SAMSUNG_EXYNOS_SPI, /* Exynos SPI */ + COMPAT_SAMSUNG_EXYNOS_EHCI, /* Exynos EHCI controller */ + COMPAT_SAMSUNG_EXYNOS_USB_PHY, /* Exynos phy controller for usb2.0 */
COMPAT_COUNT, }; diff --git a/lib/fdtdec.c b/lib/fdtdec.c index aa75710..4416670 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -51,6 +51,8 @@ static const char * const compat_names[COMPAT_COUNT] = { COMPAT(SAMSUNG_EXYNOS5_SOUND, "samsung,exynos-sound"), COMPAT(WOLFSON_WM8994_CODEC, "wolfson,wm8994-codec"), COMPAT(SAMSUNG_EXYNOS_SPI, "samsung,exynos-spi"), + COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"), + COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"), };
const char *fdtdec_get_compatible(enum fdt_compat_id id)

On 08/01/13 18:35, Vivek Gautam wrote:
From: Rajeshwari Shinde rajeshwari.s@samsung.com
Add required compatible information for USB
Signed-off-by: Vivek Gautam gautam.vivek@samsung.com Acked-by: Simon Glass sjg@chromium.org
Changes in v4: - Rebased on top of u-boot-samsung/master.
Changes in v3: - Added compatible string for USB PHY controller.
Changes in v2: - None.
include/fdtdec.h | 2 ++ lib/fdtdec.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
applied to u-boot-samsung.
Thanks, Minkyu Kang.

On 08/01/13 18:35, Vivek Gautam wrote:
From: Rajeshwari Shinde rajeshwari.s@samsung.com
Adding fdt support to ehci-exynos in order to parse register base addresses from the device node.
Signed-off-by: Vivek Gautam gautam.vivek@samsung.com Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
Changes in v4:
- Rebased on top of u-boot-samsung/master.
Changes in v3: - Using macros for error no. - Using a common function exynos_usb_parse_dt() to parse all DT related data. - Using a global structure "exynos_ehci" to store register base addresses and thereby using it.
Changes in v2: - Removed checkpatch errors.
drivers/usb/host/ehci-exynos.c | 92 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 85 insertions(+), 7 deletions(-)
applied to u-boot-samsung.
Thanks, Minkyu Kang.
participants (2)
-
Minkyu Kang
-
Vivek Gautam