| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * BRIEF MODULE DESCRIPTION | 
 | 3 |  *	MyCable XXS1500 board support | 
 | 4 |  * | 
 | 5 |  * Copyright 2003, 2008 MontaVista Software Inc. | 
 | 6 |  * Author: MontaVista Software, Inc. <source@mvista.com> | 
 | 7 |  * | 
 | 8 |  * This program is free software; you can redistribute it and/or modify | 
 | 9 |  * it under the terms of the GNU General Public License as published by | 
 | 10 |  * the Free Software Foundation; either version 2 of the License, or | 
 | 11 |  * (at your option) any later version. | 
 | 12 |  * | 
 | 13 |  * This program is distributed in the hope that it will be useful, | 
 | 14 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 15 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 16 |  * GNU General Public License for more details. | 
 | 17 |  * | 
 | 18 |  * You should have received a copy of the GNU General Public License | 
 | 19 |  * along with this program; if not, write to the Free Software | 
 | 20 |  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | 
 | 21 |  */ | 
 | 22 |  | 
 | 23 | #include <linux/kernel.h> | 
 | 24 | #include <linux/init.h> | 
 | 25 | #include <linux/interrupt.h> | 
 | 26 | #include <linux/platform_device.h> | 
 | 27 | #include <linux/gpio.h> | 
 | 28 | #include <linux/delay.h> | 
 | 29 | #include <linux/pm.h> | 
 | 30 | #include <asm/bootinfo.h> | 
 | 31 | #include <asm/reboot.h> | 
 | 32 | #include <asm/setup.h> | 
 | 33 | #include <asm/mach-au1x00/au1000.h> | 
 | 34 | #include <prom.h> | 
 | 35 |  | 
 | 36 | const char *get_system_type(void) | 
 | 37 | { | 
 | 38 | 	return "XXS1500"; | 
 | 39 | } | 
 | 40 |  | 
 | 41 | void __init prom_init(void) | 
 | 42 | { | 
 | 43 | 	unsigned char *memsize_str; | 
 | 44 | 	unsigned long memsize; | 
 | 45 |  | 
 | 46 | 	prom_argc = fw_arg0; | 
 | 47 | 	prom_argv = (char **)fw_arg1; | 
 | 48 | 	prom_envp = (char **)fw_arg2; | 
 | 49 |  | 
 | 50 | 	prom_init_cmdline(); | 
 | 51 |  | 
 | 52 | 	memsize_str = prom_getenv("memsize"); | 
 | 53 | 	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize)) | 
 | 54 | 		memsize = 0x04000000; | 
 | 55 |  | 
 | 56 | 	add_memory_region(0, memsize, BOOT_MEM_RAM); | 
 | 57 | } | 
 | 58 |  | 
 | 59 | void prom_putchar(char c) | 
 | 60 | { | 
 | 61 | 	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c); | 
 | 62 | } | 
 | 63 |  | 
 | 64 | static void xxs1500_reset(char *c) | 
 | 65 | { | 
 | 66 | 	/* Jump to the reset vector */ | 
 | 67 | 	__asm__ __volatile__("jr\t%0" : : "r"(0xbfc00000)); | 
 | 68 | } | 
 | 69 |  | 
 | 70 | static void xxs1500_power_off(void) | 
 | 71 | { | 
 | 72 | 	while (1) | 
 | 73 | 		asm volatile ( | 
 | 74 | 		"	.set	mips32					\n" | 
 | 75 | 		"	wait						\n" | 
 | 76 | 		"	.set	mips0					\n"); | 
 | 77 | } | 
 | 78 |  | 
 | 79 | void __init board_setup(void) | 
 | 80 | { | 
 | 81 | 	u32 pin_func; | 
 | 82 |  | 
 | 83 | 	pm_power_off = xxs1500_power_off; | 
 | 84 | 	_machine_halt = xxs1500_power_off; | 
 | 85 | 	_machine_restart = xxs1500_reset; | 
 | 86 |  | 
 | 87 | 	alchemy_gpio1_input_enable(); | 
 | 88 | 	alchemy_gpio2_enable(); | 
 | 89 |  | 
 | 90 | 	/* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */ | 
 | 91 | 	pin_func  = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PF_UR3; | 
 | 92 | 	pin_func |= SYS_PF_UR3; | 
 | 93 | 	alchemy_wrsys(pin_func, AU1000_SYS_PINFUNC); | 
 | 94 |  | 
 | 95 | 	/* Enable UART */ | 
 | 96 | 	alchemy_uart_enable(AU1000_UART3_PHYS_ADDR); | 
 | 97 | 	/* Enable DTR (MCR bit 0) = USB power up */ | 
 | 98 | 	__raw_writel(1, (void __iomem *)KSEG1ADDR(AU1000_UART3_PHYS_ADDR + 0x18)); | 
 | 99 | 	wmb(); | 
 | 100 | } | 
 | 101 |  | 
 | 102 | /******************************************************************************/ | 
 | 103 |  | 
 | 104 | static struct resource xxs1500_pcmcia_res[] = { | 
 | 105 | 	{ | 
 | 106 | 		.name	= "pcmcia-io", | 
 | 107 | 		.flags	= IORESOURCE_MEM, | 
 | 108 | 		.start	= AU1000_PCMCIA_IO_PHYS_ADDR, | 
 | 109 | 		.end	= AU1000_PCMCIA_IO_PHYS_ADDR + 0x000400000 - 1, | 
 | 110 | 	}, | 
 | 111 | 	{ | 
 | 112 | 		.name	= "pcmcia-attr", | 
 | 113 | 		.flags	= IORESOURCE_MEM, | 
 | 114 | 		.start	= AU1000_PCMCIA_ATTR_PHYS_ADDR, | 
 | 115 | 		.end	= AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1, | 
 | 116 | 	}, | 
 | 117 | 	{ | 
 | 118 | 		.name	= "pcmcia-mem", | 
 | 119 | 		.flags	= IORESOURCE_MEM, | 
 | 120 | 		.start	= AU1000_PCMCIA_MEM_PHYS_ADDR, | 
 | 121 | 		.end	= AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1, | 
 | 122 | 	}, | 
 | 123 | }; | 
 | 124 |  | 
 | 125 | static struct platform_device xxs1500_pcmcia_dev = { | 
 | 126 | 	.name		= "xxs1500_pcmcia", | 
 | 127 | 	.id		= -1, | 
 | 128 | 	.num_resources	= ARRAY_SIZE(xxs1500_pcmcia_res), | 
 | 129 | 	.resource	= xxs1500_pcmcia_res, | 
 | 130 | }; | 
 | 131 |  | 
 | 132 | static struct platform_device *xxs1500_devs[] __initdata = { | 
 | 133 | 	&xxs1500_pcmcia_dev, | 
 | 134 | }; | 
 | 135 |  | 
 | 136 | static int __init xxs1500_dev_init(void) | 
 | 137 | { | 
 | 138 | 	irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_HIGH); | 
 | 139 | 	irq_set_irq_type(AU1500_GPIO201_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 140 | 	irq_set_irq_type(AU1500_GPIO202_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 141 | 	irq_set_irq_type(AU1500_GPIO203_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 142 | 	irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 143 | 	irq_set_irq_type(AU1500_GPIO207_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 144 |  | 
 | 145 | 	irq_set_irq_type(AU1500_GPIO0_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 146 | 	irq_set_irq_type(AU1500_GPIO1_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 147 | 	irq_set_irq_type(AU1500_GPIO2_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 148 | 	irq_set_irq_type(AU1500_GPIO3_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 149 | 	irq_set_irq_type(AU1500_GPIO4_INT, IRQ_TYPE_LEVEL_LOW); /* CF irq */ | 
 | 150 | 	irq_set_irq_type(AU1500_GPIO5_INT, IRQ_TYPE_LEVEL_LOW); | 
 | 151 |  | 
 | 152 | 	return platform_add_devices(xxs1500_devs, | 
 | 153 | 				    ARRAY_SIZE(xxs1500_devs)); | 
 | 154 | } | 
 | 155 | device_initcall(xxs1500_dev_init); |