Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 1d3bb99

Browse files
dgibsonDavid S. Miller
authored and
David S. Miller
committed
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>
1 parent 03233b9 commit 1d3bb99

File tree

23 files changed

+6668
-71
lines changed

23 files changed

+6668
-71
lines changed

Documentation/powerpc/booting-without-of.txt

+156
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,162 @@ platforms are moved over to use the flattened-device-tree model.
18241824
fsl,has-rstcr;
18251825
};
18261826

1827+
1828+
h) 4xx/Axon EMAC ethernet nodes
1829+
1830+
The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
1831+
the Axon bridge. To operate this needs to interact with a ths
1832+
special McMAL DMA controller, and sometimes an RGMII or ZMII
1833+
interface. In addition to the nodes and properties described
1834+
below, the node for the OPB bus on which the EMAC sits must have a
1835+
correct clock-frequency property.
1836+
1837+
i) The EMAC node itself
1838+
1839+
Required properties:
1840+
- device_type : "network"
1841+
1842+
- compatible : compatible list, contains 2 entries, first is
1843+
"ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
1844+
405gp, Axon) and second is either "ibm,emac" or
1845+
"ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
1846+
"ibm,emac4"
1847+
- interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
1848+
- interrupt-parent : optional, if needed for interrupt mapping
1849+
- reg : <registers mapping>
1850+
- local-mac-address : 6 bytes, MAC address
1851+
- mal-device : phandle of the associated McMAL node
1852+
- mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
1853+
with this EMAC
1854+
- mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
1855+
with this EMAC
1856+
- cell-index : 1 cell, hardware index of the EMAC cell on a given
1857+
ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
1858+
each Axon chip)
1859+
- max-frame-size : 1 cell, maximum frame size supported in bytes
1860+
- rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
1861+
operations.
1862+
For Axon, 2048
1863+
- tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
1864+
operations.
1865+
For Axon, 2048.
1866+
- fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
1867+
thresholds).
1868+
For Axon, 0x00000010
1869+
- mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
1870+
in bytes.
1871+
For Axon, 0x00000100 (I think ...)
1872+
- phy-mode : string, mode of operations of the PHY interface.
1873+
Supported values are: "mii", "rmii", "smii", "rgmii",
1874+
"tbi", "gmii", rtbi", "sgmii".
1875+
For Axon on CAB, it is "rgmii"
1876+
- mdio-device : 1 cell, required iff using shared MDIO registers
1877+
(440EP). phandle of the EMAC to use to drive the
1878+
MDIO lines for the PHY used by this EMAC.
1879+
- zmii-device : 1 cell, required iff connected to a ZMII. phandle of
1880+
the ZMII device node
1881+
- zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
1882+
channel or 0xffffffff if ZMII is only used for MDIO.
1883+
- rgmii-device : 1 cell, required iff connected to an RGMII. phandle
1884+
of the RGMII device node.
1885+
For Axon: phandle of plb5/plb4/opb/rgmii
1886+
- rgmii-channel : 1 cell, required iff connected to an RGMII. Which
1887+
RGMII channel is used by this EMAC.
1888+
Fox Axon: present, whatever value is appropriate for each
1889+
EMAC, that is the content of the current (bogus) "phy-port"
1890+
property.
1891+
1892+
Recommended properties:
1893+
- linux,network-index : This is the intended "index" of this
1894+
network device. This is used by the bootwrapper to interpret
1895+
MAC addresses passed by the firmware when no information other
1896+
than indices is available to associate an address with a device.
1897+
1898+
Optional properties:
1899+
- phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
1900+
a search is performed.
1901+
- phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
1902+
for, used if phy-address is absent. bit 0x00000001 is
1903+
MDIO address 0.
1904+
For Axon it can be absent, thouugh my current driver
1905+
doesn't handle phy-address yet so for now, keep
1906+
0x00ffffff in it.
1907+
- rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
1908+
operations (if absent the value is the same as
1909+
rx-fifo-size). For Axon, either absent or 2048.
1910+
- tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
1911+
operations (if absent the value is the same as
1912+
tx-fifo-size). For Axon, either absent or 2048.
1913+
- tah-device : 1 cell, optional. If connected to a TAH engine for
1914+
offload, phandle of the TAH device node.
1915+
- tah-channel : 1 cell, optional. If appropriate, channel used on the
1916+
TAH engine.
1917+
1918+
Example:
1919+
1920+
EMAC0: ethernet@40000800 {
1921+
linux,network-index = <0>;
1922+
device_type = "network";
1923+
compatible = "ibm,emac-440gp", "ibm,emac";
1924+
interrupt-parent = <&UIC1>;
1925+
interrupts = <1c 4 1d 4>;
1926+
reg = <40000800 70>;
1927+
local-mac-address = [00 04 AC E3 1B 1E];
1928+
mal-device = <&MAL0>;
1929+
mal-tx-channel = <0 1>;
1930+
mal-rx-channel = <0>;
1931+
cell-index = <0>;
1932+
max-frame-size = <5dc>;
1933+
rx-fifo-size = <1000>;
1934+
tx-fifo-size = <800>;
1935+
phy-mode = "rmii";
1936+
phy-map = <00000001>;
1937+
zmii-device = <&ZMII0>;
1938+
zmii-channel = <0>;
1939+
};
1940+
1941+
ii) McMAL node
1942+
1943+
Required properties:
1944+
- device_type : "dma-controller"
1945+
- compatible : compatible list, containing 2 entries, first is
1946+
"ibm,mcmal-CHIP" where CHIP is the host ASIC (like
1947+
emac) and the second is either "ibm,mcmal" or
1948+
"ibm,mcmal2".
1949+
For Axon, "ibm,mcmal-axon","ibm,mcmal2"
1950+
- interrupts : <interrupt mapping for the MAL interrupts sources:
1951+
5 sources: tx_eob, rx_eob, serr, txde, rxde>.
1952+
For Axon: This is _different_ from the current
1953+
firmware. We use the "delayed" interrupts for txeob
1954+
and rxeob. Thus we end up with mapping those 5 MPIC
1955+
interrupts, all level positive sensitive: 10, 11, 32,
1956+
33, 34 (in decimal)
1957+
- dcr-reg : < DCR registers range >
1958+
- dcr-parent : if needed for dcr-reg
1959+
- num-tx-chans : 1 cell, number of Tx channels
1960+
- num-rx-chans : 1 cell, number of Rx channels
1961+
1962+
iii) ZMII node
1963+
1964+
Required properties:
1965+
- compatible : compatible list, containing 2 entries, first is
1966+
"ibm,zmii-CHIP" where CHIP is the host ASIC (like
1967+
EMAC) and the second is "ibm,zmii".
1968+
For Axon, there is no ZMII node.
1969+
- reg : <registers mapping>
1970+
1971+
iv) RGMII node
1972+
1973+
Required properties:
1974+
- compatible : compatible list, containing 2 entries, first is
1975+
"ibm,rgmii-CHIP" where CHIP is the host ASIC (like
1976+
EMAC) and the second is "ibm,rgmii".
1977+
For Axon, "ibm,rgmii-axon","ibm,rgmii"
1978+
- reg : <registers mapping>
1979+
- revision : as provided by the RGMII new version register if
1980+
available.
1981+
For Axon: 0x0000012a
1982+
18271983
More devices will be defined as this spec matures.
18281984

