diff mbox

[U-Boot,12/13] sunxi: A13-Olinuxino: Enable the USB OTG controller

Message ID 1441032373-16992-13-git-send-email-maxime.ripard@free-electrons.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Maxime Ripard Aug. 31, 2015, 2:46 p.m. UTC
The A13-Olinuxino has a mini-USB connector that can be used to power up
the board and as an OTG connector.

Since we have already some USB host-only ports right beside this one,
enable it in gadget mode

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 configs/A13-OLinuXino_defconfig | 2 ++
 1 file changed, 2 insertions(+)

Comments

Hans de Goede Sept. 1, 2015, 9:01 a.m. UTC | #1
Hi,

On 31-08-15 16:46, Maxime Ripard wrote:
> The A13-Olinuxino has a mini-USB connector that can be used to power up
> the board and as an OTG connector.
>
> Since we have already some USB host-only ports right beside this one,
> enable it in gadget mode
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>   configs/A13-OLinuXino_defconfig | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
> index 4b4337223ca5..70aa194b91c4 100644
> --- a/configs/A13-OLinuXino_defconfig
> +++ b/configs/A13-OLinuXino_defconfig
> @@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
>   CONFIG_MACH_SUN5I=y
>   CONFIG_DRAM_CLK=408
>   CONFIG_DRAM_EMR1=0
> +CONFIG_USB0_VBUS_DET="PG1"
>   CONFIG_USB1_VBUS_PIN="PG11"
>   CONFIG_AXP_GPIO=y
>   # CONFIG_VIDEO_HDMI is not set
> @@ -11,6 +12,7 @@ CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
>   CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
>   CONFIG_VIDEO_LCD_POWER="AXP0-0"
>   CONFIG_VIDEO_LCD_BL_PWM="PB2"
> +CONFIG_USB_MUSB_SUNXI=y
>   CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino"
>   # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>   CONFIG_SPL=y

The CONFIG_xxx defines for using MUSB in either host or gadget mode have
changed in v2015.10, looks like you need to rebase this series and fix
this.

Regards,

Hans
Maxime Ripard Sept. 3, 2015, 9:41 p.m. UTC | #2
Hi Hans,

On Tue, Sep 01, 2015 at 11:01:06AM +0200, Hans de Goede wrote:
> Hi,
> 
> On 31-08-15 16:46, Maxime Ripard wrote:
> >The A13-Olinuxino has a mini-USB connector that can be used to power up
> >the board and as an OTG connector.
> >
> >Since we have already some USB host-only ports right beside this one,
> >enable it in gadget mode
> >
> >Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> >---
> >  configs/A13-OLinuXino_defconfig | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> >diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
> >index 4b4337223ca5..70aa194b91c4 100644
> >--- a/configs/A13-OLinuXino_defconfig
> >+++ b/configs/A13-OLinuXino_defconfig
> >@@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
> >  CONFIG_MACH_SUN5I=y
> >  CONFIG_DRAM_CLK=408
> >  CONFIG_DRAM_EMR1=0
> >+CONFIG_USB0_VBUS_DET="PG1"
> >  CONFIG_USB1_VBUS_PIN="PG11"
> >  CONFIG_AXP_GPIO=y
> >  # CONFIG_VIDEO_HDMI is not set
> >@@ -11,6 +12,7 @@ CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
> >  CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
> >  CONFIG_VIDEO_LCD_POWER="AXP0-0"
> >  CONFIG_VIDEO_LCD_BL_PWM="PB2"
> >+CONFIG_USB_MUSB_SUNXI=y
> >  CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino"
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SPL=y
> 
> The CONFIG_xxx defines for using MUSB in either host or gadget mode have
> changed in v2015.10, looks like you need to rebase this series and fix
> this.

This was based on 2015.10-rc2. I enabled it as a gadget through
menuconfig. What is the policy on using gadget vs host? I guess it
would make more sense to enable all the OTG connectors to gadget, but
maybe that's just me.

