From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Tue, 26 Mar 2019 16:53:54 +0100 Subject: [U-Boot] [PATCH 1/3] usb: dwc3: Add Meson G12A USB Glue In-Reply-To: <20190326151537.23118-2-narmstrong@baylibre.com> References: <20190326151537.23118-1-narmstrong@baylibre.com> <20190326151537.23118-2-narmstrong@baylibre.com> Message-ID: <87e9c6f0-e62c-b5aa-cddd-550c25b6d705@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 3/26/19 4:15 PM, Neil Armstrong wrote: > Adds support for Amlogic G12A USB Control Glue HW. > > The Amlogic G12A SoC Family embeds 2 USB Controllers : > - a DWC3 IP configured as Host for USB2 and USB3 > - a DWC2 IP configured as Peripheral USB2 Only > > A glue connects these both controllers to 2 USB2 PHYs, and optionnally > to an USB3+PCIE Combo PHY shared with the PCIE controller. > > The Glue configures the UTMI 8bit interfaces for the USB2 PHYs, including > routing of the OTG PHY between the DWC3 and DWC2 controllers, and > setups the on-chip OTG mode selection for this PHY. > > This driver sets the OTG capable port as Host mode by default, > the switch to Device mode is to be done in a separate patch. > > Signed-off-by: Neil Armstrong > --- [...] > +static int dwc3_meson_g12a_get_phys(struct dwc3_meson_g12a *priv) > +{ > + int i, ret; > + > + for (i = 0 ; i < PHY_COUNT ; ++i) { > + ret = generic_phy_get_by_name(priv->dev, phy_names[i], > + &priv->phys[i]); > + if (ret == -ENOENT) > + continue; > + > + if (ret) > + return ret; > + > + if (i == USB3_HOST_PHY) > + priv->usb3_ports++; > + else > + priv->usb2_ports++; > + } > + > + printf("%s: usb2 ports: %d\n", __func__, priv->usb2_ports); > + printf("%s: usb3 ports: %d\n", __func__, priv->usb3_ports); Are these prints needed ? > + return 0; > +} [...] > +static int dwc3_meson_g12a_probe(struct udevice *dev) > +{ > + struct dwc3_meson_g12a *priv = dev_get_platdata(dev); > + int ret, i; > + > + priv->dev = dev; > + > + ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap); > + if (ret) > + return ret; > + > + ret = dwc3_meson_g12a_clk_init(priv); > + if (ret) > + return ret; > + > + ret = dwc3_meson_g12a_reset_init(priv); > + if (ret) > + return ret; > + > + ret = dwc3_meson_g12a_get_phys(priv); > + if (ret) > + return ret; > + > +#if CONFIG_IS_ENABLED(DM_REGULATOR) > + ret = device_get_supply_regulator(dev, "vbus-supply", > + &priv->vbus_supply); > + if (ret && ret != -ENOENT) { > + pr_err("Failed to get PHY regulator\n"); > + return ret; > + } > + > + if (priv->vbus_supply) { > + ret = regulator_set_enable(priv->vbus_supply, true); > + if (ret) > + return ret; > + } > +#endif > + > + priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev)); > + > + ret = dwc3_meson_g12a_usb_init(priv); > + if (ret) > + return ret; > + > + for (i = 0 ; i < PHY_COUNT ; ++i) { > + if (!priv->phys[i].dev) > + continue; > + > + ret = generic_phy_init(&priv->phys[i]); > + if (ret) > + goto err_phy_init; > + } Isn't there some function to init all the PHYs already ? -- Best regards, Marek Vasut From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: [PATCH 1/3] usb: dwc3: Add Meson G12A USB Glue References: <20190326151537.23118-1-narmstrong@baylibre.com> <20190326151537.23118-2-narmstrong@baylibre.com> From: Marek Vasut Message-ID: <87e9c6f0-e62c-b5aa-cddd-550c25b6d705@denx.de> Date: Tue, 26 Mar 2019 16:53:54 +0100 MIME-Version: 1.0 In-Reply-To: <20190326151537.23118-2-narmstrong@baylibre.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit To: Neil Armstrong Cc: u-boot-amlogic@groups.io, u-boot@lists.denx.de List-ID: On 3/26/19 4:15 PM, Neil Armstrong wrote: > Adds support for Amlogic G12A USB Control Glue HW. > > The Amlogic G12A SoC Family embeds 2 USB Controllers : > - a DWC3 IP configured as Host for USB2 and USB3 > - a DWC2 IP configured as Peripheral USB2 Only > > A glue connects these both controllers to 2 USB2 PHYs, and optionnally > to an USB3+PCIE Combo PHY shared with the PCIE controller. > > The Glue configures the UTMI 8bit interfaces for the USB2 PHYs, including > routing of the OTG PHY between the DWC3 and DWC2 controllers, and > setups the on-chip OTG mode selection for this PHY. > > This driver sets the OTG capable port as Host mode by default, > the switch to Device mode is to be done in a separate patch. > > Signed-off-by: Neil Armstrong > --- [...] > +static int dwc3_meson_g12a_get_phys(struct dwc3_meson_g12a *priv) > +{ > + int i, ret; > + > + for (i = 0 ; i < PHY_COUNT ; ++i) { > + ret = generic_phy_get_by_name(priv->dev, phy_names[i], > + &priv->phys[i]); > + if (ret == -ENOENT) > + continue; > + > + if (ret) > + return ret; > + > + if (i == USB3_HOST_PHY) > + priv->usb3_ports++; > + else > + priv->usb2_ports++; > + } > + > + printf("%s: usb2 ports: %d\n", __func__, priv->usb2_ports); > + printf("%s: usb3 ports: %d\n", __func__, priv->usb3_ports); Are these prints needed ? > + return 0; > +} [...] > +static int dwc3_meson_g12a_probe(struct udevice *dev) > +{ > + struct dwc3_meson_g12a *priv = dev_get_platdata(dev); > + int ret, i; > + > + priv->dev = dev; > + > + ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap); > + if (ret) > + return ret; > + > + ret = dwc3_meson_g12a_clk_init(priv); > + if (ret) > + return ret; > + > + ret = dwc3_meson_g12a_reset_init(priv); > + if (ret) > + return ret; > + > + ret = dwc3_meson_g12a_get_phys(priv); > + if (ret) > + return ret; > + > +#if CONFIG_IS_ENABLED(DM_REGULATOR) > + ret = device_get_supply_regulator(dev, "vbus-supply", > + &priv->vbus_supply); > + if (ret && ret != -ENOENT) { > + pr_err("Failed to get PHY regulator\n"); > + return ret; > + } > + > + if (priv->vbus_supply) { > + ret = regulator_set_enable(priv->vbus_supply, true); > + if (ret) > + return ret; > + } > +#endif > + > + priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev)); > + > + ret = dwc3_meson_g12a_usb_init(priv); > + if (ret) > + return ret; > + > + for (i = 0 ; i < PHY_COUNT ; ++i) { > + if (!priv->phys[i].dev) > + continue; > + > + ret = generic_phy_init(&priv->phys[i]); > + if (ret) > + goto err_phy_init; > + } Isn't there some function to init all the PHYs already ? -- Best regards, Marek Vasut