| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 1 | /* | 
 | 2 |  * arch/arm/mach-orion5x/lsmini-setup.c | 
 | 3 |  * | 
 | 4 |  * Maintainer: Alexey Kopytko <alexey@kopytko.ru> | 
 | 5 |  * | 
 | 6 |  * This file is licensed under the terms of the GNU General Public | 
 | 7 |  * License version 2.  This program is licensed "as is" without any | 
 | 8 |  * warranty of any kind, whether express or implied. | 
 | 9 |  */ | 
 | 10 |  | 
 | 11 | #include <linux/kernel.h> | 
 | 12 | #include <linux/init.h> | 
 | 13 | #include <linux/platform_device.h> | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 14 | #include <linux/mtd/physmap.h> | 
 | 15 | #include <linux/mv643xx_eth.h> | 
 | 16 | #include <linux/leds.h> | 
 | 17 | #include <linux/gpio_keys.h> | 
 | 18 | #include <linux/input.h> | 
 | 19 | #include <linux/i2c.h> | 
 | 20 | #include <linux/ata_platform.h> | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 21 | #include <linux/gpio.h> | 
| Nicolas Pitre | 1961528 | 2010-02-05 00:20:24 -0500 | [diff] [blame] | 22 | #include <asm/mach-types.h> | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 23 | #include <asm/mach/arch.h> | 
| Nicolas Pitre | 1961528 | 2010-02-05 00:20:24 -0500 | [diff] [blame] | 24 | #include <mach/orion5x.h> | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 25 | #include "common.h" | 
 | 26 | #include "mpp.h" | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 27 |  | 
 | 28 | /***************************************************************************** | 
 | 29 |  * Linkstation Mini Info | 
 | 30 |  ****************************************************************************/ | 
 | 31 |  | 
 | 32 | /* | 
 | 33 |  * 256K NOR flash Device bus boot chip select | 
 | 34 |  */ | 
 | 35 |  | 
 | 36 | #define LSMINI_NOR_BOOT_BASE	0xf4000000 | 
 | 37 | #define LSMINI_NOR_BOOT_SIZE	SZ_256K | 
 | 38 |  | 
 | 39 | /***************************************************************************** | 
 | 40 |  * 256KB NOR Flash on BOOT Device | 
 | 41 |  ****************************************************************************/ | 
 | 42 |  | 
 | 43 | static struct physmap_flash_data lsmini_nor_flash_data = { | 
 | 44 | 	.width		= 1, | 
 | 45 | }; | 
 | 46 |  | 
 | 47 | static struct resource lsmini_nor_flash_resource = { | 
 | 48 | 	.flags	= IORESOURCE_MEM, | 
 | 49 | 	.start	= LSMINI_NOR_BOOT_BASE, | 
 | 50 | 	.end	= LSMINI_NOR_BOOT_BASE + LSMINI_NOR_BOOT_SIZE - 1, | 
 | 51 | }; | 
 | 52 |  | 
 | 53 | static struct platform_device lsmini_nor_flash = { | 
 | 54 | 	.name			= "physmap-flash", | 
 | 55 | 	.id			= 0, | 
 | 56 | 	.dev		= { | 
 | 57 | 		.platform_data	= &lsmini_nor_flash_data, | 
 | 58 | 	}, | 
 | 59 | 	.num_resources		= 1, | 
 | 60 | 	.resource		= &lsmini_nor_flash_resource, | 
 | 61 | }; | 
 | 62 |  | 
 | 63 | /***************************************************************************** | 
 | 64 |  * Ethernet | 
 | 65 |  ****************************************************************************/ | 
 | 66 |  | 
 | 67 | static struct mv643xx_eth_platform_data lsmini_eth_data = { | 
 | 68 | 	.phy_addr	= 8, | 
 | 69 | }; | 
 | 70 |  | 
 | 71 | /***************************************************************************** | 
 | 72 |  * RTC 5C372a on I2C bus | 
 | 73 |  ****************************************************************************/ | 
 | 74 |  | 
 | 75 | static struct i2c_board_info __initdata lsmini_i2c_rtc = { | 
 | 76 | 	I2C_BOARD_INFO("rs5c372a", 0x32), | 
 | 77 | }; | 
 | 78 |  | 
 | 79 | /***************************************************************************** | 
 | 80 |  * LEDs attached to GPIO | 
 | 81 |  ****************************************************************************/ | 
 | 82 |  | 
 | 83 | #define LSMINI_GPIO_LED_ALARM	2 | 
 | 84 | #define LSMINI_GPIO_LED_INFO	3 | 
 | 85 | #define LSMINI_GPIO_LED_FUNC	9 | 
 | 86 | #define LSMINI_GPIO_LED_PWR	14 | 
 | 87 |  | 
 | 88 | static struct gpio_led lsmini_led_pins[] = { | 
 | 89 | 	{ | 
 | 90 | 		.name	   = "alarm:red", | 
 | 91 | 		.gpio	   = LSMINI_GPIO_LED_ALARM, | 
 | 92 | 		.active_low     = 1, | 
 | 93 | 	}, { | 
 | 94 | 		.name	   = "info:amber", | 
 | 95 | 		.gpio	   = LSMINI_GPIO_LED_INFO, | 
 | 96 | 		.active_low     = 1, | 
 | 97 | 	}, { | 
 | 98 | 		.name	   = "func:blue:top", | 
 | 99 | 		.gpio	   = LSMINI_GPIO_LED_FUNC, | 
 | 100 | 		.active_low     = 1, | 
 | 101 | 	}, { | 
 | 102 | 		.name	   = "power:blue:bottom", | 
 | 103 | 		.gpio	   = LSMINI_GPIO_LED_PWR, | 
 | 104 | 	}, | 
 | 105 | }; | 
 | 106 |  | 
 | 107 | static struct gpio_led_platform_data lsmini_led_data = { | 
 | 108 | 	.leds	   = lsmini_led_pins, | 
 | 109 | 	.num_leds       = ARRAY_SIZE(lsmini_led_pins), | 
 | 110 | }; | 
 | 111 |  | 
 | 112 | static struct platform_device lsmini_leds = { | 
 | 113 | 	.name   = "leds-gpio", | 
 | 114 | 	.id     = -1, | 
 | 115 | 	.dev    = { | 
 | 116 | 		.platform_data  = &lsmini_led_data, | 
 | 117 | 	}, | 
 | 118 | }; | 
 | 119 |  | 
 | 120 | /**************************************************************************** | 
 | 121 |  * GPIO Attached Keys | 
 | 122 |  ****************************************************************************/ | 
 | 123 |  | 
 | 124 | #define LSMINI_GPIO_KEY_FUNC       15 | 
 | 125 | #define LSMINI_GPIO_KEY_POWER	   18 | 
 | 126 | #define LSMINI_GPIO_KEY_AUTOPOWER 17 | 
 | 127 |  | 
 | 128 | #define LSMINI_SW_POWER		0x00 | 
 | 129 | #define LSMINI_SW_AUTOPOWER	0x01 | 
 | 130 |  | 
 | 131 | static struct gpio_keys_button lsmini_buttons[] = { | 
 | 132 | 	{ | 
 | 133 | 		.code	   = KEY_OPTION, | 
 | 134 | 		.gpio	   = LSMINI_GPIO_KEY_FUNC, | 
 | 135 | 		.desc	   = "Function Button", | 
 | 136 | 		.active_low     = 1, | 
 | 137 | 	}, { | 
 | 138 | 		.type		= EV_SW, | 
 | 139 | 		.code	   = LSMINI_SW_POWER, | 
 | 140 | 		.gpio	   = LSMINI_GPIO_KEY_POWER, | 
 | 141 | 		.desc	   = "Power-on Switch", | 
 | 142 | 		.active_low     = 1, | 
 | 143 | 	}, { | 
 | 144 | 		.type		= EV_SW, | 
 | 145 | 		.code	   = LSMINI_SW_AUTOPOWER, | 
 | 146 | 		.gpio	   = LSMINI_GPIO_KEY_AUTOPOWER, | 
 | 147 | 		.desc	   = "Power-auto Switch", | 
 | 148 | 		.active_low     = 1, | 
 | 149 | 	}, | 
 | 150 | }; | 
 | 151 |  | 
 | 152 | static struct gpio_keys_platform_data lsmini_button_data = { | 
 | 153 | 	.buttons	= lsmini_buttons, | 
 | 154 | 	.nbuttons       = ARRAY_SIZE(lsmini_buttons), | 
 | 155 | }; | 
 | 156 |  | 
 | 157 | static struct platform_device lsmini_button_device = { | 
 | 158 | 	.name	   = "gpio-keys", | 
 | 159 | 	.id	     = -1, | 
 | 160 | 	.num_resources  = 0, | 
 | 161 | 	.dev	    = { | 
 | 162 | 		.platform_data  = &lsmini_button_data, | 
 | 163 | 	}, | 
 | 164 | }; | 
 | 165 |  | 
 | 166 |  | 
 | 167 | /***************************************************************************** | 
 | 168 |  * SATA | 
 | 169 |  ****************************************************************************/ | 
 | 170 | static struct mv_sata_platform_data lsmini_sata_data = { | 
 | 171 | 	.n_ports	= 2, | 
 | 172 | }; | 
 | 173 |  | 
 | 174 |  | 
 | 175 | /***************************************************************************** | 
| Alexey Kopytko | 92a5de8 | 2008-09-26 11:13:39 +0900 | [diff] [blame] | 176 |  * Linkstation Mini specific power off method: reboot | 
 | 177 |  ****************************************************************************/ | 
 | 178 | /* | 
 | 179 |  * On the Linkstation Mini, the shutdown process is following: | 
 | 180 |  * - Userland monitors key events until the power switch goes to off position | 
 | 181 |  * - The board reboots | 
 | 182 |  * - U-boot starts and goes into an idle mode waiting for the user | 
 | 183 |  *   to move the switch to ON position | 
 | 184 |  */ | 
 | 185 |  | 
 | 186 | static void lsmini_power_off(void) | 
 | 187 | { | 
| Russell King | 764cbcc | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 188 | 	orion5x_restart('h', NULL); | 
| Alexey Kopytko | 92a5de8 | 2008-09-26 11:13:39 +0900 | [diff] [blame] | 189 | } | 
 | 190 |  | 
 | 191 |  | 
 | 192 | /***************************************************************************** | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 193 |  * General Setup | 
 | 194 |  ****************************************************************************/ | 
 | 195 |  | 
 | 196 | #define LSMINI_GPIO_USB_POWER	16 | 
 | 197 | #define LSMINI_GPIO_AUTO_POWER	17 | 
 | 198 | #define LSMINI_GPIO_POWER	18 | 
 | 199 |  | 
 | 200 | #define LSMINI_GPIO_HDD_POWER0	1 | 
 | 201 | #define LSMINI_GPIO_HDD_POWER1	19 | 
 | 202 |  | 
