VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / arch / ppc / platforms / 4xx / redwood6.c
1 /*
2  * arch/ppc/platforms/4xx/redwood6.c
3  *
4  * Author: Armin Kuster <akuster@mvista.com>
5  *
6  * 2002 (c) MontaVista, Software, Inc.  This file is licensed under
7  * the terms of the GNU General Public License version 2.  This program
8  * is licensed "as is" without any warranty of any kind, whether express
9  * or implied.
10  */
11
12 #include <linux/config.h>
13 #include <linux/init.h>
14 #include <linux/pagemap.h>
15 #include <linux/device.h>
16 #include <linux/ioport.h>
17 #include <asm/io.h>
18 #include <asm/ppc4xx_pic.h>
19 #include <linux/delay.h>
20 #include <asm/machdep.h>
21
22
23 /*
24  * Define all of the IRQ senses and polarities.
25  */
26
27 static u_char redwood6_IRQ_initsenses[] __initdata = {
28         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 0: RTC/FPC */
29         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 1: Transport */
30         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 2: Audio Dec */
31         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 3: Video Dec */
32         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 4: DMA Chan 0 */
33         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 5: DMA Chan 1 */
34         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 6: DMA Chan 2 */
35         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 7: DMA Chan 3 */
36         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 8: SmartCard 0 */
37         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 9: IIC0 */
38         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 10: IRR */
39         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 11: Cap Timers */
40         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 12: Cmp Timers */
41         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 13: Serial Port */
42         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 14: Soft Modem */
43         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 15: Down Ctrs */
44         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 16: SmartCard 1 */
45         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 17: Ext Int 7 */
46         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 18: Ext Int 8 */
47         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 19: Ext Int 9 */
48         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 20: Serial 0 */
49         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 21: Serial 1 */
50         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 22: Serial 2 */
51         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 23: XPT_DMA */
52         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 24: DCR timeout */
53         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 25: Ext Int 0 */
54         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 26: Ext Int 1 */
55         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 27: Ext Int 2 */
56         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 28: Ext Int 3 */
57         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 29: Ext Int 4 */
58         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 30: Ext Int 5 */
59         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 31: Ext Int 6 */
60 };
61
62 static struct resource smc91x_resources[] = {
63         [0] = {
64                 .start  = SMC91111_BASE_ADDR,
65                 .end    = SMC91111_BASE_ADDR + SMC91111_REG_SIZE - 1,
66                 .flags  = IORESOURCE_MEM,
67         },
68         [1] = {
69                 .start  = SMC91111_IRQ,
70                 .end    = SMC91111_IRQ,
71                 .flags  = IORESOURCE_IRQ,
72         },
73 };
74
75 static struct platform_device smc91x_device = {
76         .name           = "smc91x",
77         .id             = 0,
78         .num_resources  = ARRAY_SIZE(smc91x_resources),
79         .resource       = smc91x_resources,
80 };
81
82 static struct platform_device *redwood6_devs[] __initdata = {
83         &smc91x_device,
84 };
85
86 static int __init
87 redwood6_platform_add_devices(void)
88 {
89         return platform_add_devices(redwood6_devs, ARRAY_SIZE(redwood6_devs));
90 }
91
92
93 void __init
94 redwood6_setup_arch(void)
95 {
96 #ifdef CONFIG_IDE
97         void *xilinx, *xilinx_1, *xilinx_2;
98         unsigned short us_reg5;
99 #endif
100
101         ppc4xx_setup_arch();
102
103 #ifdef CONFIG_IDE
104         xilinx = (unsigned long) ioremap(IDE_XLINUX_MUX_BASE, 0x10);
105         /* init xilinx control registers - enable ide mux, clear reset bit */
106         if (!xilinx) {
107                 printk(KERN_CRIT
108                        "redwood6_setup_arch() xilinxi ioremap failed\n");
109                 return;
110         }
111         xilinx_1 = xilinx + 0xa;
112         xilinx_2 = xilinx + 0xe;
113
114         us_reg5 = readb(xilinx_1);
115         writeb(0x01d1, xilinx_1);
116         writeb(0x0008, xilinx_2);
117
118         udelay(10 * 1000);
119
120         writeb(0x01d1, xilinx_1);
121         writeb(0x0008, xilinx_2);
122 #endif
123
124 #ifdef DEBUG_BRINGUP
125         bd_t *bip = (bd_t *) __res;
126         printk("\n");
127         printk("machine\t: %s\n", PPC4xx_MACHINE_NAME);
128         printk("\n");
129         printk("bi_s_version\t %s\n", bip->bi_s_version);
130         printk("bi_r_version\t %s\n", bip->bi_r_version);
131         printk("bi_memsize\t 0x%8.8x\t %dMBytes\n", bip->bi_memsize,
132                bip->bi_memsize / (1024 * 1000));
133         printk("bi_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", 0,
134                bip->bi_enetaddr[0], bip->bi_enetaddr[1], bip->bi_enetaddr[2],
135                bip->bi_enetaddr[3], bip->bi_enetaddr[4], bip->bi_enetaddr[5]);
136
137         printk("bi_intfreq\t 0x%8.8x\t clock:\t %dMhz\n",
138                bip->bi_intfreq, bip->bi_intfreq / 1000000);
139
140         printk("bi_busfreq\t 0x%8.8x\t plb bus clock:\t %dMHz\n",
141                bip->bi_busfreq, bip->bi_busfreq / 1000000);
142         printk("bi_tbfreq\t 0x%8.8x\t TB freq:\t %dMHz\n",
143                bip->bi_tbfreq, bip->bi_tbfreq / 1000000);
144
145         printk("\n");
146 #endif
147         ibm4xxPIC_InitSenses = redwood6_IRQ_initsenses;
148         ibm4xxPIC_NumInitSenses = sizeof(redwood6_IRQ_initsenses);
149
150         /* Identify the system */
151         printk(KERN_INFO "IBM Redwood6 (STBx25XX) Platform\n");
152         printk(KERN_INFO
153                "Port by MontaVista Software, Inc. (source@mvista.com)\n");
154
155         device_initcall(redwood6_platform_add_devices);
156 }
157
158 void __init
159 redwood6_map_io(void)
160 {
161         int i;
162
163         ppc4xx_map_io();
164         for (i = 0; i < 16; i++) {
165                 unsigned long v, p;
166
167                 /* 0x400x0000 -> 0xe00x0000 */
168                 p = 0x40000000 | (i << 16);
169                 v = STBx25xx_IO_BASE | (i << 16);
170
171                 io_block_mapping(v, p, PAGE_SIZE,
172                                  _PAGE_NO_CACHE | pgprot_val(PAGE_KERNEL) |
173                                  _PAGE_GUARDED);
174         }
175 }
176
177 void __init
178 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
179               unsigned long r6, unsigned long r7)
180 {
181         ppc4xx_init(r3, r4, r5, r6, r7);
182
183         ppc_md.setup_arch = redwood6_setup_arch;
184         ppc_md.setup_io_mappings = redwood6_map_io;
185 }