From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] Add USB support for Efika
Date: Sun, 18 Sep 2011 04:33:38 +0200 [thread overview]
Message-ID: <201109180433.38522.marek.vasut@gmail.com> (raw)
In-Reply-To: <1316312368-13006-1-git-send-email-fermata7@gmail.com>
On Sunday, September 18, 2011 04:19:28 AM Jana Rapava wrote:
> From: Marek Vasut <marek.vasut@gmail.com>
>
> This commit adds USB support for EfikaMX and EfikaSB.
>
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Signed-off-by: Jana Rapava <fermata7@gmail.com>
> ---
> Changes for v2:
> - changed to proper patch
> Changes for v3:
> - merged other USB patches from u-boot-pxa/efikasb
> - offset-based access changed to struct-based access
> - use {clrset,clr,set}bits_le32() calls
> - CodingStyle and naming cleanup
Dear Jana Rapava,
the patch doesn't pass checkpatch:
WARNING: line over 80 characters
#253: FILE: board/efikamx/efikamx-usb.c:163:
+ (MXX1_OTG_WUE | MXX1_OTG_PM | MX51_H1_ULPI_IE |
MX51_H1_WUE),
and a lot of other such stuff.
Also, CC Stefano Babic and Remy Bohmer for next iteration, they're imx custodian
and usb custodian respectively.
>
> board/efikamx/Makefile | 3 +
> board/efikamx/efikamx-usb.c | 349
> +++++++++++++++++++++++++++++++++++++++++++ board/efikamx/efikamx.c |
> 10 ++
> drivers/usb/host/ehci-hcd.c | 19 +++
> drivers/usb/host/ehci-mxc.c | 9 +-
> include/configs/efikamx.h | 35 ++++-
> include/usb/ehci-fsl.h | 112 ++++++++++++++-
> 7 files changed, 524 insertions(+), 13 deletions(-)
> create mode 100644 board/efikamx/efikamx-usb.c
>
> diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
> index ee4a16e..860e4d2 100644
> --- a/board/efikamx/Makefile
> +++ b/board/efikamx/Makefile
> @@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
> LIB = $(obj)lib$(BOARD).o
>
> COBJS := efikamx.o
> +ifdef CONFIG_CMD_USB
> +COBJS += efikamx-usb.o
> +endif
>
> SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
> OBJS := $(addprefix $(obj),$(COBJS))
> diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
> new file mode 100644
> index 0000000..19227d4
> --- /dev/null
> +++ b/board/efikamx/efikamx-usb.c
[...]
> +
> +/*
> + * Configure control registers of the USB controller
> + */
> +void control_regs_setup(struct usb_control_regs *control)
> +{
> + clrsetbits_le32(&control->usbctrl,
> + (MXX1_OTG_WUE | MXX1_OTG_PM | MX51_H1_ULPI_IE |
MX51_H1_WUE),
What's this MXX1_ stuff ?
> + MX51_H1_PM);
> +
> + clrsetbits_le32(&control->phyctrl0,
> + MX51_OTG_OVERCURD,
> + MX51_EHCI_POWERPINSE);
> +
> + clrsetbits_le32(&control->phyctrl1,
> + MX51_SYSCLOCK_MASK,
> + MX51_SYSCLOCK_24_MHZ);
> +
> + setbits_le32(&control->usbctrl1, MX51_H1_EXTCLKE);
> +
> + clrsetbits_le32(&control->uh2ctrl,
> + (MX51_H2_ULPI_IE | MX51_H2_WUE),
> + MX51_H2_PM);
> +
> + udelay(10000);
> +}
> +
> +#define ULPI_ADDR_SHIFT 16
> +#define ulpi_write_mask(value) ((value) & 0xff)
> +#define ulpi_read_mask(value) (((value) >> 8) & 0xff)
> +
> +
> +void ulpi_write(u32 reg, u32 value, struct usb_ehci *ehci)
> +{
> + if (!(readl(&ehci->ulpi_viewpoint) & ULPI_SS)) {
> + writel(ULPI_WU, &ehci->ulpi_viewpoint);
> + while (readl(&ehci->ulpi_viewpoint) & ULPI_WU)
> + ;
Checkpatch issue here. Please fix globally.
> + }
> + writel(ULPI_RWRUN | ULPI_RWCTRL | reg << ULPI_ADDR_SHIFT |
> ulpi_write_mask(value), + &ehci->ulpi_viewpoint);
> +
> + while (readl(&ehci->ulpi_viewpoint) & ULPI_RWRUN)
> + ;
DTTO
> +}
> +
> +u32 ulpi_read(u32 reg, struct usb_ehci *ehci)
> +{
> + u32 tmp;
> + if (!(readl(&ehci->ulpi_viewpoint) & ULPI_SS)) {
> + writel(ULPI_WU, &ehci->ulpi_viewpoint);
> + while (readl(&ehci->ulpi_viewpoint) & ULPI_WU)
> + ;
Please avoid endless loops. Please fix globally.
> + }
> + writel(ULPI_RWRUN | reg << ULPI_ADDR_SHIFT, &ehci->ulpi_viewpoint);
> + do {
> + tmp = readl(&ehci->ulpi_viewpoint);
> + } while (tmp & ULPI_RWRUN);
> + return ulpi_read_mask(tmp);
> +}
> +
> +void ehciX_init(u32 base, struct ulpi_regs *ulpi, struct usb_ehci *ehci)
Rename to something more sensible? ulpi_init ? Is "base" unused?
> +{
> + u32 tmp = 0;
> + int reg, i;
> +
> + /* get ID from ULPI immediate registers*/
space before closing comment.
> + for (reg = ULPI_ID_REGS_COUNT - 1; reg >= 0; reg--)
> + tmp |= ulpi_read(reg, ehci) << (reg * 8);
> + /* split into vendor and product ID */
> + debug("Found ULPI TX, ID %04x:%04x\n", tmp >> 16, tmp & 0xffff);
> +
> + /* ULPI check integrity */
> + for (i = 0; i < 2; i++) {
> + ulpi_write(&ulpi->scratch_write, 0x55 << i, ehci);
Magic constant should be documented.
> + tmp = ulpi_read(&ulpi->scratch_write, ehci);
> +
> + if (tmp != (0x55 << i)) {
> + printf("ULPI integrity check failed\n");
> + return;
> + }
> + }
[...]
> +
> +int ehci_hcd_init(void)
> +{
> + struct usb_ehci *ehci;
> + struct usb_control_regs *control;
> + struct ulpi_regs *ulpi;
> +
> + /* Init iMX51 EHCI */
> + efika_usb_phy_reset();
> + efika_usb_hub_reset();
> + efika_usb_enable_devices();
> +
> + control = (struct usb_control_regs *)(OTG_BASE_ADDR +
> + MX51_CTRL_REGS);
mx5_usb_control_regs might be a more fitting name for the structure.
> + control_regs_setup(control);
> +
> + ulpi = (struct ulpi_regs *)(0);
No need for parenthesis around 0.
> + /* Init EHCI core */
> + ehci = (struct usb_ehci *)(OTG_BASE_ADDR +
> + (MX51_REGISTER_LAYOUT_LENGTH * CONFIG_MXC_USB_PORT));
> + hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength);
> + hcor = (struct ehci_hcor *)((uint32_t) hccr +
> + HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
> + setbits_le32(&ehci->usbmode, CM_HOST);
> + setbits_le32(&ehci->control, USB_EN);
> +
> + switch (CONFIG_MXC_USB_PORT) {
> + case 0:
> + ehci0_init(ehci);
> + case 1:
> + ehci1_init(ehci, ulpi);
> +#ifdef MACH_EFIKASB
> + case 2:
> + ehci2_init(ehci, ulpi);
> +#endif
> + };
Fallthrough here isn't intended I presume.
> +
> + /* EfikaMX USB has issues ... */
> + udelay(10000);
> +
Too many newlines.
> +
> + return 0;
> +}
> +
> +int ehci_hcd_stop(void)
> +{
> + return 0;
> +}
> diff --git a/board/efikamx/efikamx.c b/board/efikamx/efikamx.c
> index 5be1f6c..0f84ae0 100644
> --- a/board/efikamx/efikamx.c
> +++ b/board/efikamx/efikamx.c
> @@ -489,6 +489,15 @@ static inline void setup_iomux_ata(void) { }
> #endif
>
> /*
> + * EHCI USB
> + */
> +#ifdef CONFIG_CMD_USB
> +extern void setup_iomux_usb(void);
> +#else
> +static inline void setup_iomux_usb(void) { }
> +#endif
Avoid using extern.
> +
> +/*
> * LED configuration
> */
> void setup_iomux_led(void)
> @@ -621,6 +630,7 @@ int board_late_init(void)
>
> setup_iomux_led();
> setup_iomux_ata();
> + setup_iomux_usb();
>
> efikamx_toggle_led(EFIKAMX_LED_BLUE);
>
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 2197119..52b98c2 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -26,6 +26,7 @@
> #include <asm/io.h>
> #include <malloc.h>
> #include <watchdog.h>
> +#include <usb/ehci-fsl.h>
>
> #include "ehci.h"
>
> @@ -709,8 +710,26 @@ ehci_submit_root(struct usb_device *dev, unsigned long
> pipe, void *buffer, * usb 2.0 specification say 50 ms resets on
> * root
> */
> + /* wait_ms(50); */
> +
> +#if 1
> + struct usb_ehci *ehci = (struct usb_ehci *)(OTG_BASE_ADDR +
> + (MX51_REGISTER_LAYOUT_LENGTH));
> + extern u32 ulpi_read(u32 reg, struct usb_ehci *ehci);
> + extern void ulpi_write(u32 reg, u32 value, struct usb_ehci *ehci);
> + #define XXBASE 0x73f80200
> + /* OTG |= 1 << 4 */
> + u32 tmp = ulpi_read(0x0a, ehci);
> + tmp |= (1 << 4);
> + ulpi_write(0x0a, tmp, ehci);
> +
> wait_ms(50);
> +
> +
> /* terminate the reset */
> + reg = ehci_readl(status_reg);
> + reg |= EHCI_PS_PE;
> +#endif
UGH, no. This needs to be fixed !!
Remy, how are we supposed to handle such cases? For this hardware, when doing
usb port reset without this code fails the port reset (the VBUS is disabled on
the ulpi xmitter and it's all over). That's why you need to restart the vbus
here.
> ehci_writel(status_reg, reg & ~EHCI_PS_PR);
> /*
> * A host controller must terminate the reset
> diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
> index a0cfbb7..de7ed00 100644
> --- a/drivers/usb/host/ehci-mxc.c
> +++ b/drivers/usb/host/ehci-mxc.c
> @@ -37,9 +37,6 @@
> #endif
>
> #ifdef CONFIG_MX31
> -#define MX31_OTG_SIC_SHIFT 29
> -#define MX31_OTG_SIC_MASK (0x3 << MX31_OTG_SIC_SHIFT)
> -#define MX31_OTG_PM_BIT (1 << 24)
>
> #define MX31_H2_SIC_SHIFT 21
> #define MX31_H2_SIC_MASK (0x3 << MX31_H2_SIC_SHIFT)
> @@ -66,11 +63,11 @@ static int mxc_set_usbcontrol(int port, unsigned int
> flags)
>
> switch (port) {
> case 0: /* OTG port */
> - v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
> + v &= ~(MXX1_OTG_SIC_MASK | MXX1_OTG_PM_BIT);
Replace MXX1 with MXC?
> v |= (flags & MXC_EHCI_INTERFACE_MASK)
> - << MX31_OTG_SIC_SHIFT;
> + << MXX1_OTG_SIC_SHIFT;
> if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
> - v |= MX31_OTG_PM_BIT;
> + v |= MXX1_OTG_PM_BIT;
>
> break;
> case 1: /* H1 port */
Cheers
next prev parent reply other threads:[~2011-09-18 2:33 UTC|newest]
Thread overview: 103+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-08 21:06 [U-Boot] some USB cleanup on EfikaMX Jana Rapava
2011-09-08 22:32 ` Wolfgang Denk
2011-09-09 10:18 ` Stefano Babic
2011-09-12 17:20 ` [U-Boot] [PATCH 1/2 v2] USB cleanup for EfikaMX Jana Rapava
2011-09-12 19:25 ` Marek Vasut
2011-09-18 2:19 ` [U-Boot] [PATCH v3] Add USB support for Efika Jana Rapava
2011-09-18 2:33 ` Marek Vasut [this message]
2011-09-19 8:43 ` Stefano Babic
2011-09-19 10:30 ` Marek Vasut
2011-09-24 15:57 ` Remy Bohmer
2011-09-24 19:07 ` Fabio Estevam
2011-09-24 19:19 ` Marek Vasut
2011-09-24 21:22 ` Fabio Estevam
2011-09-22 5:18 ` Marek Vasut
2011-09-25 11:55 ` [U-Boot] [PATCH v4 1/5] EHCI: add callback ehci_fixup Jana Rapava
2011-09-25 11:55 ` [U-Boot] [PATCH v4 2/5] Add USB support for Efika Jana Rapava
2011-09-25 11:55 ` [U-Boot] [PATCH v4 3/5] /drivers/usb/host/ehci-mxc.c: naming cleanup Jana Rapava
2011-09-25 11:55 ` [U-Boot] [PATCH v4 4/5] USB: Add usb_event_poll() to get keyboards working with EHCI Jana Rapava
2011-09-25 12:02 ` Marek Vasut
2011-09-25 11:55 ` [U-Boot] [PATCH v4 5/5] USB: move ehci.h and ehci-core.h into /include/usb/ Jana Rapava
2011-09-27 10:45 ` [U-Boot] [PATCH v5 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory Jana Rapava
2011-09-27 10:57 ` Fabio Estevam
2011-09-27 11:01 ` [U-Boot] [PATCH v5 2/4] EHCI: add callback ehci_fixup Jana Rapava
2011-09-27 11:01 ` [U-Boot] [PATCH v5 3/4] EHCI: adjust for mx5 Jana Rapava
2011-09-27 11:01 ` [U-Boot] [PATCH v5 4/4] Add USB support for Efika Jana Rapava
2011-09-27 11:50 ` Marek Vasut
2011-09-27 14:12 ` Jana Rapava
2011-09-27 14:55 ` Marek Vasut
2011-09-27 18:17 ` Jana Rapava
2011-09-27 18:20 ` Marek Vasut
2011-09-28 10:26 ` Stefano Babic
2011-09-28 12:12 ` Jana Rapava
2011-09-27 11:23 ` [U-Boot] [PATCH v5 2/4] EHCI: add callback ehci_fixup Marek Vasut
2011-09-27 11:42 ` Jana Rapava
2011-09-27 19:24 ` [U-Boot] [PATCH v6 " Jana Rapava
2011-09-27 19:24 ` [U-Boot] [PATCH v6 3/4] EHCI: adjust for mx5 Jana Rapava
2011-09-27 19:41 ` Marek Vasut
2011-09-27 20:19 ` Jana Rapava
2011-09-27 20:47 ` Marek Vasut
2011-09-27 19:24 ` [U-Boot] [PATCH v6 4/4] Add USB support for Efika Jana Rapava
2011-09-27 19:47 ` Marek Vasut
2011-09-27 20:40 ` Jana Rapava
2011-09-27 20:50 ` Marek Vasut
2011-09-27 19:40 ` [U-Boot] [PATCH v6 2/4] EHCI: add callback ehci_fixup Marek Vasut
2011-09-27 22:21 ` [U-Boot] [PATCH v7 " Jana Rapava
2011-09-27 22:21 ` [U-Boot] [PATCH v7 3/4] EHCI: adjust for mx5 Jana Rapava
2011-09-27 22:21 ` [U-Boot] [PATCH v7 4/4] Add USB support for Efika Jana Rapava
2011-09-28 0:43 ` Marek Vasut
2011-09-28 12:25 ` Jana Rapava
2011-09-28 12:28 ` Marek Vasut
2011-09-28 0:46 ` [U-Boot] [PATCH v7 2/4] EHCI: add callback ehci_fixup Marek Vasut
2011-09-28 10:54 ` Marek Vasut
2011-09-28 11:52 ` Jana Rapava
2011-09-28 12:13 ` Marek Vasut
2011-09-28 15:02 ` [U-Boot] [PATCH v8 " Jana Rapava
2011-09-28 15:05 ` [U-Boot] [PATCH v8 3/4] EHCI: adjust for mx5 Jana Rapava
2011-09-28 15:07 ` [U-Boot] [PATCH v8 4/4] Add USB support for Efika Jana Rapava
2011-09-28 15:20 ` Marek Vasut
2011-09-28 18:12 ` Jana Rapava
2011-09-28 18:26 ` Marek Vasut
2011-10-06 21:18 ` Wolfgang Denk
2011-10-07 17:16 ` Jana Rapava
2011-09-28 15:21 ` [U-Boot] [PATCH v8 2/4] EHCI: add callback ehci_fixup Marek Vasut
2011-09-27 11:07 ` [U-Boot] [PATCH v5 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory Fabio Estevam
2011-09-27 11:09 ` Fabio Estevam
2011-09-27 11:27 ` Jana Rapava
2011-09-27 18:44 ` [U-Boot] [PATCH v6 " Jana Rapava
2011-09-27 22:06 ` [U-Boot] [PATCH v7 " Jana Rapava
2011-09-28 14:59 ` [U-Boot] [PATCH v8 " Jana Rapava
2011-09-28 19:49 ` [U-Boot] [PATCH v9 " Jana Rapava
2011-09-28 20:36 ` Marek Vasut
2011-09-28 21:10 ` Jana Rapava
2011-09-28 21:43 ` Marek Vasut
2011-09-28 23:04 ` Jana Rapava
2011-09-28 23:05 ` Marek Vasut
2011-09-28 23:22 ` Jana Rapava
2011-09-28 19:51 ` [U-Boot] [PATCH v9 2/4] EHCI: add callback ehci_fixup Jana Rapava
2011-09-28 19:52 ` [U-Boot] [PATCH v9 3/4] EHCI: adjust for mx5 Jana Rapava
2011-09-28 19:54 ` [U-Boot] [PATCH v9 4/4] Add USB support for Efika Jana Rapava
2011-09-28 20:44 ` Marek Vasut
2011-09-28 20:36 ` [U-Boot] [PATCH v9 2/4] EHCI: add callback ehci_fixup Marek Vasut
2011-09-28 21:14 ` Jana Rapava
2011-09-28 21:26 ` Marek Vasut
2011-09-25 12:02 ` [U-Boot] [PATCH v4 1/5] " Marek Vasut
2011-09-25 17:25 ` [U-Boot] [PATCH v4 1/4] USB: move ehci.h and ehci-core.h into /include/usb/ Jana Rapava
2011-09-25 17:25 ` [U-Boot] [PATCH v4 2/4] EHCI: add callback ehci_fixup Jana Rapava
2011-09-25 17:41 ` Marek Vasut
2011-09-25 17:25 ` [U-Boot] [PATCH v4 3/4] EHCI: adjust for mx5 Jana Rapava
2011-09-25 17:38 ` Marek Vasut
2011-09-25 17:25 ` [U-Boot] [PATCH v4 4/4] Add USB support for Efika Jana Rapava
2011-09-25 17:34 ` Marek Vasut
2011-09-26 20:28 ` Jana Rapava
2011-09-26 20:42 ` Marek Vasut
2011-09-26 20:51 ` Marek Vasut
2011-09-27 11:00 ` Jana Rapava
2011-09-25 19:01 ` [U-Boot] [PATCH v4 1/4] USB: move ehci.h and ehci-core.h into /include/usb/ Fabio Estevam
2011-09-26 8:32 ` Jana Rapava
2011-10-09 18:42 ` Marek Vasut
2011-10-09 20:22 ` Jana Rapava
2011-10-14 15:49 ` Fabio Estevam
2011-10-14 16:07 ` Marek Vasut
2011-10-14 15:50 ` Marek Vasut
2011-10-06 21:33 ` [U-Boot] [PATCH 1/2 v2] USB cleanup for EfikaMX Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201109180433.38522.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox