| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 1 | /* | 
 | 2 |  *  linux/arch/arm/mach-pxa/viper.c | 
 | 3 |  * | 
 | 4 |  *  Support for the Arcom VIPER SBC. | 
 | 5 |  * | 
 | 6 |  *  Author:	Ian Campbell | 
 | 7 |  *  Created:    Feb 03, 2003 | 
 | 8 |  *  Copyright:  Arcom Control Systems | 
 | 9 |  * | 
 | 10 |  *  Maintained by Marc Zyngier <maz@misterjones.org> | 
 | 11 |  *                             <marc.zyngier@altran.com> | 
 | 12 |  * | 
 | 13 |  * Based on lubbock.c: | 
 | 14 |  *  Author:	Nicolas Pitre | 
 | 15 |  *  Created:	Jun 15, 2001 | 
 | 16 |  *  Copyright:	MontaVista Software Inc. | 
 | 17 |  * | 
 | 18 |  *  This program is free software; you can redistribute it and/or modify | 
 | 19 |  *  it under the terms of the GNU General Public License version 2 as | 
 | 20 |  *  published by the Free Software Foundation. | 
 | 21 |  */ | 
 | 22 |  | 
 | 23 | #include <linux/types.h> | 
 | 24 | #include <linux/memory.h> | 
 | 25 | #include <linux/cpu.h> | 
 | 26 | #include <linux/cpufreq.h> | 
 | 27 | #include <linux/delay.h> | 
 | 28 | #include <linux/fs.h> | 
 | 29 | #include <linux/init.h> | 
 | 30 | #include <linux/interrupt.h> | 
 | 31 | #include <linux/major.h> | 
 | 32 | #include <linux/module.h> | 
 | 33 | #include <linux/pm.h> | 
 | 34 | #include <linux/sched.h> | 
 | 35 | #include <linux/gpio.h> | 
 | 36 | #include <linux/i2c-gpio.h> | 
 | 37 | #include <linux/serial_8250.h> | 
 | 38 | #include <linux/smc91x.h> | 
 | 39 | #include <linux/pwm_backlight.h> | 
 | 40 | #include <linux/usb/isp116x.h> | 
 | 41 | #include <linux/mtd/mtd.h> | 
 | 42 | #include <linux/mtd/partitions.h> | 
 | 43 | #include <linux/mtd/physmap.h> | 
 | 44 |  | 
| Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 45 | #include <mach/pxa25x.h> | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 46 | #include <mach/audio.h> | 
 | 47 | #include <mach/pxafb.h> | 
