idp.c 6.13 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 *  linux/arch/arm/mach-pxa/idp.c
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  Copyright (c) 2001 Cliff Brake, Accelent Systems Inc.
 *
 *  2001-09-13: Cliff Brake <cbrake@accelent.com>
 *              Initial code
 *
 *  2005-02-15: Cliff Brake <cliff.brake@gmail.com>
 *  		<http://www.vibren.com> <http://bec-systems.com>
 *              Updated for 2.6 kernel
 *
 */

#include <linux/init.h>
#include <linux/interrupt.h>
21
#include <linux/irq.h>
22
#include <linux/platform_device.h>
Linus Torvalds's avatar
Linus Torvalds committed
23 24 25 26 27
#include <linux/fb.h>

#include <asm/setup.h>
#include <asm/memory.h>
#include <asm/mach-types.h>
28
#include <mach/hardware.h>
Linus Torvalds's avatar
Linus Torvalds committed
29 30 31 32 33
#include <asm/irq.h>

#include <asm/mach/arch.h>
#include <asm/mach/map.h>

34 35
#include "pxa25x.h"
#include "idp.h"
36
#include <linux/platform_data/video-pxafb.h>
37
#include <mach/bitfield.h>
38
#include <linux/platform_data/mmc-pxamci.h>
39
#include <linux/smc91x.h>
Linus Torvalds's avatar
Linus Torvalds committed
40 41

#include "generic.h"
42
#include "devices.h"
Linus Torvalds's avatar
Linus Torvalds committed
43 44 45 46 47 48

/* TODO:
 * - add pxa2xx_audio_ops_t device structure
 * - Ethernet interrupt
 */

49
static unsigned long idp_pin_config[] __initdata = {
50
	/* LCD */
51
	GPIOxx_LCD_DSTN_16BPP,
52

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
	/* BTUART */
	GPIO42_BTUART_RXD,
	GPIO43_BTUART_TXD,
	GPIO44_BTUART_CTS,
	GPIO45_BTUART_RTS,

	/* STUART */
	GPIO46_STUART_RXD,
	GPIO47_STUART_TXD,

	/* MMC */
	GPIO6_MMC_CLK,
	GPIO8_MMC_CS0,

	/* Ethernet */
	GPIO33_nCS_5,	/* Ethernet CS */
	GPIO4_GPIO,	/* Ethernet IRQ */
};

Linus Torvalds's avatar
Linus Torvalds committed
72 73 74 75 76 77 78
static struct resource smc91x_resources[] = {
	[0] = {
		.start	= (IDP_ETH_PHYS + 0x300),
		.end	= (IDP_ETH_PHYS + 0xfffff),
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
79 80
		.start	= PXA_GPIO_TO_IRQ(4),
		.end	= PXA_GPIO_TO_IRQ(4),
81
		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Linus Torvalds's avatar
Linus Torvalds committed
82 83 84
	}
};

85
static struct smc91x_platdata smc91x_platdata = {
Russell King's avatar
Russell King committed
86 87
	.flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
		 SMC91X_USE_DMA | SMC91X_NOWAIT,
88 89
};

Linus Torvalds's avatar
Linus Torvalds committed
90 91 92 93 94
static struct platform_device smc91x_device = {
	.name		= "smc91x",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(smc91x_resources),
	.resource	= smc91x_resources,
95
	.dev.platform_data = &smc91x_platdata,
Linus Torvalds's avatar
Linus Torvalds committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
};

static void idp_backlight_power(int on)
{
	if (on) {
		IDP_CPLD_LCD |= (1<<1);
	} else {
		IDP_CPLD_LCD &= ~(1<<1);
	}
}

static void idp_vlcd(int on)
{
	if (on) {
		IDP_CPLD_LCD |= (1<<2);
	} else {
		IDP_CPLD_LCD &= ~(1<<2);
	}
}

116
static void idp_lcd_power(int on, struct fb_var_screeninfo *var)
Linus Torvalds's avatar
Linus Torvalds committed
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
{
	if (on) {
		IDP_CPLD_LCD |= (1<<0);
	} else {
		IDP_CPLD_LCD &= ~(1<<0);
	}

	/* call idp_vlcd for now as core driver does not support
	 * both power and vlcd hooks.  Note, this is not technically
	 * the correct sequence, but seems to work.  Disclaimer:
	 * this may eventually damage the display.
	 */

	idp_vlcd(on);
}

133
static struct pxafb_mode_info sharp_lm8v31_mode = {
Linus Torvalds's avatar
Linus Torvalds committed
134 135 136 137 138 139 140 141 142 143 144 145
	.pixclock	= 270000,
	.xres		= 640,
	.yres		= 480,
	.bpp		= 16,
	.hsync_len	= 1,
	.left_margin	= 3,
	.right_margin	= 3,
	.vsync_len	= 1,
	.upper_margin	= 0,
	.lower_margin	= 0,
	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
	.cmap_greyscale	= 0,
146 147 148 149 150
};

