1 /*
2  *
3  *    Module name: redwood6.c
4  *
5  *    Description:
6  *    	IBM redwood6 eval board file
7  *
8  *    Author: Armin Kuster
9  *    Copyright 2002 MontaVista Software Inc.
10  *
11  * This program is free software; you can redistribute  it and/or modify it
12  * under  the terms of  the GNU General Public License as published by the
13  * Free Software Foundation;  either version 2 of the  License, or (at your
14  * option) any later version.
15  *
16  * THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
17  * WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
19  * NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
22  * USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23  * ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * You should have received a copy of the  GNU General Public License along
28  * with this program; if not, write  to the Free Software Foundation, Inc.,
29  * 675 Mass Ave, Cambridge, MA 02139, USA.
30  *
31  *      History:  July 10, 2002 - Armin
32  *    	initial release
33  *
34  *    		: July 16, 2002 - Armin
35  *    		added xilinx init code for ide interface
36  *    		added IRQ table
37  *
38  */
39 
40 #include <linux/config.h>
41 #include <linux/init.h>
42 #include <linux/pagemap.h>
43 #include <asm/io.h>
44 #include <asm/ppc4xx_pic.h>
45 #include <linux/delay.h>
46 #include <asm/machdep.h>
47 
48 
49 /*
50  * Define all of the IRQ senses and polarities.
51  */
52 
53 static u_char redwood6_IRQ_initsenses[] __initdata = {
54 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 0: RTC/FPC */
55 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 1: Transport */
56 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 2: Audio Dec */
57 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 3: Video Dec */
58 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 4: DMA Chan 0 */
59 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 5: DMA Chan 1 */
60 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 6: DMA Chan 2 */
61 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 7: DMA Chan 3 */
62 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 8: SmartCard 0 */
63 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 9: IIC0 */
64 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 10: IRR */
65 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 11: Cap Timers */
66 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 12: Cmp Timers */
67 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 13: Serial Port */
68 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 14: Soft Modem */
69 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 15: Down Ctrs */
70 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 16: SmartCard 1 */
71 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 17: Ext Int 7 */
72 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 18: Ext Int 8 */
73 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 19: Ext Int 9 */
74 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 20: Serial 0 */
75 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 21: Serial 1 */
76 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 22: Serial 2 */
77 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 23: XPT_DMA */
78 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 24: DCR timeout */
79 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 25: Ext Int 0 */
80 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 26: Ext Int 1 */
81 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 27: Ext Int 2 */
82 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 28: Ext Int 3 */
83 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 29: Ext Int 4 */
84 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 30: Ext Int 5 */
85 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 31: Ext Int 6 */
86 };
87 
88 
89 void __init
board_setup_arch(void)90 board_setup_arch(void)
91 {
92 #ifdef CONFIG_IDE
93 	void *xilinx, *xilinx_1, *xilinx_2;
94 	unsigned short us_reg5;
95 
96 	xilinx = (unsigned long) ioremap(IDE_XLINUX_MUX_BASE, 0x10);
97 	/* init xilinx control registers - enable ide mux, clear reset bit */
98 	if (!xilinx) {
99 		printk(KERN_CRIT
100 		       "redwood6_setup_arch() xilinxi ioremap failed\n");
101 		return;
102 	}
103 	xilinx_1 = xilinx + 0xa;
104 	xilinx_2 = xilinx + 0xe;
105 
106 	us_reg5 = readb(xilinx_1);
107 	writeb(0x01d1, xilinx_1);
108 	writeb(0x0008, xilinx_2);
109 
110 	udelay(10 * 1000);
111 
112 	writeb(0x01d1, xilinx_1);
113 	writeb(0x0008, xilinx_2);
114 #endif
115 
116 #ifdef DEBUG_BRINGUP
117 	bd_t *bip = (bd_t *) __res;
118 	printk("\n");
119 	printk("machine\t: %s\n", PPC4xx_MACHINE_NAME);
120 	printk("\n");
121 	printk("bi_s_version\t %s\n", bip->bi_s_version);
122 	printk("bi_r_version\t %s\n", bip->bi_r_version);
123 	printk("bi_memsize\t 0x%8.8x\t %dMBytes\n", bip->bi_memsize,
124 	       bip->bi_memsize / (1024 * 1000));
125 	printk("bi_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", 0,
126 	       bip->bi_enetaddr[0], bip->bi_enetaddr[1], bip->bi_enetaddr[2],
127 	       bip->bi_enetaddr[3], bip->bi_enetaddr[4], bip->bi_enetaddr[5]);
128 
129 	printk("bi_intfreq\t 0x%8.8x\t clock:\t %dMhz\n",
130 	       bip->bi_intfreq, bip->bi_intfreq / 1000000);
131 
132 	printk("bi_busfreq\t 0x%8.8x\t plb bus clock:\t %dMHz\n",
133 	       bip->bi_busfreq, bip->bi_busfreq / 1000000);
134 	printk("bi_tbfreq\t 0x%8.8x\t TB freq:\t %dMHz\n",
135 	       bip->bi_tbfreq, bip->bi_tbfreq / 1000000);
136 
137 	printk("\n");
138 #endif
139 	ibm4xxPIC_InitSenses = redwood6_IRQ_initsenses;
140 	ibm4xxPIC_NumInitSenses = sizeof(redwood6_IRQ_initsenses);
141 
142 	/* Identify the system */
143 	printk(KERN_INFO "IBM Redwood6 (STBx25XX) Platform\n");
144 	printk(KERN_INFO
145 	       "Port by MontaVista Software, Inc. (source@mvista.com)\n");
146 }
147 
148 void __init
board_io_mapping(void)149 board_io_mapping(void)
150 {
151 	int i;
152 
153 	for (i = 0; i < 16; i++) {
154 		unsigned long v, p;
155 
156 		/* 0x400x0000 -> 0xe00x0000 */
157 		p = 0x40000000 | (i << 16);
158 		v = STBx25xx_IO_BASE | (i << 16);
159 
160 		io_block_mapping(v, p, PAGE_SIZE,
161 				 _PAGE_NO_CACHE | pgprot_val(PAGE_KERNEL) |
162 				 _PAGE_GUARDED);
163 	}
164 }
165 
166 void __init
board_setup_irq(void)167 board_setup_irq(void)
168 {
169 }
170 
171 void __init
board_init(void)172 board_init(void)
173 {
174 }
175