board-voiceblue.c 7.3 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
#include <linux/interrupt.h>
18
#include <linux/irq.h>
L
Linus Torvalds 已提交
19 20
#include <linux/init.h>
#include <linux/kernel.h>
21
#include <linux/mtd/physmap.h>
L
Linus Torvalds 已提交
22 23 24 25
#include <linux/notifier.h>
#include <linux/reboot.h>
#include <linux/serial_8250.h>
#include <linux/serial_reg.h>
26
#include <linux/smc91x.h>
L
Linus Torvalds 已提交
27

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

34
#include <plat/board-voiceblue.h>
35
#include <plat/common.h>
36
#include <mach/gpio.h>
37
#include <plat/flash.h>
38 39 40
#include <plat/mux.h>
#include <plat/tc.h>
#include <plat/usb.h>
L
Linus Torvalds 已提交
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 76 77 78 79

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",
80
	.id			= PLAT8250_DEV_PLATFORM1,
L
Linus Torvalds 已提交
81 82 83 84 85 86 87
	.dev			= {
		.platform_data	= voiceblue_ports,
	},
};

static int __init ext_uart_init(void)
{
88 89 90
	if (!machine_is_voiceblue())
		return -ENODEV;

L
Linus Torvalds 已提交
91 92 93 94
	return platform_device_register(&serial_device);
}
arch_initcall(ext_uart_init);

95
static struct physmap_flash_data voiceblue_flash_data = {
96
	.width		= 2,
97
	.set_vpp	= omap1_set_vpp,
98 99 100 101 102 103 104 105 106
};

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 = {
107
	.name		= "physmap-flash",
108 109 110 111 112 113 114 115
	.id		= 0,
	.dev		= {
		.platform_data	= &voiceblue_flash_data,
	},
	.num_resources	= 1,
	.resource	= &voiceblue_flash_resource,
};

116 117 118 119 120 121
static struct smc91x_platdata voiceblue_smc91x_info = {
	.flags	= SMC91X_USE_16BIT | SMC91X_NOWAIT,
	.leda	= RPC_LED_100_10,
	.ledb	= RPC_LED_TX_RX,
};

L
Linus Torvalds 已提交
122 123 124 125 126 127 128 129 130
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),
131
		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
L
Linus Torvalds 已提交
132 133 134 135 136 137
	},
};

static struct platform_device voiceblue_smc91x_device = {
	.name		= "smc91x",
	.id		= 0,
138 139 140
	.dev	= {
		.platform_data	= &voiceblue_smc91x_info,
	},
L
Linus Torvalds 已提交
141 142 143 144 145
	.num_resources	= ARRAY_SIZE(voiceblue_smc91x_resources),
	.resource	= voiceblue_smc91x_resources,
};

static struct platform_device *voiceblue_devices[] __initdata = {
146
	&voiceblue_flash_device,
L
Linus Torvalds 已提交
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
	&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,
};

static struct omap_board_config_kernel voiceblue_config[] = {
};

static void __init voiceblue_init_irq(void)
{
164
	omap1_init_common_hw();
L
Linus Torvalds 已提交
165 166 167 168 169
	omap_init_irq();
}

static void __init voiceblue_map_io(void)
{
170
	omap1_map_common_io();
L
Linus Torvalds 已提交
171 172 173 174 175 176 177 178 179 180 181 182 183
}

#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;

184
	/* Flash power LED */
L
Linus Torvalds 已提交
185
	omap_writeb(0x78, OMAP_LPG1_LCR);
186
	omap_writeb(0x01, OMAP_LPG1_PMR);	/* Enable clock */
L
Linus Torvalds 已提交
187 188 189 190 191 192 193 194

	return NOTIFY_DONE;
}

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

195
static int __init voiceblue_setup(void)
L
Linus Torvalds 已提交
196
{
197 198 199
	if (!machine_is_voiceblue())
		return -ENODEV;

L
Linus Torvalds 已提交
200
	/* Setup panic notifier */
201
	atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
L
Linus Torvalds 已提交
202 203 204

	return 0;
}
205
postcore_initcall(voiceblue_setup);
L
Linus Torvalds 已提交
206 207 208 209 210

