board-csb337.c 6.4 KB

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