Skip to contentSkip to conversation

add usb support for mx6 board

PATCH Superseded Peng Fan 6 participants 14 messages Nov 1, 2014 – Nov 3, 2014

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

cover add usb support for mx6 board

Add usb support for mx6qarm2 mx6sabresd mx6sxsabresd mx6slevk. Mainly add pad settings and ehci power settings. Also introduce a new function to set IOMUXC GPR registers, because mx6sabresd usb needs that function to work.

This patch set only contains board related settings for usb and a new gpr function. ehci_hcd_init and otg power polarity in ehci-mx6.c are not touched. Thus usb start can not work fine. As this is new feature support, post this patch set for review first.

In future patch, related patch that maybe bugfix to make usb start fine will be sent out.

Peng Fan (5):
imx:mx6sxsabresd add usb support imx:mx6slevk add usb support arm:imx-common introduce a new function to set gpr imx:mx6qarm2 add usb support imx:mx6sabresd add usb support

 arch/arm/imx-common/iomux-v3.c              | 25 ++++++++++++++
 board/freescale/mx6qarm2/mx6qarm2.c         | 27 +++++++++++++++
 board/freescale/mx6sabresd/mx6sabresd.c     | 53 +++++++++++++++++++++++++++++
 board/freescale/mx6slevk/mx6slevk.c         | 29 ++++++++++++++++
 board/freescale/mx6sxsabresd/mx6sxsabresd.c | 29 ++++++++++++++++
 include/configs/mx6qarm2.h                  | 14 ++++++++
 include/configs/mx6sabresd.h                | 14 ++++++++
 include/configs/mx6slevk.h                  | 14 ++++++++
 include/configs/mx6sxsabresd.h              | 14 ++++++++
 9 files changed, 219 insertions(+)
Signature · 1 line
1.8.4.5
author
#1 lore raw

PATCH 1/5 imx:mx6sxsabresd add usb support

Add usb support for mx6sxsabresd board.

---
 board/freescale/mx6sxsabresd/mx6sxsabresd.c | 29 +++++++++++++++++++++++++++++
 include/configs/mx6sxsabresd.h              | 14 ++++++++++++++
 2 files changed, 43 insertions(+)
board/freescale/mx6sxsabresd/mx6sxsabresd.c +29 -0
index 256ea29..016b8e8 100644
@@ -296,3 +296,32 @@ int checkboard(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+	MX6_PAD_GPIO1_IO09__USB_OTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+	MX6_PAD_GPIO1_IO10__ANATOP_OTG1_ID | MUX_PAD_CTRL(NO_PAD_CTRL)
+};
+
+iomux_v3_cfg_t const usb_otg2_pads[] = {
+	MX6_PAD_GPIO1_IO12__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+	switch (port) {
+	case 0:
+		imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
+						 ARRAY_SIZE(usb_otg1_pads));
+		break;
+	case 1:
+		imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+						 ARRAY_SIZE(usb_otg2_pads));
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
+}
+#endif
include/configs/mx6sxsabresd.h +14 -0
index e02ea18..8edf187 100644
@@ -198,6 +198,20 @@
 #define CONFIG_PHYLIB
 #define CONFIG_PHY_ATHEROS
 
