Skip to content

Commit b4cbd1a

Browse files
committed
Merge tag 'u-boot-amlogic-20240701' of https://source.denx.de/u-boot/custodians/u-boot-amlogic into next
- Switch meson dwc3/usb PHY to set_mode callback for switching USB mode
2 parents 2f96033 + 96e1a15 commit b4cbd1a

File tree

9 files changed

+35
-56
lines changed

9 files changed

+35
-56
lines changed

arch/arm/include/asm/arch-meson/usb-gx.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

arch/arm/include/asm/arch-meson/usb.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

drivers/phy/meson-gxl-usb2.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include <linux/printk.h>
2020
#include <linux/usb/otg.h>
2121

22-
#include <asm/arch/usb-gx.h>
23-
2422
#include <linux/bitops.h>
2523
#include <linux/compat.h>
2624

@@ -121,33 +119,40 @@ static void phy_meson_gxl_usb2_reset(struct phy_meson_gxl_usb2_priv *priv)
121119
udelay(RESET_COMPLETE_TIME);
122120
}
123121

124-
void phy_meson_gxl_usb2_set_mode(struct phy *phy, enum usb_dr_mode mode)
122+
static int phy_meson_gxl_usb2_set_mode(struct phy *phy, enum phy_mode mode, int submode)
125123
{
126124
struct udevice *dev = phy->dev;
127125
struct phy_meson_gxl_usb2_priv *priv = dev_get_priv(dev);
128126
uint val;
129127

128+
if (submode)
129+
return -EOPNOTSUPP;
130+
130131
regmap_read(priv->regmap, U2P_R0, &val);
131132

132133
switch (mode) {
133-
case USB_DR_MODE_UNKNOWN:
134-
case USB_DR_MODE_HOST:
135-
case USB_DR_MODE_OTG:
134+
case PHY_MODE_USB_DEVICE:
135+
val &= ~U2P_R0_DM_PULLDOWN;
136+
val &= ~U2P_R0_DP_PULLDOWN;
137+
val |= U2P_R0_ID_PULLUP;
138+
break;
139+
140+
case PHY_MODE_USB_HOST:
141+
case PHY_MODE_USB_OTG:
136142
val |= U2P_R0_DM_PULLDOWN;
137143
val |= U2P_R0_DP_PULLDOWN;
138144
val &= ~U2P_R0_ID_PULLUP;
139145
break;
140146

141-
case USB_DR_MODE_PERIPHERAL:
142-
val &= ~U2P_R0_DM_PULLDOWN;
143-
val &= ~U2P_R0_DP_PULLDOWN;
144-
val |= U2P_R0_ID_PULLUP;
145-
break;
147+
default:
148+
return -EINVAL;
146149
}
147150

148151
regmap_write(priv->regmap, U2P_R0, val);
149152

150153
phy_meson_gxl_usb2_reset(priv);
154+
155+
return 0;
151156
}
152157

153158
static int phy_meson_gxl_usb2_power_on(struct phy *phy)
@@ -161,7 +166,7 @@ static int phy_meson_gxl_usb2_power_on(struct phy *phy)
161166
val &= ~U2P_R0_POWER_ON_RESET;
162167
regmap_write(priv->regmap, U2P_R0, val);
163168

164-
phy_meson_gxl_usb2_set_mode(phy, USB_DR_MODE_HOST);
169+
phy_meson_gxl_usb2_set_mode(phy, PHY_MODE_USB_HOST, 0);
165170

166171
return 0;
167172
}
@@ -183,6 +188,7 @@ static int phy_meson_gxl_usb2_power_off(struct phy *phy)
183188
struct phy_ops meson_gxl_usb2_phy_ops = {
184189
.power_on = phy_meson_gxl_usb2_power_on,
185190
.power_off = phy_meson_gxl_usb2_power_off,
191+
.set_mode = phy_meson_gxl_usb2_set_mode,
186192
};
187193

188194
int meson_gxl_usb2_phy_probe(struct udevice *dev)

drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static const struct dm_gpio_ops meson_axg_gpio_ops = {
179179
.direction_output = meson_gpio_direction_output,
180180
};
181181

