usb: ehci-omap: Remove dead code
Subsystems (5)
RFC 1/3 usb: ehci-omap: Remove dead code
Since it's expected that DM_USB is enabled by now, remove some dead code and the checks for DM_USB.
arch/arm/include/asm/ehci-omap.h +0 -13
@@ -123,17 +123,4 @@ struct omap_ehci { u32 insreg08; /* 0xb0 */ }; -#if !CONFIG_IS_ENABLED (DM_USB ) || !CONFIG_IS_ENABLED (OF_CONTROL ) -/* -* FIXME: forward declaration of this structs needed because omap got the -* ehci implementation backwards. move out ehci_hcd_x from board files -*/ -struct ehci_hccr ; -struct ehci_hcor ; - -int omap_ehci_hcd_init (int index,struct omap_usbhs_board_data *usbhs_pdata, -struct ehci_hccr **hccr,struct ehci_hcor **hcor); -int omap_ehci_hcd_stop (void ); -#endif -#endif /* _OMAP_COMMON_EHCI_H_ */
drivers/usb/host/ehci-omap.c +0 -27
@@ -163,37 +163,14 @@ static inline void omap_ehci_phy_reset(int on, int delay)#define omap_ehci_phy_reset (on, delay) do {} while (0)#endif -/* Reset is needed otherwise the kernel-driver will throw an error. */ -int omap_ehci_hcd_stop (void ) -{ -debug ("Resetting OMAP EHCI\n" ); -omap_ehci_phy_reset (1 ,0 ); - -if (omap_uhh_reset () <0 ) -return -1 ; - -if (omap_ehci_tll_reset () <0 ) -return -1 ; - -return 0 ; -} -/* * Initialize the OMAP EHCI controller and PHY. * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1 * See there for additional Copyrights. */ -#if !CONFIG_IS_ENABLED (DM_USB ) || !CONFIG_IS_ENABLED (OF_CONTROL ) -int omap_ehci_hcd_init (int index,struct omap_usbhs_board_data *usbhs_pdata, -struct ehci_hccr **hccr,struct ehci_hcor **hcor) -{ - *hccr = (struct ehci_hccr *)(OMAP_EHCI_BASE ); - *hcor = (struct ehci_hcor *)(OMAP_EHCI_BASE +0x10 ); -#else int omap_ehci_hcd_init (int index,struct omap_usbhs_board_data *usbhs_pdata) { -#endif int ret;unsigned int i, reg =0 , rev =0 ;
@@ -304,8 +281,6 @@ int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata)return 0 ; } -#if CONFIG_IS_ENABLED (DM_USB ) -static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[0 ] =OMAP_USBHS_PORT_MODE_UNUSED , .port_mode[1 ] =OMAP_USBHS_PORT_MODE_UNUSED ,
@@ -409,5 +384,3 @@ U_BOOT_DRIVER(usb_omap_ehci) = { .ops = &ehci_usb_ops, .flags = DM_FLAG_ALLOC_PRIV_DMA, }; - -#endif
Signature · 1 line
2.25.1
RFC 2/3 phy: nop-phy: Enable reset-gpios support
Some usb-nop-xceiv devices use a gpio to put them in reset. Add a reset function to put them into that state, and have the init function take them out of reset
drivers/phy/nop-phy.c +26 -1
@@ -10,11 +10,24 @@#include <dm/device.h> #include <dm/device_compat.h> #include <generic-phy.h> +#include <asm-generic/gpio.h> struct nop_phy_priv {struct clk_bulk bulk; +struct gpio_desc reset_gpio; }; +static int nop_phy_reset (struct phy *phy) +{ +struct nop_phy_priv *priv =dev_get_priv (phy->dev); + +/* Return if there is no gpio since it's optional */ +if (!dm_gpio_is_valid (&priv->reset_gpio)) +return 0 ; + +return dm_gpio_set_value (&priv->reset_gpio, false); +} +static int nop_phy_init (struct phy *phy) {struct nop_phy_priv *priv =dev_get_priv (phy->dev);
@@ -22,7 +35,12 @@ static int nop_phy_init(struct phy *phy)if (CONFIG_IS_ENABLED (CLK ))return clk_enable_bulk (&priv->bulk); -return 0 ; +/* Return if there is no gpio since it's optional */ +if (!dm_gpio_is_valid (&priv->reset_gpio)) +return 0 ; + +/* If there is a reset gpio, take it out of reset */ +return dm_gpio_set_value (&priv->reset_gpio, true); }static int nop_phy_probe (struct udevice *dev)
@@ -38,6 +56,12 @@ static int nop_phy_probe(struct udevice *dev) } } + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , + &priv->reset_gpio, +GPIOD_IS_OUT ); +if (ret != -ENOENT ) +return ret; +return 0 ; }
@@ -49,6 +73,7 @@ static const struct udevice_id nop_phy_ids[] = {static struct phy_ops nop_phy_ops = { .init = nop_phy_init, + .reset = nop_phy_reset, };U_BOOT_DRIVER (nop_phy) = {
Signature · 1 line
2.25.1
RFC 3/3 usb: ehci-omap: Enable phy drivers to enable/reset phy
In reply to Adam FordSeveral omap boards use CONFIG_OMAP_EHCI_PHYx_RESET_GPIO to pull the phy out of reset, when this should really be done inside the phy driver. Add functions to determine which phys are associated the EHCI driver, hold them in reset before EHCI is initialized, initialize the EHCI, then release the phys from reset.
---
This is an RFC because it hangs when generic_phy_get_bulk is called, and more specifically dev_read_prop is hanging when called by generic_phy_get_bulk.
The nop_phy shows before 'usb start' is run.
phy 0 [ ] nop_phy |-- hsusb2_phy
drivers/usb/host/ehci-omap.c +30 -43
@@ -17,7 +17,6 @@#include <usb/ulpi.h> #include <errno.h> #include <asm/io.h> -#include <asm/gpio.h> #include <asm/arch/ehci.h> #include <asm/ehci-omap.h> #include <dm.h>
@@ -128,41 +127,6 @@ static void omap_ehci_soft_phy_reset(int port) }#endif -#if defined(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO ) || \ - defined(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO ) || \ - defined(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO ) -/* controls PHY(s) reset signal(s) */ -static inline void omap_ehci_phy_reset (int on,int delay) -{ -/* -* Refer ISSUE1: -* Hold the PHY in RESET for enough time till -* PHY is settled and ready -*/ -if (delay && !on) -udelay (delay); -#ifdef CONFIG_OMAP_EHCI_PHY1_RESET_GPIO -gpio_request (CONFIG_OMAP_EHCI_PHY1_RESET_GPIO ,"USB PHY1 reset" ); -gpio_direction_output (CONFIG_OMAP_EHCI_PHY1_RESET_GPIO , !on); -#endif -#ifdef CONFIG_OMAP_EHCI_PHY2_RESET_GPIO -gpio_request (CONFIG_OMAP_EHCI_PHY2_RESET_GPIO ,"USB PHY2 reset" ); -gpio_direction_output (CONFIG_OMAP_EHCI_PHY2_RESET_GPIO , !on); -#endif -#ifdef CONFIG_OMAP_EHCI_PHY3_RESET_GPIO -gpio_request (CONFIG_OMAP_EHCI_PHY3_RESET_GPIO ,"USB PHY3 reset" ); -gpio_direction_output (CONFIG_OMAP_EHCI_PHY3_RESET_GPIO , !on); -#endif - -/* Hold the PHY in RESET for enough time till DIR is high */ -/* Refer: ISSUE1 */ -if (delay && on) -udelay (delay); -} -#else -#define omap_ehci_phy_reset (on, delay) do {} while (0) -#endif -/* * Initialize the OMAP EHCI controller and PHY. * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1
@@ -180,9 +144,6 @@ int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata)if (ret <0 )return ret; -/* Put the PHY in RESET */ -omap_ehci_phy_reset (1 ,10 ); - ret =omap_uhh_reset ();if (ret <0 )return ret;
@@ -260,8 +221,6 @@ int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata)if (is_ehci_hsic_mode (usbhs_pdata->port_mode[i]))omap_usbhs_hsic_init (i); -omap_ehci_phy_reset (0 ,10 ); -/* * An undocumented "feature" in the OMAP3 EHCI controller, * causes suspended ports to be taken out of suspend when
@@ -337,7 +296,7 @@ struct ehci_omap_priv_data {#endif enum usb_init_type init_type;int portnr; -struct phy phy[OMAP_HS_USB_PORTS ]; +struct phy_bulk *phys;int nports; };
@@ -356,6 +315,7 @@ static int omap_ehci_probe(struct udevice *dev)struct ehci_omap_priv_data *priv =dev_get_priv (dev);struct ehci_hccr *hccr;struct ehci_hcor *hcor; +int i, ret; priv->ehci =dev_read_addr_ptr (dev); priv->portnr =dev_seq (dev);
@@ -364,7 +324,34 @@ static int omap_ehci_probe(struct udevice *dev) hccr = (struct ehci_hccr *)&priv->ehci->hccapbase; hcor = (struct ehci_hcor *)&priv->ehci->usbcmd; -return ehci_register (dev, hccr, hcor,NULL ,0 ,USB_INIT_HOST ); +/* Identify Phys */ + ret =generic_phy_get_bulk (dev, priv->phys); +if (ret) { +printf ("Failed to get bulk phys\n" ); +return ret; + } + +/* Hold Phys in reset */ +for (i =0 ; i < priv->phys->count; i++) { + ret =generic_phy_reset (&priv->phys->phys[i]); +if (ret) { +printf ("Failed to register EHCI\n" ); +return ret; + } + } + +/* Register the EHCI */ + ret =ehci_register (dev, hccr, hcor,NULL ,0 ,USB_INIT_HOST ); +if (ret) { +printf ("Failed to register EHCI\n" ); +return ret; + } + +/* Pull the phys out of reset */ + ret =generic_phy_init_bulk (priv->phys); +if (ret) +printf ("Failed to initialize phys\n" ); +return ret; }static const struct udevice_id omap_ehci_dt_ids[] = {
Signature · 1 line
2.25.1