Maxime
Hans de Goede Sept. 10, 2015, 6:47 p.m. UTC | #3
Hi,

On 03-09-15 23:41, Maxime Ripard wrote:
> Hi Hans,
>
> On Tue, Sep 01, 2015 at 11:01:06AM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 31-08-15 16:46, Maxime Ripard wrote:
>>> The A13-Olinuxino has a mini-USB connector that can be used to power up
>>> the board and as an OTG connector.
>>>
>>> Since we have already some USB host-only ports right beside this one,
>>> enable it in gadget mode
>>>
>>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>>> ---
>>>   configs/A13-OLinuXino_defconfig | 2 ++
>>>   1 file changed, 2 insertions(+)
>>>
>>> diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
>>> index 4b4337223ca5..70aa194b91c4 100644
>>> --- a/configs/A13-OLinuXino_defconfig
>>> +++ b/configs/A13-OLinuXino_defconfig
>>> @@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
>>>   CONFIG_MACH_SUN5I=y
>>>   CONFIG_DRAM_CLK=408
>>>   CONFIG_DRAM_EMR1=0
>>> +CONFIG_USB0_VBUS_DET="PG1"
>>>   CONFIG_USB1_VBUS_PIN="PG11"
>>>   CONFIG_AXP_GPIO=y
>>>   # CONFIG_VIDEO_HDMI is not set
>>> @@ -11,6 +12,7 @@ CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
>>>   CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
>>>   CONFIG_VIDEO_LCD_POWER="AXP0-0"
>>>   CONFIG_VIDEO_LCD_BL_PWM="PB2"
>>> +CONFIG_USB_MUSB_SUNXI=y
>>>   CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino"
>>>   # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>>>   CONFIG_SPL=y
>>
>> The CONFIG_xxx defines for using MUSB in either host or gadget mode have
>> changed in v2015.10, looks like you need to rebase this series and fix
>> this.
>
> This was based on 2015.10-rc2.

Are you sure?

drivers/usb/musb-new/Kconfig has:

config USB_MUSB_HOST
         bool "MUSB host mode support"
         help
           Enables the MUSB USB dual-role controller in host mode.

config USB_MUSB_GADGET
         bool "MUSB gadget mode support"
         help
           Enables the MUSB USB dual-role controller in gadget mode.

if USB_MUSB_HOST || USB_MUSB_GADGET

config USB_MUSB_SUNXI
         bool "Enable sunxi OTG / DRC USB controller"
         depends on ARCH_SUNXI
         default y
         ---help---
         Say y here to enable support for the sunxi OTG / DRC USB controller
         used on almost all sunxi boards.

endif

And you are not setting USB_MUSB_HOST nor USB_MUSB_GADGET so you should
never get a chance to set USB_MUSB_SUNXI. Also note that USB_MUSB_SUNXI
gets selected automatically as soon as you select either USB_MUSB_HOST
or USB_MUSB_GADGET...

 > I enabled it as a gadget through
> menuconfig. What is the policy on using gadget vs host? I guess it
> would make more sense to enable all the OTG connectors to gadget, but
> maybe that's just me.

The policy I'm thinking of (and which we are currently sorta following
wrt enabling USB_MUSB_HOST) is that on devices with no normal usb
ports we use USB_MUSB_HOST, so that people can interact with u-boot
without needing a serial console (which often requires soldering).

On boards which do have a normal usb port I fully agree that
USB_MUSB_GADGET is a good default.

In practice this will likely boil down to use USB_MUSB_HOST on tablets
and USB_MUSB_GADGET everywhere else.

Regards,

