[U-Boot] [PATCH v1 3/6] phy: Add a new driver for OMAP's USB2 PHYs
Vignesh R
vigneshr at ti.com
Mon Mar 5 11:56:04 UTC 2018
Hi,
On Friday 05 January 2018 07:20 PM, Jean-Jacques Hiblot wrote:
> This drivers supports the USB2 PHY found on omap5 and dra7 SOCs.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
> ---
>
> drivers/phy/Kconfig | 8 ++
> drivers/phy/Makefile | 2 +
> drivers/phy/omap-usb2-phy.c | 186 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 196 insertions(+)
> create mode 100644 drivers/phy/omap-usb2-phy.c
>
> diff --git a/drivers/phy/omap-usb2-phy.c b/drivers/phy/omap-usb2-phy.c
> new file mode 100644
> index 0000000..c8a87a5
> --- /dev/null
> +++ b/drivers/phy/omap-usb2-phy.c
> @@ -0,0 +1,186 @@
[...]
> +static int omap_usb2_phy_init(struct phy *usb_phy)
> +{
> + struct udevice *dev = usb_phy->dev;
> + struct omap_usb2_phy *priv = dev_get_priv(dev);
> + u32 val;
> +
> + if (priv->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) {
> + /*
> + *
> + * Reduce the sensitivity of internal PHY by enabling the
> + * DISCON_BYP_LATCH of the USB2PHY_ANA_CONFIG1 register. This
> + * resolves issues with certain devices which can otherwise
> + * be prone to false disconnects.
> + *
> + */
> + val = readl(priv->phy_base + USB2PHY_ANA_CONFIG1);
> + val |= USB2PHY_DISCON_BYP_LATCH;
> + writel(val, priv->phy_base + USB2PHY_ANA_CONFIG1);
> + }
> +
> + return omap_usb_phy_power(usb_phy, true);
phy_init() should not power on the phy, that should be done in .power_off().
I see xhci-dwc3.c calls only generic_phy_power_init() but not
generic_phy_power_on(). I have posted a fix for that.
> +}
> +
> +static int omap_usb2_phy_exit(struct phy *usb_phy)
> +{
> + return omap_usb_phy_power(usb_phy, false);
> +}
> +
> +struct phy_ops omap_usb2_phy_ops = {
> + .init = omap_usb2_phy_init,
> + .exit = omap_usb2_phy_exit,
> +};
> +
> +int omap_usb2_phy_probe(struct udevice *dev)
> +{
> + int rc;
> + struct regmap *regmap;
> + struct omap_usb2_phy *priv = dev_get_priv(dev);
> + const struct usb_phy_data *data;
> + u32 tmp[2];
> +
> + data = (const struct usb_phy_data *)dev_get_driver_data(dev);
> + if (!data)
> + return -EINVAL;
> +
> + if (data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) {
> + u32 base = dev_read_addr(dev);
> +
> + if (base == FDT_ADDR_T_NONE)
> + return -EINVAL;
> + priv->phy_base = (void *)base;
> + priv->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT;
> + }
> +
> + regmap = syscon_regmap_lookup_by_phandle(dev, "syscon-phy-power");
> + if (IS_ERR(regmap)) {
> + printf("can't get regmap (err %ld)\n", PTR_ERR(regmap));
> + return PTR_ERR(regmap);
> + }
> + priv->pwr_regmap = regmap;
> +
> + rc = dev_read_u32_array(dev, "syscon-phy-power", tmp, 2);
> + if (rc) {
> + printf("couldn't get power reg. offset (err %d)\n", rc);
> + return rc;
> + }
> + priv->pwr_reg_offset = tmp[1];
> +
> + return 0;
> +}
> +
> +U_BOOT_DRIVER(omap_usb2_phy) = {
> + .name = "omap_usb2_phy",
> + .id = UCLASS_PHY,
> + .of_match = omap_usb2_id_table,
> + .probe = omap_usb2_phy_probe,
> + .ops = &omap_usb2_phy_ops,
> + .priv_auto_alloc_size = sizeof(struct omap_usb2_phy),
> +};
>
--
Regards
Vignesh
More information about the U-Boot
mailing list