board-csb337.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 "generic.h"
  39. static void __init csb337_init_early(void)
  40. {
  41. /* Initialize processor: 3.6864 MHz crystal */
  42. at91_initialize(3686400);
  43. /* Setup the LEDs */
  44. at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
  45. /* DBGU on ttyS0 */
  46. at91_register_uart(0, 0, 0);
  47. /* make console=ttyS0 the default */
  48. at91_set_serial_console(0);
  49. }
  50. static struct macb_platform_data __initdata csb337_eth_data = {
  51. .phy_irq_pin = AT91_PIN_PC2,
  52. .is_rmii = 0,
  53. };
  54. static struct at91_usbh_data __initdata csb337_usbh_data = {
  55. .ports = 2,
  56. .vbus_pin = {-EINVAL, -EINVAL},
  57. .overcurrent_pin= {-EINVAL, -EINVAL},
  58. };
  59. static struct at91_udc_data __initdata csb337_udc_data = {
  60. .pullup_pin = AT91_PIN_PA24,
  61. .vbus_pin = -EINVAL,
  62. };
  63. static struct i2c_board_info __initdata csb337_i2c_devices[] = {
  64. {
  65. I2C_BOARD_INFO("ds1307", 0x68),
  66. },
  67. };
  68. static struct at91_cf_data __initdata csb337_cf_data = {
  69. /*
  70. * connector P4 on the CSB 337 mates to
  71. * connector P8 on the CSB 300CF
  72. */
  73. /* CSB337 specific */
  74. .det_pin = AT91_PIN_PC3,
  75. /* CSB300CF specific */
  76. .irq_pin = AT91_PIN_PA19,
  77. .vcc_pin = AT91_PIN_PD0,
  78. .rst_pin = AT91_PIN_PD2,
  79. };
  80. static struct at91_mmc_data __initdata csb337_mmc_data = {
  81. .det_pin = AT91_PIN_PD5,
  82. .slot_b = 0,
  83. .wire4 = 1,
  84. .wp_pin = AT91_PIN_PD6,
  85. .vcc_pin = -EINVAL,
  86. };
  87. static struct spi_board_info csb337_spi_devices[] = {
  88. { /* CAN controller */
  89. .modalias = "sak82c900",
  90. .chip_select = 0,
  91. .max_speed_hz = 6 * 1000 * 1000,
  92. },
  93. };
  94. #define CSB_FLASH_BASE AT91_CHIPSELECT_0
  95. #define CSB_FLASH_SIZE SZ_8M
  96. static struct mtd_partition csb_flash_partitions[] = {
  97. {
  98. .name = "uMON flash",
  99. .offset = 0,
  100. .size = MTDPART_SIZ_FULL,
  101. .mask_flags = MTD_WRITEABLE, /* read only */
  102. }
  103. };
  104. static struct physmap_flash_data csb_flash_data = {
  105. .width = 2,
  106. .parts = csb_flash_partitions,
  107. .nr_parts = ARRAY_SIZE(csb_flash_partitions),
  108. };
  109. static struct resource csb_flash_resources[] = {
  110. {
  111. .start = CSB_FLASH_BASE,
  112. .end = CSB_FLASH_BASE + CSB_FLASH_SIZE - 1,
  113. .flags = IORESOURCE_MEM,
  114. }
  115. };
  116. static struct platform_device csb_flash = {
  117. .name = "physmap-flash",
  118. .id = 0,
  119. .dev = {
  120. .platform_data = &csb_flash_data,
  121. },
  122. .resource = csb_flash_resources,
  123. .num_resources = ARRAY_SIZE(csb_flash_resources),
  124. };
  125. /*
  126. * GPIO Buttons (on CSB300)
  127. */
  128. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  129. static struct gpio_keys_button csb300_buttons[] = {
  130. {
  131. .gpio = AT91_PIN_PB29,
  132. .code = BTN_0,
  133. .desc = "sw0",
  134. .active_low = 1,
  135. .wakeup = 1,
  136. },
  137. {
  138. .gpio = AT91_PIN_PB28,
  139. .code = BTN_1,
  140. .desc = "sw1",
  141. .active_low = 1,
  142. .wakeup = 1,
  143. },
  144. {
  145. .gpio = AT91_PIN_PA21,
  146. .code = BTN_2,
  147. .desc = "sw2",
  148. .active_low = 1,
  149. .wakeup = 1,
  150. }
  151. };
  152. static struct gpio_keys_platform_data csb300_button_data = {
  153. .buttons = csb300_buttons,
  154. .nbuttons = ARRAY_SIZE(csb300_buttons),
  155. };
  156. static struct platform_device csb300_button_device = {
  157. .name = "gpio-keys",
  158. .id = -1,
  159. .num_resources = 0,
  160. .dev = {
  161. .platform_data = &csb300_button_data,
  162. }
  163. };
  164. static void __init csb300_add_device_buttons(void)
  165. {
  166. at91_set_gpio_input(AT91_PIN_PB29, 1); /* sw0 */
  167. at91_set_deglitch(AT91_PIN_PB29, 1);
  168. at91_set_gpio_input(AT91_PIN_PB28, 1); /* sw1 */
  169. at91_set_deglitch(AT91_PIN_PB28, 1);
  170. at91_set_gpio_input(AT91_PIN_PA21, 1); /* sw2 */
  171. at91_set_deglitch(AT91_PIN_PA21, 1);
  172. platform_device_register(&csb300_button_device);
  173. }
  174. #else
  175. static void __init csb300_add_device_buttons(void) {}
  176. #endif
  177. static struct gpio_led csb_leds[] = {
  178. { /* "led0", yellow */
  179. .name = "led0",
  180. .gpio = AT91_PIN_PB2,
  181. .active_low = 1,
  182. .default_trigger = "heartbeat",
  183. },
  184. { /* "led1", green */
  185. .name = "led1",
  186. .gpio = AT91_PIN_PB1,
  187. .active_low = 1,
  188. .default_trigger = "mmc0",
  189. },
  190. { /* "led2", yellow */
  191. .name = "led2",
  192. .gpio = AT91_PIN_PB0,
  193. .active_low = 1,
  194. .default_trigger = "ide-disk",
  195. }
  196. };
  197. static void __init csb337_board_init(void)
  198. {
  199. /* Serial */
  200. at91_add_device_serial();
  201. /* Ethernet */
  202. at91_add_device_eth(&csb337_eth_data);
  203. /* USB Host */
  204. at91_add_device_usbh(&csb337_usbh_data);
  205. /* USB Device */
  206. at91_add_device_udc(&csb337_udc_data);
  207. /* I2C */
  208. at91_add_device_i2c(csb337_i2c_devices, ARRAY_SIZE(csb337_i2c_devices));
  209. /* Compact Flash */
  210. at91_set_gpio_input(AT91_PIN_PB22, 1); /* IOIS16 */
  211. at91_add_device_cf(&csb337_cf_data);
  212. /* SPI */
  213. at91_add_device_spi(csb337_spi_devices, ARRAY_SIZE(csb337_spi_devices));
  214. /* MMC */
  215. at91_add_device_mmc(0, &csb337_mmc_data);
  216. /* NOR flash */
  217. platform_device_register(&csb_flash);
  218. /* LEDs */
  219. at91_gpio_leds(csb_leds, ARRAY_SIZE(csb_leds));
  220. /* Switches on CSB300 */
  221. csb300_add_device_buttons();
  222. }
  223. MACHINE_START(CSB337, "Cogent CSB337")
  224. /* Maintainer: Bill Gatliff */
  225. .timer = &at91rm9200_timer,
  226. .map_io = at91_map_io,
  227. .init_early = csb337_init_early,
  228. .init_irq = at91_init_irq_default,
  229. .init_machine = csb337_board_init,
  230. MACHINE_END