static struct pxafb_mach_info sharp_lm8v31 = {
	.modes          = &sharp_lm8v31_mode,
	.num_modes      = 1,
Linus Torvalds's avatar
Linus Torvalds committed
151 152
	.cmap_inverse	= 0,
	.cmap_static	= 0,
153 154
	.lcd_conn	= LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
			  LCD_AC_BIAS_FREQ(255),
Linus Torvalds's avatar
Linus Torvalds committed
155 156 157 158 159
	.pxafb_backlight_power = &idp_backlight_power,
	.pxafb_lcd_power = &idp_lcd_power
};

static struct pxamci_platform_data idp_mci_platform_data = {
160 161 162 163
	.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
	.gpio_card_detect	= -1,
	.gpio_card_ro		= -1,
	.gpio_power		= -1,
Linus Torvalds's avatar
Linus Torvalds committed
164 165 166 167 168 169
};

static void __init idp_init(void)
{
	printk("idp_init()\n");

170
	pxa2xx_mfp_config(ARRAY_AND_SIZE(idp_pin_config));
171 172 173
	pxa_set_ffuart_info(NULL);
	pxa_set_btuart_info(NULL);
	pxa_set_stuart_info(NULL);
174

Linus Torvalds's avatar
Linus Torvalds committed
175 176
	platform_device_register(&smc91x_device);
	//platform_device_register(&mst_audio_device);
177
	pxa_set_fb_info(NULL, &sharp_lm8v31);
Linus Torvalds's avatar
Linus Torvalds committed
178 179 180 181
	pxa_set_mci_info(&idp_mci_platform_data);
}

static struct map_desc idp_io_desc[] __initdata = {
182 183 184 185 186 187 188 189 190 191 192
  	{
		.virtual	=  IDP_COREVOLT_VIRT,
		.pfn		= __phys_to_pfn(IDP_COREVOLT_PHYS),
		.length		= IDP_COREVOLT_SIZE,
		.type		= MT_DEVICE
	}, {
		.virtual	=  IDP_CPLD_VIRT,
		.pfn		= __phys_to_pfn(IDP_CPLD_PHYS),
		.length		= IDP_CPLD_SIZE,
		.type		= MT_DEVICE
	}
Linus Torvalds's avatar
Linus Torvalds committed
193 194 195 196
};

static void __init idp_map_io(void)
{
197
	pxa25x_map_io();
Linus Torvalds's avatar
Linus Torvalds committed
198 199 200
	iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc));
}

201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
/* LEDs */
#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
struct idp_led {
	struct led_classdev     cdev;
	u8                      mask;
};

/*
 * The triggers lines up below will only be used if the
 * LED triggers are compiled in.
 */
static const struct {
	const char *name;
	const char *trigger;
} idp_leds[] = {
	{ "idp:green", "heartbeat", },
	{ "idp:red", "cpu0", },
};

static void idp_led_set(struct led_classdev *cdev,
		enum led_brightness b)
{
	struct idp_led *led = container_of(cdev,
			struct idp_led, cdev);
	u32 reg = IDP_CPLD_LED_CONTROL;

	if (b != LED_OFF)
		reg &= ~led->mask;
	else
		reg |= led->mask;

	IDP_CPLD_LED_CONTROL = reg;
}

static enum led_brightness idp_led_get(struct led_classdev *cdev)
{
	struct idp_led *led = container_of(cdev,
			struct idp_led, cdev);

	return (IDP_CPLD_LED_CONTROL & led->mask) ? LED_OFF : LED_FULL;
}

static int __init idp_leds_init(void)
{
	int i;

	if (!machine_is_pxa_idp())
		return -ENODEV;

	for (i = 0; i < ARRAY_SIZE(idp_leds); i++) {
		struct idp_led *led;

		led = kzalloc(sizeof(*led), GFP_KERNEL);
		if (!led)
			break;

		led->cdev.name = idp_leds[i].name;
		led->cdev.brightness_set = idp_led_set;
		led->cdev.brightness_get = idp_led_get;
		led->cdev.default_trigger = idp_leds[i].trigger;

		if (i == 0)
			led->mask = IDP_HB_LED;
		else
			led->mask = IDP_BUSY_LED;

		if (led_classdev_register(NULL, &led->cdev) < 0) {
			kfree(led);
			break;
		}
	}

	return 0;
}

/*
 * Since we may have triggers on any subsystem, defer registration
 * until after subsystem_init.
 */
fs_initcall(idp_leds_init);
#endif
Linus Torvalds's avatar
Linus Torvalds committed
282 283

MACHINE_START(PXA_IDP, "Vibren PXA255 IDP")
284 285
	/* Maintainer: Vibren Technologies */
	.map_io		= idp_map_io,
Rob Herring's avatar
Rob Herring committed
286
	.nr_irqs	= PXA_NR_IRQS,
287
	.init_irq	= pxa25x_init_irq,
288
	.handle_irq	= pxa25x_handle_irq,
Stephen Warren's avatar
Stephen Warren committed
289
	.init_time	= pxa_timer_init,
290
	.init_machine	= idp_init,
291
	.restart	= pxa_restart,
Linus Torvalds's avatar
Linus Torvalds committed
292
MACHINE_END