Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
/*
|
|
|
|
* drivers/net/ibm_newemac/rgmii.c
|
|
|
|
*
|
|
|
|
* Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support.
|
|
|
|
*
|
2007-12-05 00:14:33 +00:00
|
|
|
* Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
|
|
|
|
* <benh@kernel.crashing.org>
|
|
|
|
*
|
|
|
|
* Based on the arch/ppc version of the driver:
|
|
|
|
*
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
* Copyright (c) 2004, 2005 Zultys Technologies.
|
|
|
|
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
|
|
|
|
*
|
|
|
|
* Based on original work by
|
|
|
|
* Matt Porter <mporter@kernel.crashing.org>
|
|
|
|
* Copyright 2004 MontaVista Software, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include "emac.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
// XXX FIXME: Axon seems to support a subset of the RGMII, we
|
|
|
|
// thus need to take that into account and possibly change some
|
|
|
|
// of the bit settings below that don't seem to quite match the
|
|
|
|
// AXON spec
|
|
|
|
|
|
|
|
/* RGMIIx_FER */
|
|
|
|
#define RGMII_FER_MASK(idx) (0x7 << ((idx) * 4))
|
|
|
|
#define RGMII_FER_RTBI(idx) (0x4 << ((idx) * 4))
|
|
|
|
#define RGMII_FER_RGMII(idx) (0x5 << ((idx) * 4))
|
|
|
|
#define RGMII_FER_TBI(idx) (0x6 << ((idx) * 4))
|
|
|
|
#define RGMII_FER_GMII(idx) (0x7 << ((idx) * 4))
|
2008-07-08 15:03:06 +00:00
|
|
|
#define RGMII_FER_MII(idx) RGMII_FER_GMII(idx)
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
|
|
|
|
/* RGMIIx_SSR */
|
|
|
|
#define RGMII_SSR_MASK(idx) (0x7 << ((idx) * 8))
|
|
|
|
#define RGMII_SSR_100(idx) (0x2 << ((idx) * 8))
|
|
|
|
#define RGMII_SSR_1000(idx) (0x4 << ((idx) * 8))
|
|
|
|
|
|
|
|
/* RGMII bridge supports only GMII/TBI and RGMII/RTBI PHYs */
|
|
|
|
static inline int rgmii_valid_mode(int phy_mode)
|
|
|
|
{
|
|
|
|
return phy_mode == PHY_MODE_GMII ||
|
2008-07-08 15:03:06 +00:00
|
|
|
phy_mode == PHY_MODE_MII ||
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
phy_mode == PHY_MODE_RGMII ||
|
|
|
|
phy_mode == PHY_MODE_TBI ||
|
|
|
|
phy_mode == PHY_MODE_RTBI;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const char *rgmii_mode_name(int mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case PHY_MODE_RGMII:
|
|
|
|
return "RGMII";
|
|
|
|
case PHY_MODE_TBI:
|
|
|
|
return "TBI";
|
|
|
|
case PHY_MODE_GMII:
|
|
|
|
return "GMII";
|
2008-07-08 15:03:06 +00:00
|
|
|
case PHY_MODE_MII:
|
|
|
|
return "MII";
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
case PHY_MODE_RTBI:
|
|
|
|
return "RTBI";
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 rgmii_mode_mask(int mode, int input)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case PHY_MODE_RGMII:
|
|
|
|
return RGMII_FER_RGMII(input);
|
|
|
|
case PHY_MODE_TBI:
|
|
|
|
return RGMII_FER_TBI(input);
|
|
|
|
case PHY_MODE_GMII:
|
|
|
|
return RGMII_FER_GMII(input);
|
2008-07-08 15:03:06 +00:00
|
|
|
case PHY_MODE_MII:
|
|
|
|
return RGMII_FER_MII(input);
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
case PHY_MODE_RTBI:
|
|
|
|
return RGMII_FER_RTBI(input);
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int __devinit rgmii_attach(struct of_device *ofdev, int input, int mode)
|
|
|
|
{
|
|
|
|
struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
|
2007-10-14 18:36:10 +00:00
|
|
|
struct rgmii_regs __iomem *p = dev->base;
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
|
|
|
|
RGMII_DBG(dev, "attach(%d)" NL, input);
|
|
|
|
|
|
|
|
/* Check if we need to attach to a RGMII */
|
|
|
|
if (input < 0 || !rgmii_valid_mode(mode)) {
|
|
|
|
printk(KERN_ERR "%s: unsupported settings !\n",
|
|
|
|
ofdev->node->full_name);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
|
|
/* Enable this input */
|
|
|
|
out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input));
|
|
|
|
|
|
|
|
printk(KERN_NOTICE "%s: input %d in %s mode\n",
|
|
|
|
ofdev->node->full_name, input, rgmii_mode_name(mode));
|
|
|
|
|
|
|
|
++dev->users;
|
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rgmii_set_speed(struct of_device *ofdev, int input, int speed)
|
|
|
|
{
|
|
|
|
struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
|
2007-10-14 18:36:10 +00:00
|
|
|
struct rgmii_regs __iomem *p = dev->base;
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
u32 ssr;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
|
|
ssr = in_be32(&p->ssr) & ~RGMII_SSR_MASK(input);
|
|
|
|
|
|
|
|
RGMII_DBG(dev, "speed(%d, %d)" NL, input, speed);
|
|
|
|
|
|
|
|
if (speed == SPEED_1000)
|
|
|
|
ssr |= RGMII_SSR_1000(input);
|
|
|
|
else if (speed == SPEED_100)
|
|
|
|
ssr |= RGMII_SSR_100(input);
|
|
|
|
|
|
|
|
out_be32(&p->ssr, ssr);
|
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rgmii_get_mdio(struct of_device *ofdev, int input)
|
|
|
|
{
|
|
|
|
struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
|
2007-10-14 18:36:10 +00:00
|
|
|
struct rgmii_regs __iomem *p = dev->base;
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
u32 fer;
|
|
|
|
|
|
|
|
RGMII_DBG2(dev, "get_mdio(%d)" NL, input);
|
|
|
|
|
2007-12-05 00:14:28 +00:00
|
|
|
if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO))
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
|
|
fer = in_be32(&p->fer);
|
|
|
|
fer |= 0x00080000u >> input;
|
|
|
|
out_be32(&p->fer, fer);
|
|
|
|
(void)in_be32(&p->fer);
|
|
|
|
|
|
|
|
DBG2(dev, " fer = 0x%08x\n", fer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rgmii_put_mdio(struct of_device *ofdev, int input)
|
|
|
|
{
|
|
|
|
struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
|
2007-10-14 18:36:10 +00:00
|
|
|
struct rgmii_regs __iomem *p = dev->base;
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
u32 fer;
|
|
|
|
|
|
|
|
RGMII_DBG2(dev, "put_mdio(%d)" NL, input);
|
|
|
|
|
2007-12-05 00:14:28 +00:00
|
|
|
if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO))
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
fer = in_be32(&p->fer);
|
|
|
|
fer &= ~(0x00080000u >> input);
|
|
|
|
out_be32(&p->fer, fer);
|
|
|
|
(void)in_be32(&p->fer);
|
|
|
|
|
|
|
|
DBG2(dev, " fer = 0x%08x\n", fer);
|
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
}
|
|
|
|
|
2008-04-22 00:46:43 +00:00
|
|
|
void rgmii_detach(struct of_device *ofdev, int input)
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
{
|
|
|
|
struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
|
2009-07-19 06:13:04 +00:00
|
|
|
struct rgmii_regs __iomem *p;
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
|
|
|
|
BUG_ON(!dev || dev->users == 0);
|
2009-07-19 06:13:04 +00:00
|
|
|
p = dev->base;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
|
|
|
|
RGMII_DBG(dev, "detach(%d)" NL, input);
|
|
|
|
|
|
|
|
/* Disable this input */
|
|
|
|
out_be32(&p->fer, in_be32(&p->fer) & ~RGMII_FER_MASK(input));
|
|
|
|
|
|
|
|
--dev->users;
|
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rgmii_get_regs_len(struct of_device *ofdev)
|
|
|
|
{
|
|
|
|
return sizeof(struct emac_ethtool_regs_subhdr) +
|
|
|
|
sizeof(struct rgmii_regs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *rgmii_dump_regs(struct of_device *ofdev, void *buf)
|
|
|
|
{
|
|
|
|
struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
|
|
|
|
struct emac_ethtool_regs_subhdr *hdr = buf;
|
|
|
|
struct rgmii_regs *regs = (struct rgmii_regs *)(hdr + 1);
|
|
|
|
|
|
|
|
hdr->version = 0;
|
|
|
|
hdr->index = 0; /* for now, are there chips with more than one
|
|
|
|
* rgmii ? if yes, then we'll add a cell_index
|
|
|
|
* like we do for emac
|
|
|
|
*/
|
|
|
|
memcpy_fromio(regs, dev->base, sizeof(struct rgmii_regs));
|
|
|
|
return regs + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __devinit rgmii_probe(struct of_device *ofdev,
|
|
|
|
const struct of_device_id *match)
|
|
|
|
{
|
|
|
|
struct device_node *np = ofdev->node;
|
|
|
|
struct rgmii_instance *dev;
|
|
|
|
struct resource regs;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = -ENOMEM;
|
|
|
|
dev = kzalloc(sizeof(struct rgmii_instance), GFP_KERNEL);
|
|
|
|
if (dev == NULL) {
|
|
|
|
printk(KERN_ERR "%s: could not allocate RGMII device!\n",
|
|
|
|
np->full_name);
|
|
|
|
goto err_gone;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_init(&dev->lock);
|
|
|
|
dev->ofdev = ofdev;
|
|
|
|
|
|
|
|
rc = -ENXIO;
|
|
|
|
if (of_address_to_resource(np, 0, ®s)) {
|
|
|
|
printk(KERN_ERR "%s: Can't get registers address\n",
|
|
|
|
np->full_name);
|
|
|
|
goto err_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = -ENOMEM;
|
2007-10-14 18:36:10 +00:00
|
|
|
dev->base = (struct rgmii_regs __iomem *)ioremap(regs.start,
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
sizeof(struct rgmii_regs));
|
|
|
|
if (dev->base == NULL) {
|
|
|
|
printk(KERN_ERR "%s: Can't map device registers!\n",
|
|
|
|
np->full_name);
|
|
|
|
goto err_free;
|
|
|
|
}
|
|
|
|
|
2007-12-05 00:14:28 +00:00
|
|
|
/* Check for RGMII flags */
|
|
|
|
if (of_get_property(ofdev->node, "has-mdio", NULL))
|
|
|
|
dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO;
|
|
|
|
|
|
|
|
/* CAB lacks the right properties, fix this up */
|
2007-10-14 04:50:12 +00:00
|
|
|
if (of_device_is_compatible(ofdev->node, "ibm,rgmii-axon"))
|
2007-12-05 00:14:28 +00:00
|
|
|
dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO;
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
|
|
|
|
DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n",
|
|
|
|
in_be32(&dev->base->fer), in_be32(&dev->base->ssr));
|
|
|
|
|
|
|
|
/* Disable all inputs by default */
|
|
|
|
out_be32(&dev->base->fer, 0);
|
|
|
|
|
|
|
|
printk(KERN_INFO
|
2007-12-05 00:14:28 +00:00
|
|
|
"RGMII %s initialized with%s MDIO support\n",
|
|
|
|
ofdev->node->full_name,
|
|
|
|
(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out");
|
Device tree aware EMAC driver
Based on BenH's earlier work, this is a new version of the EMAC driver
for the built-in ethernet found on PowerPC 4xx embedded CPUs. The
same ASIC is also found in the Axon bridge chip. This new version is
designed to work in the arch/powerpc tree, using the device tree to
probe the device, rather than the old and ugly arch/ppc OCP layer.
This driver is designed to sit alongside the old driver (that lies in
drivers/net/ibm_emac and this one in drivers/net/ibm_newemac). The
old driver is left in place to support arch/ppc until arch/ppc itself
reaches its final demise (not too long now, with luck).
This driver still has a number of things that could do with cleaning
up, but I think they can be fixed up after merging. Specifically:
- Should be adjusted to properly use the dma mapping API.
Axon needs this.
- Probe logic needs reworking, in conjuction with the general
probing code for of_platform devices. The dependencies here between
EMAC, MAL, ZMII etc. make this complicated. At present, it usually
works, because we initialize and register the sub-drivers before the
EMAC driver itself, and (being in driver code) runs after the devices
themselves have been instantiated from the device tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-08-23 03:56:01 +00:00
|
|
|
|
|
|
|
wmb();
|
|
|
|
dev_set_drvdata(&ofdev->dev, dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_free:
|
|
|
|
kfree(dev);
|
|
|
|
err_gone:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devexit rgmii_remove(struct of_device *ofdev)
|
|
|
|
{
|
|
|
|
struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
|
|
|
|
|
|
|
|
dev_set_drvdata(&ofdev->dev, NULL);
|
|
|
|
|
|
|
|
WARN_ON(dev->users != 0);
|
|
|
|
|
|
|
|
iounmap(dev->base);
|
|
|
|
kfree(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct of_device_id rgmii_match[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.compatible = "ibm,rgmii",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = "emac-rgmii",
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct of_platform_driver rgmii_driver = {
|
|
|
|
.name = "emac-rgmii",
|
|
|
|
.match_table = rgmii_match,
|
|
|
|
|
|
|
|
.probe = rgmii_probe,
|
|
|
|
.remove = rgmii_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
int __init rgmii_init(void)
|
|
|
|
{
|
|
|
|
return of_register_platform_driver(&rgmii_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rgmii_exit(void)
|
|
|
|
{
|
|
|
|
of_unregister_platform_driver(&rgmii_driver);
|
|
|
|
}
|