From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
Date: Fri, 6 Nov 2015 16:00:43 +0100 [thread overview]
Message-ID: <201511061600.43147.marex@denx.de> (raw)
In-Reply-To: <20151106070000.GA2860@Sanchayan-Arch>
On Friday, November 06, 2015 at 08:00:01 AM, maitysanchayan at gmail.com wrote:
> On 15-10-30 14:20:29, Marek Vasut wrote:
> > On Friday, October 30, 2015 at 01:26:59 PM, Sanchayan Maity wrote:
> > > Add board_usb_phy_mode function for detecting whether a port is
> > > being used as host or client using a GPIO. On Colibri Vybrid we
> > > provide the GPIO 102 for this very same purpose.
> > >
> > > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > > ---
> > > Changes since v1:
> > >
> > > Move the GPIO request call to the board_init function as all
> > > further calls to board_usb_phy_mode will actually result in the
> > > gpio_request failing.
> > >
> > > Changes since v2:
> > >
> > > Instead of returning 0 from board_usb_phy_mode return it as
> > > USB_INIT_HOST.
> > > ---
> > >
> > > board/toradex/colibri_vf/colibri_vf.c | 23 ++++++++++++++++++++++-
> > > 1 file changed, 22 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/board/toradex/colibri_vf/colibri_vf.c
> > > b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..9878671 100644
> > > --- a/board/toradex/colibri_vf/colibri_vf.c
> > > +++ b/board/toradex/colibri_vf/colibri_vf.c
> > > @@ -21,6 +21,7 @@
> > >
> > > #include <i2c.h>
> > > #include <g_dnl.h>
> > > #include <asm/gpio.h>
> > >
> > > +#include <usb.h>
> > >
> > > DECLARE_GLOBAL_DATA_PTR;
> > >
> > > @@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
> > >
> > > PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
> > >
> > > #define USB_PEN_GPIO 83
> > >
> > > +#define USB_CDET_GPIO 102
> > >
> > > static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
> > >
> > > /* levelling */
> > >
> > > @@ -92,6 +94,7 @@ static struct ddrmc_cr_setting
> > > colibri_vf_cr_settings[] = {
> > >
> > > static const iomux_v3_cfg_t usb_pads[] = {
> > >
> > > VF610_PAD_PTD4__GPIO_83,
> > >
> > > + VF610_PAD_PTC29__GPIO_102,
> > >
> > > };
> > >
> > > int dram_init(void)
> > >
> > > @@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
> > >
> > > VF610_PAD_PTB23__GPIO_93,
> > > VF610_PAD_PTB26__GPIO_96,
> > > VF610_PAD_PTB28__GPIO_98,
> > >
> > > - VF610_PAD_PTC29__GPIO_102,
> > >
> > > VF610_PAD_PTC30__GPIO_103,
> > > VF610_PAD_PTA7__GPIO_134,
> > >
> > > };
> > >
> > > @@ -509,6 +511,10 @@ int board_init(void)
> > >
> > > setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
> > >
> > > +#ifdef CONFIG_USB_EHCI_VF
> > > + gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
> > > +#endif
> > > +
> > >
> > > return 0;
> > >
> > > }
> > >
> > > @@ -554,4 +560,19 @@ int board_ehci_hcd_init(int port)
> > >
> > > }
> > > return 0;
> > >
> > > }
> > >
> > > +
> > > +int board_usb_phy_mode(int port)
> > > +{
> > > + switch (port) {
> > > + case 0:
> > > + return gpio_get_value(USB_CDET_GPIO);
> >
> > So what would happen to this code in case we re-number the USB_INIT_HOST
> > and USB_INIT_DEVICE or in case the GPIO API starts returning something
> > else but 0 or 1 here ?
>
> Sorry for the delay in reply. Had got tied up elsewhere.
Yeah, no problem, I can relate to that.
> Currently USB_INIT_HOST and USB_INIT_DEVICE are defined with an enum. If we
> were to switch this would not work as I intended. I guess this would be
> more appropriate then
>
> if (gpio_get_value(USB_CDET_GPIO))
> return USB_INIT_DEVICE;
> else
> return USB_INIT_HOST;
Yeah.
> For the GPIO, isn't gpio_get_value always suppose to return the actual
> state of GPIO? Would we ever change the GPIO API to report otherwise?
It will report 0 for GPIO inactive and non-zero for GPIO active, that's
the behavior of it.
> Concerning the other thread from Stefan's query I will add the comments.
Thanks!
next prev parent reply other threads:[~2015-11-06 15:00 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 12:58 [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Sanchayan Maity
2015-10-26 12:58 ` [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function Sanchayan Maity
2016-01-08 12:22 ` maitysanchayan at gmail.com
2016-01-08 14:02 ` Marek Vasut
2015-10-26 12:58 ` [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function Sanchayan Maity
2015-10-27 9:18 ` Marek Vasut
2015-10-27 11:34 ` maitysanchayan at gmail.com
2015-10-29 10:15 ` [U-Boot] [PATCH v2] " Sanchayan Maity
2015-10-29 17:25 ` Marek Vasut
2015-10-30 12:26 ` [U-Boot] [PATCH v3] " Sanchayan Maity
2015-10-30 13:20 ` Marek Vasut
2015-11-06 7:00 ` maitysanchayan at gmail.com
2015-11-06 15:00 ` Marek Vasut [this message]
2015-10-30 16:12 ` Stefan Agner
2015-10-30 16:24 ` Marek Vasut
2015-10-30 16:26 ` Stefan Agner
2015-10-30 17:07 ` Marek Vasut
2015-11-09 14:59 ` [U-Boot] [PATCH v4] " Sanchayan Maity
2015-11-09 15:22 ` Marek Vasut
2015-11-12 6:17 ` [U-Boot] [PATCH v5] " Sanchayan Maity
2015-11-24 10:23 ` maitysanchayan at gmail.com
2015-11-24 10:30 ` Marek Vasut
2015-11-24 10:37 ` Stefano Babic
2015-11-24 10:38 ` maitysanchayan at gmail.com
2016-01-07 20:02 ` maitysanchayan at gmail.com
2016-01-07 21:12 ` Stefano Babic
2016-01-08 5:50 ` maitysanchayan at gmail.com
2016-01-08 12:11 ` Marek Vasut
2016-01-08 12:18 ` maitysanchayan at gmail.com
2016-01-08 12:25 ` Marek Vasut
2015-10-26 19:19 ` [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Marek Vasut
2015-10-27 3:28 ` maitysanchayan at gmail.com
2016-01-08 12:20 ` maitysanchayan at gmail.com
2016-01-08 12:26 ` Marek Vasut
2016-01-08 12:26 ` maitysanchayan at gmail.com
2016-01-08 14:02 ` Marek Vasut
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=201511061600.43147.marex@denx.de \
--to=marex@denx.de \
--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