+
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_MX6
+#define CONFIG_USB_STORAGE
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MXC_USB_PORTSC  (PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS   0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
+#endif
+
 #define CONFIG_CMD_PCI
 #ifdef CONFIG_CMD_PCI
 #define CONFIG_PCI
Signature · 1 line
1.8.4.5
#2 lore raw

PATCH 1/5 imx:mx6sxsabresd add usb support

Hi Peng,

Quoted 61 lines · Peng Fan

Add usb support for mx6sxsabresd board.

---
 board/freescale/mx6sxsabresd/mx6sxsabresd.c | 29 +++++++++++++++++++++++++++++
 include/configs/mx6sxsabresd.h              | 14 ++++++++++++++
 2 files changed, 43 insertions(+)
board/freescale/mx6sxsabresd/mx6sxsabresd.c +29 -0
index 256ea29..016b8e8 100644
@@ -296,3 +296,32 @@ int checkboard(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+	MX6_PAD_GPIO1_IO09__USB_OTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+	MX6_PAD_GPIO1_IO10__ANATOP_OTG1_ID | MUX_PAD_CTRL(NO_PAD_CTRL)
+};
+
+iomux_v3_cfg_t const usb_otg2_pads[] = {
+	MX6_PAD_GPIO1_IO12__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+	switch (port) {
+	case 0:
+		imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
+						 ARRAY_SIZE(usb_otg1_pads));
+		break;
+	case 1:
+		imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+						 ARRAY_SIZE(usb_otg2_pads));
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
+}
+#endif
include/configs/mx6sxsabresd.h +7 -0
index e02ea18..8edf187 100644
@@ -198,6 +198,20 @@
 #define CONFIG_PHYLIB
 #define CONFIG_PHY_ATHEROS
 
+
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_MX6
+#define CONFIG_USB_STORAGE
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET

include/configs/mx6sxsabresd.h line 217

Quoted 10 lines
include/configs/mx6sxsabresd.h +7 -0
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MXC_USB_PORTSC  (PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS   0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
+#endif
+
 #define CONFIG_CMD_PCI
 #ifdef CONFIG_CMD_PCI
 #define CONFIG_PCI

The OTG power polarity setting in ehci-imx6 driver is opposed with the board design. So without changing the polarity setting, we have to use GPIO to control the power switch.

Best regards,
Ye Li

reviewer
#3 lore raw

PATCH 1/5 imx:mx6sxsabresd add usb support

In reply to Peng Fan
Quoted 17 lines · Peng Fan

Add usb support for mx6sxsabresd board.

---
 board/freescale/mx6sxsabresd/mx6sxsabresd.c | 29 +++++++++++++++++++++++++++++
 include/configs/mx6sxsabresd.h              | 14 ++++++++++++++
 2 files changed, 43 insertions(+)
board/freescale/mx6sxsabresd/mx6sxsabresd.c +0 -0
index 256ea29..016b8e8 100644
@@ -296,3 +296,32 @@ int checkboard(void)
 
        return 0;
 }

board/freescale/mx6sxsabresd/mx6sxsabresd.c int checkboard(void) · line 308

Quoted 10 lines
board/freescale/mx6sxsabresd/mx6sxsabresd.c +10 -0
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+       MX6_PAD_GPIO1_IO09__USB_OTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+       MX6_PAD_GPIO1_IO10__ANATOP_OTG1_ID | MUX_PAD_CTRL(NO_PAD_CTRL)
+};
+
+iomux_v3_cfg_t const usb_otg2_pads[] = {
+       MX6_PAD_GPIO1_IO12__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};

Please make both 'static'

Quoted 6 lines
board/freescale/mx6sxsabresd/mx6sxsabresd.c +6 -0
+
+int board_ehci_hcd_init(int port)
+{
+       switch (port) {
+       case 0:
+               imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,

board/freescale/mx6sxsabresd/mx6sxsabresd.c int checkboard(void) · line 324

Quoted 10 lines
board/freescale/mx6sxsabresd/mx6sxsabresd.c +10 -0
+                                                ARRAY_SIZE(usb_otg1_pads));
+               break;
+       case 1:
+               imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+                                                ARRAY_SIZE(usb_otg2_pads));
+               break;
+       default:
+               printf("MXC USB port %d not yet supported\n", port);
+               return 1;
+       }

Please return -EINVAL.

#4 lore raw

PATCH 1/5 imx:mx6sxsabresd add usb support

In reply to Peng Fan

Hi Peng,

Quoted 36 lines · Peng Fan

Add usb support for mx6sxsabresd board.

---
 board/freescale/mx6sxsabresd/mx6sxsabresd.c | 29 +++++++++++++++++++++++++++++
 include/configs/mx6sxsabresd.h              | 14 ++++++++++++++
 2 files changed, 43 insertions(+)
