* [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031
@ 2014-10-28 10:50 Wadim Egorov
2014-10-28 10:50 ` [PATCH 2/2] net: cpsw: Set phy device_node pointer in probe Wadim Egorov
2014-11-03 7:18 ` [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031 Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Wadim Egorov @ 2014-10-28 10:50 UTC (permalink / raw)
To: barebox
Adds support for ksz9031 PAD skew configuration over devicetree.
Based on a patch from the linux kernel.
Author: Hubert Chaumette <hchaumette@adeneo-embedded.com>
Original commit: 6e4b82730c7525504fc485b370c7f09e594e2e96
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
drivers/net/phy/micrel.c | 86 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 85 insertions(+), 1 deletions(-)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 88c64e5..c9558da 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -146,6 +146,90 @@ static int ksz9021_config_init(struct phy_device *phydev)
return 0;
}
+#define KSZ9031_PS_TO_REG 60
+
+/* Extended registers */
+#define MII_KSZ9031RN_CONTROL_PAD_SKEW 4
+#define MII_KSZ9031RN_RX_DATA_PAD_SKEW 5
+#define MII_KSZ9031RN_TX_DATA_PAD_SKEW 6
+#define MII_KSZ9031RN_CLK_PAD_SKEW 8
+
+static int ksz9031_of_load_skew_values(struct phy_device *phydev,
+ struct device_node *of_node,
+ u16 reg, size_t field_sz,
+ char *field[], u8 numfields)
+{
+ int val[4] = {-1, -2, -3, -4};
+ int matches = 0;
+ u16 mask;
+ u16 maxval;
+ u16 newval;
+ int i;
+
+ for (i = 0; i < numfields; i++)
+ if (!of_property_read_u32(of_node, field[i], val + i))
+ matches++;
+
+ if (!matches)
+ return 0;
+
+ if (matches < numfields)
+ newval = phy_read_mmd_indirect(phydev, reg, 2);
+ else
+ newval = 0;
+
+ maxval = (field_sz == 4) ? 0xf : 0x1f;
+ for (i = 0; i < numfields; i++)
+ if (val[i] != -(i + 1)) {
+ mask = 0xffff;
+ mask ^= maxval << (field_sz * i);
+ newval = (newval & mask) |
+ (((val[i] / KSZ9031_PS_TO_REG) & maxval)
+ << (field_sz * i));
+ }
+
+ phy_write_mmd_indirect(phydev, reg, 2, newval);
+ return 0;
+}
+
+static int ksz9031_config_init(struct phy_device *phydev)
+{
+ struct device_d *dev = &phydev->dev;
+ struct device_node *of_node = dev->device_node;
+ char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"};
+ char *rx_data_skews[4] = {
+ "rxd0-skew-ps", "rxd1-skew-ps",
+ "rxd2-skew-ps", "rxd3-skew-ps"
+ };
+ char *tx_data_skews[4] = {
+ "txd0-skew-ps", "txd1-skew-ps",
+ "txd2-skew-ps", "txd3-skew-ps"
+ };
+ char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"};
+
+ if (!of_node && dev->parent->device_node)
+ of_node = dev->parent->device_node;
+
+ if (of_node) {
+ ksz9031_of_load_skew_values(phydev, of_node,
+ MII_KSZ9031RN_CLK_PAD_SKEW, 5,
+ clk_skews, 2);
+
+ ksz9031_of_load_skew_values(phydev, of_node,
+ MII_KSZ9031RN_CONTROL_PAD_SKEW, 4,
+ control_skews, 2);
+
+ ksz9031_of_load_skew_values(phydev, of_node,
+ MII_KSZ9031RN_RX_DATA_PAD_SKEW, 4,
+ rx_data_skews, 4);
+
+ ksz9031_of_load_skew_values(phydev, of_node,
+ MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4,
+ tx_data_skews, 4);
+ }
+ return 0;
+}
+
#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX (1 << 6)
#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED (1 << 4)
@@ -259,7 +343,7 @@ static struct phy_driver ksphy_driver[] = {
.phy_id_mask = 0x00fffff0,
.drv.name = "Micrel KSZ9031 Gigabit PHY",
.features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
- .config_init = kszphy_config_init,
+ .config_init = ksz9031_config_init,
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
}, {
--
1.7.0.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] net: cpsw: Set phy device_node pointer in probe
2014-10-28 10:50 [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031 Wadim Egorov
@ 2014-10-28 10:50 ` Wadim Egorov
2014-11-03 7:18 ` [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031 Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Wadim Egorov @ 2014-10-28 10:50 UTC (permalink / raw)
To: barebox
Set the phy device_node pointer to the equivalent cpsw slave node.
We need this, because phy drivers using this pointer for their configuration.
Create and register the phy device in cpsw_probe(), so that this phy device
can be found later by phy_device_connect() in cpsw_open().
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
drivers/net/cpsw.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 167b2dd..a0621f5 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -1200,6 +1200,19 @@ int cpsw_probe(struct device_d *dev)
mdiobus_register(&priv->miibus);
for (i = 0; i < priv->num_slaves; i++) {
+ struct phy_device *phy;
+
+ phy = mdiobus_scan(&priv->miibus, priv->slaves[i].phy_id);
+ if (IS_ERR(phy)) {
+ ret = PTR_ERR(phy);
+ goto out;
+ }
+
+ phy->dev.device_node = priv->slaves[i].dev.device_node;
+ ret = phy_register_device(phy);
+ if (ret)
+ goto out;
+
ret = cpsw_slave_setup(&priv->slaves[i], i, priv);
if (ret)
goto out;
--
1.7.0.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031
2014-10-28 10:50 [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031 Wadim Egorov
2014-10-28 10:50 ` [PATCH 2/2] net: cpsw: Set phy device_node pointer in probe Wadim Egorov
@ 2014-11-03 7:18 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-11-03 7:18 UTC (permalink / raw)
To: Wadim Egorov; +Cc: barebox
On Tue, Oct 28, 2014 at 11:50:35AM +0100, Wadim Egorov wrote:
> Adds support for ksz9031 PAD skew configuration over devicetree.
> Based on a patch from the linux kernel.
>
> Author: Hubert Chaumette <hchaumette@adeneo-embedded.com>
> Original commit: 6e4b82730c7525504fc485b370c7f09e594e2e96
>
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Applied both, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-03 7:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-28 10:50 [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031 Wadim Egorov
2014-10-28 10:50 ` [PATCH 2/2] net: cpsw: Set phy device_node pointer in probe Wadim Egorov
2014-11-03 7:18 ` [PATCH 1/2] net: phy: micrel: Add OF conf. support for ksz9031 Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox