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