Hans
Maxime Ripard Sept. 13, 2015, 5:13 p.m. UTC | #4
On Thu, Sep 10, 2015 at 08:47:03PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 03-09-15 23:41, Maxime Ripard wrote:
> >Hi Hans,
> >
> >On Tue, Sep 01, 2015 at 11:01:06AM +0200, Hans de Goede wrote:
> >>Hi,
> >>
> >>On 31-08-15 16:46, Maxime Ripard wrote:
> >>>The A13-Olinuxino has a mini-USB connector that can be used to power up
> >>>the board and as an OTG connector.
> >>>
> >>>Since we have already some USB host-only ports right beside this one,
> >>>enable it in gadget mode
> >>>
> >>>Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> >>>---
> >>>  configs/A13-OLinuXino_defconfig | 2 ++
> >>>  1 file changed, 2 insertions(+)
> >>>
> >>>diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
> >>>index 4b4337223ca5..70aa194b91c4 100644
> >>>--- a/configs/A13-OLinuXino_defconfig
> >>>+++ b/configs/A13-OLinuXino_defconfig
> >>>@@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
> >>>  CONFIG_MACH_SUN5I=y
> >>>  CONFIG_DRAM_CLK=408
> >>>  CONFIG_DRAM_EMR1=0
> >>>+CONFIG_USB0_VBUS_DET="PG1"
> >>>  CONFIG_USB1_VBUS_PIN="PG11"
> >>>  CONFIG_AXP_GPIO=y
> >>>  # CONFIG_VIDEO_HDMI is not set
> >>>@@ -11,6 +12,7 @@ CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
> >>>  CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
> >>>  CONFIG_VIDEO_LCD_POWER="AXP0-0"
> >>>  CONFIG_VIDEO_LCD_BL_PWM="PB2"
> >>>+CONFIG_USB_MUSB_SUNXI=y
> >>>  CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino"
> >>>  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >>>  CONFIG_SPL=y
> >>
> >>The CONFIG_xxx defines for using MUSB in either host or gadget mode have
> >>changed in v2015.10, looks like you need to rebase this series and fix
> >>this.
> >
> >This was based on 2015.10-rc2.
> 
> Are you sure?
> 
> drivers/usb/musb-new/Kconfig has:
> 
> config USB_MUSB_HOST
>         bool "MUSB host mode support"
>         help
>           Enables the MUSB USB dual-role controller in host mode.
> 
> config USB_MUSB_GADGET
>         bool "MUSB gadget mode support"
>         help
>           Enables the MUSB USB dual-role controller in gadget mode.
> 
> if USB_MUSB_HOST || USB_MUSB_GADGET
> 
> config USB_MUSB_SUNXI
>         bool "Enable sunxi OTG / DRC USB controller"
>         depends on ARCH_SUNXI
>         default y
>         ---help---
>         Say y here to enable support for the sunxi OTG / DRC USB controller
>         used on almost all sunxi boards.
> 
> endif
> 
> And you are not setting USB_MUSB_HOST nor USB_MUSB_GADGET so you should
> never get a chance to set USB_MUSB_SUNXI. Also note that USB_MUSB_SUNXI
> gets selected automatically as soon as you select either USB_MUSB_HOST
> or USB_MUSB_GADGET...

Hmmm, there's something fishy then. I maybe used menuconfig and forgot
to fix the defconfig or something. I don't see any other
explanation. Anyway, I'll update and fix it in v2, obviously :)

> > I enabled it as a gadget through menuconfig. What is the policy on
> >using gadget vs host? I guess it would make more sense to enable
> >all the OTG connectors to gadget, but maybe that's just me.
> 
> The policy I'm thinking of (and which we are currently sorta following
> wrt enabling USB_MUSB_HOST) is that on devices with no normal usb
> ports we use USB_MUSB_HOST, so that people can interact with u-boot
> without needing a serial console (which often requires soldering).
> 
> On boards which do have a normal usb port I fully agree that
> USB_MUSB_GADGET is a good default.
> 
> In practice this will likely boil down to use USB_MUSB_HOST on tablets
> and USB_MUSB_GADGET everywhere else.

Sounds good!

