Merge branch 'depends/rmk/memory_h' into next/fixes
[linux-2.6.git] / arch / arm / mach-omap1 / board-voiceblue.c
index d7ab11a..940faed 100644 (file)
  */
 
 #include <linux/delay.h>
+#include <linux/gpio.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/mtd/physmap.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/serial_8250.h>
 #include <linux/serial_reg.h>
-#include <linux/irq.h>
+#include <linux/smc91x.h>
 
 #include <mach/hardware.h>
+#include <mach/system.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 
-#include <mach/common.h>
-#include <mach/gpio.h>
-#include <mach/mux.h>
-#include <mach/tc.h>
-#include <mach/usb.h>
+#include <plat/board-voiceblue.h>
+#include <plat/common.h>
+#include <plat/flash.h>
+#include <plat/mux.h>
+#include <plat/tc.h>
+#include <plat/usb.h>
 
 static struct plat_serial8250_port voiceblue_ports[] = {
        {
@@ -81,13 +85,16 @@ static struct platform_device serial_device = {
 
 static int __init ext_uart_init(void)
 {
+       if (!machine_is_voiceblue())
+               return -ENODEV;
+
        return platform_device_register(&serial_device);
 }
 arch_initcall(ext_uart_init);
 
-static struct flash_platform_data voiceblue_flash_data = {
-       .map_name       = "cfi_probe",
+static struct physmap_flash_data voiceblue_flash_data = {
        .width          = 2,
+       .set_vpp        = omap1_set_vpp,
 };
 
 static struct resource voiceblue_flash_resource = {
@@ -97,7 +104,7 @@ static struct resource voiceblue_flash_resource = {
 };
 
 static struct platform_device voiceblue_flash_device = {
-       .name           = "omapflash",
+       .name           = "physmap-flash",
        .id             = 0,
        .dev            = {
                .platform_data  = &voiceblue_flash_data,
@@ -106,6 +113,12 @@ static struct platform_device voiceblue_flash_device = {
        .resource       = &voiceblue_flash_resource,
 };
 
+static struct smc91x_platdata voiceblue_smc91x_info = {
+       .flags  = SMC91X_USE_16BIT | SMC91X_NOWAIT,
+       .leda   = RPC_LED_100_10,
+       .ledb   = RPC_LED_TX_RX,
+};
+
 static struct resource voiceblue_smc91x_resources[] = {
        [0] = {
                .start  = OMAP_CS2_PHYS + 0x300,
@@ -122,6 +135,9 @@ static struct resource voiceblue_smc91x_resources[] = {
 static struct platform_device voiceblue_smc91x_device = {
        .name           = "smc91x",
        .id             = 0,
+       .dev    = {
+               .platform_data  = &voiceblue_smc91x_info,
+       },
        .num_resources  = ARRAY_SIZE(voiceblue_smc91x_resources),
        .resource       = voiceblue_smc91x_resources,
 };
@@ -140,68 +156,13 @@ static struct omap_usb_config voiceblue_usb_config __initdata = {
        .pins[2]        = 6,
 };
 
-static struct omap_mmc_config voiceblue_mmc_config __initdata = {
-       .mmc[0] = {
-               .enabled        = 1,
-               .power_pin      = 2,
-               .switch_pin     = -1,
-       },
-};
-
-static struct omap_uart_config voiceblue_uart_config __initdata = {
-       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
-};
-
 static struct omap_board_config_kernel voiceblue_config[] = {
-       { OMAP_TAG_USB,  &voiceblue_usb_config },
-       { OMAP_TAG_MMC,  &voiceblue_mmc_config },
-       { OMAP_TAG_UART, &voiceblue_uart_config },
 };
 
 static void __init voiceblue_init_irq(void)
 {
        omap1_init_common_hw();
-       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);
-       gpio_set_value(7, 1);
-       udelay(2);      /* wait at least 100ns */
-       gpio_set_value(7, 0);
-       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);
-       gpio_set_value(6, 0);
-       /* 16C554 interrupt pins */
-       omap_request_gpio(12);
-       omap_request_gpio(13);
-       omap_request_gpio(14);
-       omap_request_gpio(15);
-       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);
-
-       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();
-       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 */
+       omap1_init_irq();
 }
 
 static void __init voiceblue_map_io(void)
@@ -233,6 +194,9 @@ static struct notifier_block panic_block = {
 
 static int __init voiceblue_setup(void)
 {
+       if (!machine_is_voiceblue())
+               return -ENODEV;
+
        /* Setup panic notifier */
        atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
 
@@ -244,8 +208,7 @@ static int wdt_gpio_state;
 
 void voiceblue_wdt_enable(void)
 {
-       omap_set_gpio_direction(0, 0);
-       gpio_set_value(0, 0);
+       gpio_direction_output(0, 0);
        gpio_set_value(0, 1);
        gpio_set_value(0, 0);
        wdt_gpio_state = 0;
@@ -256,7 +219,7 @@ void voiceblue_wdt_disable(void)
        gpio_set_value(0, 0);
        gpio_set_value(0, 1);
        gpio_set_value(0, 0);
-       omap_set_gpio_direction(0, 1);
+       gpio_direction_input(0);
 }
 
 void voiceblue_wdt_ping(void)
@@ -268,8 +231,17 @@ void voiceblue_wdt_ping(void)
        gpio_set_value(0, wdt_gpio_state);
 }
 
-void voiceblue_reset(void)
+static void voiceblue_reset(char mode, const char *cmd)
 {
+       /*
+        * 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);
+       }
+
        set_bit(MACHINE_REBOOT, &machine_state);
        voiceblue_wdt_enable();
        while (1) ;
@@ -279,13 +251,60 @@ EXPORT_SYMBOL(voiceblue_wdt_enable);
 EXPORT_SYMBOL(voiceblue_wdt_disable);
 EXPORT_SYMBOL(voiceblue_wdt_ping);
 
+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");
+       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);
+
+       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;
+}
+
 MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910")
        /* Maintainer: Ladislav Michl <michl@2n.cz> */
-       .phys_io        = 0xfff00000,
-       .io_pg_offst    = ((0xfef00000) >> 18) & 0xfffc,
-       .boot_params    = 0x10000100,
+       .atag_offset    = 0x100,
        .map_io         = voiceblue_map_io,
+       .reserve        = omap_reserve,
        .init_irq       = voiceblue_init_irq,
        .init_machine   = voiceblue_init,
-       .timer          = &omap_timer,
+       .timer          = &omap1_timer,
 MACHINE_END