[U-Boot] [PATCH] imx: mx6 sabreauto: Add board support for USB EHCI

Fabio Estevam festevam at gmail.com
Fri Oct 10 13:46:26 CEST 2014


On Fri, Oct 10, 2014 at 6:01 AM, Ye.Li <B37916 at freescale.com> wrote:
> On mx6 sabreauto board, there are two USB ports:
> 0: OTG
> 1: HOST
> The EHCI driver is enabled for this board, but the IOMUX and VBUS power
> control is not implemented, which cause both USB port failed to work.
> This patch fix the problem by adding the BSP support.

BSP is a broad term here.

>
> Since the power control uses the GPIO pin from port expander MAX7310,
> the PCA953X driver is enabled for accessing the MAX7310.
>
> The ID pin of OTG Port needs to configure the GPR1 bit 13 for selecting
> its daisy chain. Add a new function "imx_iomux_set_gpr_register" to
> handle GPR register setting.
>
> Signed-off-by: Ye.Li <B37916 at freescale.com>
> ---
>  arch/arm/imx-common/iomux-v3.c                |   17 +++++-
>  arch/arm/include/asm/imx-common/iomux-v3.h    |    7 ++-
>  board/freescale/mx6qsabreauto/mx6qsabreauto.c |   89 ++++++++++++++++++++++++-
>  include/configs/mx6qsabreauto.h               |    5 +-
>  4 files changed, 114 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/imx-common/iomux-v3.c b/arch/arm/imx-common/iomux-v3.c
> index 22cd11a..2d96655 100644
> --- a/arch/arm/imx-common/iomux-v3.c
> +++ b/arch/arm/imx-common/iomux-v3.c
> @@ -4,7 +4,7 @@
>   * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
>   *                       <armlinux at phytec.de>
>   *
> - * Copyright (C) 2004-2011 Freescale Semiconductor, Inc.
> + * Copyright (C) 2004-2014 Freescale Semiconductor, Inc.

I don't see the need for changing the copyright everytime you touch a
file. Same apply to other files in this patch.

> +static int port_exp_direction_output(unsigned gpio, int value)
> +{
> +       int ret;
> +
> +       i2c_set_bus_num(2);
> +       if (i2c_probe(PORTEXP_IO_TO_CHIP(gpio)))
> +               return -ENXIO;

Would be better like this:

ret = i2c_probe(PORTEXP_IO_TO_CHIP(gpio))
if (ret)
    return ret;

> +
> +       ret = pca953x_set_dir(PORTEXP_IO_TO_CHIP(gpio),
> +               (1 << PORTEXP_IO_TO_PIN(gpio)),
> +               (PCA953X_DIR_OUT << PORTEXP_IO_TO_PIN(gpio)));

Here you can do:

if (ret)
  return ret;

> +
> +       if (!ret)

Then you don't need to check for !ret here

> +               ret = pca953x_set_val(PORTEXP_IO_TO_CHIP(gpio),
> +                       (1 << PORTEXP_IO_TO_PIN(gpio)),
> +                       (value << PORTEXP_IO_TO_PIN(gpio)));
> +
> +       if (ret)
> +               ret = -EIO;
> +
> +       return ret;
> +}

if (ret)
   return ret;

return 0;

> +int board_ehci_hcd_init(int port)
> +{
> +       switch (port) {
> +       case 0:
> +               imx_iomux_v3_setup_multiple_pads(usb_otg_pads,
> +                       ARRAY_SIZE(usb_otg_pads));
> +
> +               /*set daisy chain for otg_pin_id on 6q. for 6dl, this bit is reserved*/
> +               imx_iomux_set_gpr_register(1, 13, 1, 0);
> +               break;
> +       case 1:
> +               break;
> +       default:
> +               printf("MXC USB port %d not yet supported\n", port);
> +               return 1;

return -EINVAL;

> +int board_ehci_power(int port, int on)
> +{
> +       switch (port) {
> +       case 0:
> +               if (on)
> +                       port_exp_direction_output(USB_OTG_PWR, 1);
> +               else
> +                       port_exp_direction_output(USB_OTG_PWR, 0);
> +               break;
> +       case 1:
> +               if (on)
> +                       port_exp_direction_output(USB_HOST1_PWR, 1);
> +               else
> +                       port_exp_direction_output(USB_HOST1_PWR, 0);
> +               break;
> +       default:
> +               printf("MXC USB port %d not yet supported\n", port);
> +               return 1;

return -EINVAL;


More information about the U-Boot mailing list