board-voiceblue.c 6.8 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 * linux/arch/arm/mach-omap1/board-voiceblue.c
L
Linus Torvalds 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 * Modified from board-generic.c
 *
 * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz>
 *
 * Code for OMAP5910 based VoiceBlue board (VoIP to GSM gateway).
 *
 * 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.
 */

#include <linux/delay.h>
16
#include <linux/platform_device.h>
L
Linus Torvalds 已提交
17 18 19 20 21 22 23
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/notifier.h>
#include <linux/reboot.h>
#include <linux/serial_8250.h>
#include <linux/serial_reg.h>
24
#include <linux/irq.h>
L
Linus Torvalds 已提交
25

26
#include <mach/hardware.h>
L
Linus Torvalds 已提交
27 28
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
29
#include <asm/mach/flash.h>
L
Linus Torvalds 已提交
30 31
#include <asm/mach/map.h>

32 33 34 35 36
#include <mach/common.h>
#include <mach/gpio.h>
#include <mach/mux.h>
#include <mach/tc.h>
#include <mach/usb.h>
L
Linus Torvalds 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75

static struct plat_serial8250_port voiceblue_ports[] = {
	{
		.mapbase	= (unsigned long)(OMAP_CS1_PHYS + 0x40000),
		.irq		= OMAP_GPIO_IRQ(12),
		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP,
		.iotype		= UPIO_MEM,
		.regshift	= 1,
		.uartclk	= 3686400,
	},
	{
		.mapbase	= (unsigned long)(OMAP_CS1_PHYS + 0x50000),
		.irq		= OMAP_GPIO_IRQ(13),
		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP,
		.iotype		= UPIO_MEM,
		.regshift	= 1,
		.uartclk	= 3686400,
	},
	{
		.mapbase	= (unsigned long)(OMAP_CS1_PHYS + 0x60000),
		.irq		= OMAP_GPIO_IRQ(14),
		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP,
		.iotype		= UPIO_MEM,
		.regshift	= 1,
		.uartclk	= 3686400,
	},
	{
		.mapbase	= (unsigned long)(OMAP_CS1_PHYS + 0x70000),
		.irq		= OMAP_GPIO_IRQ(15),
		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP,
		.iotype		= UPIO_MEM,
		.regshift	= 1,
		.uartclk	= 3686400,
	},
	{ },
};

static struct platform_device serial_device = {
	.name			= "serial8250",
76
	.id			= PLAT8250_DEV_PLATFORM1,
L
Linus Torvalds 已提交
77 78 79 80 81 82 83 84 85 86 87
	.dev			= {
		.platform_data	= voiceblue_ports,
	},
};

static int __init ext_uart_init(void)
{
	return platform_device_register(&serial_device);
}
arch_initcall(ext_uart_init);

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
static struct flash_platform_data voiceblue_flash_data = {
	.map_name	= "cfi_probe",
	.width		= 2,
};

static struct resource voiceblue_flash_resource = {
	.start	= OMAP_CS0_PHYS,
	.end	= OMAP_CS0_PHYS + SZ_32M - 1,
	.flags	= IORESOURCE_MEM,
};

static struct platform_device voiceblue_flash_device = {
	.name		= "omapflash",
	.id		= 0,
	.dev		= {
		.platform_data	= &voiceblue_flash_data,
	},
	.num_resources	= 1,
	.resource	= &voiceblue_flash_resource,
};

L
Linus Torvalds 已提交
109 110 111 112 113 114 115 116 117
static struct resource voiceblue_smc91x_resources[] = {
	[0] = {
		.start	= OMAP_CS2_PHYS + 0x300,
		.end	= OMAP_CS2_PHYS + 0x300 + 16,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= OMAP_GPIO_IRQ(8),
		.end	= OMAP_GPIO_IRQ(8),
118
		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
L
Linus Torvalds 已提交
119 120 121 122 123 124 125 126 127 128 129
	},
};

static struct platform_device voiceblue_smc91x_device = {
	.name		= "smc91x",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(voiceblue_smc91x_resources),
	.resource	= voiceblue_smc91x_resources,
};

static struct platform_device *voiceblue_devices[] __initdata = {
130
	&voiceblue_flash_device,
L
Linus Torvalds 已提交
131 132 133 134 135 136 137 138 139 140 141 142
	&voiceblue_smc91x_device,
};

static struct omap_usb_config voiceblue_usb_config __initdata = {
	.hmc_mode	= 3,
	.register_host	= 1,
	.register_dev   = 1,
	.pins[0]	= 2,
	.pins[1]	= 6,
	.pins[2]	= 6,
};

143 144 145 146 147 148 149 150
static struct omap_mmc_config voiceblue_mmc_config __initdata = {
	.mmc[0] = {
		.enabled	= 1,
		.power_pin	= 2,
		.switch_pin	= -1,
	},
};

151 152 153 154
static struct omap_uart_config voiceblue_uart_config __initdata = {
	.enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
};

L
Linus Torvalds 已提交
155
static struct omap_board_config_kernel voiceblue_config[] = {
156 157 158
	{ OMAP_TAG_USB,  &voiceblue_usb_config },
	{ OMAP_TAG_MMC,  &voiceblue_mmc_config },
	{ OMAP_TAG_UART, &voiceblue_uart_config },
L
Linus Torvalds 已提交
159 160 161 162
};

