Add board level usb support for mxsxsabresd and mx6slevk
Subsystems (3)
v4 cover Add board level usb support for mxsxsabresd and mx6slevk
Changes v4:
- Take Marek's suggestions, implement usb_phy_mode function and introduce a weak function board_usb_phy_mode.
- change usb_phy_enable's return value with 0.
- reimplement board_usb_phy_mode in board code.
- add prototype type for board_usb_phy_mode and usb_phy_mode
Changes v3:
- Take Marek's suggestions, replace 'return val & USBPHY_CTRL_OTG_ID' with this new function like 'return board_usb_phy_mode(index);' Detailed discussion here:
http://lists.denx.de/pipermail/u-boot/2014-November/194131.html
Changes v2:
- Introduce a new weak function to let board have a choice to decide which mode to work at.
- move pinmux setting into board_init
- add otg polarity setting in board_ehci_hcd_init
- set pinmux struct static
Peng Fan (3):
usb:ehci-mx6 add phy mode query function imx:mx6sxsabresd add board level support for usb imx:mx6slevk add board level support for usb
arch/arm/include/asm/arch-mx6/mx6sl_pins.h | 5 +++ board/freescale/mx6slevk/mx6slevk.c | 49 +++++++++++++++++++++++++++++ board/freescale/mx6sxsabresd/mx6sxsabresd.c | 49 +++++++++++++++++++++++++++++ drivers/usb/host/ehci-mx6.c | 27 ++++++++++++++-- include/configs/mx6slevk.h | 14 +++++++++ include/configs/mx6sxsabresd.h | 14 +++++++++ include/usb/ehci-fsl.h | 2 ++ 7 files changed, 158 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.4
PATCH v4 1/3 usb:ehci-mx6 add phy mode query function
usb_phy_enable should return status bit, but not phy mode bit, thus add a new function usb_phy_mode to query the PHY for it's mode and make usb_phy_enable just return 0 but not 'phy_ctrl & USBPHY_CTRL_OTG_ID'.
Include a new board weak function board_usb_phy_mode. If board code does not reimplement this function, it just call usb_phy_mode and return usb_phy_mode's return value. The reason to include such a weak function
is: " SOC OTG core <--connect--> board HOST port, but no pin id for the board host port, so board can not use usb_phy_mode to return the phy mode, but define it's own rule."
---
Changes v4:
- Take Marek's suggestions, implement usb_phy_mode function and introduce a weak function board_usb_phy_mode.
- change usb_phy_enable's return value with 0.
- add prototype for board_usb_phy_mode and usb_phy_mode
Changes v3:
- Take Marek's suggestions, replace 'return val & USBPHY_CTRL_OTG_ID' with this new function like 'return board_usb_phy_mode(index);'
Here board_usb_phy_mode only has one parameter 'index' as board_ehci_power and board_echi_hcd_init do. "http://lists.denx.de/pipermail/u-boot/2014-November/194183.html" has detailed discussion.
Changes v2:
- Introduce a new weak function to let board have a choice to decide which mode to work at.
drivers/usb/host/ehci-mx6.c | 27 +++++++++++++++++++++++++-- include/usb/ehci-fsl.h | 2 ++ 2 files changed, 27 insertions(+), 2 deletions(-)
drivers/usb/host/ehci-mx6.c +25 -2
@@ -160,7 +160,7 @@ static int usb_phy_enable(int index, struct usb_ehci *ehci) val |= (USBPHY_CTRL_ENUTMILEVEL2 |USBPHY_CTRL_ENUTMILEVEL3 );__raw_writel (val, phy_ctrl); -return val &USBPHY_CTRL_OTG_ID ; +return 0 ; }/* Base address for this IP block is 0x02184800 */
@@ -193,6 +193,28 @@ static void usb_oc_config(int index)__raw_writel (val, ctrl); } +int usb_phy_mode (int port) +{ +void __iomem *phy_reg; +void __iomem *phy_ctrl; +u32 val; + + phy_reg = (void __iomem *)phy_bases[port]; + phy_ctrl = (void __iomem *)(phy_reg +USBPHY_CTRL ); + + val =__raw_readl (phy_ctrl); + +if (val &USBPHY_CTRL_OTG_ID ) +return USB_INIT_DEVICE ; +else +return USB_INIT_HOST ; +} + +int __weak board_usb_phy_mode (int port) +{ +return usb_phy_mode (port); +} +int __weak board_ehci_hcd_init (int port) {return 0 ;
@@ -221,7 +243,8 @@ int ehci_hcd_init(int index, enum usb_init_type init,usb_power_config (index);usb_oc_config (index);usb_internal_phy_clock_gate (index,1 ); - type =usb_phy_enable (index, ehci) ?USB_INIT_DEVICE :USB_INIT_HOST ; +usb_phy_enable (index, ehci); + type =board_usb_phy_mode (index); *hccr = (struct ehci_hccr *)((uint32_t )&ehci->caplength); *hcor = (struct ehci_hcor *)((uint32_t)*hccr +
include/usb/ehci-fsl.h +2 -0
@@ -277,7 +277,9 @@ struct usb_ehci {#define MXC_EHCI_IPPUE_DOWN (1 << 10)#define MXC_EHCI_IPPUE_UP (1 << 11) +int usb_phy_mode (int port);/* Board-specific initialization */ int board_ehci_hcd_init (int port); +int board_usb_phy_mode (int port);#endif /* _EHCI_FSL_H */
Signature · 1 line
1.8.4
PATCH v4 2/3 imx:mx6sxsabresd add board level support for usb
In reply to Peng FanAdd pinmux settings, implement board_ehci_hcd_init, board_usb_phy_mode
There are two usb port on mx6sxsabresd board:
1. otg port
2. host port
The following are the connection between usb controller and board usb interface, host port has not ID pin set:
otg1 core <---> board otg port
otg2 core <---> board host port
In order to make host port work, board_usb_phy_mode return USB_INIT_HOST to make host port work in HOST mode.
---
Changes v4:
reimplement board_usb_phy_mode.
Changes v3:
Take Marek's suggestions, replace 'return val & USBPHY_CTRL_OTG_ID' with this new function like 'return board_usb_phy_mode(index);'
Here board_usb_phy_mode only has one parameter 'index' as board_ehci_power and board_echi_hcd_init do. "http://lists.denx.de/pipermail/u-boot/2014-November/194183.html" has detailed discussion.
Changes v2:
Introduce a new weak function to let board have a choice to decide which mode to work at.
board/freescale/mx6sxsabresd/mx6sxsabresd.c | 49 +++++++++++++++++++++++++++++ include/configs/mx6sxsabresd.h | 14 +++++++++ 2 files changed, 63 insertions(+)
board/freescale/mx6sxsabresd/mx6sxsabresd.c +49 -0
@@ -25,6 +25,8 @@#include <netdev.h> #include <power/pmic.h> #include <power/pfuze100_pmic.h> +#include <usb.h> +#include <usb/ehci-fsl.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -271,6 +273,49 @@ int board_mmc_init(bd_t *bis)return fsl_esdhc_initialize (bis, &usdhc_cfg[0 ]); } +#ifdef CONFIG_USB_EHCI_MX6 +#define USB_OTHERREGS_OFFSET 0x800 +#define UCTRL_PWR_POL (1 << 9) + +static iomux_v3_cfg_t const usb_otg_pads[] = { +/* OGT1 */ +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 ), +/* OTG2 */ +MX6_PAD_GPIO1_IO12__USB_OTG2_PWR |MUX_PAD_CTRL (NO_PAD_CTRL ) +}; + +static void setup_usb (void ) +{ +imx_iomux_v3_setup_multiple_pads (usb_otg_pads, +ARRAY_SIZE (usb_otg_pads)); +} + +int board_usb_phy_mode (int port) +{ +if (port ==1 ) +return USB_INIT_HOST ; +else +return usb_phy_mode (port); +} + +int board_ehci_hcd_init (int port) +{ +u32 *usbnc_usb_ctrl; + +if (port >1 ) +return -EINVAL ; + + usbnc_usb_ctrl = (u32 *)(USB_BASE_ADDR +USB_OTHERREGS_OFFSET + + port *4 ); + +/* Set Power polarity */ +setbits_le32 (usbnc_usb_ctrl,UCTRL_PWR_POL ); + +return 0 ; +} +#endif +int board_init (void ) {/* Address of boot parameters */
@@ -280,6 +325,10 @@ int board_init(void)setup_i2c (0 ,CONFIG_SYS_I2C_SPEED ,0x7f , &i2c_pad_info1);#endif +#ifdef CONFIG_USB_EHCI_MX6 +setup_usb (); +#endif +return 0 ; }
include/configs/mx6sxsabresd.h +14 -0
@@ -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
PATCH v4 3/3 imx:mx6slevk add board level support for usb
In reply to Peng FanAdd pinmux settings, implement board_ehci_hcd_init, board_usb_phy_mode
There are two usb port on mx6slevk board:
1. otg port
2. host port
The following are the connection between usb controller and board usb interface, host port has not ID pin set:
otg1 core <---> board otg port
otg2 core <---> board host port
In order to make host port work, board_usb_phy_mode return USB_INIT_HOST to let host port work in host mode.
---
Changes v4:
reimplement board_usb_phy_mode
Changes v3:
implement board_usb_phy_mode
Changes v2:
Add otg polarity setting
move pinmux into board_init
set pinmux setting static
arch/arm/include/asm/arch-mx6/mx6sl_pins.h | 5 +++ board/freescale/mx6slevk/mx6slevk.c | 49 ++++++++++++++++++++++++++++++ include/configs/mx6slevk.h | 14 +++++++++ 3 files changed, 68 insertions(+)
arch/arm/include/asm/arch-mx6/mx6sl_pins.h +5 -0
@@ -53,5 +53,10 @@ enum {MX6_PAD_FEC_REF_CLK__FEC_REF_OUT =IOMUX_PAD (0x424 ,0x134 ,0x10 ,0x000 ,0 ,0 ),MX6_PAD_FEC_RX_ER__GPIO_4_19 =IOMUX_PAD (0x0428 ,0x0138 ,5 ,0x0000 ,0 ,0 ),MX6_PAD_FEC_TX_CLK__GPIO_4_21 =IOMUX_PAD (0x0434 ,0x0144 ,5 ,0x0000 ,0 ,0 ), + +MX6_PAD_EPDC_PWRCOM__ANATOP_USBOTG1_ID =IOMUX_PAD (0x03D0 ,0x00E0 ,4 ,0x05DC ,0 ,0 ), + +MX6_PAD_KEY_COL4__USB_USBOTG1_PWR =IOMUX_PAD (0x0484 ,0x017C ,6 ,0x0000 ,0 ,0 ), + MX6_PAD_KEY_COL5__USB_USBOTG2_PWR = IOMUX_PAD(0x0488, 0x0180, 6, 0x0000, 0, 0), };#endif /* __ASM_ARCH_MX6_MX6SL_PINS_H__ */
board/freescale/mx6slevk/mx6slevk.c +49 -0
67 lines not on this page · raw message
include/configs/mx6slevk.h +14 -0
@@ -209,6 +209,20 @@#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 +#define CONFIG_SYS_FSL_USDHC_NUM 3#if defined(CONFIG_ENV_IS_IN_MMC )#define CONFIG_SYS_MMC_ENV_DEV 1/* SDHC2*/
Signature · 1 line
1.8.4
Marek Vasut
Appliedv4 cover Add board level usb support for mxsxsabresd and mx6slevk
In reply to Peng FanQuoted 13 lines · Peng Fan
Changes v4:
- Take Marek's suggestions, implementusb_phy_modefunction and introduce a weak functionboard_usb_phy_mode.
- change usb_phy_enable's return value with 0.
- reimplementboard_usb_phy_modein board code.
- add prototype type forboard_usb_phy_modeandusb_phy_modeChanges v3:
- Take Marek's suggestions, replace 'return val &USBPHY_CTRL_OTG_ID' with this new function like 'returnboard_usb_phy_mode(index);' Detailed discussion here:
http://lists.denx.de/pipermail/u-boot/2014-November/194131.html
Quoted 6 lines
Changes v2:
- Introduce a new weak function to let board have a choice to decide which
mode to work at.
- move pinmux setting intoboard_init
- add otg polarity setting inboard_ehci_hcd_init
- set pinmux struct static
Applied all, thanks!
Best regards,
Marek Vasut