
On Friday, November 07, 2014 at 02:08:12 AM, Peng Fan wrote:
Include a weak function board_usb_phy_mode.
usb_phy_enable decide whether the controller in device mode or in host mode by '*phy_ctrl & USBPHY_CTRL_OTG_ID'.
There are two usb port on mx6sxsabresd and also mx6slevk.
- OTG port
- HOST port
There are connected to SOC USB controller OTG1 core and OTG2 core as following: OTG1 core <----> board OTG port OTG2 core <----> board HOST port
This patch has nothing to do with any board, so this part should not be in the commit message.
However to these two board, no ID pin for the board host port. If only use '*phy_ctrl & USBPHY_CTRL_OTG_ID' to decide the work mode, the host port will not work, because "type = usb_phy_enable(index, ehci) ? USB_INIT_DEVICE : USB_INIT_HOST;" will always set 'type' with USB_INIT_DEVICE.
So introduce this weak function to let board level code can decide to work in host or device mode, if board level code want to implement this function.
Signed-off-by: Peng Fan Peng.Fan@freescale.com Signed-off-by: Ye Li B37916@freescale.com
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 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 9ec5a0a..e2a247e 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -113,6 +113,20 @@ static void usb_power_config(int index) pll_480_ctrl_set); }
+int __weak board_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);
- return val & USBPHY_CTRL_OTG_ID;
+}
/* Return 0 : host node, <>0 : device mode */ static int usb_phy_enable(int index, struct usb_ehci *ehci) { @@ -160,7 +174,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 board_usb_phy_mode(index);
This should be called from ehci_hcd_init() right after usb_phy_enable(). Afterall, the mode detection has nothing to do with the PHY enabling.
btw. an idea for a separate patch(set) -- the PHY registers should be converted to struct-based access.
}
/* Base address for this IP block is 0x02184800 */