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