162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Toshiba rbtx4927 specific setup
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Author: MontaVista Software, Inc.
562306a36Sopenharmony_ci *	   source@mvista.com
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright 2001-2002 MontaVista Software Inc.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Copyright (C) 1996, 97, 2001, 04  Ralf Baechle (ralf@linux-mips.org)
1062306a36Sopenharmony_ci * Copyright (C) 2000 RidgeRun, Inc.
1162306a36Sopenharmony_ci * Author: RidgeRun, Inc.
1262306a36Sopenharmony_ci *   glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * Copyright 2001 MontaVista Software Inc.
1562306a36Sopenharmony_ci * Author: jsun@mvista.com or jsun@junsun.net
1662306a36Sopenharmony_ci *
1762306a36Sopenharmony_ci * Copyright 2002 MontaVista Software Inc.
1862306a36Sopenharmony_ci * Author: Michael Pruznick, michael_pruznick@mvista.com
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * Copyright (C) 2000-2001 Toshiba Corporation
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci * Copyright (C) 2004 MontaVista Software Inc.
2362306a36Sopenharmony_ci * Author: Manish Lachwani, mlachwani@mvista.com
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci *  This program is free software; you can redistribute it and/or modify it
2662306a36Sopenharmony_ci *  under the terms of the GNU General Public License as published by the
2762306a36Sopenharmony_ci *  Free Software Foundation; either version 2 of the License, or (at your
2862306a36Sopenharmony_ci *  option) any later version.
2962306a36Sopenharmony_ci *
3062306a36Sopenharmony_ci *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
3162306a36Sopenharmony_ci *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3262306a36Sopenharmony_ci *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
3362306a36Sopenharmony_ci *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
3462306a36Sopenharmony_ci *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
3562306a36Sopenharmony_ci *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
3662306a36Sopenharmony_ci *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3762306a36Sopenharmony_ci *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
3862306a36Sopenharmony_ci *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
3962306a36Sopenharmony_ci *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4062306a36Sopenharmony_ci *
4162306a36Sopenharmony_ci *  You should have received a copy of the GNU General Public License along
4262306a36Sopenharmony_ci *  with this program; if not, write to the Free Software Foundation, Inc.,
4362306a36Sopenharmony_ci *  675 Mass Ave, Cambridge, MA 02139, USA.
4462306a36Sopenharmony_ci */
4562306a36Sopenharmony_ci#include <linux/init.h>
4662306a36Sopenharmony_ci#include <linux/kernel.h>
4762306a36Sopenharmony_ci#include <linux/types.h>
4862306a36Sopenharmony_ci#include <linux/ioport.h>
4962306a36Sopenharmony_ci#include <linux/platform_device.h>
5062306a36Sopenharmony_ci#include <linux/delay.h>
5162306a36Sopenharmony_ci#include <linux/gpio.h>
5262306a36Sopenharmony_ci#include <linux/leds.h>
5362306a36Sopenharmony_ci#include <asm/io.h>
5462306a36Sopenharmony_ci#include <asm/reboot.h>
5562306a36Sopenharmony_ci#include <asm/txx9pio.h>
5662306a36Sopenharmony_ci#include <asm/txx9/generic.h>
5762306a36Sopenharmony_ci#include <asm/txx9/pci.h>
5862306a36Sopenharmony_ci#include <asm/txx9/rbtx4927.h>
5962306a36Sopenharmony_ci#include <asm/txx9/tx4938.h>	/* for TX4937 */
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#ifdef CONFIG_PCI
6262306a36Sopenharmony_cistatic void __init tx4927_pci_setup(void)
6362306a36Sopenharmony_ci{
6462306a36Sopenharmony_ci	int extarb = !(__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCIARB);
6562306a36Sopenharmony_ci	struct pci_controller *c = &txx9_primary_pcic;
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	register_pci_controller(c);
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci	if (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66)
7062306a36Sopenharmony_ci		txx9_pci_option =
7162306a36Sopenharmony_ci			(txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
7262306a36Sopenharmony_ci			TXX9_PCI_OPT_CLK_66; /* already configured */
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci	/* Reset PCI Bus */
7562306a36Sopenharmony_ci	writeb(1, rbtx4927_pcireset_addr);
7662306a36Sopenharmony_ci	/* Reset PCIC */
7762306a36Sopenharmony_ci	txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
7862306a36Sopenharmony_ci	if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
7962306a36Sopenharmony_ci	    TXX9_PCI_OPT_CLK_66)
8062306a36Sopenharmony_ci		tx4927_pciclk66_setup();
8162306a36Sopenharmony_ci	mdelay(10);
8262306a36Sopenharmony_ci	/* clear PCIC reset */
8362306a36Sopenharmony_ci	txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
8462306a36Sopenharmony_ci	writeb(0, rbtx4927_pcireset_addr);
8562306a36Sopenharmony_ci	iob();
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	tx4927_report_pciclk();
8862306a36Sopenharmony_ci	tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
8962306a36Sopenharmony_ci	if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
9062306a36Sopenharmony_ci	    TXX9_PCI_OPT_CLK_AUTO &&
9162306a36Sopenharmony_ci	    txx9_pci66_check(c, 0, 0)) {
9262306a36Sopenharmony_ci		/* Reset PCI Bus */
9362306a36Sopenharmony_ci		writeb(1, rbtx4927_pcireset_addr);
9462306a36Sopenharmony_ci		/* Reset PCIC */
9562306a36Sopenharmony_ci		txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
9662306a36Sopenharmony_ci		tx4927_pciclk66_setup();
9762306a36Sopenharmony_ci		mdelay(10);
9862306a36Sopenharmony_ci		/* clear PCIC reset */
9962306a36Sopenharmony_ci		txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
10062306a36Sopenharmony_ci		writeb(0, rbtx4927_pcireset_addr);
10162306a36Sopenharmony_ci		iob();
10262306a36Sopenharmony_ci		/* Reinitialize PCIC */
10362306a36Sopenharmony_ci		tx4927_report_pciclk();
10462306a36Sopenharmony_ci		tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
10562306a36Sopenharmony_ci	}
10662306a36Sopenharmony_ci	tx4927_setup_pcierr_irq();
10762306a36Sopenharmony_ci}
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_cistatic void __init tx4937_pci_setup(void)
11062306a36Sopenharmony_ci{
11162306a36Sopenharmony_ci	int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB);
11262306a36Sopenharmony_ci	struct pci_controller *c = &txx9_primary_pcic;
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci	register_pci_controller(c);
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci	if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66)
11762306a36Sopenharmony_ci		txx9_pci_option =
11862306a36Sopenharmony_ci			(txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
11962306a36Sopenharmony_ci			TXX9_PCI_OPT_CLK_66; /* already configured */
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci	/* Reset PCI Bus */
12262306a36Sopenharmony_ci	writeb(1, rbtx4927_pcireset_addr);
12362306a36Sopenharmony_ci	/* Reset PCIC */
12462306a36Sopenharmony_ci	txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
12562306a36Sopenharmony_ci	if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
12662306a36Sopenharmony_ci	    TXX9_PCI_OPT_CLK_66)
12762306a36Sopenharmony_ci		tx4938_pciclk66_setup();
12862306a36Sopenharmony_ci	mdelay(10);
12962306a36Sopenharmony_ci	/* clear PCIC reset */
13062306a36Sopenharmony_ci	txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
13162306a36Sopenharmony_ci	writeb(0, rbtx4927_pcireset_addr);
13262306a36Sopenharmony_ci	iob();
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci	tx4938_report_pciclk();
13562306a36Sopenharmony_ci	tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
13662306a36Sopenharmony_ci	if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
13762306a36Sopenharmony_ci	    TXX9_PCI_OPT_CLK_AUTO &&
13862306a36Sopenharmony_ci	    txx9_pci66_check(c, 0, 0)) {
13962306a36Sopenharmony_ci		/* Reset PCI Bus */
14062306a36Sopenharmony_ci		writeb(1, rbtx4927_pcireset_addr);
14162306a36Sopenharmony_ci		/* Reset PCIC */
14262306a36Sopenharmony_ci		txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
14362306a36Sopenharmony_ci		tx4938_pciclk66_setup();
14462306a36Sopenharmony_ci		mdelay(10);
14562306a36Sopenharmony_ci		/* clear PCIC reset */
14662306a36Sopenharmony_ci		txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
14762306a36Sopenharmony_ci		writeb(0, rbtx4927_pcireset_addr);
14862306a36Sopenharmony_ci		iob();
14962306a36Sopenharmony_ci		/* Reinitialize PCIC */
15062306a36Sopenharmony_ci		tx4938_report_pciclk();
15162306a36Sopenharmony_ci		tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
15262306a36Sopenharmony_ci	}
15362306a36Sopenharmony_ci	tx4938_setup_pcierr_irq();
15462306a36Sopenharmony_ci}
15562306a36Sopenharmony_ci#else
15662306a36Sopenharmony_cistatic inline void tx4927_pci_setup(void) {}
15762306a36Sopenharmony_cistatic inline void tx4937_pci_setup(void) {}
15862306a36Sopenharmony_ci#endif /* CONFIG_PCI */
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_cistatic void __init rbtx4927_gpio_init(void)
16162306a36Sopenharmony_ci{
16262306a36Sopenharmony_ci	/* TX4927-SIO DTR on (PIO[15]) */
16362306a36Sopenharmony_ci	gpio_request(15, "sio-dtr");
16462306a36Sopenharmony_ci	gpio_direction_output(15, 1);
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci	tx4927_sio_init(0, 0);
16762306a36Sopenharmony_ci}
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_cistatic void __init rbtx4927_arch_init(void)
17062306a36Sopenharmony_ci{
17162306a36Sopenharmony_ci	txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO);
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci	rbtx4927_gpio_init();
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci	tx4927_pci_setup();
17662306a36Sopenharmony_ci}
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_cistatic void __init rbtx4937_arch_init(void)
17962306a36Sopenharmony_ci{
18062306a36Sopenharmony_ci	txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci	rbtx4927_gpio_init();
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci	tx4937_pci_setup();
18562306a36Sopenharmony_ci}
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_cistatic void toshiba_rbtx4927_restart(char *command)
18862306a36Sopenharmony_ci{
18962306a36Sopenharmony_ci	/* enable the s/w reset register */
19062306a36Sopenharmony_ci	writeb(1, rbtx4927_softresetlock_addr);
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci	/* wait for enable to be seen */
19362306a36Sopenharmony_ci	while (!(readb(rbtx4927_softresetlock_addr) & 1))
19462306a36Sopenharmony_ci		;
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci	/* do a s/w reset */
19762306a36Sopenharmony_ci	writeb(1, rbtx4927_softreset_addr);
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci	/* fallback */
20062306a36Sopenharmony_ci	(*_machine_halt)();
20162306a36Sopenharmony_ci}
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_cistatic void __init rbtx4927_clock_init(void);
20462306a36Sopenharmony_cistatic void __init rbtx4937_clock_init(void);
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_cistatic void __init rbtx4927_mem_setup(void)
20762306a36Sopenharmony_ci{
20862306a36Sopenharmony_ci	if (TX4927_REV_PCODE() == 0x4927) {
20962306a36Sopenharmony_ci		rbtx4927_clock_init();
21062306a36Sopenharmony_ci		tx4927_setup();
21162306a36Sopenharmony_ci	} else {
21262306a36Sopenharmony_ci		rbtx4937_clock_init();
21362306a36Sopenharmony_ci		tx4938_setup();
21462306a36Sopenharmony_ci	}
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci	_machine_restart = toshiba_rbtx4927_restart;
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci#ifdef CONFIG_PCI
21962306a36Sopenharmony_ci	txx9_alloc_pci_controller(&txx9_primary_pcic,
22062306a36Sopenharmony_ci				  RBTX4927_PCIMEM, RBTX4927_PCIMEM_SIZE,
22162306a36Sopenharmony_ci				  RBTX4927_PCIIO, RBTX4927_PCIIO_SIZE);
22262306a36Sopenharmony_ci	txx9_board_pcibios_setup = tx4927_pcibios_setup;
22362306a36Sopenharmony_ci#else
22462306a36Sopenharmony_ci	set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET);
22562306a36Sopenharmony_ci#endif
22662306a36Sopenharmony_ci}
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_cistatic void __init rbtx4927_clock_init(void)
22962306a36Sopenharmony_ci{
23062306a36Sopenharmony_ci	/*
23162306a36Sopenharmony_ci	 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
23262306a36Sopenharmony_ci	 *
23362306a36Sopenharmony_ci	 * For TX4927:
23462306a36Sopenharmony_ci	 * PCIDIVMODE[12:11]'s initial value is given by S9[4:3] (ON:0, OFF:1).
23562306a36Sopenharmony_ci	 * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
23662306a36Sopenharmony_ci	 * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
23762306a36Sopenharmony_ci	 * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
23862306a36Sopenharmony_ci	 * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
23962306a36Sopenharmony_ci	 * i.e. S9[3]: ON (83MHz), OFF (100MHz)
24062306a36Sopenharmony_ci	 */
24162306a36Sopenharmony_ci	switch ((unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg) &
24262306a36Sopenharmony_ci		TX4927_CCFG_PCIDIVMODE_MASK) {
24362306a36Sopenharmony_ci	case TX4927_CCFG_PCIDIVMODE_2_5:
24462306a36Sopenharmony_ci	case TX4927_CCFG_PCIDIVMODE_5:
24562306a36Sopenharmony_ci		txx9_cpu_clock = 166666666;	/* 166MHz */
24662306a36Sopenharmony_ci		break;
24762306a36Sopenharmony_ci	default:
24862306a36Sopenharmony_ci		txx9_cpu_clock = 200000000;	/* 200MHz */
24962306a36Sopenharmony_ci	}
25062306a36Sopenharmony_ci}
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_cistatic void __init rbtx4937_clock_init(void)
25362306a36Sopenharmony_ci{
25462306a36Sopenharmony_ci	/*
25562306a36Sopenharmony_ci	 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
25662306a36Sopenharmony_ci	 *
25762306a36Sopenharmony_ci	 * For TX4937:
25862306a36Sopenharmony_ci	 * PCIDIVMODE[12:11]'s initial value is given by S1[5:4] (ON:0, OFF:1)
25962306a36Sopenharmony_ci	 * PCIDIVMODE[10] is 0.
26062306a36Sopenharmony_ci	 * CPU 266MHz: PCI 33MHz : PCIDIVMODE: 000 (1/8)
26162306a36Sopenharmony_ci	 * CPU 266MHz: PCI 66MHz : PCIDIVMODE: 001 (1/4)
26262306a36Sopenharmony_ci	 * CPU 300MHz: PCI 33MHz : PCIDIVMODE: 010 (1/9)
26362306a36Sopenharmony_ci	 * CPU 300MHz: PCI 66MHz : PCIDIVMODE: 011 (1/4.5)
26462306a36Sopenharmony_ci	 * CPU 333MHz: PCI 33MHz : PCIDIVMODE: 100 (1/10)
26562306a36Sopenharmony_ci	 * CPU 333MHz: PCI 66MHz : PCIDIVMODE: 101 (1/5)
26662306a36Sopenharmony_ci	 */
26762306a36Sopenharmony_ci	switch ((unsigned long)__raw_readq(&tx4938_ccfgptr->ccfg) &
26862306a36Sopenharmony_ci		TX4938_CCFG_PCIDIVMODE_MASK) {
26962306a36Sopenharmony_ci	case TX4938_CCFG_PCIDIVMODE_8:
27062306a36Sopenharmony_ci	case TX4938_CCFG_PCIDIVMODE_4:
27162306a36Sopenharmony_ci		txx9_cpu_clock = 266666666;	/* 266MHz */
27262306a36Sopenharmony_ci		break;
27362306a36Sopenharmony_ci	case TX4938_CCFG_PCIDIVMODE_9:
27462306a36Sopenharmony_ci	case TX4938_CCFG_PCIDIVMODE_4_5:
27562306a36Sopenharmony_ci		txx9_cpu_clock = 300000000;	/* 300MHz */
27662306a36Sopenharmony_ci		break;
27762306a36Sopenharmony_ci	default:
27862306a36Sopenharmony_ci		txx9_cpu_clock = 333333333;	/* 333MHz */
27962306a36Sopenharmony_ci	}
28062306a36Sopenharmony_ci}
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_cistatic void __init rbtx4927_time_init(void)
28362306a36Sopenharmony_ci{
28462306a36Sopenharmony_ci	tx4927_time_init(0);
28562306a36Sopenharmony_ci}
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_cistatic void __init toshiba_rbtx4927_rtc_init(void)
28862306a36Sopenharmony_ci{
28962306a36Sopenharmony_ci	struct resource res = {
29062306a36Sopenharmony_ci		.start	= RBTX4927_BRAMRTC_BASE - IO_BASE,
29162306a36Sopenharmony_ci		.end	= RBTX4927_BRAMRTC_BASE - IO_BASE + 0x800 - 1,
29262306a36Sopenharmony_ci		.flags	= IORESOURCE_MEM,
29362306a36Sopenharmony_ci	};
29462306a36Sopenharmony_ci	platform_device_register_simple("rtc-ds1742", -1, &res, 1);
29562306a36Sopenharmony_ci}
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_cistatic void __init rbtx4927_ne_init(void)
29862306a36Sopenharmony_ci{
29962306a36Sopenharmony_ci	struct resource res[] = {
30062306a36Sopenharmony_ci		{
30162306a36Sopenharmony_ci			.start	= RBTX4927_RTL_8019_BASE,
30262306a36Sopenharmony_ci			.end	= RBTX4927_RTL_8019_BASE + 0x20 - 1,
30362306a36Sopenharmony_ci			.flags	= IORESOURCE_IO,
30462306a36Sopenharmony_ci		}, {
30562306a36Sopenharmony_ci			.start	= RBTX4927_RTL_8019_IRQ,
30662306a36Sopenharmony_ci			.flags	= IORESOURCE_IRQ,
30762306a36Sopenharmony_ci		}
30862306a36Sopenharmony_ci	};
30962306a36Sopenharmony_ci	platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res));
31062306a36Sopenharmony_ci}
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_cistatic void __init rbtx4927_mtd_init(void)
31362306a36Sopenharmony_ci{
31462306a36Sopenharmony_ci	int i;
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ci	for (i = 0; i < 2; i++)
31762306a36Sopenharmony_ci		tx4927_mtd_init(i);
31862306a36Sopenharmony_ci}
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_cistatic void __init rbtx4927_gpioled_init(void)
32162306a36Sopenharmony_ci{
32262306a36Sopenharmony_ci	static const struct gpio_led leds[] = {
32362306a36Sopenharmony_ci		{ .name = "gpioled:green:0", .gpio = 0, .active_low = 1, },
32462306a36Sopenharmony_ci		{ .name = "gpioled:green:1", .gpio = 1, .active_low = 1, },
32562306a36Sopenharmony_ci	};
32662306a36Sopenharmony_ci	static struct gpio_led_platform_data pdata = {
32762306a36Sopenharmony_ci		.num_leds = ARRAY_SIZE(leds),
32862306a36Sopenharmony_ci		.leds = leds,
32962306a36Sopenharmony_ci	};
33062306a36Sopenharmony_ci	struct platform_device *pdev = platform_device_alloc("leds-gpio", 0);
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci	if (!pdev)
33362306a36Sopenharmony_ci		return;
33462306a36Sopenharmony_ci	pdev->dev.platform_data = &pdata;
33562306a36Sopenharmony_ci	if (platform_device_add(pdev))
33662306a36Sopenharmony_ci		platform_device_put(pdev);
33762306a36Sopenharmony_ci}
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_cistatic void __init rbtx4927_device_init(void)
34062306a36Sopenharmony_ci{
34162306a36Sopenharmony_ci	toshiba_rbtx4927_rtc_init();
34262306a36Sopenharmony_ci	rbtx4927_ne_init();
34362306a36Sopenharmony_ci	tx4927_wdt_init();
34462306a36Sopenharmony_ci	rbtx4927_mtd_init();
34562306a36Sopenharmony_ci	if (TX4927_REV_PCODE() == 0x4927) {
34662306a36Sopenharmony_ci		tx4927_dmac_init(2);
34762306a36Sopenharmony_ci		tx4927_aclc_init(0, 1);
34862306a36Sopenharmony_ci	} else {
34962306a36Sopenharmony_ci		tx4938_dmac_init(0, 2);
35062306a36Sopenharmony_ci		tx4938_aclc_init();
35162306a36Sopenharmony_ci	}
35262306a36Sopenharmony_ci	platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
35362306a36Sopenharmony_ci	txx9_iocled_init(RBTX4927_LED_ADDR - IO_BASE, -1, 3, 1, "green", NULL);
35462306a36Sopenharmony_ci	rbtx4927_gpioled_init();
35562306a36Sopenharmony_ci}
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_cistruct txx9_board_vec rbtx4927_vec __initdata = {
35862306a36Sopenharmony_ci	.system = "Toshiba RBTX4927",
35962306a36Sopenharmony_ci	.prom_init = rbtx4927_prom_init,
36062306a36Sopenharmony_ci	.mem_setup = rbtx4927_mem_setup,
36162306a36Sopenharmony_ci	.irq_setup = rbtx4927_irq_setup,
36262306a36Sopenharmony_ci	.time_init = rbtx4927_time_init,
36362306a36Sopenharmony_ci	.device_init = rbtx4927_device_init,
36462306a36Sopenharmony_ci	.arch_init = rbtx4927_arch_init,
36562306a36Sopenharmony_ci#ifdef CONFIG_PCI
36662306a36Sopenharmony_ci	.pci_map_irq = rbtx4927_pci_map_irq,
36762306a36Sopenharmony_ci#endif
36862306a36Sopenharmony_ci};
36962306a36Sopenharmony_cistruct txx9_board_vec rbtx4937_vec __initdata = {
37062306a36Sopenharmony_ci	.system = "Toshiba RBTX4937",
37162306a36Sopenharmony_ci	.prom_init = rbtx4927_prom_init,
37262306a36Sopenharmony_ci	.mem_setup = rbtx4927_mem_setup,
37362306a36Sopenharmony_ci	.irq_setup = rbtx4927_irq_setup,
37462306a36Sopenharmony_ci	.time_init = rbtx4927_time_init,
37562306a36Sopenharmony_ci	.device_init = rbtx4927_device_init,
37662306a36Sopenharmony_ci	.arch_init = rbtx4937_arch_init,
37762306a36Sopenharmony_ci#ifdef CONFIG_PCI
37862306a36Sopenharmony_ci	.pci_map_irq = rbtx4927_pci_map_irq,
37962306a36Sopenharmony_ci#endif
38062306a36Sopenharmony_ci};
381