Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot
Hi, On Sun, Jul 1, 2012 at 9:33 PM, Harman Sohanpal wrote: > > Thanks for your review. > But I believe you are talking of version 3 of the patches. > Kindly have a look at the version 4 I have sent. > Yes, my bad. I've seen your fourth version just after sending my comment. > I have used the same approach which Tom has mentioned > for control register offset also. > Yes, I've seen. I still think that it's a bit misguiding to conditionally define USB_CTRL0 but the general approach is ok. Other than that I think it's good to have boards.cfg entries for both options. And how much have you tested these patches? I tried them on my beaglebone and have issues both with host and device modes. In device mode I tried to use CDC ACM. My Linux host sees the device and /dev/ttyACM0 node shows up. I can put stdout in U-Boot to usbtty and this works nice too. But once I try to reassign stdin also I got my picocom hanged (only killable with kill -9). I host mode I tried with two flashdisks (512MB and 4GB) and card-reader (32MB SD and 8GB microSD cards). Only 512MB stick works as expected. With others I got: 1. 4GB flashdisk -- 0 device found, second "usb start" command seems to wedge the board 2. 8GB card -- scanning bus for storage devices... Device NOT ready Request Sense returned 00 00 00. Second "usb start" is lethal too. 3. 32MB card -- scanning bus for storage devices... READ_CAP ERROR Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot
On Sat, Jun 30, 2012 at 9:38 PM, Ilya Yanok wrote: > Hi, > > Harman Sohanpal ti.com> writes: >> +/* Control Module Registers */ >> +#define CM_REGISTERS CTRL_BASE >> +#define USB_CTRL0_REG_OFFSET (0x628) >> +#define USB_CTRL1_REG_OFFSET (0x680) Hi llya, Thanks for your review. But I believe you are talking of version 3 of the patches. Kindly have a look at the version 4 I have sent. I have used the same approach which Tom has mentioned for control register offset also. Thanks, Harman > USB_CTRL1 seems to be unused. Furthermore, both values seems to be incorrect: > according to the RM USB_CTRL0 offset should be 0x628 and USB_CTRL1 should be > 0x628. I understand that's cause you use USB1 by default but that's kind of > misguiding. Could you please use the approach Tom suggested for base address > here too? Define USB_CRTL* to correct values but use USB_CONTROL_REG_OFFSET > (defined conditionally) in code? > > Regards, Ilya. > > > ___ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot
Hi, Harman Sohanpal ti.com> writes: > +/* Control Module Registers */ > +#define CM_REGISTERS CTRL_BASE > +#define USB_CTRL0_REG_OFFSET (0x628) > +#define USB_CTRL1_REG_OFFSET (0x680) USB_CTRL1 seems to be unused. Furthermore, both values seems to be incorrect: according to the RM USB_CTRL0 offset should be 0x628 and USB_CTRL1 should be 0x628. I understand that's cause you use USB1 by default but that's kind of misguiding. Could you please use the approach Tom suggested for base address here too? Define USB_CRTL* to correct values but use USB_CONTROL_REG_OFFSET (defined conditionally) in code? Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot
> -Original Message- > From: Tom Rini [mailto:tom.r...@gmail.com] On Behalf Of Rini, Tom > Sent: Wednesday, June 27, 2012 10:50 PM > To: Sohanpal, Harman > Cc: u-boot@lists.denx.de; Gene Zarkhin > Subject: Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x > in u-boot > > On Tue, Jun 26, 2012 at 03:08:01PM +0530, Harman Sohanpal wrote: > > > From: Gene Zarkhin > > > > Adds USB support in uboot for AM335x. > > By default the USB 1 module is enabled. > > The support for USB 0 can be enabled by changing the > > USB base address and the phy control register address > > in the header file am335x.h. > > USB 1 has a full size connector so acts in host mode and > > USB 0 has a mini connector so used in device mode. > > By default, the support is added for host mode hence USB 1 > > has been enabled by default. > > > > Signed-off-by: Gene Zarkhin > > Signed-off-by: Harman Sohanpal > > What I was saying was that we want to make am335x.h do: > #define AM335X_USB0_BASE 0x47401000 > #define AM335X_USB1_BASE 0x47401800 > > Then: > #ifdef CONFIG_AM335X_USB0 > #define AM335X_USB_OTG_BASE AM335X_USB0_BASE > #elif defined(CONFIG_AM335X_USB1) > #define AM335X_USB_OTG_BASE AM335X_USB1_BASE > #endif > #define AM335X_USB_OTG_CORE_BASE (AM335X_USB_OTG_BASE + 0x400) > > So that in boards.cfg we could add an entry for am335x_evm_usb1 and set > CONFIG_AM335X_USB1 dynamically. Then in am335x_evm.h set either > MUSB_HCD or MUSB_UDC based on if CONFIG_AM335X_USB0 or > CONFIG_AM335X_USB1 is set (and have boards.cfg set CONFIG_AM335X_USB0 > for 'am335x_evm). > > Then you can test device mode on the evm :) And how did you test device > mode on the beaglebone? I couldn't since I don't have the rest set of > adapters here. > > Also: > > > +++ b/drivers/usb/musb/am335x.h > [snip] > > +/* Control Module Registers */ > > +#define CM_REGISTERS CTRL_BASE > > +#define USB_CTRL0_REG_OFFSET (0x628) > > +#define USB_CTRL1_REG_OFFSET (0x680) > > Please get all indentation out to a consistent level > > > +#define PRCM_IDLEST 0x3 > > +#define DPLL_CLKDCOLDO_GATE_CTRL0x300 > > And always use tabs :) > Hi Tom, Thanks for the review. I will send the patches doing all the modifications you have mentioned. Also there was some confusion regarding testing in the device mode. A new node /dev/ttyUSB0 was seen when beagle bone was connected to a linux machine, but it is not using USB as serial using usbtty. It was using the USB to serial chip in the beagle bone. Sorry for that. So I am still to confirm whether the device mode works with usbtty. But previously I have tested the device mode on both evm and beagle bone using some local DFU patches and it worked fine. Thanks, Harman ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot
On Tue, Jun 26, 2012 at 03:08:01PM +0530, Harman Sohanpal wrote: > From: Gene Zarkhin > > Adds USB support in uboot for AM335x. > By default the USB 1 module is enabled. > The support for USB 0 can be enabled by changing the > USB base address and the phy control register address > in the header file am335x.h. > USB 1 has a full size connector so acts in host mode and > USB 0 has a mini connector so used in device mode. > By default, the support is added for host mode hence USB 1 > has been enabled by default. > > Signed-off-by: Gene Zarkhin > Signed-off-by: Harman Sohanpal What I was saying was that we want to make am335x.h do: #define AM335X_USB0_BASE 0x47401000 #define AM335X_USB1_BASE 0x47401800 Then: #ifdef CONFIG_AM335X_USB0 #define AM335X_USB_OTG_BASE AM335X_USB0_BASE #elif defined(CONFIG_AM335X_USB1) #define AM335X_USB_OTG_BASE AM335X_USB1_BASE #endif #define AM335X_USB_OTG_CORE_BASE (AM335X_USB_OTG_BASE + 0x400) So that in boards.cfg we could add an entry for am335x_evm_usb1 and set CONFIG_AM335X_USB1 dynamically. Then in am335x_evm.h set either MUSB_HCD or MUSB_UDC based on if CONFIG_AM335X_USB0 or CONFIG_AM335X_USB1 is set (and have boards.cfg set CONFIG_AM335X_USB0 for 'am335x_evm). Then you can test device mode on the evm :) And how did you test device mode on the beaglebone? I couldn't since I don't have the rest set of adapters here. Also: > +++ b/drivers/usb/musb/am335x.h [snip] > +/* Control Module Registers */ > +#define CM_REGISTERS CTRL_BASE > +#define USB_CTRL0_REG_OFFSET (0x628) > +#define USB_CTRL1_REG_OFFSET (0x680) Please get all indentation out to a consistent level > +#define PRCM_IDLEST 0x3 > +#define DPLL_CLKDCOLDO_GATE_CTRL0x300 And always use tabs :) -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot
From: Gene Zarkhin Adds USB support in uboot for AM335x. By default the USB 1 module is enabled. The support for USB 0 can be enabled by changing the USB base address and the phy control register address in the header file am335x.h. USB 1 has a full size connector so acts in host mode and USB 0 has a mini connector so used in device mode. By default, the support is added for host mode hence USB 1 has been enabled by default. Signed-off-by: Gene Zarkhin Signed-off-by: Harman Sohanpal --- Changes for v2: - none Changes for v3: - Changed commit message to specify why USB 1 has been enabled by default. drivers/usb/musb/Makefile |1 + drivers/usb/musb/am335x.c | 121 + drivers/usb/musb/am335x.h | 113 ++ include/usb.h |3 +- 4 files changed, 237 insertions(+), 1 deletions(-) create mode 100644 drivers/usb/musb/am335x.c create mode 100644 drivers/usb/musb/am335x.h diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 20b5503..d00ec40 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -32,6 +32,7 @@ COBJS-$(CONFIG_USB_DAVINCI) += davinci.o COBJS-$(CONFIG_USB_OMAP3) += omap3.o COBJS-$(CONFIG_USB_DA8XX) += da8xx.o COBJS-$(CONFIG_USB_AM35X) += am35x.o +COBJS-$(CONFIG_USB_AM335X) += am335x.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/usb/musb/am335x.c b/drivers/usb/musb/am335x.c new file mode 100644 index 000..4b59769 --- /dev/null +++ b/drivers/usb/musb/am335x.c @@ -0,0 +1,121 @@ +/* + * am335x.c - TI's AM335x platform specific usb wrapper functions. + * + * Author: gene Zarkhin + * Modified by: Harman Sohanpal + * + * Based on drivers/usb/musb/da8xx.c + * + * Copyright (c) 2012 Texas Instruments Incorporated + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include +#include "am335x.h" + +/* MUSB platform configuration */ +struct musb_config musb_cfg = { + .regs = (struct musb_regs *)(AM335X_USB_OTG_CORE_BASE), + .timeout= AM335X_USB_OTG_TIMEOUT, + .musb_speed = 0, +}; + +/* + * Enable the USB phy + */ +static u8 phy_on(void) +{ + u32 timeout; + u32 regAddr = CM_REGISTERS + USB_CTRL0_REG_OFFSET; + u32 usb_ctrl_reg; + + usb_ctrl_reg = readl(regAddr); + usb_ctrl_reg &= ~(CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + usb_ctrl_reg |= (OTGVDET_EN | OTGSESSENDEN); + writel(usb_ctrl_reg, regAddr); + + timeout = musb_cfg.timeout; + writel(0x1, &am335x_usb_regs->ctrl); + udelay(6000); + while (timeout--) { + if ((readl(&am335x_usb_regs->ctrl) & SOFT_RESET_BIT) == 0) + return 1; + } + /* USB phy was not turned on */ + return 0; +} + +/* + * Disable the USB phy + */ +static void phy_off(void) +{ + u32 regAddr = CM_REGISTERS + USB_CTRL0_REG_OFFSET; + u32 usb_ctrl_reg; + + usb_ctrl_reg = readl(regAddr); + usb_ctrl_reg |= (CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + writel(usb_ctrl_reg, regAddr); + + /* Disable the USB module */ + writel(PRCM_MODULE_DSBL, CM_PER_USB0_CLKCTRL); +} + +/* + * This function performs platform specific initialization for usb0. + */ +int musb_platform_init(void) +{ + u32 timeout; + u32 revision; + + /* USB */ + /* PLL Gate set up */ + writel(DPLL_CLKDCOLDO_GATE_CTRL, CM_CLKDCOLDO_DPLL_PER); + + /* CLOCK */ + writel(PRCM_MOD_EN, CM_PER_USB0_CLKCTRL); + timeout = musb_cfg.timeout; + while (timeout--) { + if (readl(CM_PER_USB0_CLKCTRL) != PRCM_MOD_EN) + continue; + else + break; + } + if (timeout == 0) { + printf("\nUSB module not enabled\nAborting"); + return -1; + } + + /* USB module fully functional */ + /* start the on-chip usb phy and its pll */ + if (phy_on() == 0) + return -1; + /* Returns zero if e.g. not clocked */ + revision = readl(&am335x_usb_regs->revision); + if (revision == 0) + return -1; + + return 0; +} + +/* + * This function performs platform specific deinitialization for usb0. + */ +void musb_platform_d