Re: [U-Boot] [PATCH 4/6] sunxi: phy: Add USB PHY support for Allwinner H6

2019-06-18 Thread Clément Péron
Hi,

On Thu, 16 May 2019 at 03:27, Andre Przywara  wrote:
>
> The USB PHY used in the Allwinner H6 SoC has some pecularities (as usual),

Checkpatch warning:
WARNING: 'pecularities' may be misspelled - perhaps 'peculiarities'?

> which require a small addition to the USB PHY driver:
> In this case the second PHY is PHY3, not PHY1, so we need to skip number
> 1 and 2 in the code. Just use the respective code from Linux for that.
>
> Signed-off-by: Andre Przywara 
> ---
>  drivers/phy/allwinner/phy-sun4i-usb.c | 20 
>  1 file changed, 20 insertions(+)
>
> diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c 
> b/drivers/phy/allwinner/phy-sun4i-usb.c
> index f206fa3f5d..5e8f87717f 100644
> --- a/drivers/phy/allwinner/phy-sun4i-usb.c
> +++ b/drivers/phy/allwinner/phy-sun4i-usb.c
> @@ -75,6 +75,7 @@ enum sun4i_usb_phy_type {
> sun8i_h3_phy,
> sun8i_v3s_phy,
> sun50i_a64_phy,
> +   sun50i_h6_phy,
>  };
>
>  struct sun4i_usb_phy_cfg {
> @@ -85,6 +86,7 @@ struct sun4i_usb_phy_cfg {
> bool dedicated_clocks;
> bool enable_pmu_unk1;
> bool phy0_dual_route;
> +   int missing_phys;
>  };
>
>  struct sun4i_usb_phy_info {
> @@ -349,6 +351,9 @@ static int sun4i_usb_phy_xlate(struct phy *phy,
> if (args->args_count >= data->cfg->num_phys)
> return -EINVAL;
>
> +   if (data->cfg->missing_phys & BIT(args->args[0]))
> +   return -ENODEV;
> +
> if (args->args_count)
> phy->id = args->args[0];
> else
> @@ -429,6 +434,9 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
> struct sun4i_usb_phy_info *info = _info[i];
> char name[16];
>
> +   if (data->cfg->missing_phys & BIT(i))
> +   continue;
> +
> phy->gpio_vbus = sunxi_name_to_gpio(info->gpio_vbus);
> if (phy->gpio_vbus >= 0) {
> ret = gpio_request(phy->gpio_vbus, "usb_vbus");
> @@ -583,6 +591,17 @@ static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = {
> .phy0_dual_route = true,
>  };
>
> +static const struct sun4i_usb_phy_cfg sun50i_h6_cfg = {
> +   .num_phys = 4,
> +   .type = sun50i_h6_phy,
> +   .disc_thresh = 3,
> +   .phyctl_offset = REG_PHYCTL_A33,
> +   .dedicated_clocks = true,
> +   .enable_pmu_unk1 = true,
> +   .phy0_dual_route = true,
> +   .missing_phys = BIT(1) | BIT(2),
> +};
> +
>  static const struct udevice_id sun4i_usb_phy_ids[] = {
> { .compatible = "allwinner,sun4i-a10-usb-phy", .data = 
> (ulong)_a10_cfg },
> { .compatible = "allwinner,sun5i-a13-usb-phy", .data = 
> (ulong)_a13_cfg },
> @@ -594,6 +613,7 @@ static const struct udevice_id sun4i_usb_phy_ids[] = {
> { .compatible = "allwinner,sun8i-h3-usb-phy", .data = 
> (ulong)_h3_cfg },
> { .compatible = "allwinner,sun8i-v3s-usb-phy", .data = 
> (ulong)_v3s_cfg },
> { .compatible = "allwinner,sun50i-a64-usb-phy", .data = 
> (ulong)_a64_cfg},
> +   { .compatible = "allwinner,sun50i-h6-usb-phy", .data = 
> (ulong)_h6_cfg},
> { }
>  };
>
> --
> 2.14.5
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/6] sunxi: phy: Add USB PHY support for Allwinner H6

2019-05-15 Thread Andre Przywara
The USB PHY used in the Allwinner H6 SoC has some pecularities (as usual),
which require a small addition to the USB PHY driver:
In this case the second PHY is PHY3, not PHY1, so we need to skip number
1 and 2 in the code. Just use the respective code from Linux for that.

Signed-off-by: Andre Przywara 
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c 
b/drivers/phy/allwinner/phy-sun4i-usb.c
index f206fa3f5d..5e8f87717f 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -75,6 +75,7 @@ enum sun4i_usb_phy_type {
sun8i_h3_phy,
sun8i_v3s_phy,
sun50i_a64_phy,
+   sun50i_h6_phy,
 };
 
 struct sun4i_usb_phy_cfg {
@@ -85,6 +86,7 @@ struct sun4i_usb_phy_cfg {
bool dedicated_clocks;
bool enable_pmu_unk1;
bool phy0_dual_route;
+   int missing_phys;
 };
 
 struct sun4i_usb_phy_info {
@@ -349,6 +351,9 @@ static int sun4i_usb_phy_xlate(struct phy *phy,
if (args->args_count >= data->cfg->num_phys)
return -EINVAL;
 
+   if (data->cfg->missing_phys & BIT(args->args[0]))
+   return -ENODEV;
+
if (args->args_count)
phy->id = args->args[0];
else
@@ -429,6 +434,9 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
struct sun4i_usb_phy_info *info = _info[i];
char name[16];
 
+   if (data->cfg->missing_phys & BIT(i))
+   continue;
+
phy->gpio_vbus = sunxi_name_to_gpio(info->gpio_vbus);
if (phy->gpio_vbus >= 0) {
ret = gpio_request(phy->gpio_vbus, "usb_vbus");
@@ -583,6 +591,17 @@ static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = {
.phy0_dual_route = true,
 };
 
+static const struct sun4i_usb_phy_cfg sun50i_h6_cfg = {
+   .num_phys = 4,
+   .type = sun50i_h6_phy,
+   .disc_thresh = 3,
+   .phyctl_offset = REG_PHYCTL_A33,
+   .dedicated_clocks = true,
+   .enable_pmu_unk1 = true,
+   .phy0_dual_route = true,
+   .missing_phys = BIT(1) | BIT(2),
+};
+
 static const struct udevice_id sun4i_usb_phy_ids[] = {
{ .compatible = "allwinner,sun4i-a10-usb-phy", .data = 
(ulong)_a10_cfg },
{ .compatible = "allwinner,sun5i-a13-usb-phy", .data = 
(ulong)_a13_cfg },
@@ -594,6 +613,7 @@ static const struct udevice_id sun4i_usb_phy_ids[] = {
{ .compatible = "allwinner,sun8i-h3-usb-phy", .data = 
(ulong)_h3_cfg },
{ .compatible = "allwinner,sun8i-v3s-usb-phy", .data = 
(ulong)_v3s_cfg },
{ .compatible = "allwinner,sun50i-a64-usb-phy", .data = 
(ulong)_a64_cfg},
+   { .compatible = "allwinner,sun50i-h6-usb-phy", .data = 
(ulong)_h6_cfg},
{ }
 };
 
-- 
2.14.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot