2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2005-07-11 02:58:11 +08:00
|
|
|
* linux/arch/arm/mach-omap1/board-voiceblue.c
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* 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>
|
2005-10-30 02:07:23 +08:00
|
|
|
#include <linux/platform_device.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/interrupt.h>
|
2008-12-11 09:37:16 +08:00
|
|
|
#include <linux/irq.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#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>
|
|
|
|
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/hardware.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/mach-types.h>
|
|
|
|
#include <asm/mach/arch.h>
|
2005-09-09 06:07:38 +08:00
|
|
|
#include <asm/mach/flash.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/mach/map.h>
|
|
|
|
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/common.h>
|
|
|
|
#include <mach/gpio.h>
|
|
|
|
#include <mach/mux.h>
|
|
|
|
#include <mach/tc.h>
|
|
|
|
#include <mach/usb.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
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",
|
2005-09-08 23:04:41 +08:00
|
|
|
.id = PLAT8250_DEV_PLATFORM1,
|
2005-04-17 06:20:36 +08:00
|
|
|
.dev = {
|
|
|
|
.platform_data = voiceblue_ports,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init ext_uart_init(void)
|
|
|
|
{
|
|
|
|
return platform_device_register(&serial_device);
|
|
|
|
}
|
|
|
|
arch_initcall(ext_uart_init);
|
|
|
|
|
2005-09-09 06:07:38 +08:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
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),
|
2008-01-15 06:30:10 +08:00
|
|
|
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
|
2005-04-17 06:20:36 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
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 = {
|
2005-09-09 06:07:38 +08:00
|
|
|
&voiceblue_flash_device,
|
2005-04-17 06:20:36 +08:00
|
|
|
&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,
|
|
|
|
};
|
|
|
|
|
2005-11-10 22:26:48 +08:00
|
|
|
static struct omap_uart_config voiceblue_uart_config __initdata = {
|
|
|
|
.enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct omap_board_config_kernel voiceblue_config[] = {
|
2006-04-03 00:46:30 +08:00
|
|
|
{ OMAP_TAG_UART, &voiceblue_uart_config },
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void __init voiceblue_init_irq(void)
|
|
|
|
{
|
2006-02-09 06:06:46 +08:00
|
|
|
omap1_init_common_hw();
|
2005-04-17 06:20:36 +08:00
|
|
|
omap_init_irq();
|
|
|
|
omap_gpio_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init voiceblue_init(void)
|
|
|
|
{
|
|
|
|
/* Watchdog */
|
2008-12-11 09:35:30 +08:00
|
|
|
gpio_request(0, "Watchdog");
|
2005-04-17 06:20:36 +08:00
|
|
|
/* smc91x reset */
|
2008-12-11 09:35:30 +08:00
|
|
|
gpio_request(7, "SMC91x reset");
|
2008-12-11 09:35:26 +08:00
|
|
|
gpio_direction_output(7, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
udelay(2); /* wait at least 100ns */
|
2008-12-11 09:35:25 +08:00
|
|
|
gpio_set_value(7, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
mdelay(50); /* 50ms until PHY ready */
|
|
|
|
/* smc91x interrupt pin */
|
2008-12-11 09:35:30 +08:00
|
|
|
gpio_request(8, "SMC91x irq");
|
2005-04-17 06:20:36 +08:00
|
|
|
/* 16C554 reset*/
|
2008-12-11 09:35:30 +08:00
|
|
|
gpio_request(6, "16C554 reset");
|
2008-12-11 09:35:26 +08:00
|
|
|
gpio_direction_output(6, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* 16C554 interrupt pins */
|
2008-12-11 09:35:30 +08:00
|
|
|
gpio_request(12, "16C554 irq");
|
|
|
|
gpio_request(13, "16C554 irq");
|
|
|
|
gpio_request(14, "16C554 irq");
|
|
|
|
gpio_request(15, "16C554 irq");
|
2008-12-11 09:35:26 +08:00
|
|
|
set_irq_type(gpio_to_irq(12), IRQ_TYPE_EDGE_RISING);
|
|
|
|
set_irq_type(gpio_to_irq(13), IRQ_TYPE_EDGE_RISING);
|
|
|
|
set_irq_type(gpio_to_irq(14), IRQ_TYPE_EDGE_RISING);
|
|
|
|
set_irq_type(gpio_to_irq(15), IRQ_TYPE_EDGE_RISING);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices));
|
|
|
|
omap_board_config = voiceblue_config;
|
|
|
|
omap_board_config_size = ARRAY_SIZE(voiceblue_config);
|
2005-11-10 22:26:48 +08:00
|
|
|
omap_serial_init();
|
2009-03-24 09:07:49 +08:00
|
|
|
omap_usb_init(&voiceblue_usb_config);
|
2007-11-07 12:54:32 +08:00
|
|
|
omap_register_i2c_bus(1, 100, NULL, 0);
|
2005-09-09 06:07:38 +08:00
|
|
|
|
|
|
|
/* 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 */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __init voiceblue_map_io(void)
|
|
|
|
{
|
2006-02-09 06:06:46 +08:00
|
|
|
omap1_map_common_io();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2005-09-09 06:07:38 +08:00
|
|
|
/* Flash power LED */
|
2005-04-17 06:20:36 +08:00
|
|
|
omap_writeb(0x78, OMAP_LPG1_LCR);
|
2005-09-09 06:07:38 +08:00
|
|
|
omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block panic_block = {
|
|
|
|
.notifier_call = panic_event,
|
|
|
|
};
|
|
|
|
|
2005-09-09 06:07:38 +08:00
|
|
|
static int __init voiceblue_setup(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
/* Setup panic notifier */
|
2006-12-08 05:58:17 +08:00
|
|
|
atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2005-09-09 06:07:38 +08:00
|
|
|
postcore_initcall(voiceblue_setup);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int wdt_gpio_state;
|
|
|
|
|
|
|
|
void voiceblue_wdt_enable(void)
|
|
|
|
{
|
2008-12-11 09:35:26 +08:00
|
|
|
gpio_direction_output(0, 0);
|
2008-12-11 09:35:25 +08:00
|
|
|
gpio_set_value(0, 1);
|
|
|
|
gpio_set_value(0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
wdt_gpio_state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void voiceblue_wdt_disable(void)
|
|
|
|
{
|
2008-12-11 09:35:25 +08:00
|
|
|
gpio_set_value(0, 0);
|
|
|
|
gpio_set_value(0, 1);
|
|
|
|
gpio_set_value(0, 0);
|
2008-12-11 09:35:26 +08:00
|
|
|
gpio_direction_input(0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void voiceblue_wdt_ping(void)
|
|
|
|
{
|
|
|
|
if (test_bit(MACHINE_REBOOT, &machine_state))
|
|
|
|
return;
|
|
|
|
|
|
|
|
wdt_gpio_state = !wdt_gpio_state;
|
2008-12-11 09:35:25 +08:00
|
|
|
gpio_set_value(0, wdt_gpio_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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")
|
2005-07-04 00:38:58 +08:00
|
|
|
/* 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,
|
2005-04-17 06:20:36 +08:00
|
|
|
MACHINE_END
|