182-
const struct driver meson_axg_gpio_driver = {
182+
U_BOOT_DRIVER(meson_axg_gpio) = {
183183
.name = "meson-axg-gpio",
184184
.id = UCLASS_GPIO,
185185
.probe = meson_gpio_probe,

drivers/pinctrl/meson/pinctrl-meson-axg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ struct meson_pinctrl_data meson_axg_periphs_pinctrl_data = {
939939
.num_groups = ARRAY_SIZE(meson_axg_periphs_groups),
940940
.num_funcs = ARRAY_SIZE(meson_axg_periphs_functions),
941941
.num_banks = ARRAY_SIZE(meson_axg_periphs_banks),
942-
.gpio_driver = &meson_axg_gpio_driver,
942+
.gpio_driver = DM_DRIVER_REF(meson_axg_gpio),
943943
.pmx_data = &meson_axg_periphs_pmx_banks_data,
944944
};
945945

@@ -953,7 +953,7 @@ struct meson_pinctrl_data meson_axg_aobus_pinctrl_data = {
953953
.num_groups = ARRAY_SIZE(meson_axg_aobus_groups),
954954
.num_funcs = ARRAY_SIZE(meson_axg_aobus_functions),
955955
.num_banks = ARRAY_SIZE(meson_axg_aobus_banks),
956-
.gpio_driver = &meson_axg_gpio_driver,
956+
.gpio_driver = DM_DRIVER_REF(meson_axg_gpio),
957957
.pmx_data = &meson_axg_aobus_pmx_banks_data,
958958
};
959959

drivers/pinctrl/meson/pinctrl-meson-axg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ struct meson_pmx_axg_data {
6161
}
6262

6363
extern const struct pinctrl_ops meson_axg_pinctrl_ops;
64-
extern const struct driver meson_axg_gpio_driver;
64+
extern U_BOOT_DRIVER(meson_axg_gpio);
6565

6666
#endif /* __PINCTRL_MESON_AXG_H__ */

drivers/pinctrl/meson/pinctrl-meson-g12a.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ static struct meson_pinctrl_data meson_g12a_periphs_pinctrl_data = {
12531253
.num_groups = ARRAY_SIZE(meson_g12a_periphs_groups),
12541254
.num_funcs = ARRAY_SIZE(meson_g12a_periphs_functions),
12551255
.num_banks = ARRAY_SIZE(meson_g12a_periphs_banks),
1256-
.gpio_driver = &meson_axg_gpio_driver,
1256+
.gpio_driver = DM_DRIVER_REF(meson_axg_gpio),
12571257
.pmx_data = &meson_g12a_periphs_pmx_banks_data,
12581258
};
12591259

@@ -1267,7 +1267,7 @@ static struct meson_pinctrl_data meson_g12a_aobus_pinctrl_data = {
12671267
.num_groups = ARRAY_SIZE(meson_g12a_aobus_groups),
12681268
.num_funcs = ARRAY_SIZE(meson_g12a_aobus_functions),
12691269
.num_banks = ARRAY_SIZE(meson_g12a_aobus_banks),
1270-
.gpio_driver = &meson_axg_gpio_driver,
1270+
.gpio_driver = DM_DRIVER_REF(meson_axg_gpio),
12711271
.pmx_data = &meson_g12a_aobus_pmx_banks_data,
12721272
};
12731273

drivers/usb/dwc3/dwc3-meson-g12a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static int dwc3_meson_g12a_usb_init(struct dwc3_meson_g12a *priv)
270270
return 0;
271271
}
272272

273-
int dwc3_meson_g12a_force_mode(struct udevice *dev, enum usb_dr_mode mode)
273+
static int dwc3_meson_g12a_force_mode(struct udevice *dev, enum usb_dr_mode mode)
274274
{
275275
struct dwc3_meson_g12a *priv = dev_get_plat(dev);
276276

drivers/usb/dwc3/dwc3-meson-gxl.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <linux/bitfield.h>
2727
#include <linux/bitops.h>
2828
#include <linux/compat.h>
29-
#include <asm/arch/usb-gx.h>
3029

3130
/* USB Glue Control Registers */
3231

@@ -158,9 +157,9 @@ static int dwc3_meson_gxl_usb2_init(struct dwc3_meson_gxl *priv)
158157
if (!priv->phys[i].dev)
159158
continue;
160159

161-
phy_meson_gxl_usb2_set_mode(&priv->phys[i],
162-
(i == USB2_OTG_PHY) ? USB_DR_MODE_PERIPHERAL
163-
: USB_DR_MODE_HOST);
160+
generic_phy_set_mode(&priv->phys[i],
161+
(i == USB2_OTG_PHY) ? PHY_MODE_USB_DEVICE
162+
: PHY_MODE_USB_HOST, 0);
164163
}
165164

166165
return 0;
@@ -193,7 +192,7 @@ static int dwc3_meson_gxl_usb_init(struct dwc3_meson_gxl *priv)
193192
return 0;
194193
}
195194

196-
int dwc3_meson_gxl_force_mode(struct udevice *dev, enum usb_dr_mode mode)
195+
static int dwc3_meson_gxl_force_mode(struct udevice *dev, enum usb_dr_mode mode)
197196
{
198197
struct dwc3_meson_gxl *priv = dev_get_plat(dev);
199198

@@ -224,7 +223,9 @@ int dwc3_meson_gxl_force_mode(struct udevice *dev, enum usb_dr_mode mode)
224223
#endif
225224
priv->otg_phy_mode = mode;
226225

227-
phy_meson_gxl_usb2_set_mode(&priv->phys[USB2_OTG_PHY], mode);
226+
generic_phy_set_mode(&priv->phys[USB2_OTG_PHY],
227+
mode == USB_DR_MODE_PERIPHERAL ? PHY_MODE_USB_DEVICE
228+
: PHY_MODE_USB_HOST, 0);
228229

229230
dwc3_meson_gxl_usb2_set_mode(priv, mode);
230231

@@ -361,8 +362,9 @@ static int dwc3_meson_gxl_probe(struct udevice *dev)
361362
}
362363

363364
if (priv->phys[USB2_OTG_PHY].dev)
364-
phy_meson_gxl_usb2_set_mode(&priv->phys[USB2_OTG_PHY],
365-
priv->otg_phy_mode);
365+
generic_phy_set_mode(&priv->phys[USB2_OTG_PHY],
366+
priv->otg_phy_mode == USB_DR_MODE_PERIPHERAL ? PHY_MODE_USB_DEVICE
367+
: PHY_MODE_USB_HOST, 0);
366368

367369
dwc3_meson_gxl_usb2_set_mode(priv, priv->otg_phy_mode);
368370

0 commit comments

Comments
 (0)