ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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 <asm/io.h>
16 #include <asm/ppc4xx_pic.h>
17 #include <linux/delay.h>
18 #include <asm/machdep.h>
19
20
21 /*
22  * Define all of the IRQ senses and polarities.
23  */
24
25 static u_char redwood6_IRQ_initsenses[] __initdata = {
26         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 0: RTC/FPC */
27         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 1: Transport */
28         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 2: Audio Dec */
29         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 3: Video Dec */
30         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 4: DMA Chan 0 */
31         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 5: DMA Chan 1 */
32         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 6: DMA Chan 2 */
33         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 7: DMA Chan 3 */
34         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 8: SmartCard 0 */
35         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 9: IIC0 */
36         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 10: IRR */
37         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 11: Cap Timers */
38         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 12: Cmp Timers */
39         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 13: Serial Port */
40         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 14: Soft Modem */
41         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 15: Down Ctrs */
42         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 16: SmartCard 1 */
43         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 17: Ext Int 7 */
44         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 18: Ext Int 8 */
45         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 19: Ext Int 9 */
46         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 20: Serial 0 */
47         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 21: Serial 1 */
48         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 22: Serial 2 */
49         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 23: XPT_DMA */
50         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 24: DCR timeout */
51         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 25: Ext Int 0 */
52         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 26: Ext Int 1 */
53         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 27: Ext Int 2 */
54         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 28: Ext Int 3 */
55         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 29: Ext Int 4 */
56         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 30: Ext Int 5 */
57         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 31: Ext Int 6 */
58 };
59
60
61 void __init
62 redwood6_setup_arch(void)
63 {
64 #ifdef CONFIG_IDE
65         void *xilinx, *xilinx_1, *xilinx_2;
66         unsigned short us_reg5;
67 #endif
68
69         ppc4xx_setup_arch();
70
71 #ifdef CONFIG_IDE
72         xilinx = (unsigned long) ioremap(IDE_XLINUX_MUX_BASE, 0x10);
73         /* init xilinx control registers - enable ide mux, clear reset bit */
74         if (!xilinx) {
75                 printk(KERN_CRIT
76                        "redwood6_setup_arch() xilinxi ioremap failed\n");
77                 return;
78         }
79         xilinx_1 = xilinx + 0xa;
80         xilinx_2 = xilinx + 0xe;
81
82         us_reg5 = readb(xilinx_1);
83         writeb(0x01d1, xilinx_1);
84         writeb(0x0008, xilinx_2);
85
86         udelay(10 * 1000);
87
88         writeb(0x01d1, xilinx_1);
89         writeb(0x0008, xilinx_2);
90 #endif
91
92 #ifdef DEBUG_BRINGUP
93         bd_t *bip = (bd_t *) __res;
94         printk("\n");
95         printk("machine\t: %s\n", PPC4xx_MACHINE_NAME);
96         printk("\n");
97         printk("bi_s_version\t %s\n", bip->bi_s_version);
98         printk("bi_r_version\t %s\n", bip->bi_r_version);
99         printk("bi_memsize\t 0x%8.8x\t %dMBytes\n", bip->bi_memsize,
100                bip->bi_memsize / (1024 * 1000));
101         printk("bi_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", 0,
102                bip->bi_enetaddr[0], bip->bi_enetaddr[1], bip->bi_enetaddr[2],
103                bip->bi_enetaddr[3], bip->bi_enetaddr[4], bip->bi_enetaddr[5]);
104
105         printk("bi_intfreq\t 0x%8.8x\t clock:\t %dMhz\n",
106                bip->bi_intfreq, bip->bi_intfreq / 1000000);
107
108         printk("bi_busfreq\t 0x%8.8x\t plb bus clock:\t %dMHz\n",
109                bip->bi_busfreq, bip->bi_busfreq / 1000000);
110         printk("bi_tbfreq\t 0x%8.8x\t TB freq:\t %dMHz\n",
111                bip->bi_tbfreq, bip->bi_tbfreq / 1000000);
112
113         printk("\n");
114 #endif
115         ibm4xxPIC_InitSenses = redwood6_IRQ_initsenses;
116         ibm4xxPIC_NumInitSenses = sizeof(redwood6_IRQ_initsenses);
117
118         /* Identify the system */
119         printk(KERN_INFO "IBM Redwood6 (STBx25XX) Platform\n");
120         printk(KERN_INFO
121                "Port by MontaVista Software, Inc. (source@mvista.com)\n");
122 }
123
124 void __init
125 redwood6_map_io(void)
126 {
127         int i;
128
129         ppc4xx_map_io();
130         for (i = 0; i < 16; i++) {
131                 unsigned long v, p;
132
133                 /* 0x400x0000 -> 0xe00x0000 */
134                 p = 0x40000000 | (i << 16);
135                 v = STBx25xx_IO_BASE | (i << 16);
136
137                 io_block_mapping(v, p, PAGE_SIZE,
138                                  _PAGE_NO_CACHE | pgprot_val(PAGE_KERNEL) |
139                                  _PAGE_GUARDED);
140         }
141 }
142
143 void __init
144 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
145               unsigned long r6, unsigned long r7)
146 {
147         ppc4xx_init(r3, r4, r5, r6, r7);
148
149         ppc_md.setup_arch = redwood6_setup_arch;
150         ppc_md.setup_io_mappings = redwood6_map_io;
151 }