If there's a UART gadget, we could also always select USB_MUSB_GADGET,
and export a UART there for the tablets, but I haven't seen such a
gadget in the code, so I guess your idea makes more sense :)

Maxime
Hans de Goede Sept. 13, 2015, 5:38 p.m. UTC | #5
Hi,

On 13-09-15 19:13, Maxime Ripard wrote:
> On Thu, Sep 10, 2015 at 08:47:03PM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 03-09-15 23:41, Maxime Ripard wrote:
>>> Hi Hans,
>>>
>>> On Tue, Sep 01, 2015 at 11:01:06AM +0200, Hans de Goede wrote:
>>>> Hi,
>>>>
>>>> On 31-08-15 16:46, Maxime Ripard wrote:
>>>>> The A13-Olinuxino has a mini-USB connector that can be used to power up
>>>>> the board and as an OTG connector.
>>>>>
>>>>> Since we have already some USB host-only ports right beside this one,
>>>>> enable it in gadget mode
>>>>>
>>>>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>>>>> ---
>>>>>   configs/A13-OLinuXino_defconfig | 2 ++
>>>>>   1 file changed, 2 insertions(+)
>>>>>
>>>>> diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
>>>>> index 4b4337223ca5..70aa194b91c4 100644
>>>>> --- a/configs/A13-OLinuXino_defconfig
>>>>> +++ b/configs/A13-OLinuXino_defconfig
>>>>> @@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
>>>>>   CONFIG_MACH_SUN5I=y
>>>>>   CONFIG_DRAM_CLK=408
>>>>>   CONFIG_DRAM_EMR1=0
>>>>> +CONFIG_USB0_VBUS_DET="PG1"
>>>>>   CONFIG_USB1_VBUS_PIN="PG11"
>>>>>   CONFIG_AXP_GPIO=y
>>>>>   # CONFIG_VIDEO_HDMI is not set
>>>>> @@ -11,6 +12,7 @@ CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
>>>>>   CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
>>>>>   CONFIG_VIDEO_LCD_POWER="AXP0-0"
>>>>>   CONFIG_VIDEO_LCD_BL_PWM="PB2"
>>>>> +CONFIG_USB_MUSB_SUNXI=y
>>>>>   CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino"
>>>>>   # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>>>>>   CONFIG_SPL=y
>>>>
>>>> The CONFIG_xxx defines for using MUSB in either host or gadget mode have
>>>> changed in v2015.10, looks like you need to rebase this series and fix
>>>> this.
>>>
>>> This was based on 2015.10-rc2.
>>
>> Are you sure?
>>
>> drivers/usb/musb-new/Kconfig has:
>>
>> config USB_MUSB_HOST
>>          bool "MUSB host mode support"
>>          help
>>            Enables the MUSB USB dual-role controller in host mode.
>>
>> config USB_MUSB_GADGET
>>          bool "MUSB gadget mode support"
>>          help
>>            Enables the MUSB USB dual-role controller in gadget mode.
>>
>> if USB_MUSB_HOST || USB_MUSB_GADGET
>>
>> config USB_MUSB_SUNXI
>>          bool "Enable sunxi OTG / DRC USB controller"
>>          depends on ARCH_SUNXI
>>          default y
>>          ---help---
>>          Say y here to enable support for the sunxi OTG / DRC USB controller
>>          used on almost all sunxi boards.
>>
>> endif
>>
>> And you are not setting USB_MUSB_HOST nor USB_MUSB_GADGET so you should
>> never get a chance to set USB_MUSB_SUNXI. Also note that USB_MUSB_SUNXI
>> gets selected automatically as soon as you select either USB_MUSB_HOST
>> or USB_MUSB_GADGET...
>
> Hmmm, there's something fishy then. I maybe used menuconfig and forgot
> to fix the defconfig or something. I don't see any other
> explanation. Anyway, I'll update and fix it in v2, obviously :)
>
>>> I enabled it as a gadget through menuconfig. What is the policy on
>>> using gadget vs host? I guess it would make more sense to enable
>>> all the OTG connectors to gadget, but maybe that's just me.
>>
>> The policy I'm thinking of (and which we are currently sorta following
>> wrt enabling USB_MUSB_HOST) is that on devices with no normal usb
>> ports we use USB_MUSB_HOST, so that people can interact with u-boot
>> without needing a serial console (which often requires soldering).
>>
>> On boards which do have a normal usb port I fully agree that
>> USB_MUSB_GADGET is a good default.
>>
>> In practice this will likely boil down to use USB_MUSB_HOST on tablets
>> and USB_MUSB_GADGET everywhere else.
>
> Sounds good!
>
> If there's a UART gadget, we could also always select USB_MUSB_GADGET,
> and export a UART there for the tablets, but I haven't seen such a
> gadget in the code, so I guess your idea makes more sense :)

