xref: /OK3568_Linux_fs/kernel/arch/mips/txx9/rbtx4938/setup.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Setup pointers to hardware-dependent routines.
3*4882a593Smuzhiyun  * Copyright (C) 2000-2001 Toshiba Corporation
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6*4882a593Smuzhiyun  * terms of the GNU General Public License version 2. This program is
7*4882a593Smuzhiyun  * licensed "as is" without any warranty of any kind, whether express
8*4882a593Smuzhiyun  * or implied.
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun #include <linux/init.h>
13*4882a593Smuzhiyun #include <linux/types.h>
14*4882a593Smuzhiyun #include <linux/ioport.h>
15*4882a593Smuzhiyun #include <linux/delay.h>
16*4882a593Smuzhiyun #include <linux/platform_device.h>
17*4882a593Smuzhiyun #include <linux/gpio/driver.h>
18*4882a593Smuzhiyun #include <linux/gpio.h>
19*4882a593Smuzhiyun #include <linux/mtd/physmap.h>
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun #include <asm/reboot.h>
22*4882a593Smuzhiyun #include <asm/io.h>
23*4882a593Smuzhiyun #include <asm/txx9/generic.h>
24*4882a593Smuzhiyun #include <asm/txx9/pci.h>
25*4882a593Smuzhiyun #include <asm/txx9/rbtx4938.h>
26*4882a593Smuzhiyun #include <linux/spi/spi.h>
27*4882a593Smuzhiyun #include <asm/txx9/spi.h>
28*4882a593Smuzhiyun #include <asm/txx9pio.h>
29*4882a593Smuzhiyun 
rbtx4938_machine_restart(char * command)30*4882a593Smuzhiyun static void rbtx4938_machine_restart(char *command)
31*4882a593Smuzhiyun {
32*4882a593Smuzhiyun 	local_irq_disable();
33*4882a593Smuzhiyun 	writeb(1, rbtx4938_softresetlock_addr);
34*4882a593Smuzhiyun 	writeb(1, rbtx4938_sfvol_addr);
35*4882a593Smuzhiyun 	writeb(1, rbtx4938_softreset_addr);
36*4882a593Smuzhiyun 	/* fallback */
37*4882a593Smuzhiyun 	(*_machine_halt)();
38*4882a593Smuzhiyun }
39*4882a593Smuzhiyun 
rbtx4938_pci_setup(void)40*4882a593Smuzhiyun static void __init rbtx4938_pci_setup(void)
41*4882a593Smuzhiyun {
42*4882a593Smuzhiyun #ifdef CONFIG_PCI
43*4882a593Smuzhiyun 	int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB);
44*4882a593Smuzhiyun 	struct pci_controller *c = &txx9_primary_pcic;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun 	register_pci_controller(c);
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66)
49*4882a593Smuzhiyun 		txx9_pci_option =
50*4882a593Smuzhiyun 			(txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
51*4882a593Smuzhiyun 			TXX9_PCI_OPT_CLK_66; /* already configured */
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun 	/* Reset PCI Bus */
54*4882a593Smuzhiyun 	writeb(0, rbtx4938_pcireset_addr);
55*4882a593Smuzhiyun 	/* Reset PCIC */
56*4882a593Smuzhiyun 	txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
57*4882a593Smuzhiyun 	if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
58*4882a593Smuzhiyun 	    TXX9_PCI_OPT_CLK_66)
59*4882a593Smuzhiyun 		tx4938_pciclk66_setup();
60*4882a593Smuzhiyun 	mdelay(10);
61*4882a593Smuzhiyun 	/* clear PCIC reset */
62*4882a593Smuzhiyun 	txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
63*4882a593Smuzhiyun 	writeb(1, rbtx4938_pcireset_addr);
64*4882a593Smuzhiyun 	iob();
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun 	tx4938_report_pciclk();
67*4882a593Smuzhiyun 	tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
68*4882a593Smuzhiyun 	if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
69*4882a593Smuzhiyun 	    TXX9_PCI_OPT_CLK_AUTO &&
70*4882a593Smuzhiyun 	    txx9_pci66_check(c, 0, 0)) {
71*4882a593Smuzhiyun 		/* Reset PCI Bus */
72*4882a593Smuzhiyun 		writeb(0, rbtx4938_pcireset_addr);
73*4882a593Smuzhiyun 		/* Reset PCIC */
74*4882a593Smuzhiyun 		txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
75*4882a593Smuzhiyun 		tx4938_pciclk66_setup();
76*4882a593Smuzhiyun 		mdelay(10);
77*4882a593Smuzhiyun 		/* clear PCIC reset */
78*4882a593Smuzhiyun 		txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
79*4882a593Smuzhiyun 		writeb(1, rbtx4938_pcireset_addr);
80*4882a593Smuzhiyun 		iob();
81*4882a593Smuzhiyun 		/* Reinitialize PCIC */
82*4882a593Smuzhiyun 		tx4938_report_pciclk();
83*4882a593Smuzhiyun 		tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
84*4882a593Smuzhiyun 	}
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun 	if (__raw_readq(&tx4938_ccfgptr->pcfg) &
87*4882a593Smuzhiyun 	    (TX4938_PCFG_ETH0_SEL|TX4938_PCFG_ETH1_SEL)) {
88*4882a593Smuzhiyun 		/* Reset PCIC1 */
89*4882a593Smuzhiyun 		txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
90*4882a593Smuzhiyun 		/* PCI1DMD==0 => PCI1CLK==GBUSCLK/2 => PCI66 */
91*4882a593Smuzhiyun 		if (!(__raw_readq(&tx4938_ccfgptr->ccfg)
92*4882a593Smuzhiyun 		      & TX4938_CCFG_PCI1DMD))
93*4882a593Smuzhiyun 			tx4938_ccfg_set(TX4938_CCFG_PCI1_66);
94*4882a593Smuzhiyun 		mdelay(10);
95*4882a593Smuzhiyun 		/* clear PCIC1 reset */
96*4882a593Smuzhiyun 		txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
97*4882a593Smuzhiyun 		tx4938_report_pci1clk();
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun 		/* mem:64K(max), io:64K(max) (enough for ETH0,ETH1) */
100*4882a593Smuzhiyun 		c = txx9_alloc_pci_controller(NULL, 0, 0x10000, 0, 0x10000);
101*4882a593Smuzhiyun 		register_pci_controller(c);
102*4882a593Smuzhiyun 		tx4927_pcic_setup(tx4938_pcic1ptr, c, 0);
103*4882a593Smuzhiyun 	}
104*4882a593Smuzhiyun 	tx4938_setup_pcierr_irq();
105*4882a593Smuzhiyun #endif /* CONFIG_PCI */
106*4882a593Smuzhiyun }
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun /* SPI support */
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun /* chip select for SPI devices */
111*4882a593Smuzhiyun #define SEEPROM1_CS	7	/* PIO7 */
112*4882a593Smuzhiyun #define SEEPROM2_CS	0	/* IOC */
113*4882a593Smuzhiyun #define SEEPROM3_CS	1	/* IOC */
114*4882a593Smuzhiyun #define SRTC_CS 2	/* IOC */
115*4882a593Smuzhiyun #define SPI_BUSNO	0
116*4882a593Smuzhiyun 
rbtx4938_ethaddr_init(void)117*4882a593Smuzhiyun static int __init rbtx4938_ethaddr_init(void)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun #ifdef CONFIG_PCI
120*4882a593Smuzhiyun 	unsigned char dat[17];
121*4882a593Smuzhiyun 	unsigned char sum;
122*4882a593Smuzhiyun 	int i;
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun 	/* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */
125*4882a593Smuzhiyun 	if (spi_eeprom_read(SPI_BUSNO, SEEPROM1_CS, 0, dat, sizeof(dat))) {
126*4882a593Smuzhiyun 		pr_err("seeprom: read error.\n");
127*4882a593Smuzhiyun 		return -ENODEV;
128*4882a593Smuzhiyun 	} else {
129*4882a593Smuzhiyun 		if (strcmp(dat, "MAC") != 0)
130*4882a593Smuzhiyun 			pr_warn("seeprom: bad signature.\n");
131*4882a593Smuzhiyun 		for (i = 0, sum = 0; i < sizeof(dat); i++)
132*4882a593Smuzhiyun 			sum += dat[i];
133*4882a593Smuzhiyun 		if (sum)
134*4882a593Smuzhiyun 			pr_warn("seeprom: bad checksum.\n");
135*4882a593Smuzhiyun 	}
136*4882a593Smuzhiyun 	tx4938_ethaddr_init(&dat[4], &dat[4 + 6]);
137*4882a593Smuzhiyun #endif /* CONFIG_PCI */
138*4882a593Smuzhiyun 	return 0;
139*4882a593Smuzhiyun }
140*4882a593Smuzhiyun 
rbtx4938_spi_setup(void)141*4882a593Smuzhiyun static void __init rbtx4938_spi_setup(void)
142*4882a593Smuzhiyun {
143*4882a593Smuzhiyun 	/* set SPI_SEL */
144*4882a593Smuzhiyun 	txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_SPI_SEL);
145*4882a593Smuzhiyun }
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun static struct resource rbtx4938_fpga_resource;
148*4882a593Smuzhiyun 
rbtx4938_time_init(void)149*4882a593Smuzhiyun static void __init rbtx4938_time_init(void)
150*4882a593Smuzhiyun {
151*4882a593Smuzhiyun 	tx4938_time_init(0);
152*4882a593Smuzhiyun }
153*4882a593Smuzhiyun 
rbtx4938_mem_setup(void)154*4882a593Smuzhiyun static void __init rbtx4938_mem_setup(void)
155*4882a593Smuzhiyun {
156*4882a593Smuzhiyun 	unsigned long long pcfg;
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun 	if (txx9_master_clock == 0)
159*4882a593Smuzhiyun 		txx9_master_clock = 25000000; /* 25MHz */
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun 	tx4938_setup();
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun #ifdef CONFIG_PCI
164*4882a593Smuzhiyun 	txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0);
165*4882a593Smuzhiyun 	txx9_board_pcibios_setup = tx4927_pcibios_setup;
166*4882a593Smuzhiyun #else
167*4882a593Smuzhiyun 	set_io_port_base(RBTX4938_ETHER_BASE);
168*4882a593Smuzhiyun #endif
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun 	tx4938_sio_init(7372800, 0);
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61
173*4882a593Smuzhiyun 	pr_info("PIOSEL: disabling both ATA and NAND selection\n");
174*4882a593Smuzhiyun 	txx9_clear64(&tx4938_ccfgptr->pcfg,
175*4882a593Smuzhiyun 		     TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL);
176*4882a593Smuzhiyun #endif
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND
179*4882a593Smuzhiyun 	pr_info("PIOSEL: enabling NAND selection\n");
180*4882a593Smuzhiyun 	txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL);
181*4882a593Smuzhiyun 	txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL);
182*4882a593Smuzhiyun #endif
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA
185*4882a593Smuzhiyun 	pr_info("PIOSEL: enabling ATA selection\n");
186*4882a593Smuzhiyun 	txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL);
187*4882a593Smuzhiyun 	txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL);
188*4882a593Smuzhiyun #endif
189*4882a593Smuzhiyun 
190*4882a593Smuzhiyun #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_KEEP
191*4882a593Smuzhiyun 	pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg);
192*4882a593Smuzhiyun 	pr_info("PIOSEL: NAND %s, ATA %s\n",
193*4882a593Smuzhiyun 		(pcfg & TX4938_PCFG_NDF_SEL) ? "enabled" : "disabled",
194*4882a593Smuzhiyun 		(pcfg & TX4938_PCFG_ATA_SEL) ? "enabled" : "disabled");
195*4882a593Smuzhiyun #endif
196*4882a593Smuzhiyun 
197*4882a593Smuzhiyun 	rbtx4938_spi_setup();
198*4882a593Smuzhiyun 	pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg);	/* updated */
199*4882a593Smuzhiyun 	/* fixup piosel */
200*4882a593Smuzhiyun 	if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
201*4882a593Smuzhiyun 	    TX4938_PCFG_ATA_SEL)
202*4882a593Smuzhiyun 		writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x04,
203*4882a593Smuzhiyun 		       rbtx4938_piosel_addr);
204*4882a593Smuzhiyun 	else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
205*4882a593Smuzhiyun 		 TX4938_PCFG_NDF_SEL)
206*4882a593Smuzhiyun 		writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x08,
207*4882a593Smuzhiyun 		       rbtx4938_piosel_addr);
208*4882a593Smuzhiyun 	else
209*4882a593Smuzhiyun 		writeb(readb(rbtx4938_piosel_addr) & ~(0x08 | 0x04),
210*4882a593Smuzhiyun 		       rbtx4938_piosel_addr);
211*4882a593Smuzhiyun 
212*4882a593Smuzhiyun 	rbtx4938_fpga_resource.name = "FPGA Registers";
213*4882a593Smuzhiyun 	rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR);
214*4882a593Smuzhiyun 	rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff;
215*4882a593Smuzhiyun 	rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
216*4882a593Smuzhiyun 	if (request_resource(&txx9_ce_res[2], &rbtx4938_fpga_resource))
217*4882a593Smuzhiyun 		pr_err("request resource for fpga failed\n");
218*4882a593Smuzhiyun 
219*4882a593Smuzhiyun 	_machine_restart = rbtx4938_machine_restart;
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun 	writeb(0xff, rbtx4938_led_addr);
222*4882a593Smuzhiyun 	pr_info("RBTX4938 --- FPGA(Rev %02x) DIPSW:%02x,%02x\n",
223*4882a593Smuzhiyun 		readb(rbtx4938_fpga_rev_addr),
224*4882a593Smuzhiyun 		readb(rbtx4938_dipsw_addr), readb(rbtx4938_bdipsw_addr));
225*4882a593Smuzhiyun }
226*4882a593Smuzhiyun 
rbtx4938_ne_init(void)227*4882a593Smuzhiyun static void __init rbtx4938_ne_init(void)
228*4882a593Smuzhiyun {
229*4882a593Smuzhiyun 	struct resource res[] = {
230*4882a593Smuzhiyun 		{
231*4882a593Smuzhiyun 			.start	= RBTX4938_RTL_8019_BASE,
232*4882a593Smuzhiyun 			.end	= RBTX4938_RTL_8019_BASE + 0x20 - 1,
233*4882a593Smuzhiyun 			.flags	= IORESOURCE_IO,
234*4882a593Smuzhiyun 		}, {
235*4882a593Smuzhiyun 			.start	= RBTX4938_RTL_8019_IRQ,
236*4882a593Smuzhiyun 			.flags	= IORESOURCE_IRQ,
237*4882a593Smuzhiyun 		}
238*4882a593Smuzhiyun 	};
239*4882a593Smuzhiyun 	platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res));
240*4882a593Smuzhiyun }
241*4882a593Smuzhiyun 
242*4882a593Smuzhiyun static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock);
243*4882a593Smuzhiyun 
rbtx4938_spi_gpio_set(struct gpio_chip * chip,unsigned int offset,int value)244*4882a593Smuzhiyun static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset,
245*4882a593Smuzhiyun 				  int value)
246*4882a593Smuzhiyun {
247*4882a593Smuzhiyun 	u8 val;
248*4882a593Smuzhiyun 	unsigned long flags;
249*4882a593Smuzhiyun 	spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags);
250*4882a593Smuzhiyun 	val = readb(rbtx4938_spics_addr);
251*4882a593Smuzhiyun 	if (value)
252*4882a593Smuzhiyun 		val |= 1 << offset;
253*4882a593Smuzhiyun 	else
254*4882a593Smuzhiyun 		val &= ~(1 << offset);
255*4882a593Smuzhiyun 	writeb(val, rbtx4938_spics_addr);
256*4882a593Smuzhiyun 	mmiowb();
257*4882a593Smuzhiyun 	spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags);
258*4882a593Smuzhiyun }
259*4882a593Smuzhiyun 
rbtx4938_spi_gpio_dir_out(struct gpio_chip * chip,unsigned int offset,int value)260*4882a593Smuzhiyun static int rbtx4938_spi_gpio_dir_out(struct gpio_chip *chip,
261*4882a593Smuzhiyun 				     unsigned int offset, int value)
262*4882a593Smuzhiyun {
263*4882a593Smuzhiyun 	rbtx4938_spi_gpio_set(chip, offset, value);
264*4882a593Smuzhiyun 	return 0;
265*4882a593Smuzhiyun }
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun static struct gpio_chip rbtx4938_spi_gpio_chip = {
268*4882a593Smuzhiyun 	.set = rbtx4938_spi_gpio_set,
269*4882a593Smuzhiyun 	.direction_output = rbtx4938_spi_gpio_dir_out,
270*4882a593Smuzhiyun 	.label = "RBTX4938-SPICS",
271*4882a593Smuzhiyun 	.base = 16,
272*4882a593Smuzhiyun 	.ngpio = 3,
273*4882a593Smuzhiyun };
274*4882a593Smuzhiyun 
rbtx4938_spi_init(void)275*4882a593Smuzhiyun static int __init rbtx4938_spi_init(void)
276*4882a593Smuzhiyun {
277*4882a593Smuzhiyun 	struct spi_board_info srtc_info = {
278*4882a593Smuzhiyun 		.modalias = "rtc-rs5c348",
279*4882a593Smuzhiyun 		.max_speed_hz = 1000000, /* 1.0Mbps @ Vdd 2.0V */
280*4882a593Smuzhiyun 		.bus_num = 0,
281*4882a593Smuzhiyun 		.chip_select = 16 + SRTC_CS,
282*4882a593Smuzhiyun 		/* Mode 1 (High-Active, Shift-Then-Sample), High Avtive CS  */
283*4882a593Smuzhiyun 		.mode = SPI_MODE_1 | SPI_CS_HIGH,
284*4882a593Smuzhiyun 	};
285*4882a593Smuzhiyun 	spi_register_board_info(&srtc_info, 1);
286*4882a593Smuzhiyun 	spi_eeprom_register(SPI_BUSNO, SEEPROM1_CS, 128);
287*4882a593Smuzhiyun 	spi_eeprom_register(SPI_BUSNO, 16 + SEEPROM2_CS, 128);
288*4882a593Smuzhiyun 	spi_eeprom_register(SPI_BUSNO, 16 + SEEPROM3_CS, 128);
289*4882a593Smuzhiyun 	gpio_request(16 + SRTC_CS, "rtc-rs5c348");
290*4882a593Smuzhiyun 	gpio_direction_output(16 + SRTC_CS, 0);
291*4882a593Smuzhiyun 	gpio_request(SEEPROM1_CS, "seeprom1");
292*4882a593Smuzhiyun 	gpio_direction_output(SEEPROM1_CS, 1);
293*4882a593Smuzhiyun 	gpio_request(16 + SEEPROM2_CS, "seeprom2");
294*4882a593Smuzhiyun 	gpio_direction_output(16 + SEEPROM2_CS, 1);
295*4882a593Smuzhiyun 	gpio_request(16 + SEEPROM3_CS, "seeprom3");
296*4882a593Smuzhiyun 	gpio_direction_output(16 + SEEPROM3_CS, 1);
297*4882a593Smuzhiyun 	tx4938_spi_init(SPI_BUSNO);
298*4882a593Smuzhiyun 	return 0;
299*4882a593Smuzhiyun }
300*4882a593Smuzhiyun 
rbtx4938_mtd_init(void)301*4882a593Smuzhiyun static void __init rbtx4938_mtd_init(void)
302*4882a593Smuzhiyun {
303*4882a593Smuzhiyun 	struct physmap_flash_data pdata = {
304*4882a593Smuzhiyun 		.width = 4,
305*4882a593Smuzhiyun 	};
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun 	switch (readb(rbtx4938_bdipsw_addr) & 7) {
308*4882a593Smuzhiyun 	case 0:
309*4882a593Smuzhiyun 		/* Boot */
310*4882a593Smuzhiyun 		txx9_physmap_flash_init(0, 0x1fc00000, 0x400000, &pdata);
311*4882a593Smuzhiyun 		/* System */
312*4882a593Smuzhiyun 		txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
313*4882a593Smuzhiyun 		break;
314*4882a593Smuzhiyun 	case 1:
315*4882a593Smuzhiyun 		/* System */
316*4882a593Smuzhiyun 		txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
317*4882a593Smuzhiyun 		/* Boot */
318*4882a593Smuzhiyun 		txx9_physmap_flash_init(1, 0x1ec00000, 0x400000, &pdata);
319*4882a593Smuzhiyun 		break;
320*4882a593Smuzhiyun 	case 2:
321*4882a593Smuzhiyun 		/* Ext */
322*4882a593Smuzhiyun 		txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
323*4882a593Smuzhiyun 		/* System */
324*4882a593Smuzhiyun 		txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
325*4882a593Smuzhiyun 		/* Boot */
326*4882a593Smuzhiyun 		txx9_physmap_flash_init(2, 0x1dc00000, 0x400000, &pdata);
327*4882a593Smuzhiyun 		break;
328*4882a593Smuzhiyun 	case 3:
329*4882a593Smuzhiyun 		/* Boot */
330*4882a593Smuzhiyun 		txx9_physmap_flash_init(1, 0x1bc00000, 0x400000, &pdata);
331*4882a593Smuzhiyun 		/* System */
332*4882a593Smuzhiyun 		txx9_physmap_flash_init(2, 0x1a000000, 0x1000000, &pdata);
333*4882a593Smuzhiyun 		break;
334*4882a593Smuzhiyun 	}
335*4882a593Smuzhiyun }
336*4882a593Smuzhiyun 
rbtx4938_arch_init(void)337*4882a593Smuzhiyun static void __init rbtx4938_arch_init(void)
338*4882a593Smuzhiyun {
339*4882a593Smuzhiyun 	txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
340*4882a593Smuzhiyun 	gpiochip_add_data(&rbtx4938_spi_gpio_chip, NULL);
341*4882a593Smuzhiyun 	rbtx4938_pci_setup();
342*4882a593Smuzhiyun 	rbtx4938_spi_init();
343*4882a593Smuzhiyun }
344*4882a593Smuzhiyun 
rbtx4938_device_init(void)345*4882a593Smuzhiyun static void __init rbtx4938_device_init(void)
346*4882a593Smuzhiyun {
347*4882a593Smuzhiyun 	rbtx4938_ethaddr_init();
348*4882a593Smuzhiyun 	rbtx4938_ne_init();
349*4882a593Smuzhiyun 	tx4938_wdt_init();
350*4882a593Smuzhiyun 	rbtx4938_mtd_init();
351*4882a593Smuzhiyun 	/* TC58DVM82A1FT: tDH=10ns, tWP=tRP=tREADID=35ns */
352*4882a593Smuzhiyun 	tx4938_ndfmc_init(10, 35);
353*4882a593Smuzhiyun 	tx4938_ata_init(RBTX4938_IRQ_IOC_ATA, 0, 1);
354*4882a593Smuzhiyun 	tx4938_dmac_init(0, 2);
355*4882a593Smuzhiyun 	tx4938_aclc_init();
356*4882a593Smuzhiyun 	platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
357*4882a593Smuzhiyun 	tx4938_sramc_init();
358*4882a593Smuzhiyun 	txx9_iocled_init(RBTX4938_LED_ADDR - IO_BASE, -1, 8, 1, "green", NULL);
359*4882a593Smuzhiyun }
360*4882a593Smuzhiyun 
361*4882a593Smuzhiyun struct txx9_board_vec rbtx4938_vec __initdata = {
362*4882a593Smuzhiyun 	.system = "Toshiba RBTX4938",
363*4882a593Smuzhiyun 	.prom_init = rbtx4938_prom_init,
364*4882a593Smuzhiyun 	.mem_setup = rbtx4938_mem_setup,
365*4882a593Smuzhiyun 	.irq_setup = rbtx4938_irq_setup,
366*4882a593Smuzhiyun 	.time_init = rbtx4938_time_init,
367*4882a593Smuzhiyun 	.device_init = rbtx4938_device_init,
368*4882a593Smuzhiyun 	.arch_init = rbtx4938_arch_init,
369*4882a593Smuzhiyun #ifdef CONFIG_PCI
370*4882a593Smuzhiyun 	.pci_map_irq = rbtx4938_pci_map_irq,
371*4882a593Smuzhiyun #endif
372*4882a593Smuzhiyun };
373