[PATCH] USB: Rename hcd->hub_suspend to hcd->bus_suspend
[linux/fpc-iii.git] / drivers / net / fec_8xx / fec_8xx-netta.c
blob29c275e1d566f5c25c0d3adac39836a13d6bb540
1 /*
2 * FEC instantatiation file for NETTA
3 */
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>
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>
33 #include "fec_8xx.h"
35 /*************************************************/
37 static 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,
50 static 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,
63 static struct net_device *fec1_dev;
64 static struct net_device *fec2_dev;
66 /* XXX custom u-boot & Linux startup needed */
67 extern const char *__fw_getenv(const char *var);
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))
73 #define setbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) | (_v))
74 #define clrbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) & ~(_v))
76 int fec_8xx_platform_init(void)
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;
84 /* use MDC for MII */
85 setbits16(immap->im_ioport.iop_pdpar, 0x0080);
86 clrbits16(immap->im_ioport.iop_pddir, 0x0080);
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);
93 setbits32(immap->im_cpm.cp_pbpar, 0x00000001);
94 clrbits32(immap->im_cpm.cp_pbdir, 0x00000001);
96 setbits32(immap->im_cpm.cp_cptr, 0x00000100);
97 clrbits32(immap->im_cpm.cp_cptr, 0x00000050);
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);
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);
110 setbits32(immap->im_cpm.cp_cptr, 0x00000080);
111 clrbits32(immap->im_cpm.cp_cptr, 0x00000028);
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);
118 /* fill up */
119 fec1_info.sys_clk = bd->bi_intfreq;
120 fec2_info.sys_clk = bd->bi_intfreq;
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;
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;
140 fec_8xx_init_one(&fec1_info, &fec1_dev);
141 fec_8xx_init_one(&fec2_info, &fec2_dev);
143 return fec1_dev != NULL && fec2_dev != NULL ? 0 : -1;
146 void fec_8xx_platform_cleanup(void)
148 if (fec2_dev != NULL)
149 fec_8xx_cleanup_one(fec2_dev);
151 if (fec1_dev != NULL)
152 fec_8xx_cleanup_one(fec1_dev);