board/freescale/mx6sxsabresd/mx6sxsabresd.c +19 -0
index 256ea29..016b8e8 100644
@@ -296,3 +296,32 @@ int checkboard(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+	MX6_PAD_GPIO1_IO09__USB_OTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+	MX6_PAD_GPIO1_IO10__ANATOP_OTG1_ID | MUX_PAD_CTRL(NO_PAD_CTRL)
+};
+
+iomux_v3_cfg_t const usb_otg2_pads[] = {
+	MX6_PAD_GPIO1_IO12__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+	switch (port) {
+	case 0:
+		imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
+						 ARRAY_SIZE(usb_otg1_pads));
+		break;
+	case 1:

board/freescale/mx6sxsabresd/mx6sxsabresd.c int checkboard(void) · line 327

Quoted 10 lines
board/freescale/mx6sxsabresd/mx6sxsabresd.c +10 -0
+		imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+						 ARRAY_SIZE(usb_otg2_pads));
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
+}
+#endif

Frankly, I am expecting that this function power up the bus instead of pin multiplexing. If the pins are reserved for USB, why should we set the pinmux each time board_ehci_hcd_init() is called ? And, in any case, pins are not reset after their usage for USB. You can move this setup in board_init() or in another init function.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#5 lore raw

PATCH 1/5 imx:mx6sxsabresd add usb support

Hi,

? 11/3/2014 8:28 PM, Stefano Babic ??:

Quoted 47 lines

Hi Peng,

Quoted 44 lines · Peng Fan

Add usb support for mx6sxsabresd board.

---
  board/freescale/mx6sxsabresd/mx6sxsabresd.c | 29 +++++++++++++++++++++++++++++
  include/configs/mx6sxsabresd.h              | 14 ++++++++++++++
  2 files changed, 43 insertions(+)
board/freescale/mx6sxsabresd/mx6sxsabresd.c +27 -0
index 256ea29..016b8e8 100644
@@ -296,3 +296,32 @@ int checkboard(void)
 
  	return 0;
  }
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+	MX6_PAD_GPIO1_IO09__USB_OTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+	MX6_PAD_GPIO1_IO10__ANATOP_OTG1_ID | MUX_PAD_CTRL(NO_PAD_CTRL)
+};
+
+iomux_v3_cfg_t const usb_otg2_pads[] = {
+	MX6_PAD_GPIO1_IO12__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+	switch (port) {
+	case 0:
+		imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
+						 ARRAY_SIZE(usb_otg1_pads));
+		break;
+	case 1:
+		imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+						 ARRAY_SIZE(usb_otg2_pads));
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
Quoted 8 lines

board/freescale/mx6sxsabresd/mx6sxsabresd.c int checkboard(void) · line 327

Quoted 2 lines
board/freescale/mx6sxsabresd/mx6sxsabresd.c +2 -0
+}
+#endif

Frankly, I am expecting that this function power up the bus instead of pin multiplexing. If the pins are reserved for USB, why should we set the pinmux each time board_ehci_hcd_init() is called ? And, in any case, pins are not reset after their usage for USB. You can move this setup in board_init() or in another init function.

Because otg power problem which is pointed out by Ye Li, I'll do power enable/disable in board_ehci_power function and move the pin settings to board_init.
And sent patch v2.

Thanks,
Peng.

Quoted 4 lines

Best regards,
Stefano Babic

author
#6 lore raw

PATCH 2/5 imx:mx6slevk add usb support

In reply to Peng Fan

Add usb support for mx6slevk board.

---
 board/freescale/mx6slevk/mx6slevk.c | 29 +++++++++++++++++++++++++++++
 include/configs/mx6slevk.h          | 14 ++++++++++++++
 2 files changed, 43 insertions(+)
