aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fec_8xx/fec_8xx-netta.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/net/fec_8xx/fec_8xx-netta.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/net/fec_8xx/fec_8xx-netta.c')
-rw-r--r--drivers/net/fec_8xx/fec_8xx-netta.c153
1 files changed, 153 insertions, 0 deletions
diff --git a/drivers/net/fec_8xx/fec_8xx-netta.c b/drivers/net/fec_8xx/fec_8xx-netta.c
new file mode 100644
index 000000000000..29c275e1d566
--- /dev/null
+++ b/drivers/net/fec_8xx/fec_8xx-netta.c
@@ -0,0 +1,153 @@
1/*
2 * FEC instantatiation file for NETTA
3 */
4
5#include <linux/config.h>
6#include <linux/kernel.h>
7#include <linux/types.h>
8#include <linux/sched.h>
9#include <linux/string.h>
10#include <linux/ptrace.h>
11#include <linux/errno.h>
12#include <linux/ioport.h>
13#include <linux/slab.h>
14#include <linux/interrupt.h>
15#include <linux/pci.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/netdevice.h>
19#include <linux/etherdevice.h>
20#include <linux/skbuff.h>
21#include <linux/spinlock.h>
22#include <linux/mii.h>
23#include <linux/ethtool.h>
24#include <linux/bitops.h>
25
26#include <asm/8xx_immap.h>
27#include <asm/pgtable.h>
28#include <asm/mpc8xx.h>
29#include <asm/irq.h>
30#include <asm/uaccess.h>
31#include <asm/commproc.h>
32
33#include "fec_8xx.h"
34
35/*************************************************/
36
37static struct fec_platform_info fec1_info = {
38 .fec_no = 0,
39 .use_mdio = 1,
40 .phy_addr = 8,
41 .fec_irq = SIU_LEVEL1,
42 .phy_irq = CPM_IRQ_OFFSET + CPMVEC_PIO_PC6,
43 .rx_ring = 128,
44 .tx_ring = 16,
45 .rx_copybreak = 240,
46 .use_napi = 1,
47 .napi_weight = 17,
48};
49
50static struct fec_platform_info fec2_info = {
51 .fec_no = 1,
52 .use_mdio = 1,
53 .phy_addr = 2,
54 .fec_irq = SIU_LEVEL3,
55 .phy_irq = CPM_IRQ_OFFSET + CPMVEC_PIO_PC7,
56 .rx_ring = 128,
57 .tx_ring = 16,
58 .rx_copybreak = 240,
59 .use_napi = 1,
60 .napi_weight = 17,
61};
62
63static struct net_device *fec1_dev;
64static struct net_device *fec2_dev;
65
66/* XXX custom u-boot & Linux startup needed */
67extern const char *__fw_getenv(const char *var);
68
69/* access ports */
70#define setbits32(_addr, _v) __fec_out32(&(_addr), __fec_in32(&(_addr)) | (_v))
71#define clrbits32(_addr, _v) __fec_out32(&(_addr), __fec_in32(&(_addr)) & ~(_v))
72
73#define setbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) | (_v))
74#define clrbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) & ~(_v))
75
76int fec_8xx_platform_init(void)
77{
78 immap_t *immap = (immap_t *)IMAP_ADDR;
79 bd_t *bd = (bd_t *) __res;
80 const char *s;
81 char *e;
82 int i;
83
84 /* use MDC for MII */
85 setbits16(immap->im_ioport.iop_pdpar, 0x0080);
86 clrbits16(immap->im_ioport.iop_pddir, 0x0080);
87
88 /* configure FEC1 pins */
89 setbits16(immap->im_ioport.iop_papar, 0xe810);
90 setbits16(immap->im_ioport.iop_padir, 0x0810);
91 clrbits16(immap->im_ioport.iop_padir, 0xe000);
92
93 setbits32(immap->im_cpm.cp_pbpar, 0x00000001);
94 clrbits32(immap->im_cpm.cp_pbdir, 0x00000001);
95
96 setbits32(immap->im_cpm.cp_cptr, 0x00000100);
97 clrbits32(immap->im_cpm.cp_cptr, 0x00000050);
98
99 clrbits16(immap->im_ioport.iop_pcpar, 0x0200);
100 clrbits16(immap->im_ioport.iop_pcdir, 0x0200);
101 clrbits16(immap->im_ioport.iop_pcso, 0x0200);
102 setbits16(immap->im_ioport.iop_pcint, 0x0200);
103
104 /* configure FEC2 pins */
105 setbits32(immap->im_cpm.cp_pepar, 0x00039620);
106 setbits32(immap->im_cpm.cp_pedir, 0x00039620);
107 setbits32(immap->im_cpm.cp_peso, 0x00031000);
108 clrbits32(immap->im_cpm.cp_peso, 0x00008620);
109
110 setbits32(immap->im_cpm.cp_cptr, 0x00000080);
111 clrbits32(immap->im_cpm.cp_cptr, 0x00000028);
112
113 clrbits16(immap->im_ioport.iop_pcpar, 0x0200);
114 clrbits16(immap->im_ioport.iop_pcdir, 0x0200);
115 clrbits16(immap->im_ioport.iop_pcso, 0x0200);
116 setbits16(immap->im_ioport.iop_pcint, 0x0200);
117
118 /* fill up */
119 fec1_info.sys_clk = bd->bi_intfreq;
120 fec2_info.sys_clk = bd->bi_intfreq;
121
122 s = __fw_getenv("ethaddr");
123 if (s != NULL) {
124 for (i = 0; i < 6; i++) {
125 fec1_info.macaddr[i] = simple_strtoul(s, &e, 16);
126 if (*e)
127 s = e + 1;
128 }
129 }
130
131 s = __fw_getenv("eth1addr");
132 if (s != NULL) {
133 for (i = 0; i < 6; i++) {
134 fec2_info.macaddr[i] = simple_strtoul(s, &e, 16);
135 if (*e)
136 s = e + 1;
137 }
138 }
139
140 fec_8xx_init_one(&fec1_info, &fec1_dev);
141 fec_8xx_init_one(&fec2_info, &fec2_dev);
142
143 return fec1_dev != NULL && fec2_dev != NULL ? 0 : -1;
144}
145
146void fec_8xx_platform_cleanup(void)
147{
148 if (fec2_dev != NULL)
149 fec_8xx_cleanup_one(fec2_dev);
150
151 if (fec1_dev != NULL)
152 fec_8xx_cleanup_one(fec1_dev);
153}