Skip to contentSkip to conversation

EHCI: Exynos: Add fdt support

PATCH Superseded Vivek Gautam 4 participants 13 messages Jan 3, 2013 – Jan 8, 2013

Subsystems (5)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 EHCI: Exynos: Add fdt support

From: Rajeshwari Shinde <[email protected]>

Adding fdt support to ehci-exynos in order to parse register base addresses from the device node.

---

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.

Chnages in v2:
- Removed checkpatch errors.

 drivers/usb/host/ehci-exynos.c |   92 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 85 insertions(+), 7 deletions(-)
drivers/usb/host/ehci-exynos.c +85 -7
index 9f0ed06..3ca4c5c 100644
@@ -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;
 }
Signature · 1 line
1.7.6.5
#1 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

---

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(-)
arch/arm/dts/exynos5250.dtsi +13 -0
index fa4d498..9179fc9 100644
@@ -28,4 +28,17 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 	};
+
+	ehci at 12110000 {
+		compatible = "samsung,exynos-ehci";
+		reg = <0x12110000 0x100>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		phy {
+			compatible = "samsung,exynos-usb-phy";
+			reg = <0x12130000 0x100>;
+		};
+	};
+
 };
Signature · 1 line
1.7.6.5
#3 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

Hi Marek,

Quoted 10 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 5 lines

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

Please rebase on u-boot-usb/next.

"exynos5250.dtsi" seems to be missing in u-boot-usb tree. :-(
I can't find the exynos5250 side basic device tree support which is already been applied on u-boot-samsung-mainline.

Set of five patches from Hatim Ali mentioned below, needs to be pulled for exysno5250 side device tree support.
- EXYNOS5: FDT: add initial dts file for EXYNOS5250, SMDK5250
- fdt: exynos5: Add DT node definition for SROM and SMSC9215
- exynos5: Add DT based driver for SMC911X ethernet
- exynos5: config: Rename the smdk5250.h to exynos5250-dt.h
- SMDK5250: config: Add configuration file for SMDK5250 board

Please suggest.

Signature · 2 lines
Thanks & Regards
Vivek
#4 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

Dear Vivek Gautam,

Quoted 9 lines

Hi Marek,

Quoted 6 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 4 lines

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Please rebase on u-boot-usb/next.

"exynos5250.dtsi" seems to be missing in u-boot-usb tree. :-(
I can't find the exynos5250 side basic device tree support which is already been applied on u-boot-samsung-mainline.

Ok, let's change how to do this then. Apply all four on u-boot-samsung/next.

Quoted 9 lines

Set of five patches from Hatim Ali mentioned below, needs to be pulled for exysno5250 side device tree support.
- EXYNOS5: FDT: add initial dts file for EXYNOS5250, SMDK5250
- fdt: exynos5: Add DT node definition for SROM and SMSC9215
- exynos5: Add DT based driver for SMC911X ethernet
- exynos5: config: Rename the smdk5250.h to exynos5250-dt.h
- SMDK5250: config: Add configuration file for SMDK5250 board

Please suggest.

Best regards,
Marek Vasut

#5 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

Quoted 13 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 11 lines

Hi Marek,

Quoted 8 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 5 lines

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Please rebase on u-boot-usb/next.

"exynos5250.dtsi" seems to be missing in u-boot-usb tree. :-(
I can't find the exynos5250 side basic device tree support which is already been applied on u-boot-samsung-mainline.

Ok, let's change how to do this then. Apply all four on u-boot-samsung/next.

Ok, sure. I shall post all 4 patches including 3 for ehci fdt support and 1 patch
for usb vbus rebased on top of u-boot-samsung/master.

Signature · 2 lines
Thanks & Regards
Vivek
#6 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

Dear Vivek Gautam,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

Dear Vivek Gautam,

Quoted 16 lines

Hi Marek,

Quoted 9 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 5 lines

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

Please rebase on u-boot-usb/next.

"exynos5250.dtsi" seems to be missing in u-boot-usb tree. :-( I can't find the exynos5250 side basic device tree support which is already been applied on u-boot-samsung-mainline.

Quoted 6 lines
Quoted 2 lines

Ok, let's change how to do this then. Apply all four on u-boot-samsung/next.

Ok, sure. I shall post all 4 patches including 3 for ehci fdt support and 1 patch
for usb vbus rebased on top of u-boot-samsung/master.

I think the -samsung custodian shall just pick your series as is.

Best regards,
Marek Vasut

#7 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

Hello,

Quoted 22 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

Dear Vivek Gautam,

Quoted 16 lines

Hi Marek,

Quoted 9 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 5 lines

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

Please rebase on u-boot-usb/next.

"exynos5250.dtsi" seems to be missing in u-boot-usb tree. :-( I can't find the exynos5250 side basic device tree support which is already been applied on u-boot-samsung-mainline.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Ok, let's change how to do this then. Apply all four on u-boot-samsung/next.

Ok, sure. I shall post all 4 patches including 3 for ehci fdt support and 1 patch
for usb vbus rebased on top of u-boot-samsung/master.

I think the -samsung custodian shall just pick your series as is.

Then, I will pick up following patches.

[U-Boot,v3,1/3] EHCI: Exynos: Add fdt support [U-Boot,v3,2/3] EXYNOS5: Add device node for USB. [U-Boot,v3,3/3] EXYNOS5: FDT: Add compatible strings for USB [U-Boot,v2] SMDK5250: Enable VBus for USB 2.0 controller (V2! not V3)

Is it right?

Thanks,
Minkyu Kang.

#8 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

Dear Minkyu Kang,

Quoted 34 lines

Hello,

Quoted 22 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

Dear Vivek Gautam,

Quoted 16 lines

Hi Marek,

Quoted 9 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 5 lines

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

Please rebase on u-boot-usb/next.

"exynos5250.dtsi" seems to be missing in u-boot-usb tree. :-( I can't find the exynos5250 side basic device tree support which is already been applied on u-boot-samsung-mainline.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Ok, let's change how to do this then. Apply all four on u-boot-samsung/next.

Ok, sure. I shall post all 4 patches including 3 for ehci fdt support and 1 patch
for usb vbus rebased on top of u-boot-samsung/master.

I think the -samsung custodian shall just pick your series as is.

Quoted 8 lines

Then, I will pick up following patches.

[U-Boot,v3,1/3] EHCI: Exynos: Add fdt support [U-Boot,v3,2/3] EXYNOS5: Add device node for USB. [U-Boot,v3,3/3] EXYNOS5: FDT: Add compatible strings for USB [U-Boot,v2] SMDK5250: Enable VBus for USB 2.0 controller (V2! not V3)

Is it right?

Yes, thanks man!

Quoted 2 lines

Thanks,
Minkyu Kang.

Best regards,
Marek Vasut

#9 lore raw

PATCH v3 2/3 EXYNOS5: Add device node for USB.

Hi Minkyu Kang,

Quoted 38 lines · Marek Vasut

Dear Minkyu Kang,

Quoted 36 lines

Hello,

Quoted 22 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

Dear Vivek Gautam,

Quoted 16 lines

Hi Marek,

Quoted 9 lines · Marek Vasut

Dear Vivek Gautam,

Quoted 5 lines

From: Rajeshwari Shinde <[email protected]>

This patch adds the device node required for USB

Please rebase on u-boot-usb/next.

"exynos5250.dtsi" seems to be missing in u-boot-usb tree. :-( I can't find the exynos5250 side basic device tree support which is already been applied on u-boot-samsung-mainline.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Ok, let's change how to do this then. Apply all four on u-boot-samsung/next.

Ok, sure. I shall post all 4 patches including 3 for ehci fdt support and 1 patch
for usb vbus rebased on top of u-boot-samsung/master.

I think the -samsung custodian shall just pick your series as is.

Then, I will pick up following patches.

Quoted 9 lines
Quoted 6 lines

[U-Boot,v3,1/3] EHCI: Exynos: Add fdt support [U-Boot,v3,2/3] EXYNOS5: Add device node for USB. [U-Boot,v3,3/3] EXYNOS5: FDT: Add compatible strings for USB [U-Boot,v2] SMDK5250: Enable VBus for USB 2.0 controller (V2! not V3)

Is it right?

Yes, thanks man!

I have just sent the v4 for these patches.

[U-Boot] [PATCH v4 1/3] EHCI: Exynos: Add fdt support [U-Boot] [PATCH v4 2/3] EXYNOS5: Add device node for USB. [U-Boot] [PATCH v4 3/3] EXYNOS5: FDT: Add compatible strings for USB [U-Boot] [PATCH v4] SMDK5250: Enable VBus for USB 2.0 controller

Please apply the same.
these are rebased on top of tree of u-boot-samsung.

Signature · 2 lines
Thanks & Regards
Vivek
#10 lore raw

PATCH v3 3/3 EXYNOS5: FDT: Add compatible strings for USB

In reply to Vivek Gautam

From: Rajeshwari Shinde <[email protected]>

Add required compatible information for USB

---

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(-)
include/fdtdec.h +2 -0
index 12587f9..c18108e 100644
@@ -72,6 +72,8 @@ enum fdt_compat_id {
 	COMPAT_NVIDIA_TEGRA20_DC,	/* Tegra 2 Display controller */
 	COMPAT_SMSC_LAN9215,		/* SMSC 10/100 Ethernet LAN9215 */
 	COMPAT_SAMSUNG_EXYNOS5_SROMC,	/* Exynos5 SROMC */
+	COMPAT_SAMSUNG_EXYNOS_EHCI,	/* Exynos EHCI controller */
+	COMPAT_SAMSUNG_EXYNOS_USB_PHY,	/* Exynos phy controller for usb2.0 */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +2 -0
index adebd79..4682d1b 100644
@@ -47,6 +47,8 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(NVIDIA_TEGRA20_DC, "nvidia,tegra20-dc"),
 	COMPAT(SMSC_LAN9215, "smsc,lan9215"),
 	COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"),
+	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)
Signature · 1 line
1.7.6.5