On Tue, Jan 28, 2014 at 04:28:44PM +0100, Michael Grzeschik wrote:
> This patch makes it possible to set the chipidea udc into full-speed only 
> mode.
> It is set by the oftree property "maximum-speed = full-speed".
> 
> Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
> Signed-off-by: Marc Kleine-Budde <m...@pengutronix.de>
> ---
>  Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt |  2 ++
>  drivers/usb/chipidea/bits.h                           |  2 ++
>  drivers/usb/chipidea/core.c                           | 11 +++++++++++
>  include/linux/usb/chipidea.h                          |  1 +
>  4 files changed, 16 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt 
> b/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt
> index b4b5b79..a6a32cb 100644
> --- a/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt
> +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt
> @@ -18,6 +18,7 @@ Optional properties:
>  - vbus-supply: regulator for vbus
>  - disable-over-current: disable over current detect
>  - external-vbus-divider: enables off-chip resistor divider for Vbus
> +- maximum-speed: limit the maximum connection speed to "full-speed".
>  
>  Examples:
>  usb@02184000 { /* USB OTG */
> @@ -28,4 +29,5 @@ usb@02184000 { /* USB OTG */
>       fsl,usbmisc = <&usbmisc 0>;
>       disable-over-current;
>       external-vbus-divider;
> +     maximum-speed = "full-speed";
>  };
> diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
> index a857131..83d06c1 100644
> --- a/drivers/usb/chipidea/bits.h
> +++ b/drivers/usb/chipidea/bits.h
> @@ -50,12 +50,14 @@
>  #define PORTSC_PTC            (0x0FUL << 16)
>  #define PORTSC_PHCD(d)             ((d) ? BIT(22) : BIT(23))
>  /* PTS and PTW for non lpm version only */
> +#define PORTSC_PFSC           BIT(24)
>  #define PORTSC_PTS(d)                                                \
>       (u32)((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0))
>  #define PORTSC_PTW            BIT(28)
>  #define PORTSC_STS            BIT(29)
>  
>  /* DEVLC */
> +#define DEVLC_PFSC            BIT(23)
>  #define DEVLC_PSPD            (0x03UL << 25)
>  #define DEVLC_PSPD_HS         (0x02UL << 25)
>  #define DEVLC_PTW             BIT(27)
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 33f22bc..e813bf1 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -64,6 +64,7 @@
>  #include <linux/usb/otg.h>
>  #include <linux/usb/chipidea.h>
>  #include <linux/usb/of.h>
> +#include <linux/of.h>
>  #include <linux/phy.h>
>  #include <linux/regulator/consumer.h>
>  
> @@ -298,6 +299,13 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
>       if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
>               hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
>  
> +     if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) {
> +             if (ci->hw_bank.lpm)
> +                     hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC);
> +             else
> +                     hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
> +     }
> +
>       /* USBMODE should be configured step by step */
>       hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
>       hw_write(ci, OP_USBMODE, USBMODE_CM, mode);
> @@ -412,6 +420,9 @@ static int ci_get_platdata(struct device *dev,
>               }
>       }
>  
> +     if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
> +             platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
> +
>       return 0;
>  }
>  
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index 708bd11..bbe779f 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -25,6 +25,7 @@ struct ci_hdrc_platform_data {
>        */
>  #define CI_HDRC_DUAL_ROLE_NOT_OTG    BIT(4)
>  #define CI_HDRC_IMX28_WRITE_FIX              BIT(5)
> +#define CI_HDRC_FORCE_FULLSPEED              BIT(6)
>       enum usb_dr_mode        dr_mode;
>  #define CI_HDRC_CONTROLLER_RESET_EVENT               0
>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT     1
> -- 
> 1.8.5.3
> 
> 
> 

Good patch, I will have a try after China New Year holiday
has finished (Feb 7th).

-- 

Best Regards,
Peter Chen

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to