18291985
VII - Specifying interrupt information for devices

arch/powerpc/platforms/44x/Kconfig

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ config 440EP
3838

3939
config 440GP
4040
bool
41-
# Disabled until the new EMAC Driver is merged.
42-
# select IBM_NEW_EMAC_ZMII
41+
select IBM_NEW_EMAC_ZMII
4342

4443
config 440GX
4544
bool

arch/powerpc/platforms/cell/Kconfig

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ config PPC_CELL_NATIVE
1010
select PPC_INDIRECT_IO
1111
select PPC_NATIVE
1212
select MPIC
13+
select IBM_NEW_EMAC_EMAC4
14+
select IBM_NEW_EMAC_RGMII
15+
select IBM_NEW_EMAC_ZMII #test only
16+
select IBM_NEW_EMAC_TAH #test only
1317
default n
1418

1519
config PPC_IBM_CELL_BLADE

drivers/net/Kconfig

+2-69
Original file line numberDiff line numberDiff line change
@@ -1247,75 +1247,8 @@ config IBMVETH
12471247
<file:Documentation/networking/net-modules.txt>. The module will
12481248
be called ibmveth.
12491249

1250-
config IBM_EMAC
1251-
tristate "PowerPC 4xx on-chip Ethernet support"
1252-
depends on 4xx && !PPC_MERGE
1253-
help
1254-
This driver supports the PowerPC 4xx EMAC family of on-chip
1255-
Ethernet controllers.
1256-
1257-
config IBM_EMAC_RXB
1258-
int "Number of receive buffers"
1259-
depends on IBM_EMAC
1260-
default "128"
1261-
1262-
config IBM_EMAC_TXB
1263-
int "Number of transmit buffers"
1264-
depends on IBM_EMAC
1265-
default "64"
1266-
1267-
config IBM_EMAC_POLL_WEIGHT
1268-
int "MAL NAPI polling weight"
1269-
depends on IBM_EMAC
1270-
default "32"
1271-
1272-
config IBM_EMAC_RX_COPY_THRESHOLD
1273-
int "RX skb copy threshold (bytes)"
1274-
depends on IBM_EMAC
1275-
default "256"
1276-
1277-
config IBM_EMAC_RX_SKB_HEADROOM
1278-
int "Additional RX skb headroom (bytes)"
1279-
depends on IBM_EMAC
1280-
default "0"
1281-
help
1282-
Additional receive skb headroom. Note, that driver
1283-
will always reserve at least 2 bytes to make IP header
1284-
aligned, so usually there is no need to add any additional
1285-
headroom.
1286-
1287-
If unsure, set to 0.
1288-
1289-
config IBM_EMAC_PHY_RX_CLK_FIX
1290-
bool "PHY Rx clock workaround"
1291-
depends on IBM_EMAC && (405EP || 440GX || 440EP || 440GR)
1292-
help
1293-
Enable this if EMAC attached to a PHY which doesn't generate
1294-
RX clock if there is no link, if this is the case, you will
1295-
see "TX disable timeout" or "RX disable timeout" in the system
1296-
log.
1297-
1298-
If unsure, say N.
1299-
1300-
config IBM_EMAC_DEBUG
1301-
bool "Debugging"
1302-
depends on IBM_EMAC
1303-
default n
1304-
1305-
config IBM_EMAC_ZMII
1306-
bool
1307-
depends on IBM_EMAC && (NP405H || NP405L || 44x)
1308-
default y
1309-
1310-
config IBM_EMAC_RGMII
1311-
bool
1312-
depends on IBM_EMAC && 440GX
1313-
default y
1314-
1315-
config IBM_EMAC_TAH
1316-
bool
1317-
depends on IBM_EMAC && 440GX
1318-
default y
1250+
source "drivers/net/ibm_emac/Kconfig"
1251+
source "drivers/net/ibm_newemac/Kconfig"
13191252