| Eric Miao | f0a8370 | 2009-04-13 15:03:11 +0800 | [diff] [blame] | 48 | #include <plat/i2c.h> | 
| Ricardo Martins | 776abac | 2009-05-11 00:15:08 +0100 | [diff] [blame] | 49 | #include <mach/regs-uart.h> | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 50 | #include <mach/viper.h> | 
 | 51 |  | 
 | 52 | #include <asm/setup.h> | 
 | 53 | #include <asm/mach-types.h> | 
 | 54 | #include <asm/irq.h> | 
 | 55 | #include <asm/sizes.h> | 
 | 56 |  | 
 | 57 | #include <asm/mach/arch.h> | 
 | 58 | #include <asm/mach/map.h> | 
 | 59 | #include <asm/mach/irq.h> | 
 | 60 |  | 
 | 61 | #include "generic.h" | 
 | 62 | #include "devices.h" | 
 | 63 |  | 
 | 64 | static unsigned int icr; | 
 | 65 |  | 
 | 66 | static void viper_icr_set_bit(unsigned int bit) | 
 | 67 | { | 
 | 68 | 	icr |= bit; | 
 | 69 | 	VIPER_ICR = icr; | 
 | 70 | } | 
 | 71 |  | 
 | 72 | static void viper_icr_clear_bit(unsigned int bit) | 
 | 73 | { | 
 | 74 | 	icr &= ~bit; | 
 | 75 | 	VIPER_ICR = icr; | 
 | 76 | } | 
 | 77 |  | 
 | 78 | /* This function is used from the pcmcia module to reset the CF */ | 
 | 79 | void viper_cf_rst(int state) | 
 | 80 | { | 
 | 81 | 	if (state) | 
 | 82 | 		viper_icr_set_bit(VIPER_ICR_CF_RST); | 
 | 83 | 	else | 
 | 84 | 		viper_icr_clear_bit(VIPER_ICR_CF_RST); | 
 | 85 | } | 
 | 86 | EXPORT_SYMBOL(viper_cf_rst); | 
 | 87 |  | 
 | 88 | /* | 
 | 89 |  * The CPLD version register was not present on VIPER boards prior to | 
 | 90 |  * v2i1. On v1 boards where the version register is not present we | 
 | 91 |  * will just read back the previous value from the databus. | 
 | 92 |  * | 
 | 93 |  * Therefore we do two reads. The first time we write 0 to the | 
 | 94 |  * (read-only) register before reading and the second time we write | 
 | 95 |  * 0xff first. If the two reads do not match or they read back as 0xff | 
 | 96 |  * or 0x00 then we have version 1 hardware. | 
 | 97 |  */ | 
 | 98 | static u8 viper_hw_version(void) | 
 | 99 | { | 
 | 100 | 	u8 v1, v2; | 
 | 101 | 	unsigned long flags; | 
 | 102 |  | 
 | 103 | 	local_irq_save(flags); | 
 | 104 |  | 
 | 105 | 	VIPER_VERSION = 0; | 
 | 106 | 	v1 = VIPER_VERSION; | 
 | 107 | 	VIPER_VERSION = 0xff; | 
 | 108 | 	v2 = VIPER_VERSION; | 
 | 109 |  | 
 | 110 | 	v1 = (v1 != v2 || v1 == 0xff) ? 0 : v1; | 
 | 111 |  | 
 | 112 | 	local_irq_restore(flags); | 
 | 113 | 	return v1; | 
 | 114 | } | 
 | 115 |  | 
 | 116 | /* CPU sysdev */ | 
 | 117 | static int viper_cpu_suspend(struct sys_device *sysdev, pm_message_t state) | 
 | 118 | { | 
 | 119 | 	viper_icr_set_bit(VIPER_ICR_R_DIS); | 
 | 120 | 	return 0; | 
 | 121 | } | 
 | 122 |  | 
 | 123 | static int viper_cpu_resume(struct sys_device *sysdev) | 
 | 124 | { | 
 | 125 | 	viper_icr_clear_bit(VIPER_ICR_R_DIS); | 
 | 126 | 	return 0; | 
 | 127 | } | 
 | 128 |  | 
 | 129 | static struct sysdev_driver viper_cpu_sysdev_driver = { | 
 | 130 | 	.suspend	= viper_cpu_suspend, | 
 | 131 | 	.resume		= viper_cpu_resume, | 
 | 132 | }; | 
 | 133 |  | 
 | 134 | static unsigned int current_voltage_divisor; | 
 | 135 |  | 
 | 136 | /* | 
 | 137 |  * If force is not true then step from existing to new divisor. If | 
 | 138 |  * force is true then jump straight to the new divisor. Stepping is | 
 | 139 |  * used because if the jump in voltage is too large, the VCC can dip | 
 | 140 |  * too low and the regulator cuts out. | 
 | 141 |  * | 
 | 142 |  * force can be used to initialize the divisor to a know state by | 
 | 143 |  * setting the value for the current clock speed, since we are already | 
 | 144 |  * running at that speed we know the voltage should be pretty close so | 
 | 145 |  * the jump won't be too large | 
 | 146 |  */ | 
 | 147 | static void viper_set_core_cpu_voltage(unsigned long khz, int force) | 
 | 148 | { | 
 | 149 | 	int i = 0; | 
 | 150 | 	unsigned int divisor = 0; | 
 | 151 | 	const char *v; | 
 | 152 |  | 
 | 153 | 	if (khz < 200000) { | 
 | 154 | 		v = "1.0"; divisor = 0xfff; | 
 | 155 | 	} else if (khz < 300000) { | 
 | 156 | 		v = "1.1"; divisor = 0xde5; | 
 | 157 | 	} else { | 
 | 158 | 		v = "1.3"; divisor = 0x325; | 
 | 159 | 	} | 
 | 160 |  | 
 | 161 | 	pr_debug("viper: setting CPU core voltage to %sV at %d.%03dMHz\n", | 
 | 162 | 		 v, (int)khz / 1000, (int)khz % 1000); | 
 | 163 |  | 
 | 164 | #define STEP 0x100 | 
 | 165 | 	do { | 
 | 166 | 		int step; | 
 | 167 |  | 
 | 168 | 		if (force) | 
 | 169 | 			step = divisor; | 
 | 170 | 		else if (current_voltage_divisor < divisor - STEP) | 
 | 171 | 			step = current_voltage_divisor + STEP; | 
 | 172 | 		else if (current_voltage_divisor > divisor + STEP) | 
 | 173 | 			step = current_voltage_divisor - STEP; | 
 | 174 | 		else | 
 | 175 | 			step = divisor; | 
 | 176 | 		force = 0; | 
 | 177 |  | 
 | 178 | 		gpio_set_value(VIPER_PSU_CLK_GPIO, 0); | 
 | 179 | 		gpio_set_value(VIPER_PSU_nCS_LD_GPIO, 0); | 
 | 180 |  | 
 | 181 | 		for (i = 1 << 11 ; i > 0 ; i >>= 1) { | 
 | 182 | 			udelay(1); | 
 | 183 |  | 
 | 184 | 			gpio_set_value(VIPER_PSU_DATA_GPIO, step & i); | 
 | 185 | 			udelay(1); | 
 | 186 |  | 
 | 187 | 			gpio_set_value(VIPER_PSU_CLK_GPIO, 1); | 
 | 188 | 			udelay(1); | 
 | 189 |  | 
 | 190 | 			gpio_set_value(VIPER_PSU_CLK_GPIO, 0); | 
 | 191 | 		} | 
 | 192 | 		udelay(1); | 
 | 193 |  | 
 | 194 | 		gpio_set_value(VIPER_PSU_nCS_LD_GPIO, 1); | 
 | 195 | 		udelay(1); | 
 | 196 |  | 
 | 197 | 		gpio_set_value(VIPER_PSU_nCS_LD_GPIO, 0); | 
 | 198 |  | 
 | 199 | 		current_voltage_divisor = step; | 
 | 200 | 	} while (current_voltage_divisor != divisor); | 
 | 201 | } | 
 | 202 |  | 
 | 203 | /* Interrupt handling */ | 
 | 204 | static unsigned long viper_irq_enabled_mask; | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 205 | static const int viper_isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, 9, 14, 15 }; | 
 | 206 | static const int viper_isa_irq_map[] = { | 
 | 207 | 	0,		/* ISA irq #0, invalid */ | 
 | 208 | 	0,		/* ISA irq #1, invalid */ | 
 | 209 | 	0,		/* ISA irq #2, invalid */ | 
 | 210 | 	1 << 0,		/* ISA irq #3 */ | 
 | 211 | 	1 << 1,		/* ISA irq #4 */ | 
 | 212 | 	1 << 2,		/* ISA irq #5 */ | 
 | 213 | 	1 << 3,		/* ISA irq #6 */ | 
 | 214 | 	1 << 4,		/* ISA irq #7 */ | 
 | 215 | 	0,		/* ISA irq #8, invalid */ | 
 | 216 | 	1 << 8,		/* ISA irq #9 */ | 
 | 217 | 	1 << 5,		/* ISA irq #10 */ | 
 | 218 | 	1 << 6,		/* ISA irq #11 */ | 
 | 219 | 	1 << 7,		/* ISA irq #12 */ | 
 | 220 | 	0,		/* ISA irq #13, invalid */ | 
 | 221 | 	1 << 9,		/* ISA irq #14 */ | 
 | 222 | 	1 << 10,	/* ISA irq #15 */ | 
 | 223 | }; | 
 | 224 |  | 
 | 225 | static inline int viper_irq_to_bitmask(unsigned int irq) | 
 | 226 | { | 
 | 227 | 	return viper_isa_irq_map[irq - PXA_ISA_IRQ(0)]; | 
 | 228 | } | 
 | 229 |  | 
 | 230 | static inline int viper_bit_to_irq(int bit) | 
 | 231 | { | 
 | 232 | 	return viper_isa_irqs[bit] + PXA_ISA_IRQ(0); | 
 | 233 | } | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 234 |  | 
 | 235 | static void viper_ack_irq(unsigned int irq) | 
 | 236 | { | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 237 | 	int viper_irq = viper_irq_to_bitmask(irq); | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 238 |  | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 239 | 	if (viper_irq & 0xff) | 
 | 240 | 		VIPER_LO_IRQ_STATUS = viper_irq; | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 241 | 	else | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 242 | 		VIPER_HI_IRQ_STATUS = (viper_irq >> 8); | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 243 | } | 
 | 244 |  | 
 | 245 | static void viper_mask_irq(unsigned int irq) | 
 | 246 | { | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 247 | 	viper_irq_enabled_mask &= ~(viper_irq_to_bitmask(irq)); | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 248 | } | 
 | 249 |  | 
 | 250 | static void viper_unmask_irq(unsigned int irq) | 
 | 251 | { | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 252 | 	viper_irq_enabled_mask |= viper_irq_to_bitmask(irq); | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 253 | } | 
 | 254 |  | 
 | 255 | static inline unsigned long viper_irq_pending(void) | 
 | 256 | { | 
 | 257 | 	return (VIPER_HI_IRQ_STATUS << 8 | VIPER_LO_IRQ_STATUS) & | 
 | 258 | 			viper_irq_enabled_mask; | 
 | 259 | } | 
 | 260 |  | 
 | 261 | static void viper_irq_handler(unsigned int irq, struct irq_desc *desc) | 
 | 262 | { | 
 | 263 | 	unsigned long pending; | 
 | 264 |  | 
 | 265 | 	pending = viper_irq_pending(); | 
 | 266 | 	do { | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 267 | 		/* we're in a chained irq handler, | 
 | 268 | 		 * so ack the interrupt by hand */ | 
 | 269 | 		GEDR(VIPER_CPLD_GPIO) = GPIO_bit(VIPER_CPLD_GPIO); | 
 | 270 |  | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 271 | 		if (likely(pending)) { | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 272 | 			irq = viper_bit_to_irq(__ffs(pending)); | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 273 | 			generic_handle_irq(irq); | 
 | 274 | 		} | 
 | 275 | 		pending = viper_irq_pending(); | 
 | 276 | 	} while (pending); | 
 | 277 | } | 
 | 278 |  | 
 | 279 | static struct irq_chip viper_irq_chip = { | 
 | 280 | 	.name	= "ISA", | 
 | 281 | 	.ack	= viper_ack_irq, | 
 | 282 | 	.mask	= viper_mask_irq, | 
 | 283 | 	.unmask	= viper_unmask_irq | 
 | 284 | }; | 
 | 285 |  | 
 | 286 | static void __init viper_init_irq(void) | 
 | 287 | { | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 288 | 	int level; | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 289 | 	int isa_irq; | 
 | 290 |  | 
 | 291 | 	pxa25x_init_irq(); | 
 | 292 |  | 
 | 293 | 	/* setup ISA IRQs */ | 
| Marc Zyngier | a9ff8f6 | 2008-10-15 12:54:05 +0100 | [diff] [blame] | 294 | 	for (level = 0; level < ARRAY_SIZE(viper_isa_irqs); level++) { | 
 | 295 | 		isa_irq = viper_bit_to_irq(level); | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 296 | 		set_irq_chip(isa_irq, &viper_irq_chip); | 
 | 297 | 		set_irq_handler(isa_irq, handle_edge_irq); | 
 | 298 | 		set_irq_flags(isa_irq, IRQF_VALID | IRQF_PROBE); | 
 | 299 | 	} | 
 | 300 |  | 
 | 301 | 	set_irq_chained_handler(gpio_to_irq(VIPER_CPLD_GPIO), | 
 | 302 | 				viper_irq_handler); | 
 | 303 | 	set_irq_type(gpio_to_irq(VIPER_CPLD_GPIO), IRQ_TYPE_EDGE_BOTH); | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 304 | } | 
 | 305 |  | 
 | 306 | /* Flat Panel */ | 
 | 307 | static struct pxafb_mode_info fb_mode_info[] = { | 
 | 308 | 	{ | 
 | 309 | 		.pixclock	= 157500, | 
 | 310 |  | 
 | 311 | 		.xres		= 320, | 
 | 312 | 		.yres		= 240, | 
 | 313 |  | 
 | 314 | 		.bpp		= 16, | 
 | 315 |  | 
 | 316 | 		.hsync_len	= 63, | 
 | 317 | 		.left_margin	= 7, | 
 | 318 | 		.right_margin	= 13, | 
 | 319 |  | 
 | 320 | 		.vsync_len	= 20, | 
 | 321 | 		.upper_margin	= 0, | 
 | 322 | 		.lower_margin	= 0, | 
 | 323 |  | 
 | 324 | 		.sync		= 0, | 
 | 325 | 	}, | 
 | 326 | }; | 
 | 327 |  | 
 | 328 | static struct pxafb_mach_info fb_info = { | 
 | 329 | 	.modes			= fb_mode_info, | 
 | 330 | 	.num_modes		= 1, | 
 | 331 | 	.lcd_conn		= LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | 
 | 332 | }; | 
 | 333 |  | 
 | 334 | static int viper_backlight_init(struct device *dev) | 
 | 335 | { | 
 | 336 | 	int ret; | 
 | 337 |  | 
 | 338 | 	/* GPIO9 and 10 control FB backlight. Initialise to off */ | 
 | 339 | 	ret = gpio_request(VIPER_BCKLIGHT_EN_GPIO, "Backlight"); | 
 | 340 | 	if (ret) | 
 | 341 | 		goto err_request_bckl; | 
 | 342 |  | 
 | 343 | 	ret = gpio_request(VIPER_LCD_EN_GPIO, "LCD"); | 
 | 344 | 	if (ret) | 
 | 345 | 		goto err_request_lcd; | 
 | 346 |  | 
 | 347 | 	ret = gpio_direction_output(VIPER_BCKLIGHT_EN_GPIO, 0); | 
 | 348 | 	if (ret) | 
 | 349 | 		goto err_dir; | 
 | 350 |  | 
 | 351 | 	ret = gpio_direction_output(VIPER_LCD_EN_GPIO, 0); | 
 | 352 | 	if (ret) | 
 | 353 | 		goto err_dir; | 
 | 354 |  | 
 | 355 | 	return 0; | 
 | 356 |  | 
 | 357 | err_dir: | 
 | 358 | 	gpio_free(VIPER_LCD_EN_GPIO); | 
 | 359 | err_request_lcd: | 
 | 360 | 	gpio_free(VIPER_BCKLIGHT_EN_GPIO); | 
 | 361 | err_request_bckl: | 
 | 362 | 	dev_err(dev, "Failed to setup LCD GPIOs\n"); | 
 | 363 |  | 
 | 364 | 	return ret; | 
 | 365 | } | 
 | 366 |  | 
 | 367 | static int viper_backlight_notify(int brightness) | 
 | 368 | { | 
 | 369 | 	gpio_set_value(VIPER_LCD_EN_GPIO, !!brightness); | 
 | 370 | 	gpio_set_value(VIPER_BCKLIGHT_EN_GPIO, !!brightness); | 
 | 371 |  | 
 | 372 | 	return brightness; | 
 | 373 | } | 
 | 374 |  | 
 | 375 | static void viper_backlight_exit(struct device *dev) | 
 | 376 | { | 
 | 377 | 	gpio_free(VIPER_LCD_EN_GPIO); | 
 | 378 | 	gpio_free(VIPER_BCKLIGHT_EN_GPIO); | 
 | 379 | } | 
 | 380 |  | 
 | 381 | static struct platform_pwm_backlight_data viper_backlight_data = { | 
 | 382 | 	.pwm_id		= 0, | 
 | 383 | 	.max_brightness	= 100, | 
 | 384 | 	.dft_brightness	= 100, | 
 | 385 | 	.pwm_period_ns	= 1000000, | 
 | 386 | 	.init		= viper_backlight_init, | 
 | 387 | 	.notify		= viper_backlight_notify, | 
 | 388 | 	.exit		= viper_backlight_exit, | 
 | 389 | }; | 
 | 390 |  | 
 | 391 | static struct platform_device viper_backlight_device = { | 
 | 392 | 	.name		= "pwm-backlight", | 
 | 393 | 	.dev		= { | 
 | 394 | 		.parent		= &pxa25x_device_pwm0.dev, | 
 | 395 | 		.platform_data	= &viper_backlight_data, | 
 | 396 | 	}, | 
 | 397 | }; | 
 | 398 |  | 
 | 399 | /* Ethernet */ | 
 | 400 | static struct resource smc91x_resources[] = { | 
 | 401 | 	[0] = { | 
 | 402 | 		.name	= "smc91x-regs", | 
 | 403 | 		.start  = VIPER_ETH_PHYS + 0x300, | 
 | 404 | 		.end    = VIPER_ETH_PHYS + 0x30f, | 
 | 405 | 		.flags  = IORESOURCE_MEM, | 
 | 406 | 	}, | 
 | 407 | 	[1] = { | 
 | 408 | 		.start  = gpio_to_irq(VIPER_ETH_GPIO), | 
 | 409 | 		.end    = gpio_to_irq(VIPER_ETH_GPIO), | 
 | 410 | 		.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | 
 | 411 | 	}, | 
 | 412 | 	[2] = { | 
 | 413 | 		.name	= "smc91x-data32", | 
 | 414 | 		.start  = VIPER_ETH_DATA_PHYS, | 
 | 415 | 		.end    = VIPER_ETH_DATA_PHYS + 3, | 
 | 416 | 		.flags  = IORESOURCE_MEM, | 
 | 417 | 	}, | 
 | 418 | }; | 
 | 419 |  | 
 | 420 | static struct smc91x_platdata viper_smc91x_info = { | 
 | 421 | 	.flags	= SMC91X_USE_16BIT | SMC91X_NOWAIT, | 
 | 422 | 	.leda	= RPC_LED_100_10, | 
 | 423 | 	.ledb	= RPC_LED_TX_RX, | 
 | 424 | }; | 
 | 425 |  | 
 | 426 | static struct platform_device smc91x_device = { | 
 | 427 | 	.name		= "smc91x", | 
 | 428 | 	.id		= -1, | 
 | 429 | 	.num_resources  = ARRAY_SIZE(smc91x_resources), | 
 | 430 | 	.resource       = smc91x_resources, | 
 | 431 | 	.dev		= { | 
 | 432 | 		.platform_data	= &viper_smc91x_info, | 
 | 433 | 	}, | 
 | 434 | }; | 
 | 435 |  | 
 | 436 | /* i2c */ | 
 | 437 | static struct i2c_gpio_platform_data i2c_bus_data = { | 
 | 438 | 	.sda_pin = VIPER_RTC_I2C_SDA_GPIO, | 
 | 439 | 	.scl_pin = VIPER_RTC_I2C_SCL_GPIO, | 
 | 440 | 	.udelay  = 10, | 
 | 441 | 	.timeout = 100, | 
 | 442 | }; | 
 | 443 |  | 
 | 444 | static struct platform_device i2c_bus_device = { | 
 | 445 | 	.name		= "i2c-gpio", | 
 | 446 | 	.id		= 1, /* pxa2xx-i2c is bus 0, so start at 1 */ | 
 | 447 | 	.dev = { | 
 | 448 | 		.platform_data = &i2c_bus_data, | 
 | 449 | 	} | 
 | 450 | }; | 
 | 451 |  | 
 | 452 | static struct i2c_board_info __initdata viper_i2c_devices[] = { | 
 | 453 | 	{ | 
 | 454 | 		I2C_BOARD_INFO("ds1338", 0x68), | 
 | 455 | 	}, | 
 | 456 | }; | 
 | 457 |  | 
 | 458 | /* | 
 | 459 |  * Serial configuration: | 
 | 460 |  * You can either have the standard PXA ports driven by the PXA driver, | 
 | 461 |  * or all the ports (PXA + 16850) driven by the 8250 driver. | 
 | 462 |  * Choose your poison. | 
 | 463 |  */ | 
 | 464 |  | 
 | 465 | static struct resource viper_serial_resources[] = { | 
 | 466 | #ifndef CONFIG_SERIAL_PXA | 
 | 467 | 	{ | 
 | 468 | 		.start	= 0x40100000, | 
 | 469 | 		.end	= 0x4010001f, | 
 | 470 | 		.flags	= IORESOURCE_MEM, | 
 | 471 | 	}, | 
 | 472 | 	{ | 
 | 473 | 		.start	= 0x40200000, | 
 | 474 | 		.end	= 0x4020001f, | 
 | 475 | 		.flags	= IORESOURCE_MEM, | 
 | 476 | 	}, | 
 | 477 | 	{ | 
 | 478 | 		.start	= 0x40700000, | 
 | 479 | 		.end	= 0x4070001f, | 
 | 480 | 		.flags	= IORESOURCE_MEM, | 
 | 481 | 	}, | 
 | 482 | 	{ | 
 | 483 | 		.start	= VIPER_UARTA_PHYS, | 
 | 484 | 		.end	= VIPER_UARTA_PHYS + 0xf, | 
 | 485 | 		.flags	= IORESOURCE_MEM, | 
 | 486 | 	}, | 
 | 487 | 	{ | 
 | 488 | 		.start	= VIPER_UARTB_PHYS, | 
 | 489 | 		.end	= VIPER_UARTB_PHYS + 0xf, | 
 | 490 | 		.flags	= IORESOURCE_MEM, | 
 | 491 | 	}, | 
 | 492 | #else | 
 | 493 | 	{ | 
 | 494 | 		0, | 
 | 495 | 	}, | 
 | 496 | #endif | 
 | 497 | }; | 
 | 498 |  | 
 | 499 | static struct plat_serial8250_port serial_platform_data[] = { | 
 | 500 | #ifndef CONFIG_SERIAL_PXA | 
 | 501 | 	/* Internal UARTs */ | 
 | 502 | 	{ | 
 | 503 | 		.membase	= (void *)&FFUART, | 
 | 504 | 		.mapbase	= __PREG(FFUART), | 
 | 505 | 		.irq		= IRQ_FFUART, | 
 | 506 | 		.uartclk	= 921600 * 16, | 
 | 507 | 		.regshift	= 2, | 
 | 508 | 		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, | 
 | 509 | 		.iotype		= UPIO_MEM, | 
 | 510 | 	}, | 
 | 511 | 	{ | 
 | 512 | 		.membase	= (void *)&BTUART, | 
 | 513 | 		.mapbase	= __PREG(BTUART), | 
 | 514 | 		.irq		= IRQ_BTUART, | 
 | 515 | 		.uartclk	= 921600 * 16, | 
 | 516 | 		.regshift	= 2, | 
 | 517 | 		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, | 
 | 518 | 		.iotype		= UPIO_MEM, | 
 | 519 | 	}, | 
 | 520 | 	{ | 
 | 521 | 		.membase	= (void *)&STUART, | 
 | 522 | 		.mapbase	= __PREG(STUART), | 
 | 523 | 		.irq		= IRQ_STUART, | 
 | 524 | 		.uartclk	= 921600 * 16, | 
 | 525 | 		.regshift	= 2, | 
 | 526 | 		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, | 
 | 527 | 		.iotype		= UPIO_MEM, | 
 | 528 | 	}, | 
 | 529 | 	/* External UARTs */ | 
 | 530 | 	{ | 
 | 531 | 		.mapbase	= VIPER_UARTA_PHYS, | 
 | 532 | 		.irq		= gpio_to_irq(VIPER_UARTA_GPIO), | 
| Marc Zyngier | 3fe6ccf | 2009-11-14 15:53:14 +0100 | [diff] [blame] | 533 | 		.irqflags	= IRQF_TRIGGER_RISING, | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 534 | 		.uartclk	= 1843200, | 
 | 535 | 		.regshift	= 1, | 
 | 536 | 		.iotype		= UPIO_MEM, | 
 | 537 | 		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP | | 
 | 538 | 				  UPF_SKIP_TEST, | 
 | 539 | 	}, | 
 | 540 | 	{ | 
 | 541 | 		.mapbase	= VIPER_UARTB_PHYS, | 
 | 542 | 		.irq		= gpio_to_irq(VIPER_UARTB_GPIO), | 
| Marc Zyngier | 3fe6ccf | 2009-11-14 15:53:14 +0100 | [diff] [blame] | 543 | 		.irqflags	= IRQF_TRIGGER_RISING, | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 544 | 		.uartclk	= 1843200, | 
 | 545 | 		.regshift	= 1, | 
 | 546 | 		.iotype		= UPIO_MEM, | 
 | 547 | 		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP | | 
 | 548 | 				  UPF_SKIP_TEST, | 
 | 549 | 	}, | 
 | 550 | #endif | 
 | 551 | 	{ }, | 
 | 552 | }; | 
 | 553 |  | 
 | 554 | static struct platform_device serial_device = { | 
 | 555 | 	.name			= "serial8250", | 
 | 556 | 	.id			= 0, | 
 | 557 | 	.dev			= { | 
 | 558 | 		.platform_data	= serial_platform_data, | 
 | 559 | 	}, | 
 | 560 | 	.num_resources		= ARRAY_SIZE(viper_serial_resources), | 
 | 561 | 	.resource		= viper_serial_resources, | 
 | 562 | }; | 
 | 563 |  | 
 | 564 | /* USB */ | 
 | 565 | static void isp116x_delay(struct device *dev, int delay) | 
 | 566 | { | 
 | 567 | 	ndelay(delay); | 
 | 568 | } | 
 | 569 |  | 
 | 570 | static struct resource isp116x_resources[] = { | 
 | 571 | 	[0] = { /* DATA */ | 
 | 572 | 		.start  = VIPER_USB_PHYS + 0, | 
 | 573 | 		.end    = VIPER_USB_PHYS + 1, | 
 | 574 | 		.flags  = IORESOURCE_MEM, | 
 | 575 | 	}, | 
 | 576 | 	[1] = { /* ADDR */ | 
 | 577 | 		.start  = VIPER_USB_PHYS + 2, | 
 | 578 | 		.end    = VIPER_USB_PHYS + 3, | 
 | 579 | 		.flags  = IORESOURCE_MEM, | 
 | 580 | 	}, | 
 | 581 | 	[2] = { | 
 | 582 | 		.start  = gpio_to_irq(VIPER_USB_GPIO), | 
 | 583 | 		.end    = gpio_to_irq(VIPER_USB_GPIO), | 
 | 584 | 		.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | 
 | 585 | 	}, | 
 | 586 | }; | 
 | 587 |  | 
 | 588 | /* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */ | 
 | 589 | static struct isp116x_platform_data isp116x_platform_data = { | 
 | 590 | 	/* Enable internal resistors on downstream ports */ | 
 | 591 | 	.sel15Kres		= 1, | 
 | 592 | 	/* On-chip overcurrent protection */ | 
 | 593 | 	.oc_enable		= 1, | 
 | 594 | 	/* INT output polarity */ | 
 | 595 | 	.int_act_high		= 1, | 
 | 596 | 	/* INT edge or level triggered */ | 
 | 597 | 	.int_edge_triggered	= 0, | 
 | 598 |  | 
 | 599 | 	/* WAKEUP pin connected - NOT SUPPORTED  */ | 
 | 600 | 	/* .remote_wakeup_connected = 0, */ | 
 | 601 | 	/* Wakeup by devices on usb bus enabled */ | 
 | 602 | 	.remote_wakeup_enable	= 0, | 
 | 603 | 	.delay			= isp116x_delay, | 
 | 604 | }; | 
 | 605 |  | 
 | 606 | static struct platform_device isp116x_device = { | 
 | 607 | 	.name			= "isp116x-hcd", | 
 | 608 | 	.id			= -1, | 
 | 609 | 	.num_resources  	= ARRAY_SIZE(isp116x_resources), | 
 | 610 | 	.resource       	= isp116x_resources, | 
 | 611 | 	.dev			= { | 
 | 612 | 		.platform_data	= &isp116x_platform_data, | 
 | 613 | 	}, | 
 | 614 |  | 
 | 615 | }; | 
 | 616 |  | 
 | 617 | /* MTD */ | 
 | 618 | static struct resource mtd_resources[] = { | 
 | 619 | 	[0] = {	/* RedBoot config + filesystem flash */ | 
 | 620 | 		.start	= VIPER_FLASH_PHYS, | 
 | 621 | 		.end	= VIPER_FLASH_PHYS + SZ_32M - 1, | 
 | 622 | 		.flags	= IORESOURCE_MEM, | 
 | 623 | 	}, | 
 | 624 | 	[1] = {	/* Boot flash */ | 
 | 625 | 		.start	= VIPER_BOOT_PHYS, | 
 | 626 | 		.end	= VIPER_BOOT_PHYS + SZ_1M - 1, | 
 | 627 | 		.flags	= IORESOURCE_MEM, | 
 | 628 | 	}, | 
 | 629 | 	[2] = { /* | 
 | 630 | 		 * SRAM size is actually 256KB, 8bits, with a sparse mapping | 
 | 631 | 		 * (each byte is on a 16bit boundary). | 
 | 632 | 		 */ | 
 | 633 | 		.start	= _VIPER_SRAM_BASE, | 
 | 634 | 		.end	= _VIPER_SRAM_BASE + SZ_512K - 1, | 
 | 635 | 		.flags	= IORESOURCE_MEM, | 
 | 636 | 	}, | 
 | 637 | }; | 
 | 638 |  | 
 | 639 | static struct mtd_partition viper_boot_flash_partition = { | 
 | 640 | 	.name		= "RedBoot", | 
 | 641 | 	.size		= SZ_1M, | 
 | 642 | 	.offset		= 0, | 
 | 643 | 	.mask_flags	= MTD_WRITEABLE,	/* force R/O */ | 
 | 644 | }; | 
 | 645 |  | 
 | 646 | static struct physmap_flash_data viper_flash_data[] = { | 
 | 647 | 	[0] = { | 
 | 648 | 		.width		= 2, | 
 | 649 | 		.parts		= NULL, | 
 | 650 | 		.nr_parts	= 0, | 
 | 651 | 	}, | 
 | 652 | 	[1] = { | 
 | 653 | 		.width		= 2, | 
 | 654 | 		.parts		= &viper_boot_flash_partition, | 
 | 655 | 		.nr_parts	= 1, | 
 | 656 | 	}, | 
 | 657 | }; | 
 | 658 |  | 
 | 659 | static struct platform_device viper_mtd_devices[] = { | 
 | 660 | 	[0] = { | 
 | 661 | 		.name		= "physmap-flash", | 
 | 662 | 		.id		= 0, | 
 | 663 | 		.dev		= { | 
 | 664 | 			.platform_data	= &viper_flash_data[0], | 
 | 665 | 		}, | 
 | 666 | 		.resource	= &mtd_resources[0], | 
 | 667 | 		.num_resources	= 1, | 
 | 668 | 	}, | 
 | 669 | 	[1] = { | 
 | 670 | 		.name		= "physmap-flash", | 
 | 671 | 		.id		= 1, | 
 | 672 | 		.dev		= { | 
 | 673 | 			.platform_data	= &viper_flash_data[1], | 
 | 674 | 		}, | 
 | 675 | 		.resource	= &mtd_resources[1], | 
 | 676 | 		.num_resources	= 1, | 
 | 677 | 	}, | 
 | 678 | }; | 
 | 679 |  | 
 | 680 | static struct platform_device *viper_devs[] __initdata = { | 
 | 681 | 	&smc91x_device, | 
 | 682 | 	&i2c_bus_device, | 
 | 683 | 	&serial_device, | 
 | 684 | 	&isp116x_device, | 
 | 685 | 	&viper_mtd_devices[0], | 
 | 686 | 	&viper_mtd_devices[1], | 
 | 687 | 	&viper_backlight_device, | 
 | 688 | }; | 
 | 689 |  | 
 | 690 | static mfp_cfg_t viper_pin_config[] __initdata = { | 
 | 691 | 	/* Chip selects */ | 
 | 692 | 	GPIO15_nCS_1, | 
 | 693 | 	GPIO78_nCS_2, | 
 | 694 | 	GPIO79_nCS_3, | 
 | 695 | 	GPIO80_nCS_4, | 
 | 696 | 	GPIO33_nCS_5, | 
 | 697 |  | 
 | 698 | 	/* FP Backlight */ | 
 | 699 | 	GPIO9_GPIO, 				/* VIPER_BCKLIGHT_EN_GPIO */ | 
 | 700 | 	GPIO10_GPIO,				/* VIPER_LCD_EN_GPIO */ | 
 | 701 | 	GPIO16_PWM0_OUT, | 
 | 702 |  | 
 | 703 | 	/* Ethernet PHY Ready */ | 
 | 704 | 	GPIO18_RDY, | 
 | 705 |  | 
 | 706 | 	/* Serial shutdown */ | 
 | 707 | 	GPIO12_GPIO | MFP_LPM_DRIVE_HIGH,	/* VIPER_UART_SHDN_GPIO */ | 
 | 708 |  | 
 | 709 | 	/* Compact-Flash / PC104 */ | 
 | 710 | 	GPIO48_nPOE, | 
 | 711 | 	GPIO49_nPWE, | 
 | 712 | 	GPIO50_nPIOR, | 
 | 713 | 	GPIO51_nPIOW, | 
 | 714 | 	GPIO52_nPCE_1, | 
 | 715 | 	GPIO53_nPCE_2, | 
 | 716 | 	GPIO54_nPSKTSEL, | 
 | 717 | 	GPIO55_nPREG, | 
 | 718 | 	GPIO56_nPWAIT, | 
 | 719 | 	GPIO57_nIOIS16, | 
 | 720 | 	GPIO8_GPIO,				/* VIPER_CF_RDY_GPIO */ | 
 | 721 | 	GPIO32_GPIO,				/* VIPER_CF_CD_GPIO */ | 
 | 722 | 	GPIO82_GPIO,				/* VIPER_CF_POWER_GPIO */ | 
 | 723 |  | 
 | 724 | 	/* Integrated UPS control */ | 
 | 725 | 	GPIO20_GPIO,				/* VIPER_UPS_GPIO */ | 
 | 726 |  | 
 | 727 | 	/* Vcc regulator control */ | 
 | 728 | 	GPIO6_GPIO,				/* VIPER_PSU_DATA_GPIO */ | 
 | 729 | 	GPIO11_GPIO,				/* VIPER_PSU_CLK_GPIO */ | 
 | 730 | 	GPIO19_GPIO,				/* VIPER_PSU_nCS_LD_GPIO */ | 
 | 731 |  | 
 | 732 | 	/* i2c busses */ | 
 | 733 | 	GPIO26_GPIO,				/* VIPER_TPM_I2C_SDA_GPIO */ | 
 | 734 | 	GPIO27_GPIO,				/* VIPER_TPM_I2C_SCL_GPIO */ | 
 | 735 | 	GPIO83_GPIO,				/* VIPER_RTC_I2C_SDA_GPIO */ | 
 | 736 | 	GPIO84_GPIO,				/* VIPER_RTC_I2C_SCL_GPIO */ | 
 | 737 |  | 
 | 738 | 	/* PC/104 Interrupt */ | 
 | 739 | 	GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,	/* VIPER_CPLD_GPIO */ | 
 | 740 | }; | 
 | 741 |  | 
 | 742 | static unsigned long viper_tpm; | 
 | 743 |  | 
 | 744 | static int __init viper_tpm_setup(char *str) | 
 | 745 | { | 
 | 746 | 	strict_strtoul(str, 10, &viper_tpm); | 
 | 747 | 	return 1; | 
 | 748 | } | 
 | 749 |  | 
 | 750 | __setup("tpm=", viper_tpm_setup); | 
 | 751 |  | 
 | 752 | static void __init viper_tpm_init(void) | 
 | 753 | { | 
 | 754 | 	struct platform_device *tpm_device; | 
 | 755 | 	struct i2c_gpio_platform_data i2c_tpm_data = { | 
 | 756 | 		.sda_pin = VIPER_TPM_I2C_SDA_GPIO, | 
 | 757 | 		.scl_pin = VIPER_TPM_I2C_SCL_GPIO, | 
 | 758 | 		.udelay  = 10, | 
 | 759 | 		.timeout = 100, | 
 | 760 | 	}; | 
 | 761 | 	char *errstr; | 
 | 762 |  | 
 | 763 | 	/* Allocate TPM i2c bus if requested */ | 
 | 764 | 	if (!viper_tpm) | 
 | 765 | 		return; | 
 | 766 |  | 
 | 767 | 	tpm_device = platform_device_alloc("i2c-gpio", 2); | 
 | 768 | 	if (tpm_device) { | 
 | 769 | 		if (!platform_device_add_data(tpm_device, | 
 | 770 | 					      &i2c_tpm_data, | 
 | 771 | 					      sizeof(i2c_tpm_data))) { | 
 | 772 | 			if (platform_device_add(tpm_device)) { | 
 | 773 | 				errstr = "register TPM i2c bus"; | 
 | 774 | 				goto error_free_tpm; | 
 | 775 | 			} | 
 | 776 | 		} else { | 
 | 777 | 			errstr = "allocate TPM i2c bus data"; | 
 | 778 | 			goto error_free_tpm; | 
 | 779 | 		} | 
 | 780 | 	} else { | 
 | 781 | 		errstr = "allocate TPM i2c device"; | 
 | 782 | 		goto error_tpm; | 
 | 783 | 	} | 
 | 784 |  | 
 | 785 | 	return; | 
 | 786 |  | 
 | 787 | error_free_tpm: | 
 | 788 | 	kfree(tpm_device); | 
 | 789 | error_tpm: | 
 | 790 | 	pr_err("viper: Couldn't %s, giving up\n", errstr); | 
 | 791 | } | 
 | 792 |  | 
 | 793 | static void __init viper_init_vcore_gpios(void) | 
 | 794 | { | 
 | 795 | 	if (gpio_request(VIPER_PSU_DATA_GPIO, "PSU data")) | 
 | 796 | 		goto err_request_data; | 
 | 797 |  | 
 | 798 | 	if (gpio_request(VIPER_PSU_CLK_GPIO, "PSU clock")) | 
 | 799 | 		goto err_request_clk; | 
 | 800 |  | 
 | 801 | 	if (gpio_request(VIPER_PSU_nCS_LD_GPIO, "PSU cs")) | 
 | 802 | 		goto err_request_cs; | 
 | 803 |  | 
 | 804 | 	if (gpio_direction_output(VIPER_PSU_DATA_GPIO, 0) || | 
 | 805 | 	    gpio_direction_output(VIPER_PSU_CLK_GPIO, 0) || | 
 | 806 | 	    gpio_direction_output(VIPER_PSU_nCS_LD_GPIO, 0)) | 
 | 807 | 		goto err_dir; | 
 | 808 |  | 
 | 809 | 	/* c/should assume redboot set the correct level ??? */ | 
 | 810 | 	viper_set_core_cpu_voltage(get_clk_frequency_khz(0), 1); | 
 | 811 |  | 
 | 812 | 	return; | 
 | 813 |  | 
 | 814 | err_dir: | 
 | 815 | 	gpio_free(VIPER_PSU_nCS_LD_GPIO); | 
 | 816 | err_request_cs: | 
 | 817 | 	gpio_free(VIPER_PSU_CLK_GPIO); | 
 | 818 | err_request_clk: | 
 | 819 | 	gpio_free(VIPER_PSU_DATA_GPIO); | 
 | 820 | err_request_data: | 
 | 821 | 	pr_err("viper: Failed to setup vcore control GPIOs\n"); | 
 | 822 | } | 
 | 823 |  | 
 | 824 | static void __init viper_init_serial_gpio(void) | 
 | 825 | { | 
 | 826 | 	if (gpio_request(VIPER_UART_SHDN_GPIO, "UARTs shutdown")) | 
 | 827 | 		goto err_request; | 
 | 828 |  | 
 | 829 | 	if (gpio_direction_output(VIPER_UART_SHDN_GPIO, 0)) | 
 | 830 | 		goto err_dir; | 
 | 831 |  | 
 | 832 | 	return; | 
 | 833 |  | 
 | 834 | err_dir: | 
 | 835 | 	gpio_free(VIPER_UART_SHDN_GPIO); | 
 | 836 | err_request: | 
 | 837 | 	pr_err("viper: Failed to setup UART shutdown GPIO\n"); | 
 | 838 | } | 
 | 839 |  | 
 | 840 | #ifdef CONFIG_CPU_FREQ | 
 | 841 | static int viper_cpufreq_notifier(struct notifier_block *nb, | 
 | 842 | 				  unsigned long val, void *data) | 
 | 843 | { | 
 | 844 | 	struct cpufreq_freqs *freq = data; | 
 | 845 |  | 
 | 846 | 	/* TODO: Adjust timings??? */ | 
 | 847 |  | 
 | 848 | 	switch (val) { | 
 | 849 | 	case CPUFREQ_PRECHANGE: | 
 | 850 | 		if (freq->old < freq->new) { | 
 | 851 | 			/* we are getting faster so raise the voltage | 
 | 852 | 			 * before we change freq */ | 
 | 853 | 			viper_set_core_cpu_voltage(freq->new, 0); | 
 | 854 | 		} | 
 | 855 | 		break; | 
 | 856 | 	case CPUFREQ_POSTCHANGE: | 
 | 857 | 		if (freq->old > freq->new) { | 
 | 858 | 			/* we are slowing down so drop the power | 
 | 859 | 			 * after we change freq */ | 
 | 860 | 			viper_set_core_cpu_voltage(freq->new, 0); | 
 | 861 | 		} | 
 | 862 | 		break; | 
 | 863 | 	case CPUFREQ_RESUMECHANGE: | 
 | 864 | 		viper_set_core_cpu_voltage(freq->new, 0); | 
 | 865 | 		break; | 
 | 866 | 	default: | 
 | 867 | 		/* ignore */ | 
 | 868 | 		break; | 
 | 869 | 	} | 
 | 870 |  | 
 | 871 | 	return 0; | 
 | 872 | } | 
 | 873 |  | 
 | 874 | static struct notifier_block viper_cpufreq_notifier_block = { | 
 | 875 | 	.notifier_call  = viper_cpufreq_notifier | 
 | 876 | }; | 
 | 877 |  | 
 | 878 | static void __init viper_init_cpufreq(void) | 
 | 879 | { | 
 | 880 | 	if (cpufreq_register_notifier(&viper_cpufreq_notifier_block, | 
 | 881 | 				      CPUFREQ_TRANSITION_NOTIFIER)) | 
 | 882 | 		pr_err("viper: Failed to setup cpufreq notifier\n"); | 
 | 883 | } | 
 | 884 | #else | 
 | 885 | static inline void viper_init_cpufreq(void) {} | 
 | 886 | #endif | 
 | 887 |  | 
 | 888 | static void viper_power_off(void) | 
 | 889 | { | 
 | 890 | 	pr_notice("Shutting off UPS\n"); | 
 | 891 | 	gpio_set_value(VIPER_UPS_GPIO, 1); | 
 | 892 | 	/* Spin to death... */ | 
 | 893 | 	while (1); | 
 | 894 | } | 
 | 895 |  | 
 | 896 | static void __init viper_init(void) | 
 | 897 | { | 
 | 898 | 	u8 version; | 
 | 899 |  | 
 | 900 | 	pm_power_off = viper_power_off; | 
 | 901 |  | 
 | 902 | 	pxa2xx_mfp_config(ARRAY_AND_SIZE(viper_pin_config)); | 
 | 903 |  | 
| Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 904 | 	pxa_set_ffuart_info(NULL); | 
 | 905 | 	pxa_set_btuart_info(NULL); | 
 | 906 | 	pxa_set_stuart_info(NULL); | 
 | 907 |  | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 908 | 	/* Wake-up serial console */ | 
 | 909 | 	viper_init_serial_gpio(); | 
 | 910 |  | 
 | 911 | 	set_pxa_fb_info(&fb_info); | 
 | 912 |  | 
 | 913 | 	/* v1 hardware cannot use the datacs line */ | 
 | 914 | 	version = viper_hw_version(); | 
 | 915 | 	if (version == 0) | 
 | 916 | 		smc91x_device.num_resources--; | 
 | 917 |  | 
 | 918 | 	pxa_set_i2c_info(NULL); | 
 | 919 | 	platform_add_devices(viper_devs, ARRAY_SIZE(viper_devs)); | 
 | 920 |  | 
 | 921 | 	viper_init_vcore_gpios(); | 
 | 922 | 	viper_init_cpufreq(); | 
 | 923 |  | 
 | 924 | 	sysdev_driver_register(&cpu_sysdev_class, &viper_cpu_sysdev_driver); | 
 | 925 |  | 
 | 926 | 	if (version) { | 
 | 927 | 		pr_info("viper: hardware v%di%d detected. " | 
 | 928 | 			"CPLD revision %d.\n", | 
 | 929 | 			VIPER_BOARD_VERSION(version), | 
 | 930 | 			VIPER_BOARD_ISSUE(version), | 
 | 931 | 			VIPER_CPLD_REVISION(version)); | 
 | 932 | 		system_rev = (VIPER_BOARD_VERSION(version) << 8) | | 
 | 933 | 			     (VIPER_BOARD_ISSUE(version) << 4) | | 
 | 934 | 			     VIPER_CPLD_REVISION(version); | 
 | 935 | 	} else { | 
 | 936 | 		pr_info("viper: No version register.\n"); | 
 | 937 | 	} | 
 | 938 |  | 
 | 939 | 	i2c_register_board_info(1, ARRAY_AND_SIZE(viper_i2c_devices)); | 
 | 940 |  | 
 | 941 | 	viper_tpm_init(); | 
 | 942 | 	pxa_set_ac97_info(NULL); | 
 | 943 | } | 
 | 944 |  | 
 | 945 | static struct map_desc viper_io_desc[] __initdata = { | 
 | 946 | 	{ | 
 | 947 | 		.virtual = VIPER_CPLD_BASE, | 
 | 948 | 		.pfn     = __phys_to_pfn(VIPER_CPLD_PHYS), | 
 | 949 | 		.length  = 0x00300000, | 
 | 950 | 		.type    = MT_DEVICE, | 
 | 951 | 	}, | 
 | 952 | 	{ | 
 | 953 | 		.virtual = VIPER_PC104IO_BASE, | 
| Eric Miao | b393c69 | 2009-01-19 17:34:27 +0800 | [diff] [blame] | 954 | 		.pfn     = __phys_to_pfn(0x30000000), | 
| Marc Zyngier | 352699a | 2008-08-14 17:20:31 +0200 | [diff] [blame] | 955 | 		.length  = 0x00800000, | 
 | 956 | 		.type    = MT_DEVICE, | 
 | 957 | 	}, | 
 | 958 | }; | 
 | 959 |  | 
 | 960 | static void __init viper_map_io(void) | 
 | 961 | { | 
 | 962 | 	pxa_map_io(); | 
 | 963 |  | 
 | 964 | 	iotable_init(viper_io_desc, ARRAY_SIZE(viper_io_desc)); | 
 | 965 |  | 
 | 966 | 	PCFR |= PCFR_OPDE; | 
 | 967 | } | 
 | 968 |  | 
 | 969 | MACHINE_START(VIPER, "Arcom/Eurotech VIPER SBC") | 
 | 970 | 	/* Maintainer: Marc Zyngier <maz@misterjones.org> */ | 
 | 971 | 	.phys_io	= 0x40000000, | 
 | 972 | 	.io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc, | 
 | 973 | 	.boot_params	= 0xa0000100, | 
 | 974 | 	.map_io		= viper_map_io, | 
 | 975 | 	.init_irq	= viper_init_irq, | 
 | 976 | 	.timer          = &pxa_timer, | 
 | 977 | 	.init_machine	= viper_init, | 
 | 978 | MACHINE_END |