diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-08-22 23:56:01 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:52 -0400 |
commit | 1d3bb996481e116f5f2b127cbd29b83365d2cf62 (patch) | |
tree | b612a1dbf51c920fb5a9758a6d35f9ed37eb927f /drivers/net/ibm_newemac/zmii.h | |
parent | 03233b90b0977d577322a6e1ddd56d9cc570d406 (diff) |
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>
Diffstat (limited to 'drivers/net/ibm_newemac/zmii.h')
-rw-r--r-- | drivers/net/ibm_newemac/zmii.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/drivers/net/ibm_newemac/zmii.h b/drivers/net/ibm_newemac/zmii.h new file mode 100644 index 000000000000..82a9968b1f74 --- /dev/null +++ b/drivers/net/ibm_newemac/zmii.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * drivers/net/ibm_newemac/zmii.h | ||
3 | * | ||
4 | * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. | ||
5 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | ||
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | ||
8 | * | ||
9 | * Based on original work by | ||
10 | * Armin Kuster <akuster@mvista.com> | ||
11 | * Copyright 2001 MontaVista Softare Inc. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify it | ||
14 | * under the terms of the GNU General Public License as published by the | ||
15 | * Free Software Foundation; either version 2 of the License, or (at your | ||
16 | * option) any later version. | ||
17 | * | ||
18 | */ | ||
19 | #ifndef __IBM_NEWEMAC_ZMII_H | ||
20 | #define __IBM_NEWEMAC_ZMII_H | ||
21 | |||
22 | /* ZMII bridge registers */ | ||
23 | struct zmii_regs { | ||
24 | u32 fer; /* Function enable reg */ | ||
25 | u32 ssr; /* Speed select reg */ | ||
26 | u32 smiirs; /* SMII status reg */ | ||
27 | }; | ||
28 | |||
29 | /* ZMII device */ | ||
30 | struct zmii_instance { | ||
31 | struct zmii_regs __iomem *base; | ||
32 | |||
33 | /* Only one EMAC whacks us at a time */ | ||
34 | struct mutex lock; | ||
35 | |||
36 | /* subset of PHY_MODE_XXXX */ | ||
37 | int mode; | ||
38 | |||
39 | /* number of EMACs using this ZMII bridge */ | ||
40 | int users; | ||
41 | |||
42 | /* FER value left by firmware */ | ||
43 | u32 fer_save; | ||
44 | |||
45 | /* OF device instance */ | ||
46 | struct of_device *ofdev; | ||
47 | }; | ||
48 | |||
49 | #ifdef CONFIG_IBM_NEW_EMAC_ZMII | ||
50 | |||
51 | extern int zmii_init(void); | ||
52 | extern void zmii_exit(void); | ||
53 | extern int zmii_attach(struct of_device *ofdev, int input, int *mode); | ||
54 | extern void zmii_detach(struct of_device *ofdev, int input); | ||
55 | extern void zmii_get_mdio(struct of_device *ofdev, int input); | ||
56 | extern void zmii_put_mdio(struct of_device *ofdev, int input); | ||
57 | extern void zmii_set_speed(struct of_device *ofdev, int input, int speed); | ||
58 | extern int zmii_get_regs_len(struct of_device *ocpdev); | ||
59 | extern void *zmii_dump_regs(struct of_device *ofdev, void *buf); | ||
60 | |||
61 | #else | ||
62 | # define zmii_init() 0 | ||
63 | # define zmii_exit() do { } while(0) | ||
64 | # define zmii_attach(x,y,z) (-ENXIO) | ||
65 | # define zmii_detach(x,y) do { } while(0) | ||
66 | # define zmii_get_mdio(x,y) do { } while(0) | ||
67 | # define zmii_put_mdio(x,y) do { } while(0) | ||
68 | # define zmii_set_speed(x,y,z) do { } while(0) | ||
69 | # define zmii_get_regs_len(x) 0 | ||
70 | # define zmii_dump_regs(x,buf) (buf) | ||
71 | #endif /* !CONFIG_IBM_NEW_EMAC_ZMII */ | ||
72 | |||
73 | #endif /* __IBM_NEWEMAC_ZMII_H */ | ||