13201253
config NET_PCI
13211254
bool "EISA, VLB, PCI and on board controllers"

drivers/net/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
obj-$(CONFIG_E1000) += e1000/
66
obj-$(CONFIG_E1000E) += e1000e/
77
obj-$(CONFIG_IBM_EMAC) += ibm_emac/
8+
obj-$(CONFIG_IBM_NEW_EMAC) += ibm_newemac/
89
obj-$(CONFIG_IXGBE) += ixgbe/
910
obj-$(CONFIG_IXGB) += ixgb/
1011
obj-$(CONFIG_IP1000) += ipg.o

drivers/net/ibm_emac/Kconfig

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
config IBM_EMAC
2+
tristate "PowerPC 4xx on-chip Ethernet support"
3+
depends on 4xx && !PPC_MERGE
4+
help
5+
This driver supports the PowerPC 4xx EMAC family of on-chip
6+
Ethernet controllers.
7+
8+
config IBM_EMAC_RXB
9+
int "Number of receive buffers"
10+
depends on IBM_EMAC
11+
default "128"
12+
13+
config IBM_EMAC_TXB
14+
int "Number of transmit buffers"
15+
depends on IBM_EMAC
16+
default "64"
17+
18+
config IBM_EMAC_POLL_WEIGHT
19+
int "MAL NAPI polling weight"
20+
depends on IBM_EMAC
21+
default "32"
22+
23+
config IBM_EMAC_RX_COPY_THRESHOLD
24+
int "RX skb copy threshold (bytes)"
25+
depends on IBM_EMAC
26+
default "256"
27+
28+
config IBM_EMAC_RX_SKB_HEADROOM
29+
int "Additional RX skb headroom (bytes)"
30+
depends on IBM_EMAC
31+
default "0"
32+
help
33+
Additional receive skb headroom. Note, that driver
34+
will always reserve at least 2 bytes to make IP header
35+
aligned, so usually there is no need to add any additional
36+
headroom.
37+
38+
If unsure, set to 0.
39+
40+
config IBM_EMAC_PHY_RX_CLK_FIX
41+
bool "PHY Rx clock workaround"
42+
depends on IBM_EMAC && (405EP || 440GX || 440EP || 440GR)
43+
help
44+
Enable this if EMAC attached to a PHY which doesn't generate
45+
RX clock if there is no link, if this is the case, you will
46+
see "TX disable timeout" or "RX disable timeout" in the system
47+
log.
48+
49+
If unsure, say N.
50+
51+
config IBM_EMAC_DEBUG
52+
bool "Debugging"
53+
depends on IBM_EMAC
54+
default n
55+
56+
config IBM_EMAC_ZMII
57+
bool
58+
depends on IBM_EMAC && (NP405H || NP405L || 44x)
59+
default y
60+
61+
config IBM_EMAC_RGMII
62+
bool
63+
depends on IBM_EMAC && 440GX
64+
default y
65+
66+
config IBM_EMAC_TAH
67+
bool
68+
depends on IBM_EMAC && 440GX
69+
default y
70+

0 commit comments

Comments
 (0)