| Andrew Lunn | 554cdae | 2011-05-15 13:32:53 +0200 | [diff] [blame] | 203 | static unsigned int lsmini_mpp_modes[] __initdata = { | 
 | 204 | 	MPP0_UNUSED, /* LED_RESERVE1 (unused) */ | 
 | 205 | 	MPP1_GPIO, /* HDD_PWR */ | 
 | 206 | 	MPP2_GPIO, /* LED_ALARM */ | 
 | 207 | 	MPP3_GPIO, /* LED_INFO */ | 
 | 208 | 	MPP4_UNUSED, | 
 | 209 | 	MPP5_UNUSED, | 
 | 210 | 	MPP6_UNUSED, | 
 | 211 | 	MPP7_UNUSED, | 
 | 212 | 	MPP8_UNUSED, | 
 | 213 | 	MPP9_GPIO, /* LED_FUNC */ | 
 | 214 | 	MPP10_UNUSED, | 
 | 215 | 	MPP11_UNUSED, /* LED_ETH (dummy) */ | 
 | 216 | 	MPP12_UNUSED, | 
 | 217 | 	MPP13_UNUSED, | 
 | 218 | 	MPP14_GPIO, /* LED_PWR */ | 
 | 219 | 	MPP15_GPIO, /* FUNC */ | 
 | 220 | 	MPP16_GPIO, /* USB_PWR */ | 
 | 221 | 	MPP17_GPIO, /* AUTO_POWER */ | 
 | 222 | 	MPP18_GPIO, /* POWER */ | 
 | 223 | 	MPP19_GPIO, /* HDD_PWR1 */ | 
 | 224 | 	0, | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 225 | }; | 
 | 226 |  | 
 | 227 | static void __init lsmini_init(void) | 
 | 228 | { | 
 | 229 | 	/* | 
 | 230 | 	 * Setup basic Orion functions. Need to be called early. | 
 | 231 | 	 */ | 
 | 232 | 	orion5x_init(); | 
 | 233 |  | 
 | 234 | 	orion5x_mpp_conf(lsmini_mpp_modes); | 
 | 235 |  | 
 | 236 | 	/* | 
 | 237 | 	 * Configure peripherals. | 
 | 238 | 	 */ | 
 | 239 | 	orion5x_ehci0_init(); | 
 | 240 | 	orion5x_ehci1_init(); | 
 | 241 | 	orion5x_eth_init(&lsmini_eth_data); | 
 | 242 | 	orion5x_i2c_init(); | 
 | 243 | 	orion5x_sata_init(&lsmini_sata_data); | 
 | 244 | 	orion5x_uart0_init(); | 
 | 245 | 	orion5x_xor_init(); | 
 | 246 |  | 
 | 247 | 	orion5x_setup_dev_boot_win(LSMINI_NOR_BOOT_BASE, | 
 | 248 | 				   LSMINI_NOR_BOOT_SIZE); | 
 | 249 | 	platform_device_register(&lsmini_nor_flash); | 
 | 250 |  | 
 | 251 | 	platform_device_register(&lsmini_button_device); | 
 | 252 |  | 
 | 253 | 	platform_device_register(&lsmini_leds); | 
 | 254 |  | 
 | 255 | 	i2c_register_board_info(0, &lsmini_i2c_rtc, 1); | 
 | 256 |  | 
 | 257 | 	/* enable USB power */ | 
 | 258 | 	gpio_set_value(LSMINI_GPIO_USB_POWER, 1); | 
 | 259 |  | 
| Alexey Kopytko | 92a5de8 | 2008-09-26 11:13:39 +0900 | [diff] [blame] | 260 | 	/* register power-off method */ | 
 | 261 | 	pm_power_off = lsmini_power_off; | 
 | 262 |  | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 263 | 	pr_info("%s: finished\n", __func__); | 
 | 264 | } | 
 | 265 |  | 
 | 266 | #ifdef CONFIG_MACH_LINKSTATION_MINI | 
 | 267 | MACHINE_START(LINKSTATION_MINI, "Buffalo Linkstation Mini") | 
 | 268 | 	/* Maintainer: Alexey Kopytko <alexey@kopytko.ru> */ | 
| Nicolas Pitre | 65aa1b1 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 269 | 	.atag_offset	= 0x100, | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 270 | 	.init_machine	= lsmini_init, | 
 | 271 | 	.map_io		= orion5x_map_io, | 
| Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 272 | 	.init_early	= orion5x_init_early, | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 273 | 	.init_irq	= orion5x_init_irq, | 
 | 274 | 	.timer		= &orion5x_timer, | 
 | 275 | 	.fixup		= tag_fixup_mem32, | 
| Russell King | 764cbcc | 2011-11-05 10:13:41 +0000 | [diff] [blame] | 276 | 	.restart	= orion5x_restart, | 
| Alexey Kopytko | 7b0a26f | 2008-09-25 22:47:30 +0900 | [diff] [blame] | 277 | MACHINE_END | 
 | 278 | #endif |