static void __init voiceblue_init_irq(void)
{
163
	omap1_init_common_hw();
L
Linus Torvalds 已提交
164 165 166 167 168 169 170 171 172 173 174
	omap_init_irq();
	omap_gpio_init();
}

static void __init voiceblue_init(void)
{
	/* Watchdog */
	omap_request_gpio(0);
	/* smc91x reset */
	omap_request_gpio(7);
	omap_set_gpio_direction(7, 0);
175
	gpio_set_value(7, 1);
L
Linus Torvalds 已提交
176
	udelay(2);	/* wait at least 100ns */
177
	gpio_set_value(7, 0);
L
Linus Torvalds 已提交
178 179 180 181 182 183
	mdelay(50);	/* 50ms until PHY ready */
	/* smc91x interrupt pin */
	omap_request_gpio(8);
	/* 16C554 reset*/
	omap_request_gpio(6);
	omap_set_gpio_direction(6, 0);
184
	gpio_set_value(6, 0);
L
Linus Torvalds 已提交
185 186 187 188 189
	/* 16C554 interrupt pins */
	omap_request_gpio(12);
	omap_request_gpio(13);
	omap_request_gpio(14);
	omap_request_gpio(15);
190 191 192 193
	set_irq_type(OMAP_GPIO_IRQ(12), IRQ_TYPE_EDGE_RISING);
	set_irq_type(OMAP_GPIO_IRQ(13), IRQ_TYPE_EDGE_RISING);
	set_irq_type(OMAP_GPIO_IRQ(14), IRQ_TYPE_EDGE_RISING);
	set_irq_type(OMAP_GPIO_IRQ(15), IRQ_TYPE_EDGE_RISING);
L
Linus Torvalds 已提交
194 195 196 197

	platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices));
	omap_board_config = voiceblue_config;
	omap_board_config_size = ARRAY_SIZE(voiceblue_config);
198
	omap_serial_init();
199
	omap_register_i2c_bus(1, 100, NULL, 0);
200 201 202 203 204

	/* There is a good chance board is going up, so enable power LED
	 * (it is connected through invertor) */
	omap_writeb(0x00, OMAP_LPG1_LCR);
	omap_writeb(0x00, OMAP_LPG1_PMR);	/* Disable clock */
L
Linus Torvalds 已提交
205 206 207 208
}

static void __init voiceblue_map_io(void)
{
209
	omap1_map_common_io();
L
Linus Torvalds 已提交
210 211 212 213 214 215 216 217 218 219 220 221 222
}

#define MACHINE_PANICED		1
#define MACHINE_REBOOTING	2
#define MACHINE_REBOOT		4
static unsigned long machine_state;

static int panic_event(struct notifier_block *this, unsigned long event,
	 void *ptr)
{
	if (test_and_set_bit(MACHINE_PANICED, &machine_state))
		return NOTIFY_DONE;

223
	/* Flash power LED */
L
Linus Torvalds 已提交
224
	omap_writeb(0x78, OMAP_LPG1_LCR);
225
	omap_writeb(0x01, OMAP_LPG1_PMR);	/* Enable clock */
L
Linus Torvalds 已提交
226 227 228 229 230 231 232 233

	return NOTIFY_DONE;
}

static struct notifier_block panic_block = {
	.notifier_call	= panic_event,
};

234
static int __init voiceblue_setup(void)
L
Linus Torvalds 已提交
235 236
{
	/* Setup panic notifier */
237
	atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
L
Linus Torvalds 已提交
238 239 240

	return 0;
}
241
postcore_initcall(voiceblue_setup);
L
Linus Torvalds 已提交
242 243 244 245 246 247

static int wdt_gpio_state;

void voiceblue_wdt_enable(void)
{
	omap_set_gpio_direction(0, 0);
248 249 250
	gpio_set_value(0, 0);
	gpio_set_value(0, 1);
	gpio_set_value(0, 0);
L
Linus Torvalds 已提交
251 252 253 254 255
	wdt_gpio_state = 0;
}

void voiceblue_wdt_disable(void)
{
256 257 258
	gpio_set_value(0, 0);
	gpio_set_value(0, 1);
	gpio_set_value(0, 0);
259
	gpio_direction_input(0);
L
Linus Torvalds 已提交
260 261 262 263 264 265 266 267
}

void voiceblue_wdt_ping(void)
{
	if (test_bit(MACHINE_REBOOT, &machine_state))
		return;

	wdt_gpio_state = !wdt_gpio_state;
268
	gpio_set_value(0, wdt_gpio_state);
L
Linus Torvalds 已提交
269 270 271 272 273 274 275 276 277 278 279 280 281 282
}

void voiceblue_reset(void)
{
	set_bit(MACHINE_REBOOT, &machine_state);
	voiceblue_wdt_enable();
	while (1) ;
}

EXPORT_SYMBOL(voiceblue_wdt_enable);
EXPORT_SYMBOL(voiceblue_wdt_disable);
EXPORT_SYMBOL(voiceblue_wdt_ping);

MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910")
283 284 285 286 287 288 289 290
	/* Maintainer: Ladislav Michl <michl@2n.cz> */
	.phys_io	= 0xfff00000,
	.io_pg_offst	= ((0xfef00000) >> 18) & 0xfffc,
	.boot_params	= 0x10000100,
	.map_io		= voiceblue_map_io,
	.init_irq	= voiceblue_init_irq,
	.init_machine	= voiceblue_init,
	.timer		= &omap_timer,
L
Linus Torvalds 已提交
291
MACHINE_END