aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2017-10-03 18:02:59 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2017-10-11 22:32:39 +0200
commit7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c (patch)
treee42a4555f9845f78fb9baf7102da8d3d45adfacc /target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch
parent2909a4b78e2bce5f6b9c35361866d5e9477a1bdc (diff)
downloadupstream-7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c.tar.gz
upstream-7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c.tar.bz2
upstream-7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c.zip
ar71xx: Add kernel 4.9 support
This add support for kernel 4.9 to the ar71xx target. It was compile tested with the generic, NAND and mikrotik subtarget. Multiple members of the community tested it on their boards and did not report any major problem so far. Especially the NAND part received some changes to adapt to the new kernel APIs. The serial driver hack used for the Arduino Yun was not ported because the kernel changed there a lot. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch')
-rw-r--r--target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch b/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch
new file mode 100644
index 0000000000..cb3ed89e98
--- /dev/null
+++ b/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch
@@ -0,0 +1,68 @@
+Add support for configuring AT803x GPIO reset via platform data.
+This is necessary, because ath79 is not converted to device tree yet.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+
+--- a/include/linux/platform_data/phy-at803x.h
++++ b/include/linux/platform_data/phy-at803x.h
+@@ -6,6 +6,8 @@ struct at803x_platform_data {
+ int enable_rgmii_tx_delay:1;
+ int enable_rgmii_rx_delay:1;
+ int fixup_rgmii_tx_delay:1;
++ int has_reset_gpio:1;
++ int reset_gpio;
+ };
+
+ #endif /* _PHY_AT803X_PDATA_H */
+--- a/drivers/net/phy/at803x.c
++++ b/drivers/net/phy/at803x.c
+@@ -264,6 +264,7 @@ static int at803x_resume(struct phy_devi
+
+ static int at803x_probe(struct phy_device *phydev)
+ {
++ struct at803x_platform_data *pdata;
+ struct device *dev = &phydev->mdio.dev;
+ struct at803x_priv *priv;
+ struct gpio_desc *gpiod_reset;
+@@ -276,6 +277,12 @@ static int at803x_probe(struct phy_devic
+ phydev->drv->phy_id != ATH8032_PHY_ID)
+ goto does_not_require_reset_workaround;
+
++ pdata = dev_get_platdata(dev);
++ if (pdata && pdata->has_reset_gpio) {
++ devm_gpio_request(dev, pdata->reset_gpio, "reset");
++ gpio_direction_output(pdata->reset_gpio, 1);
++ }
++
+ gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod_reset))
+ return PTR_ERR(gpiod_reset);
+@@ -407,15 +414,23 @@ static void at803x_link_change_notify(st
+ * cannot recover from by software.
+ */
+ if (phydev->state == PHY_NOLINK) {
+- if (priv->gpiod_reset && !priv->phy_reset) {
++ if ((priv->gpiod_reset || (pdata && pdata->has_reset_gpio)) &&
++ !priv->phy_reset) {
+ struct at803x_context context;
+
+ at803x_context_save(phydev, &context);
+
+- gpiod_set_value(priv->gpiod_reset, 1);
+- msleep(1);
+- gpiod_set_value(priv->gpiod_reset, 0);
+- msleep(1);
++ if (pdata && pdata->has_reset_gpio) {
++ gpio_set_value_cansleep(pdata->reset_gpio, 0);
++ msleep(1);
++ gpio_set_value_cansleep(pdata->reset_gpio, 1);
++ msleep(1);
++ } else {
++ gpiod_set_value(priv->gpiod_reset, 1);
++ msleep(1);
++ gpiod_set_value(priv->gpiod_reset, 0);
++ msleep(1);
++ }
+
+ at803x_context_restore(phydev, &context);
+