board-csb337.c 6.1 KB

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