Ack. AFAIK u-boot currently lacks a serial gadget, once it gets one
things get somewhat more complicated, for debugging a serial gadget
is fine. But for now (no usable tablet ui) I sorta expect people to
want to have hooked up a usb-keyb to a tablet (which is not running
android) anyways, at which point the host option makes more sense.

Ideally we would build in both, and decide which one to use based
on the id-pin. The sunxi musb-host code already checks the id-pin
and does not touch the controller if it is not pulled down (iow
if no host cable is inserted).

Regards,

Hans




>
> Maxime
>
Maxime Ripard Sept. 14, 2015, 9:19 p.m. UTC | #6
On Sun, Sep 13, 2015 at 07:38:27PM +0200, Hans de Goede wrote:
> >>The policy I'm thinking of (and which we are currently sorta following
> >>wrt enabling USB_MUSB_HOST) is that on devices with no normal usb
> >>ports we use USB_MUSB_HOST, so that people can interact with u-boot
> >>without needing a serial console (which often requires soldering).
> >>
> >>On boards which do have a normal usb port I fully agree that
> >>USB_MUSB_GADGET is a good default.
> >>
> >>In practice this will likely boil down to use USB_MUSB_HOST on tablets
> >>and USB_MUSB_GADGET everywhere else.
> >
> >Sounds good!
> >
> >If there's a UART gadget, we could also always select USB_MUSB_GADGET,
> >and export a UART there for the tablets, but I haven't seen such a
> >gadget in the code, so I guess your idea makes more sense :)
> 
> Ack. AFAIK u-boot currently lacks a serial gadget, once it gets one
> things get somewhat more complicated, for debugging a serial gadget
> is fine. But for now (no usable tablet ui) I sorta expect people to
> want to have hooked up a usb-keyb to a tablet (which is not running
> android) anyways, at which point the host option makes more sense.
> 
> Ideally we would build in both, and decide which one to use based
> on the id-pin. The sunxi musb-host code already checks the id-pin
> and does not touch the controller if it is not pulled down (iow
> if no host cable is inserted).

Looks like a good plan. I'll update my patch and resend it.

Thanks!
Maxime
diff mbox

Patch

diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
index 4b4337223ca5..70aa194b91c4 100644
--- a/configs/A13-OLinuXino_defconfig
+++ b/configs/A13-OLinuXino_defconfig
@@ -3,6 +3,7 @@  CONFIG_ARCH_SUNXI=y
 CONFIG_MACH_SUN5I=y
 CONFIG_DRAM_CLK=408
 CONFIG_DRAM_EMR1=0
+CONFIG_USB0_VBUS_DET="PG1"
 CONFIG_USB1_VBUS_PIN="PG11"
 CONFIG_AXP_GPIO=y
 # CONFIG_VIDEO_HDMI is not set
@@ -11,6 +12,7 @@  CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
 CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
 CONFIG_VIDEO_LCD_POWER="AXP0-0"
 CONFIG_VIDEO_LCD_BL_PWM="PB2"
+CONFIG_USB_MUSB_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL=y