This series reworks some of the phylib code and adds of_mdio helper functions to make it easier for device drivers to retrieve the PHY configuration by reading the OF device tree. Most of these changes have been only compile tested, but not booted on real hardware. Exceptions are mpc52xx and ll_temac which have been tested, and pasemi which hasn't even been compile tested because my 64bit environment is broken at the moment. For those with access to hardware, please test and provide me with feedback. This series also adds a new network driver for the Xilinx ll_temac 10/100/1000 MAC. For those who are interested, this series is available on my git server at: git://git.secretlab.ca/git/linux-2.6-mpc52xx test Right now it is based on current mainline plus a bunch of patches that I've already got in Benh's -next tree (but is not actually based on Benh's tree). I'll probably rebase before I post v3 Changes since v1: - Add ll_temac driver - Clean up of_node_put() calls - removal of dead code from ucc_geth driver - Fix changes to gianfar driver to not try to connect to tbi phy. diffstat: arch/powerpc/boot/dts/virtex440-ml507.dts | 14 +- arch/powerpc/platforms/82xx/ep8248e.c | 7 +- arch/powerpc/platforms/pasemi/gpio_mdio.c | 29 +- drivers/net/Kconfig | 8 + drivers/net/Makefile | 2 + drivers/net/fec_mpc52xx.c | 228 +++---- drivers/net/fec_mpc52xx_phy.c | 26 +- drivers/net/fs_enet/fs_enet-main.c | 69 +-- drivers/net/fs_enet/mii-bitbang.c | 29 +- drivers/net/fs_enet/mii-fec.c | 26 +- drivers/net/gianfar.c | 103 ++-- drivers/net/gianfar.h | 3 +- drivers/net/gianfar_mii.c | 52 +-- drivers/net/pasemi_mac.c | 19 +- drivers/net/pasemi_mac.h | 1 - drivers/net/phy/marvell.c | 2 + drivers/net/phy/mdio_bus.c ...
From: Grant Likely <grant.likely@secretlab.ca>
of_parse_phandle() is a helper function to read and parse a phandle
property and return a pointer to the resulting device_node.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
CC: Michael Ellerman <michael@ellerman.id.au>
---
drivers/of/base.c | 24 ++++++++++++++++++++++++
include/linux/of.h | 3 +++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index cd17092..104b8c0 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -494,6 +494,30 @@ int of_modalias_node(struct device_node *node, char *modalias, int len)
EXPORT_SYMBOL_GPL(of_modalias_node);
/**
+ * of_parse_phandle - Resolve a phandle property to a device_node pointer
+ * @np: Pointer to device node holding phandle property
+ * @phandle_name: Name of property holding a phandle value
+ * @index: For properties holding a table of phandles, this is the index into
+ * the table
+ *
+ * Returns the device_node pointer with refcount incremented. Use
+ * of_node_put() on it when done.
+ */
+struct device_node *
+of_parse_phandle(struct device_node *np, const char *phandle_name, int index)
+{
+ const phandle *phandle;
+ int size;
+
+ phandle = of_get_property(np, phandle_name, &size);
+ if ((!phandle) || (size < sizeof(*phandle) * (index + 1)))
+ return NULL;
+
+ return of_find_node_by_phandle(phandle[index]);
+}
+EXPORT_SYMBOL(of_parse_phandle);
+
+/**
* of_parse_phandles_with_args - Find a node pointed by phandle in a list
* @np: pointer to a device tree node containing a list
* @list_name: property name that contains a list
diff --git a/include/linux/of.h b/include/linux/of.h
index 6a7efa2..7be2d10 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -77,6 +77,9 @@ extern int of_n_size_cells(struct device_node *np);
extern const struct of_device_id *of_match_node(
const struct of_device_id *matches, const struct device_node *node);
extern int ...From: Henk Stegeman <henk.stegeman@gmail.com>
Fix fec_mpc52xx driver to use net_device_ops and to be careful not to
dereference phy_device if a phy has not yet been connected.
Waiting for a signed-off-by line from Henk on this one
CC: Henk Stegeman <henk.stegeman@gmail.com>
---
drivers/net/fec_mpc52xx.c | 47 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 049b0a7..3d55f9a 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -847,24 +847,40 @@ static void mpc52xx_fec_get_drvinfo(struct net_device *dev,
static int mpc52xx_fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
+
+ if (!priv->phydev)
+ return -ENODEV;
+
return phy_ethtool_gset(priv->phydev, cmd);
}
static int mpc52xx_fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
+
+ if (!priv->phydev)
+ return -ENODEV;
+
return phy_ethtool_sset(priv->phydev, cmd);
}
static u32 mpc52xx_fec_get_msglevel(struct net_device *dev)
{
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
+
+ if (!priv->phydev)
+ return 0;
+
return priv->msg_enable;
}
static void mpc52xx_fec_set_msglevel(struct net_device *dev, u32 level)
{
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
+
+ if (!priv->phydev)
+ return;
+
priv->msg_enable = level;
}
@@ -882,12 +898,31 @@ static int mpc52xx_fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
+ if (!priv->phydev)
+ return -ENODEV;
+
return mpc52xx_fec_phy_mii_ioctl(priv, if_mii(rq), cmd);
}
/* ======================================================================== */
/* OF Driver */
/* ...From: Grant Likely <grant.likely@secretlab.ca> This patch makes changes in preparation for supporting open firmware device tree descriptions of MDIO busses. Changes include: - Cleanup handling of phy_map[] entries; they are already NULLed when registering and so don't need to be re-cleared, and it is good practice to clear them out when unregistering. - Split phy_device registration out into a new function so that the OF helpers can do two stage registration (separate allocation and registration steps). Signed-off-by: Grant Likely <grant.likely@secretlab.ca> CC: linuxppc-dev@ozlabs.org CC: netdev@vger.kernel.org CC: Andy Fleming <afleming@freescale.com> --- drivers/net/phy/mdio_bus.c | 29 +++------------------------ drivers/net/phy/phy_device.c | 45 ++++++++++++++++++++++++++++++++++++++---- include/linux/phy.h | 1 + 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 811a637..3c39c7b 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -112,7 +112,6 @@ int mdiobus_register(struct mii_bus *bus) bus->reset(bus); for (i = 0; i < PHY_MAX_ADDR; i++) { - bus->phy_map[i] = NULL; if ((bus->phy_mask & (1 << i)) == 0) { struct phy_device *phydev; @@ -149,6 +148,7 @@ void mdiobus_unregister(struct mii_bus *bus) for (i = 0; i < PHY_MAX_ADDR; i++) { if (bus->phy_map[i]) device_unregister(&bus->phy_map[i]->dev); + bus->phy_map[i] = NULL; } } EXPORT_SYMBOL(mdiobus_unregister); @@ -187,35 +187,12 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) if (IS_ERR(phydev) || phydev == NULL) return phydev; - /* There's a PHY at this address - * We need to set: - * 1) IRQ - * 2) bus_id - * 3) parent - * 4) bus - * 5) mii_bus - * And, we need to register it */ - - phydev->irq = bus->irq != NULL ? bus->irq[addr] : PHY_POLL; - - phydev->dev.parent = bus->parent; - phydev->dev.bus = ...
Andy, can you please make comment on patch 3, 4 and 5 of this series? I think they are ready to merge and the driver changes can be applied any time after the phylib changes. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. --
From: Grant Likely <grant.likely@secretlab.ca>
Add phy_connect_direct() and phy_attach_direct() functions so that
drivers can use a pointer to the phy_device instead of trying to determine
the phy's bus_id string.
This patch is useful for OF device tree descriptions of phy devices where
the driver doesn't need or know what the bus_id value in order to get a
phy_device pointer.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/net/phy/phy_device.c | 118 ++++++++++++++++++++++++++++++------------
include/linux/phy.h | 5 ++
2 files changed, 90 insertions(+), 33 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 9352ca8..3c8c1de 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -292,6 +292,33 @@ void phy_prepare_link(struct phy_device *phydev,
}
/**
+ * phy_connect_direct - connect an ethernet device to a specific phy_device
+ * @dev: the network device to connect
+ * @phydev: the pointer to the phy device
+ * @handler: callback function for state change notifications
+ * @flags: PHY device's dev_flags
+ * @interface: PHY device's interface
+ */
+int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
+ void (*handler)(struct net_device *), u32 flags,
+ phy_interface_t interface)
+{
+ int rc;
+
+ rc = phy_attach_direct(dev, phydev, flags, interface);
+ if (rc)
+ return rc;
+
+ phy_prepare_link(phydev, handler);
+ phy_start_machine(phydev, NULL);
+ if (phydev->irq > 0)
+ phy_start_interrupts(phydev);
+
+ return 0;
+}
+EXPORT_SYMBOL(phy_connect_direct);
+
+/**
* phy_connect - connect an ethernet device to a PHY device
* @dev: the network device to connect
* @bus_id: the id string of the PHY device to connect
@@ -312,18 +339,21 @@ struct phy_device * phy_connect(struct net_device *dev, const char *bus_id,
phy_interface_t interface)
{
struct phy_device *phydev;
+ struct device *d;
+ int rc;
...From: Grant Likely <grant.likely@secretlab.ca>
The patch reworks the MPC5200 Fast Ethernet Controller (FEC) driver to
use the of_mdio infrastructure for registering PHY devices from data out
openfirmware device tree, and eliminates the assumption that the PHY
for the FEC is always attached to the FEC's own MDIO bus. With this
patch, the FEC can use a PHY attached to any MDIO bus if it is described
in the device tree.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/net/fec_mpc52xx.c | 183 ++++++++++++-----------------------------
drivers/net/fec_mpc52xx_phy.c | 26 +-----
2 files changed, 60 insertions(+), 149 deletions(-)
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 3d55f9a..7ae2232 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -25,6 +25,7 @@
#include <linux/hardirq.h>
#include <linux/delay.h>
#include <linux/of_device.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <linux/netdevice.h>
@@ -43,11 +44,9 @@
#define DRIVER_NAME "mpc52xx-fec"
-#define FEC5200_PHYADDR_NONE (-1)
-#define FEC5200_PHYADDR_7WIRE (-2)
-
/* Private driver data structure */
struct mpc52xx_fec_priv {
+ struct net_device *ndev;
int duplex;
int speed;
int r_irq;
@@ -59,10 +58,11 @@ struct mpc52xx_fec_priv {
int msg_enable;
/* MDIO link details */
- int phy_addr;
- unsigned int phy_speed;
+ unsigned int mdio_speed;
+ struct device_node *phy_node;
struct phy_device *phydev;
enum phy_state link;
+ int seven_wire_mode;
};
@@ -210,66 +210,6 @@ static void mpc52xx_fec_adjust_link(struct net_device *dev)
phy_print_status(phydev);
}
-static int mpc52xx_fec_init_phy(struct net_device *dev)
-{
- struct mpc52xx_fec_priv *priv = netdev_priv(dev);
- struct phy_device *phydev;
- char phy_id[BUS_ID_SIZE];
-
- snprintf(phy_id, sizeof(phy_id), "%x:%02x",
- (unsigned int)dev->base_addr, priv->phy_addr);
-
- priv->link = ...From: Grant Likely <grant.likely@secretlab.ca> Add support for parsing the device tree for PHY devices on an MDIO bus CC: Andy Fleming <afleming@freescale.com> CC: linuxppc-dev@ozlabs.org CC: devtree-discuss@ozlabs.org Signed-off-by: Grant Likely <grant.likely@secretlab.ca> --- drivers/of/Kconfig | 6 ++ drivers/of/Makefile | 1 drivers/of/of_mdio.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_mdio.h | 22 +++++++ 4 files changed, 168 insertions(+), 0 deletions(-) create mode 100644 drivers/of/of_mdio.c create mode 100644 include/linux/of_mdio.h diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index f821dbc..6fe043b 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -19,3 +19,9 @@ config OF_SPI depends on OF && PPC_OF && SPI help OpenFirmware SPI accessors + +config OF_MDIO + def_tristate PHYLIB + depends on OF && PHYLIB + help + OpenFirmware MDIO bus (Ethernet PHY) accessors diff --git a/drivers/of/Makefile b/drivers/of/Makefile index 4c3c6f8..bdfb5f5 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_OF_DEVICE) += device.o platform.o obj-$(CONFIG_OF_GPIO) += gpio.o obj-$(CONFIG_OF_I2C) += of_i2c.o obj-$(CONFIG_OF_SPI) += of_spi.o +obj-$(CONFIG_OF_MDIO) += of_mdio.o diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c new file mode 100644 index 0000000..aee967d --- /dev/null +++ b/drivers/of/of_mdio.c @@ -0,0 +1,139 @@ +/* + * OF helpers for the MDIO (Ethernet PHY) API + * + * Copyright (c) 2009 Secret Lab Technologies, Ltd. + * + * This file is released under the GPLv2 + * + * This file provides helper functions for extracting PHY device information + * out of the OpenFirmware device tree and using it to populate an mii_bus. + */ + +#include <linux/phy.h> +#include <linux/of.h> +#include <linux/of_mdio.h> +#include <linux/module.h> + +MODULE_AUTHOR("Grant Likely ...
From: Grant Likely <grant.likely@secretlab.ca>
This patch simplifies the driver by making use of more common code.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/net/gianfar.c | 103 +++++++++++++++++----------------------------
drivers/net/gianfar.h | 3 +
drivers/net/gianfar_mii.c | 52 +----------------------
3 files changed, 43 insertions(+), 115 deletions(-)
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 9831b3f..f40ab7d 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -75,6 +75,7 @@
#include <linux/if_vlan.h>
#include <linux/spinlock.h>
#include <linux/mm.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <linux/ip.h>
#include <linux/tcp.h>
@@ -155,17 +156,13 @@ static inline int gfar_uses_fcb(struct gfar_private *priv)
static int gfar_of_init(struct net_device *dev)
{
- struct device_node *phy, *mdio;
- const unsigned int *id;
const char *model;
const char *ctype;
const void *mac_addr;
- const phandle *ph;
u64 addr, size;
int err = 0;
struct gfar_private *priv = netdev_priv(dev);
struct device_node *np = priv->node;
- char bus_name[MII_BUS_ID_SIZE];
if (!np || !of_device_is_available(np))
return -ENODEV;
@@ -228,8 +225,8 @@ static int gfar_of_init(struct net_device *dev)
if (of_get_property(np, "fsl,magic-packet", NULL))
priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
- ph = of_get_property(np, "phy-handle", NULL);
- if (ph == NULL) {
+ priv->phy_node = of_parse_phandle(np, "phy-device", 0);
+ if (!priv->phy_node) {
u32 *fixed_link;
fixed_link = (u32 *)of_get_property(np, "fixed-link", NULL);
@@ -237,57 +234,10 @@ static int gfar_of_init(struct net_device *dev)
err = -ENODEV;
goto err_out;
}
-
- snprintf(priv->phy_bus_id, sizeof(priv->phy_bus_id),
- PHY_ID_FMT, "0", fixed_link[0]);
- } else {
- phy = of_find_node_by_phandle(*ph);
-
- if (phy == NULL) {
- err = ...From: Grant Likely <grant.likely@secretlab.ca> This patch modifies the bitbanged MDIO driver in the ep8248e platform code to use the common of_mdio infrastructure. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> --- arch/powerpc/platforms/82xx/ep8248e.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c index 0eb6d7f..bd323b5 100644 --- a/arch/powerpc/platforms/82xx/ep8248e.c +++ b/arch/powerpc/platforms/82xx/ep8248e.c @@ -14,6 +14,7 @@ #include <linux/interrupt.h> #include <linux/fsl_devices.h> #include <linux/mdio-bitbang.h> +#include <linux/of_mdio.h> #include <linux/of_platform.h> #include <asm/io.h> @@ -130,17 +131,13 @@ static int __devinit ep8248e_mdio_probe(struct of_device *ofdev, if (!bus) return -ENOMEM; - bus->phy_mask = 0; bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); - for (i = 0; i < PHY_MAX_ADDR; i++) - bus->irq[i] = -1; - bus->name = "ep8248e-mdio-bitbang"; bus->parent = &ofdev->dev; snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); - return mdiobus_register(bus); + return of_mdiobus_register(bus, ofdev->node); } static int ep8248e_mdio_remove(struct of_device *ofdev) --
From: Grant Likely <grant.likely@secretlab.ca>
This patch simplifies the driver by making use of more common code.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/net/fs_enet/fs_enet-main.c | 69 ++++++------------------------------
drivers/net/fs_enet/mii-bitbang.c | 29 +--------------
drivers/net/fs_enet/mii-fec.c | 26 +-------------
include/linux/fs_enet_pd.h | 6 +--
4 files changed, 16 insertions(+), 114 deletions(-)
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index ce900e5..28dde90 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -36,6 +36,8 @@
#include <linux/fs.h>
#include <linux/platform_device.h>
#include <linux/phy.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
@@ -752,9 +754,10 @@ static int fs_init_phy(struct net_device *dev)
fep->oldlink = 0;
fep->oldspeed = 0;
fep->oldduplex = -1;
- if(fep->fpi->bus_id)
- phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0,
- PHY_INTERFACE_MODE_MII);
+ if(fep->fpi->phy_node)
+ phydev = of_phy_connect(dev, fep->fpi->phy_node,
+ &fs_adjust_link, 0,
+ PHY_INTERFACE_MODE_MII);
else {
printk("No phy bus ID specified in BSP code\n");
return -EINVAL;
@@ -962,57 +965,6 @@ static void cleanup_immap(void)
/**************************************************************************************/
-static int __devinit find_phy(struct device_node *np,
- struct fs_platform_info *fpi)
-{
- struct device_node *phynode, *mdionode;
- int ret = 0, len, bus_id;
- const u32 *data;
-
- data = of_get_property(np, "fixed-link", NULL);
- if (data) {
- snprintf(fpi->bus_id, 16, "%x:%02x", 0, *data);
- return 0;
- }
-
- data = of_get_property(np, "phy-handle", &len);
- if (!data || len != 4)
- return -EINVAL;
-
- phynode = ...From: Grant Likely <grant.likely@secretlab.ca>
CC: Yoshio Kashiwagi <kashiwagi@co-nss.co.jp>
CC: David H. Lynch Jr. <dhlii@dlasys.net>
CC: John Linn <john.linn@xilinx.com>
CC: John Bonesio <john.bonesio@xilinx.com>
CC: David DeBonis <ddeboni@xilinx.com>
CC: Wilson Yang <wyang@xilinx.com>
For information and testing only. Do not merge to mainline
---
arch/powerpc/boot/dts/virtex440-ml507.dts | 14 ++++++++++----
drivers/net/phy/marvell.c | 2 ++
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/boot/dts/virtex440-ml507.dts b/arch/powerpc/boot/dts/virtex440-ml507.dts
index 52d8c1a..65cc433 100644
--- a/arch/powerpc/boot/dts/virtex440-ml507.dts
+++ b/arch/powerpc/boot/dts/virtex440-ml507.dts
@@ -31,7 +31,7 @@
reg = < 0 0x10000000 >;
} ;
chosen {
- bootargs = "console=ttyS0 root=/dev/ram";
+ bootargs = "console=ttyS0,115200 root=/dev/ram";
linux,stdout-path = &RS232_Uart_1;
} ;
cpus {
@@ -257,12 +257,13 @@
#size-cells = <1>;
compatible = "xlnx,compound";
ethernet@81c00000 {
+ #address-cells = < 1 >;
+ #size-cells = < 0 >;
compatible = "xlnx,xps-ll-temac-1.01.b";
- device_type = "network";
interrupt-parent = <&xps_intc_0>;
interrupts = < 5 2 >;
llink-connected = <&DMA0>;
- local-mac-address = [ 02 00 00 00 00 00 ];
+ local-mac-address = [ 00 00 00 00 00 00 ];
reg = < 0x81c00000 0x40 >;
xlnx,bus2core-clk-ratio = <1>;
xlnx,phy-type = <1>;
@@ -272,6 +273,11 @@
xlnx,temac-type = <0>;
xlnx,txcsum = <1>;
xlnx,txfifo = <0x1000>;
+ phy-handle = < &phy7 >;
+ phy7: phy@7 {
+ compatible = "marvell,88e1111";
+ reg = <7>;
+ };
} ;
} ;
IIC_EEPROM: i2c@81600000 {
@@ -340,7 +346,7 @@
RS232_Uart_1: serial@83e00000 {
clock-frequency = <100000000>;
compatible = "xlnx,xps-uart16550-2.00.b", "ns16550";
- current-speed = <9600>;
+ current-speed = <115200>;
device_type = "serial";
...From: Grant Likely <grant.likely@secretlab.ca>
This patch simplifies the driver by making use of more common code.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/powerpc/platforms/pasemi/gpio_mdio.c | 29 ++++-------------------------
drivers/net/pasemi_mac.c | 19 +++----------------
drivers/net/pasemi_mac.h | 1 -
3 files changed, 7 insertions(+), 42 deletions(-)
diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c
index 75cc165..26e8f36 100644
--- a/arch/powerpc/platforms/pasemi/gpio_mdio.c
+++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c
@@ -29,7 +29,7 @@
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/phy.h>
-#include <linux/platform_device.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#define DELAY 1
@@ -39,6 +39,7 @@ static void __iomem *gpio_regs;
struct gpio_priv {
int mdc_pin;
int mdio_pin;
+ int mdio_irqs[PHY_MAX_ADDR];
};
#define MDC_PIN(bus) (((struct gpio_priv *)bus->priv)->mdc_pin)
@@ -244,27 +245,7 @@ static int __devinit gpio_mdio_probe(struct of_device *ofdev,
snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop);
new_bus->priv = priv;
- new_bus->phy_mask = 0;
-
- new_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
-
- if (!new_bus->irq)
- goto out_free_bus;
-
- for (i = 0; i < PHY_MAX_ADDR; i++)
- new_bus->irq[i] = NO_IRQ;
-
- for (phy_dn = of_get_next_child(np, NULL);
- phy_dn != NULL;
- phy_dn = of_get_next_child(np, phy_dn)) {
- const unsigned int *ip, *regp;
-
- ip = of_get_property(phy_dn, "interrupts", NULL);
- regp = of_get_property(phy_dn, "reg", NULL);
- if (!ip || !regp || *regp >= PHY_MAX_ADDR)
- continue;
- new_bus->irq[*regp] = irq_create_mapping(NULL, *ip);
- }
+ new_bus->irq = priv->mdio_irqs;
prop = of_get_property(np, "mdc-pin", NULL);
priv->mdc_pin = *prop;
@@ -275,7 +256,7 @@ static int __devinit ...Did you ever try building it? pasemi_defconfig gives me: drivers/net/pasemi_mac.c: In function 'pasemi_mac_phy_init': drivers/net/pasemi_mac.c:1102: error: implicit declaration of function 'of_phy_connect' drivers/net/pasemi_mac.c:1103: warning: assignment makes pointer from integer without a cast drivers/net/pasemi_mac.c:1114: warning: label 'err' defined but not used drivers/net/pasemi_mac.c:1092: warning: unused variable 'ret' drivers/net/pasemi_mac.c:1091: warning: unused variable 'r' drivers/net/pasemi_mac.c:1090: warning: unused variable 'prop' drivers/net/pasemi_mac.c:1089: warning: unused variable 'ph' make[2]: *** [drivers/net/pasemi_mac.o] Error 1 The changes needed are trivial, include <linux/of_mdio.h> and remove the variables, label and following code. I could send a patch but that's likely more of a hassle than you fixing it up yourself? Otherwise, with the above changes, seems to test out ok on my Electra. When you checkin the changes, feel free to add: Tested-by: Olof Johansson <olof@lixom.net> Acked-by: Olof Johansson <olof@lixom.net> to it. -Olof --
No. I mentioned it in the series header email, but not in the patch description. My 64bit build environment is broken at the moment so I couldn't build test the pasemi patch. All the others are build Awesome. Thanks for the testing. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. --
NP! Thanks for doing this cleanup! -Olof --
From: Grant Likely <grant.likely@secretlab.ca>
This patch simplifies the driver by making use of more common code.
It also removes what appears to be a large block of duplicated code.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/net/ucc_geth.c | 65 +++++---------------------------------------
drivers/net/ucc_geth.h | 2 -
drivers/net/ucc_geth_mii.c | 17 ++----------
3 files changed, 11 insertions(+), 73 deletions(-)
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index e879868..fa8336b 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -28,6 +28,7 @@
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/workqueue.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <asm/uaccess.h>
@@ -1537,35 +1538,19 @@ static int init_phy(struct net_device *dev)
{
struct ucc_geth_private *priv = netdev_priv(dev);
struct device_node *np = priv->node;
- struct device_node *phy, *mdio;
- const phandle *ph;
- char bus_name[MII_BUS_ID_SIZE];
- const unsigned int *id;
+ struct device_node *phy;
struct phy_device *phydev;
- char phy_id[BUS_ID_SIZE];
priv->oldlink = 0;
priv->oldspeed = 0;
priv->oldduplex = -1;
- ph = of_get_property(np, "phy-handle", NULL);
- phy = of_find_node_by_phandle(*ph);
- mdio = of_get_parent(phy);
-
- id = of_get_property(phy, "reg", NULL);
-
+ phy = of_parse_phandle(np, "phy-handle", 0);
+ phydev = of_phy_connect(dev, phy, &adjust_link, 0, priv->phy_interface);
of_node_put(phy);
- of_node_put(mdio);
-
- uec_mdio_bus_name(bus_name, mdio);
- snprintf(phy_id, sizeof(phy_id), "%s:%02x",
- bus_name, *id);
-
- phydev = phy_connect(dev, phy_id, &adjust_link, 0, priv->phy_interface);
-
- if (IS_ERR(phydev)) {
+ if (!phydev) {
printk("%s: Could not attach to PHY\n", dev->name);
- return PTR_ERR(phydev);
+ return -ENODEV;
}
phydev->supported &= (ADVERTISED_10baseT_Half |
@@ -3522,15 ...From: Grant Likely <grant.likely@secretlab.ca> This patch adds support for the Xilinx ll_temac 10/100/1000 Ethernet device. The ll_temac ipcore is typically used on Xilinx Virtex and Spartan designs attached to either a PowerPC 4xx or Microblaze processor. At the present moment, this driver only works with Virtex5 PowerPC designs because it assumes DCR is used to access the DMA registers. However, the low level access to DMA registers is abstracted and it should be easy to adapt for the other implementations. I'm posting this driver now as an RFC. There are still some things that need to be tightened up, but it does appear to be stable. Derived from driver code written by Yoshio Kashiwagi and David H. Lynch Jr. CC: Yoshio Kashiwagi <kashiwagi@co-nss.co.jp> CC: David H. Lynch Jr. <dhlii@dlasys.net> CC: John Linn <john.linn@xilinx.com> CC: John Bonesio <john.bonesio@xilinx.com> CC: David DeBonis <ddeboni@xilinx.com> CC: Wilson Yang <wyang@xilinx.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca> --- drivers/net/Kconfig | 8 drivers/net/Makefile | 2 drivers/net/xilinx_temac.c | 970 +++++++++++++++++++++++++++++++++++++++ drivers/net/xilinx_temac.h | 374 +++++++++++++++ drivers/net/xilinx_temac_mdio.c | 119 +++++ 5 files changed, 1473 insertions(+), 0 deletions(-) create mode 100644 drivers/net/xilinx_temac.c create mode 100644 drivers/net/xilinx_temac.h create mode 100644 drivers/net/xilinx_temac_mdio.c diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 435e2e3..29d6c1f 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2321,6 +2321,14 @@ config MV643XX_ETH Some boards that use the Discovery chipset are the Momenco Ocelot C and Jaguar ATX and Pegasos II. +config XILINX_TEMAC + tristate "Xilinx TEMAC 10/100/1000 Ethernet MAC driver" + select PHYLIB + depends on PPC + help + This driver supports the Xilinx 10/100/1000 LocalLink TEMAC + device found in Virtex ...