board/freescale/mx6slevk/mx6slevk.c +29 -0
index a500133..6d972e8 100644
@@ -182,3 +182,32 @@ int checkboard(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+	MX6_PAD_KEY_COL4__USB_USBOTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+	MX6_PAD_EPDC_PWRCOM__ANATOP_USBOTG1_ID | MUX_PAD_CTRL(NO_PAD_CTRL)
+};
+
+iomux_v3_cfg_t const usb_otg2_pads[] = {
+	MX6_PAD_KEY_COL5__USB_USBOTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+	switch (port) {
+	case 0:
+		imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
+						 ARRAY_SIZE(usb_otg1_pads));
+		break;
+	case 1:
+		imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+						 ARRAY_SIZE(usb_otg2_pads));
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
+}
+#endif
include/configs/mx6slevk.h +14 -0
index fddedf1..021dc0e 100644
@@ -210,4 +210,18 @@
 #define CONFIG_SF_DEFAULT_MODE		SPI_MODE_0
 #endif
 
+/* USB Configs */
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_MX6
+#define CONFIG_USB_STORAGE
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS		0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT	2
+#endif
+
 #endif				/* __CONFIG_H */
Signature · 1 line
1.8.4.5
reviewer
#7 lore raw

PATCH 2/5 imx:mx6slevk add usb support

board/freescale/mx6slevk/mx6slevk.c int checkboard(void) · line 188

Quoted 5 lines · Peng Fan

}

board/freescale/mx6slevk/mx6slevk.c +4 -0
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+       MX6_PAD_KEY_COL4__USB_USBOTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),

This can be 'static'.

Quoted 4 lines
board/freescale/mx6slevk/mx6slevk.c +4 -0
+int board_ehci_hcd_init(int port)
+{
+       switch (port) {
+       case 0:

board/freescale/mx6slevk/mx6slevk.c int checkboard(void) · line 209

Quoted 10 lines
board/freescale/mx6slevk/mx6slevk.c +10 -0
+               imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
+                                                ARRAY_SIZE(usb_otg1_pads));
+               break;
+       case 1:
+               imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+                                                ARRAY_SIZE(usb_otg2_pads));
+               break;
+       default:
+               printf("MXC USB port %d not yet supported\n", port);
+               return 1;

It would be better to return -EINVAL instead.

author
#8 lore raw

PATCH 3/5 arm:imx-common introduce a new function to set gpr

In reply to Peng Fan

Add a new function mxc_iomux_set_gpr_register to
set the iomux gpr register.

32-bit general purpose registers according to SoC
requirements for any usage.

---
 arch/arm/imx-common/iomux-v3.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm/imx-common/iomux-v3.c +25 -0
index 22cd11a..b27aab8 100644
@@ -77,3 +77,28 @@ void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
 		p += stride;
 	}
 }
+
+/*
+ * Configure the IOMUX General Purpose Registers.
+ *
+ * @group, which gpr register to configure.
+ * @start_bit, the first bit to set
+ * @num_bits, how many bits to set
+ * @value, the value will be set to [start_bits...start_bits+num_bits-1]
+ */
+void mxc_iomux_set_gpr_register(int group, int start_bit, int num_bits,
+				int value)
+{
+	int i = 0;
+	u32 reg;
+
+	reg = readl(base + group * 4);
+	while (num_bits) {
+		reg &= ~(1 << (start_bit + i));
+		i++;
+		num_bits--;
+	}
+
+	reg |= (value << start_bit);
+	writel(reg, base + group * 4);
+}
Signature · 1 line
1.8.4.5
#9 lore raw

PATCH 3/5 arm:imx-common introduce a new function to set gpr

Hi Peng,

Quoted 36 lines · Peng Fan

Add a new function mxc_iomux_set_gpr_register to
set the iomux gpr register.

32-bit general purpose registers according to SoC
requirements for any usage.

---
 arch/arm/imx-common/iomux-v3.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm/imx-common/iomux-v3.c +15 -0
index 22cd11a..b27aab8 100644
@@ -77,3 +77,28 @@ void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
 		p += stride;
 	}
 }
+
+/*
+ * Configure the IOMUX General Purpose Registers.
+ *
+ * @group, which gpr register to configure.
+ * @start_bit, the first bit to set
+ * @num_bits, how many bits to set
+ * @value, the value will be set to [start_bits...start_bits+num_bits-1]
+ */
+void mxc_iomux_set_gpr_register(int group, int start_bit, int num_bits,
+				int value)
+{
+	int i = 0;
+	u32 reg;
+

arch/arm/imx-common/iomux-v3.c void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list, · line 104

Quoted 10 lines
arch/arm/imx-common/iomux-v3.c +10 -0
+	reg = readl(base + group * 4);
+	while (num_bits) {
+		reg &= ~(1 << (start_bit + i));
+		i++;
+		num_bits--;
+	}
+
+	reg |= (value << start_bit);
+	writel(reg, base + group * 4);
+}

This function is already in my previous patch (http://patchwork.ozlabs.org/patch/405013/). The function name is changed to imx_iomux_set_gpr_register.

Best regards,

Ye Li

#10 lore raw

PATCH 3/5 arm:imx-common introduce a new function to set gpr

Quoted 44 lines · On 11/01/2014 03:39 PM, Li Ye-B37916 wrote:

Hi Peng,

Quoted 39 lines · Peng Fan

Add a new function mxc_iomux_set_gpr_register to
set the iomux gpr register.

32-bit general purpose registers according to SoC
requirements for any usage.

---
 arch/arm/imx-common/iomux-v3.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm/imx-common/iomux-v3.c +18 -0
index 22cd11a..b27aab8 100644
@@ -77,3 +77,28 @@ void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
 		p += stride;
 	}
 }
+
+/*
+ * Configure the IOMUX General Purpose Registers.
+ *
+ * @group, which gpr register to configure.
+ * @start_bit, the first bit to set
+ * @num_bits, how many bits to set
+ * @value, the value will be set to [start_bits...start_bits+num_bits-1]
+ */
+void mxc_iomux_set_gpr_register(int group, int start_bit, int num_bits,
+				int value)
+{
+	int i = 0;
+	u32 reg;
+
+	reg = readl(base + group * 4);
+	while (num_bits) {
+		reg &= ~(1 << (start_bit + i));
Quoted 9 lines

arch/arm/imx-common/iomux-v3.c void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list, · line 104

Quoted 7 lines
arch/arm/imx-common/iomux-v3.c +7 -0
+		i++;
+		num_bits--;
+	}
+
+	reg |= (value << start_bit);
+	writel(reg, base + group * 4);
+}

