Message ID | 1415190653-8987-3-git-send-email-fgretief@spaceteq.co.za |
---|---|
State | Changes Requested |
Delegated to: | Joe Hershberger |
Headers | show |
Hi Francios, On Wed, Nov 5, 2014 at 6:30 AM, Francois Retief <fgretief@spaceteq.co.za> wrote: > Added MDIO support to the Aeroflex Gaisler GRETH driver. The result is > that we can now use the CONFIG_CMD_MII commands to access the PHY chip. > > Signed-off-by: Francois Retief <fgretief@spaceteq.co.za> > --- I noticed this still sitting in patchwork. I attempted to apply it, but it fails checkpatch.pl. WARNING: please, no spaces at the start of a line #41: FILE: drivers/net/greth.c:57: + struct mii_dev *bus;$ WARNING: line over 80 characters #51: FILE: drivers/net/greth.c:132: +static int greth_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr, int regnum) WARNING: please, no spaces at the start of a line #53: FILE: drivers/net/greth.c:134: + greth_regs *regs = (greth_regs *)bus->priv;$ WARNING: line over 80 characters #55: FILE: drivers/net/greth.c:136: + debug("GRETH: mdio_read (port_addr=%d, dev_addr=%d, reg=%d)\n", port_addr, dev_addr, regnum); WARNING: please, no spaces at the start of a line #55: FILE: drivers/net/greth.c:136: + debug("GRETH: mdio_read (port_addr=%d, dev_addr=%d, reg=%d)\n", port_addr, dev_addr, regnum);$ WARNING: please, no spaces at the start of a line #57: FILE: drivers/net/greth.c:138: + return read_mii(port_addr, regnum, regs);$ WARNING: line over 80 characters #60: FILE: drivers/net/greth.c:141: +static int greth_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr, int regnum, u16 value) WARNING: please, no spaces at the start of a line #62: FILE: drivers/net/greth.c:143: + greth_regs *regs = (greth_regs *)bus->priv;$ WARNING: line over 80 characters #64: FILE: drivers/net/greth.c:145: + debug("GRETH: mdio_write (port_addr=%d, dev_addr=%d, reg=%d, value=%d)\n", port_addr, dev_addr, regnum, value); WARNING: please, no spaces at the start of a line #64: FILE: drivers/net/greth.c:145: + debug("GRETH: mdio_write (port_addr=%d, dev_addr=%d, reg=%d, value=%d)\n", port_addr, dev_addr, regnum, value);$ WARNING: please, no spaces at the start of a line #66: FILE: drivers/net/greth.c:147: + write_mii(port_addr, regnum, value, regs);$ WARNING: please, no spaces at the start of a line #67: FILE: drivers/net/greth.c:148: + return 0;$ WARNING: please, no spaces at the start of a line #72: FILE: drivers/net/greth.c:153: + puts("GRETH: Reset PHY via MDIO reset\n");$ WARNING: please, no spaces at the start of a line #73: FILE: drivers/net/greth.c:154: + return 0;$ WARNING: please, no spaces at the start of a line #78: FILE: drivers/net/greth.c:159: + struct mii_dev *bus = mdio_alloc();$ WARNING: please, no spaces at the start of a line #80: FILE: drivers/net/greth.c:161: + if (!bus) {$ WARNING: suspect code indent for conditional statements (7, 15) #80: FILE: drivers/net/greth.c:161: + if (!bus) { + printf("GRETH: Failed to allocate MDIO bus\n"); ERROR: code indent should use tabs where possible #81: FILE: drivers/net/greth.c:162: + printf("GRETH: Failed to allocate MDIO bus\n");$ WARNING: please, no spaces at the start of a line #81: FILE: drivers/net/greth.c:162: + printf("GRETH: Failed to allocate MDIO bus\n");$ ERROR: code indent should use tabs where possible #82: FILE: drivers/net/greth.c:163: + return -ENOMEM;$ WARNING: please, no spaces at the start of a line #82: FILE: drivers/net/greth.c:163: + return -ENOMEM;$ WARNING: please, no spaces at the start of a line #83: FILE: drivers/net/greth.c:164: + }$ WARNING: please, no spaces at the start of a line #85: FILE: drivers/net/greth.c:166: + bus->read = greth_mdio_read;$ WARNING: please, no spaces at the start of a line #86: FILE: drivers/net/greth.c:167: + bus->write = greth_mdio_write;$ WARNING: please, no spaces at the start of a line #87: FILE: drivers/net/greth.c:168: + bus->reset = greth_mdio_reset;$ WARNING: please, no spaces at the start of a line #88: FILE: drivers/net/greth.c:169: + sprintf(bus->name, "GRETH%d", 0);$ WARNING: please, no spaces at the start of a line #90: FILE: drivers/net/greth.c:171: + bus->priv = (void *)greth->regs;$ WARNING: please, no spaces at the start of a line #91: FILE: drivers/net/greth.c:172: + greth->bus = bus;$ WARNING: please, no spaces at the start of a line #93: FILE: drivers/net/greth.c:174: + return mdio_register(bus);$ WARNING: line over 80 characters #97: FILE: drivers/net/greth.c:178: +static inline int greth_mdio_register(greth_priv *greth, bd_t *bis) { return 0; } WARNING: please, no spaces at the start of a line #108: FILE: drivers/net/greth.c:691: + greth_mdio_register(greth, bis);$ total: 2 errors, 29 warnings, 0 checks, 81 lines checked NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or scripts/cleanfile Please clean up and repost. Thanks, -Joe
diff --git a/drivers/net/greth.c b/drivers/net/greth.c index 7784684..5f5abd6 100644 --- a/drivers/net/greth.c +++ b/drivers/net/greth.c @@ -18,6 +18,8 @@ #include <asm/processor.h> #include <ambapp.h> #include <asm/leon.h> +#include <miiphy.h> +#include <errno.h> #include "greth.h" @@ -52,6 +54,7 @@ typedef struct { greth_regs *regs; int irq; struct eth_device *dev; + struct mii_dev *bus; /* Hardware info */ unsigned char phyaddr; @@ -124,6 +127,57 @@ static void write_mii(int phyaddr, int regaddr, int data, volatile greth_regs * } +#ifdef CONFIG_MII + +static int greth_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr, int regnum) +{ + greth_regs *regs = (greth_regs *)bus->priv; + + debug("GRETH: mdio_read (port_addr=%d, dev_addr=%d, reg=%d)\n", port_addr, dev_addr, regnum); + + return read_mii(port_addr, regnum, regs); +} + +static int greth_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr, int regnum, u16 value) +{ + greth_regs *regs = (greth_regs *)bus->priv; + + debug("GRETH: mdio_write (port_addr=%d, dev_addr=%d, reg=%d, value=%d)\n", port_addr, dev_addr, regnum, value); + + write_mii(port_addr, regnum, value, regs); + return 0; +} + +static int greth_mdio_reset(struct mii_dev *bus) +{ + puts("GRETH: Reset PHY via MDIO reset\n"); + return 0; +} + +int greth_mdio_register(greth_priv *greth, bd_t *bis) +{ + struct mii_dev *bus = mdio_alloc(); + + if (!bus) { + printf("GRETH: Failed to allocate MDIO bus\n"); + return -ENOMEM; + } + + bus->read = greth_mdio_read; + bus->write = greth_mdio_write; + bus->reset = greth_mdio_reset; + sprintf(bus->name, "GRETH%d", 0); + + bus->priv = (void *)greth->regs; + greth->bus = bus; + + return mdio_register(bus); +} + +#else +static inline int greth_mdio_register(greth_priv *greth, bd_t *bis) { return 0; } +#endif /* CONFIG_CMD_MII */ + /* init/start hardware and allocate descriptor buffers for rx side * */ @@ -633,6 +687,9 @@ int greth_initialize(bd_t * bis) sprintf(dev->name, "GRETH_10/100"); } + /* Register our device with the MDIO subsystem */ + greth_mdio_register(greth, bis); + /* initiate PHY, select speed/duplex depending on connected PHY */ if (greth_init_phy(greth, bis)) { /* Failed to init PHY (timedout) */
Added MDIO support to the Aeroflex Gaisler GRETH driver. The result is that we can now use the CONFIG_CMD_MII commands to access the PHY chip. Signed-off-by: Francois Retief <fgretief@spaceteq.co.za> --- drivers/net/greth.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) -- 1.9.3