static int wdt_gpio_state;

void voiceblue_wdt_enable(void)
{
211
	gpio_direction_output(0, 0);
212 213
	gpio_set_value(0, 1);
	gpio_set_value(0, 0);
L
Linus Torvalds 已提交
214 215 216 217 218
	wdt_gpio_state = 0;
}

void voiceblue_wdt_disable(void)
{
219 220 221
	gpio_set_value(0, 0);
	gpio_set_value(0, 1);
	gpio_set_value(0, 0);
222
	gpio_direction_input(0);
L
Linus Torvalds 已提交
223 224 225 226 227 228 229 230
}

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

	wdt_gpio_state = !wdt_gpio_state;
231
	gpio_set_value(0, wdt_gpio_state);
L
Linus Torvalds 已提交
232 233
}

234
static void voiceblue_reset(char mode, const char *cmd)
L
Linus Torvalds 已提交
235
{
236 237 238 239 240 241 242 243 244
	/*
	 * Workaround for 5912/1611b bug mentioned in sprz209d.pdf p. 28
	 * "Global Software Reset Affects Traffic Controller Frequency".
	 */
	if (cpu_is_omap5912()) {
		omap_writew(omap_readw(DPLL_CTL) & ~(1 << 4), DPLL_CTL);
		omap_writew(0x8, ARM_RSTCT1);
	}

L
Linus Torvalds 已提交
245 246 247 248 249 250 251 252 253
	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);

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
static void __init voiceblue_init(void)
{
	/* mux pins for uarts */
	omap_cfg_reg(UART1_TX);
	omap_cfg_reg(UART1_RTS);
	omap_cfg_reg(UART2_TX);
	omap_cfg_reg(UART2_RTS);
	omap_cfg_reg(UART3_TX);
	omap_cfg_reg(UART3_RX);

	/* Watchdog */
	gpio_request(0, "Watchdog");
	/* smc91x reset */
	gpio_request(7, "SMC91x reset");
	gpio_direction_output(7, 1);
	udelay(2);	/* wait at least 100ns */
	gpio_set_value(7, 0);
	mdelay(50);	/* 50ms until PHY ready */
	/* smc91x interrupt pin */
	gpio_request(8, "SMC91x irq");
	/* 16C554 reset*/
	gpio_request(6, "16C554 reset");
	gpio_direction_output(6, 0);
	/* 16C554 interrupt pins */
	gpio_request(12, "16C554 irq");
	gpio_request(13, "16C554 irq");
	gpio_request(14, "16C554 irq");
	gpio_request(15, "16C554 irq");
T
Thomas Gleixner 已提交
282 283 284 285
	irq_set_irq_type(gpio_to_irq(12), IRQ_TYPE_EDGE_RISING);
	irq_set_irq_type(gpio_to_irq(13), IRQ_TYPE_EDGE_RISING);
	irq_set_irq_type(gpio_to_irq(14), IRQ_TYPE_EDGE_RISING);
	irq_set_irq_type(gpio_to_irq(15), IRQ_TYPE_EDGE_RISING);
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

	platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices));
	omap_board_config = voiceblue_config;
	omap_board_config_size = ARRAY_SIZE(voiceblue_config);
	omap_serial_init();
	omap1_usb_init(&voiceblue_usb_config);
	omap_register_i2c_bus(1, 100, NULL, 0);

	/* 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 */

	arch_reset = voiceblue_reset;
}

L
Linus Torvalds 已提交
302
MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910")
303 304 305
	/* Maintainer: Ladislav Michl <michl@2n.cz> */
	.boot_params	= 0x10000100,
	.map_io		= voiceblue_map_io,
306
	.reserve	= omap_reserve,
307 308 309
	.init_irq	= voiceblue_init_irq,
	.init_machine	= voiceblue_init,
	.timer		= &omap_timer,
L
Linus Torvalds 已提交
310
MACHINE_END