This function is already in my previous patch (http://patchwork.ozlabs.org/patch/405013/). The function name is changed to imx_iomux_set_gpr_register.

oh. I missed this piece of code.
Then please ignore this patch set. Sorry for troubles.

Regards,
Peng.

Quoted 7 lines

Best regards,

Ye Li

#11 lore raw

PATCH 3/5 arm:imx-common introduce a new function to set gpr

In reply to Peng Fan

Dear Peng Fan,

Quoted 5 lines · In message <[email protected]> you wrote:

Add a new function mxc_iomux_set_gpr_register to
set the iomux gpr register.

32-bit general purpose registers according to SoC
requirements for any usage.

...

Quoted 8 lines

+/*
+ * Configure the IOMUX General Purpose Registers.
+ *
+ * @group, which gpr register to configure.
+ * @start_bit, the first bit to set
+ * @num_bits, how many bits to set
+ * @value, the value will be set to [start_bits...start_bits+num_bits-1]
+ */

Can you please rework the API and use a mask instead of counting bits? Relying on bit numbers is error prone and inherently non-portable.

Use the standard register access macros (like setbits, clrbits, clrsetbits) as example, please.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
All I ask is a chance to prove that money can't make me happy.
author
#12 lore raw

PATCH 4/5 imx:mx6qarm2 add usb support

In reply to Peng Fan

Add usb support for mx6qarm2 board.

---
 board/freescale/mx6qarm2/mx6qarm2.c | 27 +++++++++++++++++++++++++++
 include/configs/mx6qarm2.h          | 14 ++++++++++++++
 2 files changed, 41 insertions(+)
board/freescale/mx6qarm2/mx6qarm2.c +27 -0
index 667dca5..3108750 100644
@@ -237,3 +237,30 @@ int checkboard(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg_pads[] = {
+	MX6_PAD_EIM_D22__USB_OTG_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+	MX6_PAD_GPIO_1__USB_OTG_ID | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+	switch (port) {
+	case 0:
+		imx_iomux_v3_setup_multiple_pads(usb_otg_pads,
+						 ARRAY_SIZE(usb_otg_pads));
+
+		/*
+		 * set daisy chain for otg_pin_id on 6q.
+		 * for 6dl, this bit is reserved
+		 */
+		mxc_iomux_set_gpr_register(1, 13, 1, 1);
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
+}
+#endif
include/configs/mx6qarm2.h +14 -0
index 6e01fa0..76cfef1 100644
@@ -189,4 +189,18 @@
 #define CONFIG_OF_LIBFDT
 #define CONFIG_CMD_BOOTZ
 
+/* USB Configs */
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_MX6
+#define CONFIG_USB_STORAGE
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS		0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT	1
+#endif
+
 #endif				/* __CONFIG_H */
Signature · 1 line
1.8.4.5
author
#13 lore raw

PATCH 5/5 imx:mx6sabresd add usb support

In reply to Peng Fan

Add usb support for mx6sabresd.

---
 board/freescale/mx6sabresd/mx6sabresd.c | 53 +++++++++++++++++++++++++++++++++
 include/configs/mx6sabresd.h            | 14 +++++++++
 2 files changed, 67 insertions(+)
board/freescale/mx6sabresd/mx6sabresd.c +53 -0
index 81dcd6e..6bf9b25 100644
@@ -546,3 +546,56 @@ int checkboard(void)
 	puts("Board: MX6-SabreSD\n");
 	return 0;
 }
+
+#ifdef CONFIG_USB_EHCI_MX6
+iomux_v3_cfg_t const usb_otg_pads[] = {
+	MX6_PAD_EIM_D22__USB_OTG_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+	MX6_PAD_ENET_RX_ER__USB_OTG_ID | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+iomux_v3_cfg_t const usb_hc1_pads[] = {
+	MX6_PAD_ENET_TXD1__GPIO1_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+	switch (port) {
+	case 0:
+		imx_iomux_v3_setup_multiple_pads(usb_otg_pads,
+						 ARRAY_SIZE(usb_otg_pads));
+
+		/*
+		 * set daisy chain for otg_pin_id on 6q.
+		 * for 6dl, this bit is reserved.
+		 */
+		mxc_iomux_set_gpr_register(1, 13, 1, 0);
+		break;
+	case 1:
+		imx_iomux_v3_setup_multiple_pads(usb_hc1_pads,
+						 ARRAY_SIZE(usb_hc1_pads));
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
+}
+
+int board_ehci_power(int port, int on)
+{
+	switch (port) {
+	case 0:
+		break;
+	case 1:
+		if (on)
+			gpio_direction_output(IMX_GPIO_NR(1, 29), 1);
+		else
+			gpio_direction_output(IMX_GPIO_NR(1, 29), 0);
+		break;
+	default:
+		printf("MXC USB port %d not yet supported\n", port);
+		return 1;
+	}
+	return 0;
+}
+#endif
include/configs/mx6sabresd.h +14 -0
index 938030d..da870f3 100644
@@ -54,4 +54,18 @@
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 
+/* USB Configs */
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_MX6
+#define CONFIG_USB_STORAGE
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS		0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT	1 /* Enabled USB controller number */
+#endif
+
 #endif                         /* __MX6QSABRESD_CONFIG_H */
Signature · 1 line
1.8.4.5