From: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
To: Magnus Damm <magnus.damm@gmail.com>
Cc: SH-Linux <linux-sh@vger.kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
linux-gpio <linux-gpio@vger.kernel.org>,
"Simon Horman [Horms]" <horms@verge.net.au>,
Alexandre Courbot <gnurou@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Valentine Barshak <valentine.barshak@cogentembedded.com>
Subject: Re: [PATCH V4 3/4] ARM: shmobile: koelsch: Add USBHS and internal PCI USB support
Date: Mon, 24 Feb 2014 12:29:17 +0400 [thread overview]
Message-ID: <530B02DD.6070600@cogentembedded.com> (raw)
In-Reply-To: <CANqRtoQjFMezrw0oEYCE97+sWu2mNZnHz0nher8oKxzx7FH5_w@mail.gmail.com>
Hi Magnus,
On 02/24/2014 12:05 PM, Magnus Damm wrote:
> Hi Vladimir,
>
> On Mon, Feb 24, 2014 at 4:34 PM, Vladimir Barinov
> <vladimir.barinov@cogentembedded.com> wrote:
>> Hello Magnus,
>>
>> Thank you for the quick response.
>>
>>
>> On 02/24/2014 07:52 AM, Magnus Damm wrote:
>>> +static int usbhs_hardware_init(struct platform_device *pdev)
>>> +{
>>> + struct usbhs_private *priv = usbhs_get_priv(pdev);
>>> + struct usb_phy *phy;
>>> +
>>> + phy = usb_get_phy_dev(&pdev->dev, 0);
>>> + if (IS_ERR(phy))
>>> + return PTR_ERR(phy);
>>> +
>>> + priv->phy = phy;
>>> + return 0;
>>> +}
>>> +
>>> +static int usbhs_hardware_exit(struct platform_device *pdev)
>>> +{
>>> + struct usbhs_private *priv = usbhs_get_priv(pdev);
>>> +
>>> + if (!priv->phy)
>>> + return 0;
>>> +
>>> + usb_put_phy(priv->phy);
>>> + priv->phy = NULL;
>>> + return 0;
>>> +}
>>> +
>>> +static int usbhs_get_id(struct platform_device *pdev)
>>> +{
>>> + return USBHS_GADGET;
>>> +}
>>> Uhm, I sort of expected this place to be where you read out the ID pin
>>> state from the MAX device.
>> Yes, I've seen your work for lager board.
>> I did differently then you beacause of problem in USBHS Host driver, hence
>> the need of setup PHY at initial stage to PCI USB and not to USBHS.
> Yeah, I understand. But with the current patches I wonder, isn't there
> risk for short circuit ? Say that a USB host cable is connected during
> boot and the PCI USB host controller is hooked up, what is stopping us
> from switching the cable and driving VBUS from two sides using a USB
> function cable? So the current patches seem a bit unsafe to me.
Yes.
In case of such condition, when the usb cable changed after host device
probe the
risk of VBUS collision is obvious.
The interrupt driven ID pin monitoring in board file could help?
Probably the separate driver for the MAX3355 should not be added since
this provides
poor information, most significant is cable ID.
>
>>>> +static u32 koelsch_usbhs_pipe_type[] = {
>>>> +
>>>> +/* Add all available USB devices */
>>>> +static void __init koelsch_add_usb_devices(void)
>>>> +{
>>>> + /* MAX3355E ID pin */
>>>> + gpio_request_one(RCAR_GP_PIN(5, 31), GPIOF_IN, NULL);
>>>> + if (!gpio_get_value(RCAR_GP_PIN(5, 31))) {
>>>> + usbhs_phy_pdata.chan0_pci = 1; /* Channel 0 is PCI USB
>>>> host */
>>>> + koelsch_add_usb0_host();
>>>> + } else {
>>>> + usbhs_phy_pdata.chan0_pci = 0; /* Channel 0 is USBHS */
>>>> + koelsch_add_usb0_gadget();
>>>> + }
>>> I don't think we should perform this kind of check at boot-up. This
>>> goes without saying, but normal USB supports hot-plug so we should
>>> check the cable type when the cable insertion event happens. Please
>>> see my comment above for USBHS-specific location.
>>>
>>> I do however understand that according to your investigation you
>>> cannot use USBHS in host mode. I believe further investigation is
>>> needed in that area to determine what is the best way forward.
>>> Regarding VBUS control, I believe it should be possible to drive the
>>> USB0_VBUS as GPIO and manually control the power.
>> I see.
> To control USB0_VBUS as GPIO you may need to adjust the PFC tables for
> pinctrl. At some point, would it be possible for you to cook up some
> prototype code to try to control the USB0_VBUS signal via GPIO? This
> may be pointless if the USBHS hardware cannot operate in Host mode
> though.
No need, there is a set_vbus callback in HSBHS platform code for this
purpose.
>
>>> Would it be possible for you to break out USB PCI support for USB1 and
>>> resend that so we can begin by merging that?
>> Wouldn't you like me also add USBHS in gadget mode for USB0 with the similar
>> check like you did on lager (with ID pin),
>> since it does not need the gpio-rcar changes too.
> Thanks for your offer. Yes, that would be nice. May I suggest doing it
> on two levels:
> 1) Gadget-only support (is it possible to perform runtime check of ID
> pin value at insert event and give error in case of Host?)
> 2) Incremental USBHS host patch
>
> Using two incremental patches like above we can begin by merging 1)
> and keep on working on 2).
>
>> Also if you'd like I can add the USBHS in Host mode with the ID pin check
>> like you suggested, but the usb0 host will not be stable.
>> Probably this could speed up the USBHS Host development/fixing.
> Please add it as a separate incremental patch if possible. I'd like to
> have some kind of stable level of support without any funky
> dependencies as a first goal, then keep on trying to get USBHS
> working.
>
> I think PCI USB for the micro USB port can simply be dropped now and
> only use USBHS.
Sure, will do.
Regards,
Vladimir
next prev parent reply other threads:[~2014-02-24 8:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-23 18:00 [PATCH V4 0/4] ARM: shmobile: koelsch: Add USB support vladimir.barinov
2014-02-23 18:00 ` [PATCH V4 1/4] ARM: shmobile: r8a7791: Add USBHS clock support vladimir.barinov
2014-02-23 18:00 ` [PATCH V4 2/4] ARM: shmobile: r8a7791: Add PCI USB host " vladimir.barinov
2014-02-23 18:00 ` [PATCH V4 3/4] ARM: shmobile: koelsch: Add USBHS and internal PCI USB support vladimir.barinov
2014-02-24 3:52 ` Magnus Damm
2014-02-24 7:34 ` Vladimir Barinov
2014-02-24 8:05 ` Magnus Damm
2014-02-24 8:29 ` Vladimir Barinov [this message]
2014-02-24 8:57 ` Magnus Damm
2014-02-23 18:00 ` [PATCH V4 4/4] ARM: shmobile: koelsch: Add USB and PCI to defconfig vladimir.barinov
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=530B02DD.6070600@cogentembedded.com \
--to=vladimir.barinov@cogentembedded.com \
--cc=gnurou@gmail.com \
--cc=horms@verge.net.au \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=valentine.barshak@cogentembedded.com \
/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