Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Modified from board-generic.c |
| 3 | * |
| 4 | * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz> |
| 5 | * |
| 6 | * Code for Netstar OMAP board. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/delay.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/notifier.h> |
| 19 | #include <linux/reboot.h> |
| 20 | |
| 21 | #include <asm/hardware.h> |
| 22 | #include <asm/mach-types.h> |
| 23 | #include <asm/mach/arch.h> |
| 24 | #include <asm/mach/map.h> |
| 25 | |
| 26 | #include <asm/arch/gpio.h> |
| 27 | #include <asm/arch/mux.h> |
| 28 | #include <asm/arch/usb.h> |
Tony Lindgren | d48af15 | 2005-07-10 19:58:17 +0100 | [diff] [blame] | 29 | #include <asm/arch/common.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | extern void __init omap_init_time(void); |
| 32 | extern int omap_gpio_init(void); |
| 33 | |
| 34 | static struct resource netstar_smc91x_resources[] = { |
| 35 | [0] = { |
| 36 | .start = OMAP_CS1_PHYS + 0x300, |
| 37 | .end = OMAP_CS1_PHYS + 0x300 + 16, |
| 38 | .flags = IORESOURCE_MEM, |
| 39 | }, |
| 40 | [1] = { |
| 41 | .start = OMAP_GPIO_IRQ(8), |
| 42 | .end = OMAP_GPIO_IRQ(8), |
| 43 | .flags = IORESOURCE_IRQ, |
| 44 | }, |
| 45 | }; |
| 46 | |
| 47 | static struct platform_device netstar_smc91x_device = { |
| 48 | .name = "smc91x", |
| 49 | .id = 0, |
| 50 | .num_resources = ARRAY_SIZE(netstar_smc91x_resources), |
| 51 | .resource = netstar_smc91x_resources, |
| 52 | }; |
| 53 | |
| 54 | static struct platform_device *netstar_devices[] __initdata = { |
| 55 | &netstar_smc91x_device, |
| 56 | }; |
| 57 | |
Tony Lindgren | 3179a01 | 2005-11-10 14:26:48 +0000 | [diff] [blame] | 58 | static struct omap_uart_config netstar_uart_config __initdata = { |
| 59 | .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)), |
| 60 | }; |
| 61 | |
| 62 | static struct omap_board_config_kernel netstar_config[] = { |
| 63 | { OMAP_TAG_UART, &netstar_uart_config }, |
| 64 | }; |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | static void __init netstar_init_irq(void) |
| 67 | { |
Tony Lindgren | 87bd63f | 2006-02-08 22:06:46 +0000 | [diff] [blame^] | 68 | omap1_init_common_hw(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | omap_init_irq(); |
| 70 | omap_gpio_init(); |
| 71 | } |
| 72 | |
| 73 | static void __init netstar_init(void) |
| 74 | { |
| 75 | /* green LED */ |
| 76 | omap_request_gpio(4); |
| 77 | omap_set_gpio_direction(4, 0); |
| 78 | /* smc91x reset */ |
| 79 | omap_request_gpio(7); |
| 80 | omap_set_gpio_direction(7, 0); |
| 81 | omap_set_gpio_dataout(7, 1); |
| 82 | udelay(2); /* wait at least 100ns */ |
| 83 | omap_set_gpio_dataout(7, 0); |
| 84 | mdelay(50); /* 50ms until PHY ready */ |
| 85 | /* smc91x interrupt pin */ |
| 86 | omap_request_gpio(8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | omap_request_gpio(12); |
| 89 | omap_request_gpio(13); |
| 90 | omap_request_gpio(14); |
| 91 | omap_request_gpio(15); |
Tony Lindgren | 7c38cf0 | 2005-09-08 23:07:38 +0100 | [diff] [blame] | 92 | set_irq_type(OMAP_GPIO_IRQ(12), IRQT_FALLING); |
| 93 | set_irq_type(OMAP_GPIO_IRQ(13), IRQT_FALLING); |
| 94 | set_irq_type(OMAP_GPIO_IRQ(14), IRQT_FALLING); |
| 95 | set_irq_type(OMAP_GPIO_IRQ(15), IRQT_FALLING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | platform_add_devices(netstar_devices, ARRAY_SIZE(netstar_devices)); |
| 98 | |
| 99 | /* Switch on green LED */ |
| 100 | omap_set_gpio_dataout(4, 0); |
| 101 | /* Switch off red LED */ |
| 102 | omap_writeb(0x00, OMAP_LPG1_PMR); /* Disable clock */ |
| 103 | omap_writeb(0x80, OMAP_LPG1_LCR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Tony Lindgren | 3179a01 | 2005-11-10 14:26:48 +0000 | [diff] [blame] | 105 | omap_board_config = netstar_config; |
| 106 | omap_board_config_size = ARRAY_SIZE(netstar_config); |
| 107 | omap_serial_init(); |
| 108 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
| 110 | static void __init netstar_map_io(void) |
| 111 | { |
Tony Lindgren | 87bd63f | 2006-02-08 22:06:46 +0000 | [diff] [blame^] | 112 | omap1_map_common_io(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | #define MACHINE_PANICED 1 |
| 116 | #define MACHINE_REBOOTING 2 |
| 117 | #define MACHINE_REBOOT 4 |
| 118 | static unsigned long machine_state; |
| 119 | |
| 120 | static int panic_event(struct notifier_block *this, unsigned long event, |
| 121 | void *ptr) |
| 122 | { |
| 123 | if (test_and_set_bit(MACHINE_PANICED, &machine_state)) |
| 124 | return NOTIFY_DONE; |
| 125 | |
| 126 | /* Switch off green LED */ |
| 127 | omap_set_gpio_dataout(4, 1); |
| 128 | /* Flash red LED */ |
| 129 | omap_writeb(0x78, OMAP_LPG1_LCR); |
| 130 | omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */ |
| 131 | |
| 132 | return NOTIFY_DONE; |
| 133 | } |
| 134 | |
| 135 | static struct notifier_block panic_block = { |
| 136 | .notifier_call = panic_event, |
| 137 | }; |
| 138 | |
| 139 | static int __init netstar_late_init(void) |
| 140 | { |
| 141 | /* TODO: Setup front panel switch here */ |
| 142 | |
| 143 | /* Setup panic notifier */ |
| 144 | notifier_chain_register(&panic_notifier_list, &panic_block); |
| 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | postcore_initcall(netstar_late_init); |
| 150 | |
| 151 | MACHINE_START(NETSTAR, "NetStar OMAP5910") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 152 | /* Maintainer: Ladislav Michl <michl@2n.cz> */ |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 153 | .phys_io = 0xfff00000, |
| 154 | .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc, |
| 155 | .boot_params = 0x10000100, |
| 156 | .map_io = netstar_map_io, |
| 157 | .init_irq = netstar_init_irq, |
| 158 | .init_machine = netstar_init, |
| 159 | .timer = &omap_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | MACHINE_END |