Message ID | 11f8eded1a7972ae990bf8ce25c9146674503cd8.1445862541.git.maitysanchayan@gmail.com |
---|---|
State | Superseded |
Headers | show |
On Monday, October 26, 2015 at 01:58:51 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 the very same purpose. > > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com> > --- > board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/board/toradex/colibri_vf/colibri_vf.c > b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..fd90ef2 100644 > --- a/board/toradex/colibri_vf/colibri_vf.c > +++ b/board/toradex/colibri_vf/colibri_vf.c > @@ -34,6 +34,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 +93,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 +282,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, > }; > @@ -554,4 +555,20 @@ int board_ehci_hcd_init(int port) > } > return 0; > } > + > +int board_usb_phy_mode(int port) > +{ > + switch (port) { > + case 0: > + gpio_request(USB_CDET_GPIO, "usb-cdet-gpio"); The gpio_request() here will fail the second time you do "usb reset" on the command line I think. You might want to request this elsewhere. > + return gpio_get_value(USB_CDET_GPIO); > + break; > + case 1: > + return 0; > + break; > + default: > + return 0; > + break; > + } > +} > #endif Best regards, Marek Vasut
On 15-10-27 10:18:47, Marek Vasut wrote: > On Monday, October 26, 2015 at 01:58:51 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 the very same purpose. > > > > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com> > > --- > > board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++- > > 1 file changed, 18 insertions(+), 1 deletion(-) > > > > diff --git a/board/toradex/colibri_vf/colibri_vf.c > > b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..fd90ef2 100644 > > --- a/board/toradex/colibri_vf/colibri_vf.c > > +++ b/board/toradex/colibri_vf/colibri_vf.c > > @@ -34,6 +34,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 +93,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 +282,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, > > }; > > @@ -554,4 +555,20 @@ int board_ehci_hcd_init(int port) > > } > > return 0; > > } > > + > > +int board_usb_phy_mode(int port) > > +{ > > + switch (port) { > > + case 0: > > + gpio_request(USB_CDET_GPIO, "usb-cdet-gpio"); > > The gpio_request() here will fail the second time you do "usb reset" on > the command line I think. You might want to request this elsewhere. Hmmm makes sense. I did not try usb reset. Only usb start stop and dfu cmds. Will check and revert back accordingly. Thanks. - Sanchayan. > > > + return gpio_get_value(USB_CDET_GPIO); > > + break; > > + case 1: > > + return 0; > > + break; > > + default: > > + return 0; > > + break; > > + } > > +} > > #endif > > Best regards, > Marek Vasut
diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..fd90ef2 100644 --- a/board/toradex/colibri_vf/colibri_vf.c +++ b/board/toradex/colibri_vf/colibri_vf.c @@ -34,6 +34,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 +93,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 +282,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, }; @@ -554,4 +555,20 @@ int board_ehci_hcd_init(int port) } return 0; } + +int board_usb_phy_mode(int port) +{ + switch (port) { + case 0: + gpio_request(USB_CDET_GPIO, "usb-cdet-gpio"); + return gpio_get_value(USB_CDET_GPIO); + break; + case 1: + return 0; + break; + default: + return 0; + break; + } +} #endif
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 the very same purpose. Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com> --- board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)