board-csb337.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * linux/arch/arm/mach-at91/board-csb337.c
  3. *
  4. * Copyright (C) 2005 SAN People
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/types.h>
  21. #include <linux/gpio.h>
  22. #include <linux/init.h>
  23. #include <linux/mm.h>
  24. #include <linux/module.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/mtd/physmap.h>
  28. #include <linux/input.h>
  29. #include <linux/gpio_keys.h>
  30. #include <asm/setup.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/irq.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/irq.h>
  36. #include <mach/hardware.h>
  37. #include <mach/board.h>
  38. #include <mach/at91_aic.h>
  39. #include "generic.h"
  40. static void __init csb337_init_early(void)
  41. {
  42. /* Initialize processor: 3.6864 MHz crystal */
  43. at91_initialize(3686400);
  44. }
  45. static struct macb_platform_data __initdata csb337_eth_data = {
  46. .phy_irq_pin = AT91_PIN_PC2,
  47. .is_rmii = 0,
  48. };
  49. static struct at91_usbh_data __initdata csb337_usbh_data = {
  50. .ports = 2,
  51. .vbus_pin = {-EINVAL, -EINVAL},
  52. .overcurrent_pin= {-EINVAL, -EINVAL},
  53. };
  54. static struct at91_udc_data __initdata csb337_udc_data = {
  55. .pullup_pin = AT91_PIN_PA24,
  56. .vbus_pin = -EINVAL,
  57. };
  58. static struct i2c_board_info __initdata csb337_i2c_devices[] = {
  59. {
  60. I2C_BOARD_INFO("ds1307", 0x68),
  61. },
  62. };
  63. static struct at91_cf_data __initdata csb337_cf_data = {
  64. /*
  65. * connector P4 on the CSB 337 mates to
  66. * connector P8 on the CSB 300CF
  67. */
  68. /* CSB337 specific */
  69. .det_pin = AT91_PIN_PC3,
  70. /* CSB300CF specific */
  71. .irq_pin = AT91_PIN_PA19,
  72. .vcc_pin = AT91_PIN_PD0,
  73. .rst_pin = AT91_PIN_PD2,
  74. };
  75. static struct at91_mmc_data __initdata csb337_mmc_data = {
  76. .det_pin = AT91_PIN_PD5,
  77. .slot_b = 0,
  78. .wire4 = 1,
  79. .wp_pin = AT91_PIN_PD6,
  80. .vcc_pin = -EINVAL,
  81. };
  82. static struct spi_board_info csb337_spi_devices[] = {
  83. { /* CAN controller */
  84. .modalias = "sak82c900",
  85. .chip_select = 0,
  86. .max_speed_hz = 6 * 1000 * 1000,
  87. },
  88. };
  89. #define CSB_FLASH_BASE AT91_CHIPSELECT_0
  90. #define CSB_FLASH_SIZE SZ_8M
  91. static struct mtd_partition csb_flash_partitions[] = {
  92. {
  93. .name = "uMON flash",
  94. .offset = 0,
  95. .size = MTDPART_SIZ_FULL,
  96. .mask_flags = MTD_WRITEABLE, /* read only */
  97. }
  98. };
  99. static struct physmap_flash_data csb_flash_data = {
  100. .width = 2,
  101. .parts = csb_flash_partitions,
  102. .nr_parts = ARRAY_SIZE(csb_flash_partitions),
  103. };
  104. static struct resource csb_flash_resources[] = {
  105. {
  106. .start = CSB_FLASH_BASE,
  107. .end = CSB_FLASH_BASE + CSB_FLASH_SIZE - 1,
  108. .flags = IORESOURCE_MEM,
  109. }
  110. };
  111. static struct platform_device csb_flash = {
  112. .name = "physmap-flash",
  113. .id = 0,
  114. .dev = {
  115. .platform_data = &csb_flash_data,
  116. },
  117. .resource = csb_flash_resources,
  118. .num_resources = ARRAY_SIZE(csb_flash_resources),
  119. };
  120. /*
  121. * GPIO Buttons (on CSB300)
  122. */
  123. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  124. static struct gpio_keys_button csb300_buttons[] = {
  125. {
  126. .gpio = AT91_PIN_PB29,
  127. .code = BTN_0,
  128. .desc = "sw0",
  129. .active_low = 1,
  130. .wakeup = 1,
  131. },
  132. {
  133. .gpio = AT91_PIN_PB28,
  134. .code = BTN_1,
  135. .desc = "sw1",
  136. .active_low = 1,
  137. .wakeup = 1,
  138. },
  139. {
  140. .gpio = AT91_PIN_PA21,
  141. .code = BTN_2,
  142. .desc = "sw2",
  143. .active_low = 1,
  144. .wakeup = 1,
  145. }
  146. };
  147. static struct gpio_keys_platform_data csb300_button_data = {
  148. .buttons = csb300_buttons,
  149. .nbuttons = ARRAY_SIZE(csb300_buttons),
  150. };
  151. static struct platform_device csb300_button_device = {
  152. .name = "gpio-keys",
  153. .id = -1,
  154. .num_resources = 0,
  155. .dev = {
  156. .platform_data = &csb300_button_data,
  157. }
  158. };
  159. static void __init csb300_add_device_buttons(void)
  160. {
  161. at91_set_gpio_input(AT91_PIN_PB29, 1); /* sw0 */
  162. at91_set_deglitch(AT91_PIN_PB29, 1);
  163. at91_set_gpio_input(AT91_PIN_PB28, 1); /* sw1 */
  164. at91_set_deglitch(AT91_PIN_PB28, 1);
  165. at91_set_gpio_input(AT91_PIN_PA21, 1); /* sw2 */
  166. at91_set_deglitch(AT91_PIN_PA21, 1);
  167. platform_device_register(&csb300_button_device);
  168. }
  169. #else
  170. static void __init csb300_add_device_buttons(void) {}
  171. #endif
  172. static struct gpio_led csb_leds[] = {
  173. { /* "led0", yellow */
  174. .name = "led0",
  175. .gpio = AT91_PIN_PB2,
  176. .active_low = 1,
  177. .default_trigger = "heartbeat",
  178. },
  179. { /* "led1", green */
  180. .name = "led1",
  181. .gpio = AT91_PIN_PB1,
  182. .active_low = 1,
  183. .default_trigger = "mmc0",
  184. },
  185. { /* "led2", yellow */
  186. .name = "led2",
  187. .gpio = AT91_PIN_PB0,
  188. .active_low = 1,
  189. .default_trigger = "ide-disk",
  190. }
  191. };
  192. static void __init csb337_board_init(void)
  193. {
  194. /* Setup the LEDs */
  195. at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
  196. /* Serial */
  197. /* DBGU on ttyS0 */
  198. at91_register_uart(0, 0, 0);
  199. at91_add_device_serial();
  200. /* Ethernet */
  201. at91_add_device_eth(&csb337_eth_data);
  202. /* USB Host */
  203. at91_add_device_usbh(&csb337_usbh_data);
  204. /* USB Device */
  205. at91_add_device_udc(&csb337_udc_data);
  206. /* I2C */
  207. at91_add_device_i2c(csb337_i2c_devices, ARRAY_SIZE(csb337_i2c_devices));
  208. /* Compact Flash */
  209. at91_set_gpio_input(AT91_PIN_PB22, 1); /* IOIS16 */
  210. at91_add_device_cf(&csb337_cf_data);
  211. /* SPI */
  212. at91_add_device_spi(csb337_spi_devices, ARRAY_SIZE(csb337_spi_devices));
  213. /* MMC */
  214. at91_add_device_mmc(0, &csb337_mmc_data);
  215. /* NOR flash */
  216. platform_device_register(&csb_flash);
  217. /* LEDs */
  218. at91_gpio_leds(csb_leds, ARRAY_SIZE(csb_leds));
  219. /* Switches on CSB300 */
  220. csb300_add_device_buttons();
  221. }
  222. MACHINE_START(CSB337, "Cogent CSB337")
  223. /* Maintainer: Bill Gatliff */
  224. .timer = &at91rm9200_timer,
  225. .map_io = at91_map_io,
  226. .handle_irq = at91_aic_handle_irq,
  227. .init_early = csb337_init_early,
  228. .init_irq = at91_init_irq_default,
  229. .init_machine = csb337_board_init,
  230. MACHINE_END