Skip to contentSkip to conversation

usb: lpc32xx: add host USB driver

PATCH New slemieux.tyco at gmail.com 2 participants 2 messages Aug 13, 2015 – Aug 18, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v7 5/5 usb: lpc32xx: add host USB driver

From: Sylvain Lemieux <[email protected]>

Incorporate USB driver from legacy LPCLinux NXP BSP. The files taken from the legacy patch are:
- lpc32xx USB driver
- lpc3250 header file USB registers definition.

The legacy driver was updated and clean-up as part of the integration with the latest u-boot.

---
Changes from v6 to v7:
* Addressed Vladimir's comments on LPC32xx USB driver:
- display an error on timeout inside "wait_for_bit()".
- always enable I2C OTG clock, instead of verifying first.

Changes from v5 to v6:
* Addressed Marek's comments on LPC32xx USB driver:
- return "-ETIMEDOUT" on timeout.
* Addressed Vladimir's comments on LPC32xx USB driver:
- follow alphabetic order when adding "lpc32xx_usb_init()".
- use "CONFIG_SYS_HZ" when verifying if timer expired.
- use "wait_for_bit()" when verify the I2C OTG clock status.

Changes from v4 to v5:
* Addressed Marek's comments on LPC32xx USB driver:
- update "wait_for_bit()" implementation to use "get_timer()".
- use return value of "wait_for_bit()" instead of returning -1.
* Updated multiline comments style.

Changes from v3 to v4:
* Addressed Marek's comments on LPC32xx USB driver:
- use same "wait_for_bit()" implementation as drivers/usb/host/dwc2.c
- use a const variable to define a mask to make the code more clear to read.
* Fixed legacy USB driver; use "otg_clk_sts" register to verify clock status instead of control register.

Changes from v2 to v3:
* Addressed Marek's comments on LPC32xx USB driver:
- use "get_timer()" to handle timeout (usbpll_setup).
- submit i2c driver update into a separate patch.
- use "u32" for 4 bytes registers definition.
- Move pin mux code to setup file (i.e. "device.c").
* Updated ISP1301 register definition (set & clear) instead of using an extra mask for the clear address.

Changes from v1 to v2:
* Addressed Marek's comments on LPC32xx USB driver:
- use "get_timer()" to handle timeout.
- Split USB and I2C driver.
* Updated LPC32xx I2C driver to support the I2C that is part
of the USB module.
* Removed ISP1301 USB transceiver I2C registers definition
that are not used.
* Use "cpu" initialization & stop functions API instead of the "board" API.

Update to the legacy driver to integrate with the latest u-boot:
1) Fixed checkpatch script output in legacy code.
2) Use LPC32xx definition from "cpu.h" and "clk.h".
3) Incorporate USB specific register definition from "lpc3250.h" header file from legacy BSP patch from LPCLinux.
4) Use u-boot API for register access to remove the volatile in register definition taken from "lpc3250.h" header file.
5) Update driver for latest u-boot USB API.
6) Use the peripheral clock to compute the I2C divider.

The legacy BSP patch (u-boot-2009.03_lpc32x0-v1.07.patch.tar.bz2) was downloaded from the LPCLinux Web site.

 arch/arm/cpu/arm926ejs/lpc32xx/devices.c      |   6 +
 arch/arm/include/asm/arch-lpc32xx/clk.h       |  12 ++
 arch/arm/include/asm/arch-lpc32xx/sys_proto.h |   1 +
 drivers/usb/host/Makefile                     |   1 +
 drivers/usb/host/ohci-lpc32xx.c               | 231 ++++++++++++++++++++++++++
 5 files changed, 251 insertions(+)
 create mode 100644 drivers/usb/host/ohci-lpc32xx.c
arch/arm/cpu/arm926ejs/lpc32xx/devices.c +6 -0
index f0af851..d9fa280 100644
@@ -72,6 +72,12 @@ void lpc32xx_slc_nand_init(void)
 	writel(CLK_NAND_SLC | CLK_NAND_SLC_SELECT, &clk->flashclk_ctrl);
 }
 
+void lpc32xx_usb_init(void)
+{
+	/* Do not route the UART 5 Tx/Rx pins to the USB D+ and USB D- pins. */
+	clrbits_le32(&ctrl->ctrl, UART_CTRL_UART5_USB_MODE);
+}
+
 void lpc32xx_i2c_init(unsigned int devnum)
 {
 	/* Enable I2C interface */
arch/arm/include/asm/arch-lpc32xx/clk.h +12 -0
index 663f6bc..d21310e 100644
@@ -167,6 +167,18 @@ struct clk_pm_regs {
 /* SDRAMCLK register bits */
 #define CLK_SDRAM_DDR_SEL		(1 << 1)
 
+/* USB control register definitions */
+#define CLK_USBCTRL_PLL_STS		(1 << 0)
+#define CLK_USBCTRL_FDBK_PLUS1(n)	(((n) & 0xFF) << 1)
+#define CLK_USBCTRL_POSTDIV_2POW(n)	(((n) & 0x3) << 11)
+#define CLK_USBCTRL_PLL_PWRUP		(1 << 16)
+#define CLK_USBCTRL_CLK_EN1		(1 << 17)
+#define CLK_USBCTRL_CLK_EN2		(1 << 18)
+#define CLK_USBCTRL_BUS_KEEPER		(0x1 << 19)
+#define CLK_USBCTRL_USBHSTND_EN		(1 << 21)
+#define CLK_USBCTRL_USBDVND_EN		(1 << 22)
+#define CLK_USBCTRL_HCLK_EN		(1 << 24)
+
 unsigned int get_sys_clk_rate(void);
 unsigned int get_hclk_pll_rate(void);
 unsigned int get_hclk_clk_div(void);
arch/arm/include/asm/arch-lpc32xx/sys_proto.h +1 -0
index d6e5e68..eb8010f 100644
@@ -16,6 +16,7 @@ void lpc32xx_mlc_nand_init(void);
 void lpc32xx_slc_nand_init(void);
 void lpc32xx_i2c_init(unsigned int devnum);
 void lpc32xx_ssp_init(void);
+void lpc32xx_usb_init(void);
 #if defined(CONFIG_SPL_BUILD)
 void ddr_init(const struct emc_dram_settings *dram);
 #endif
drivers/usb/host/Makefile +1 -0
index 4d35d3e..9dfdc94 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_USB_SL811HS) += sl811-hcd.o
 obj-$(CONFIG_USB_OHCI_S3C24XX) += ohci-s3c24xx.o
 obj-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o
 obj-$(CONFIG_USB_OHCI_SUNXI) += ohci-sunxi.o
+obj-$(CONFIG_USB_OHCI_LPC32XX) += ohci-lpc32xx.o
 
 # echi
 obj-$(CONFIG_USB_EHCI) += ehci-hcd.o
drivers/usb/host/ohci-lpc32xx.c new file +231 -0

231 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v7 5/5 usb: lpc32xx: add host USB driver

Quoted 7 lines · slemieux.tyco at gmail.com

From: Sylvain Lemieux <[email protected]>

Incorporate USB driver from legacy LPCLinux NXP BSP. The files taken from the legacy patch are:
- lpc32xx USB driver
- lpc3250 header file USB registers definition.

Quoted 5 lines

The legacy driver was updated and clean-up as part of the integration with the latest u-boot.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150818/e2f52a96/attachment.sig>