Re: [PATCH v5 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver

From: Vinod Koul
Date: Mon Jul 13 2020 - 01:51:35 EST


On 19-06-20, 12:00, Álvaro Fernández Rojas wrote:
> Add BCM63xx USBH PHY driver for BMIPS.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari@xxxxxxxxx>
> ---
> v5: use devm_reset_control_get_exclusive.
> v4: several improvements:
> - Use devm_platform_ioremap_resource.
> - Code cleanups.
> - Improve device mode config:
> - Move USBH_SWAP_CONTROL device mode value to variant variable.
> - Set USBH_UTMI_CONTROL1 register value (variant variable).
> v3: introduce changes suggested by Florian:
> - Add support for device mode.
> v2: introduce changes suggested by Florian:
> - Drop OF dependency (use device_get_match_data).
> - Drop __initconst from variant tables.
> - Use devm_clk_get_optional.
>
> drivers/phy/broadcom/Kconfig | 9 +
> drivers/phy/broadcom/Makefile | 1 +
> drivers/phy/broadcom/phy-bcm63xx-usbh.c | 457 ++++++++++++++++++++++++
> 3 files changed, 467 insertions(+)
> create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.c
>
> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
> index b29f11c19155..a7889df8c541 100644
> --- a/drivers/phy/broadcom/Kconfig
> +++ b/drivers/phy/broadcom/Kconfig
> @@ -2,6 +2,15 @@
> #
> # Phy drivers for Broadcom platforms
> #
> +config PHY_BCM63XX_USBH
> + tristate "BCM63xx USBH PHY driver"
> + depends on BMIPS_GENERIC || COMPILE_TEST
> + select GENERIC_PHY
> + default BMIPS_GENERIC

you depend on BMIPS_GENERIC and also use as default?

> +static int __init bcm63xx_usbh_phy_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct bcm63xx_usbh_phy *usbh;
> + const struct bcm63xx_usbh_phy_variant *variant;
> + struct phy *phy;
> + struct phy_provider *phy_provider;
> +
> + usbh = devm_kzalloc(dev, sizeof(*usbh), GFP_KERNEL);
> + if (!usbh)
> + return -ENOMEM;
> +
> + variant = device_get_match_data(dev);
> + if (!variant)
> + return -EINVAL;
> + usbh->variant = variant;
> +
> + usbh->base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(usbh->base))
> + return PTR_ERR(usbh->base);
> +
> + usbh->reset = devm_reset_control_get_exclusive(dev, NULL);
> + if (IS_ERR(usbh->reset)) {
> + if (PTR_ERR(usbh->reset) != -EPROBE_DEFER)
> + dev_err(dev, "failed to get reset\n");
> + return PTR_ERR(usbh->reset);
> + }
> +
> + usbh->usbh_clk = devm_clk_get_optional(dev, "usbh");
> + if (IS_ERR(usbh->usbh_clk))
> + return PTR_ERR(usbh->usbh_clk);
> +
> + usbh->usb_ref_clk = devm_clk_get_optional(dev, "usb_ref");
> + if (IS_ERR(usbh->usb_ref_clk))
> + return PTR_ERR(usbh->usb_ref_clk);
> +
> + phy = devm_phy_create(dev, NULL, &bcm63xx_usbh_phy_ops);
> + if (IS_ERR(phy)) {
> + dev_err(dev, "failed to create PHY\n");
> + return PTR_ERR(phy);
> + }
> +
> + platform_set_drvdata(pdev, usbh);
> + phy_set_drvdata(phy, usbh);
> +
> + phy_provider = devm_of_phy_provider_register(dev,
> + bcm63xx_usbh_phy_xlate);
> + if (IS_ERR(phy_provider)) {
> + dev_err(dev, "failed to register PHY provider\n");
> + return PTR_ERR(phy_provider);
> + }
> +
> + dev_info(dev, "Registered BCM63xx USB PHY driver\n");

debug level?
--
~Vinod