1
0

902-at803x-add-reset-gpio-pdata.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Add support for configuring AT803x GPIO reset via platform data.
  2. This is necessary, because ath79 is not converted to device tree yet.
  3. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  4. --- a/include/linux/platform_data/phy-at803x.h
  5. +++ b/include/linux/platform_data/phy-at803x.h
  6. @@ -6,6 +6,8 @@ struct at803x_platform_data {
  7. int enable_rgmii_tx_delay:1;
  8. int enable_rgmii_rx_delay:1;
  9. int fixup_rgmii_tx_delay:1;
  10. + int has_reset_gpio:1;
  11. + int reset_gpio;
  12. };
  13. #endif /* _PHY_AT803X_PDATA_H */
  14. --- a/drivers/net/phy/at803x.c
  15. +++ b/drivers/net/phy/at803x.c
  16. @@ -243,6 +243,7 @@ static int at803x_resume(struct phy_devi
  17. static int at803x_probe(struct phy_device *phydev)
  18. {
  19. + struct at803x_platform_data *pdata;
  20. struct device *dev = &phydev->dev;
  21. struct at803x_priv *priv;
  22. struct gpio_desc *gpiod_reset;
  23. @@ -255,6 +256,12 @@ static int at803x_probe(struct phy_devic
  24. phydev->drv->phy_id != ATH8032_PHY_ID)
  25. goto does_not_require_reset_workaround;
  26. + pdata = dev_get_platdata(&phydev->dev);
  27. + if (pdata && pdata->has_reset_gpio) {
  28. + devm_gpio_request(dev, pdata->reset_gpio, "reset");
  29. + gpio_direction_output(pdata->reset_gpio, 1);
  30. + }
  31. +
  32. gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
  33. if (IS_ERR(gpiod_reset))
  34. return PTR_ERR(gpiod_reset);
  35. @@ -377,15 +384,23 @@ static void at803x_link_change_notify(st
  36. * cannot recover from by software.
  37. */
  38. if (phydev->state == PHY_NOLINK) {
  39. - if (priv->gpiod_reset && !priv->phy_reset) {
  40. + if ((priv->gpiod_reset || pdata->has_reset_gpio) &&
  41. + !priv->phy_reset) {
  42. struct at803x_context context;
  43. at803x_context_save(phydev, &context);
  44. - gpiod_set_value(priv->gpiod_reset, 1);
  45. - msleep(1);
  46. - gpiod_set_value(priv->gpiod_reset, 0);
  47. - msleep(1);
  48. + if (pdata->has_reset_gpio) {
  49. + gpio_set_value_cansleep(pdata->reset_gpio, 0);
  50. + msleep(1);
  51. + gpio_set_value_cansleep(pdata->reset_gpio, 1);
  52. + msleep(1);
  53. + } else {
  54. + gpiod_set_value(priv->gpiod_reset, 1);
  55. + msleep(1);
  56. + gpiod_set_value(priv->gpiod_reset, 0);
  57. + msleep(1);
  58. + }
  59. at803x_context_restore(phydev, &context);