db88f5281-setup.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*
  2. * arch/arm/mach-orion5x/db88f5281-setup.c
  3. *
  4. * Marvell Orion-2 Development Board Setup
  5. *
  6. * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/gpio.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/pci.h>
  17. #include <linux/irq.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/mtd/nand.h>
  20. #include <linux/timer.h>
  21. #include <linux/mv643xx_eth.h>
  22. #include <linux/i2c.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/pci.h>
  26. #include <linux/platform_data/mtd-orion_nand.h>
  27. #include "common.h"
  28. #include "mpp.h"
  29. #include "orion5x.h"
  30. /*****************************************************************************
  31. * DB-88F5281 on board devices
  32. ****************************************************************************/
  33. /*
  34. * 512K NOR flash Device bus boot chip select
  35. */
  36. #define DB88F5281_NOR_BOOT_BASE 0xf4000000
  37. #define DB88F5281_NOR_BOOT_SIZE SZ_512K
  38. /*
  39. * 7-Segment on Device bus chip select 0
  40. */
  41. #define DB88F5281_7SEG_BASE 0xfa000000
  42. #define DB88F5281_7SEG_SIZE SZ_1K
  43. /*
  44. * 32M NOR flash on Device bus chip select 1
  45. */
  46. #define DB88F5281_NOR_BASE 0xfc000000
  47. #define DB88F5281_NOR_SIZE SZ_32M
  48. /*
  49. * 32M NAND flash on Device bus chip select 2
  50. */
  51. #define DB88F5281_NAND_BASE 0xfa800000
  52. #define DB88F5281_NAND_SIZE SZ_1K
  53. /*
  54. * PCI
  55. */
  56. #define DB88F5281_PCI_SLOT0_OFFS 7
  57. #define DB88F5281_PCI_SLOT0_IRQ_PIN 12
  58. #define DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN 13
  59. /*****************************************************************************
  60. * 512M NOR Flash on Device bus Boot CS
  61. ****************************************************************************/
  62. static struct physmap_flash_data db88f5281_boot_flash_data = {
  63. .width = 1, /* 8 bit bus width */
  64. };
  65. static struct resource db88f5281_boot_flash_resource = {
  66. .flags = IORESOURCE_MEM,
  67. .start = DB88F5281_NOR_BOOT_BASE,
  68. .end = DB88F5281_NOR_BOOT_BASE + DB88F5281_NOR_BOOT_SIZE - 1,
  69. };
  70. static struct platform_device db88f5281_boot_flash = {
  71. .name = "physmap-flash",
  72. .id = 0,
  73. .dev = {
  74. .platform_data = &db88f5281_boot_flash_data,
  75. },
  76. .num_resources = 1,
  77. .resource = &db88f5281_boot_flash_resource,
  78. };
  79. /*****************************************************************************
  80. * 32M NOR Flash on Device bus CS1
  81. ****************************************************************************/
  82. static struct physmap_flash_data db88f5281_nor_flash_data = {
  83. .width = 4, /* 32 bit bus width */
  84. };
  85. static struct resource db88f5281_nor_flash_resource = {
  86. .flags = IORESOURCE_MEM,
  87. .start = DB88F5281_NOR_BASE,
  88. .end = DB88F5281_NOR_BASE + DB88F5281_NOR_SIZE - 1,
  89. };
  90. static struct platform_device db88f5281_nor_flash = {
  91. .name = "physmap-flash",
  92. .id = 1,
  93. .dev = {
  94. .platform_data = &db88f5281_nor_flash_data,
  95. },
  96. .num_resources = 1,
  97. .resource = &db88f5281_nor_flash_resource,
  98. };
  99. /*****************************************************************************
  100. * 32M NAND Flash on Device bus CS2
  101. ****************************************************************************/
  102. static struct mtd_partition db88f5281_nand_parts[] = {
  103. {
  104. .name = "kernel",
  105. .offset = 0,
  106. .size = SZ_2M,
  107. }, {
  108. .name = "root",
  109. .offset = SZ_2M,
  110. .size = (SZ_16M - SZ_2M),
  111. }, {
  112. .name = "user",
  113. .offset = SZ_16M,
  114. .size = SZ_8M,
  115. }, {
  116. .name = "recovery",
  117. .offset = (SZ_16M + SZ_8M),
  118. .size = SZ_8M,
  119. },
  120. };
  121. static struct resource db88f5281_nand_resource = {
  122. .flags = IORESOURCE_MEM,
  123. .start = DB88F5281_NAND_BASE,
  124. .end = DB88F5281_NAND_BASE + DB88F5281_NAND_SIZE - 1,
  125. };
  126. static struct orion_nand_data db88f5281_nand_data = {
  127. .parts = db88f5281_nand_parts,
  128. .nr_parts = ARRAY_SIZE(db88f5281_nand_parts),
  129. .cle = 0,
  130. .ale = 1,
  131. .width = 8,
  132. };
  133. static struct platform_device db88f5281_nand_flash = {
  134. .name = "orion_nand",
  135. .id = -1,
  136. .dev = {
  137. .platform_data = &db88f5281_nand_data,
  138. },
  139. .resource = &db88f5281_nand_resource,
  140. .num_resources = 1,
  141. };
  142. /*****************************************************************************
  143. * 7-Segment on Device bus CS0
  144. * Dummy counter every 2 sec
  145. ****************************************************************************/
  146. static void __iomem *db88f5281_7seg;
  147. static struct timer_list db88f5281_timer;
  148. static void db88f5281_7seg_event(unsigned long data)
  149. {
  150. static int count = 0;
  151. writel(0, db88f5281_7seg + (count << 4));
  152. count = (count + 1) & 7;
  153. mod_timer(&db88f5281_timer, jiffies + 2 * HZ);
  154. }
  155. static int __init db88f5281_7seg_init(void)
  156. {
  157. if (machine_is_db88f5281()) {
  158. db88f5281_7seg = ioremap(DB88F5281_7SEG_BASE,
  159. DB88F5281_7SEG_SIZE);
  160. if (!db88f5281_7seg) {
  161. printk(KERN_ERR "Failed to ioremap db88f5281_7seg\n");
  162. return -EIO;
  163. }
  164. setup_timer(&db88f5281_timer, db88f5281_7seg_event, 0);
  165. mod_timer(&db88f5281_timer, jiffies + 2 * HZ);
  166. }
  167. return 0;
  168. }
  169. __initcall(db88f5281_7seg_init);
  170. /*****************************************************************************
  171. * PCI
  172. ****************************************************************************/
  173. static void __init db88f5281_pci_preinit(void)
  174. {
  175. int pin;
  176. /*
  177. * Configure PCI GPIO IRQ pins
  178. */
  179. pin = DB88F5281_PCI_SLOT0_IRQ_PIN;
  180. if (gpio_request(pin, "PCI Int1") == 0) {
  181. if (gpio_direction_input(pin) == 0) {
  182. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  183. } else {
  184. printk(KERN_ERR "db88f5281_pci_preinit failed to "
  185. "set_irq_type pin %d\n", pin);
  186. gpio_free(pin);
  187. }
  188. } else {
  189. printk(KERN_ERR "db88f5281_pci_preinit failed to gpio_request %d\n", pin);
  190. }
  191. pin = DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN;
  192. if (gpio_request(pin, "PCI Int2") == 0) {
  193. if (gpio_direction_input(pin) == 0) {
  194. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  195. } else {
  196. printk(KERN_ERR "db88f5281_pci_preinit failed "
  197. "to set_irq_type pin %d\n", pin);
  198. gpio_free(pin);
  199. }
  200. } else {
  201. printk(KERN_ERR "db88f5281_pci_preinit failed to gpio_request %d\n", pin);
  202. }
  203. }
  204. static int __init db88f5281_pci_map_irq(const struct pci_dev *dev, u8 slot,
  205. u8 pin)
  206. {
  207. int irq;
  208. /*
  209. * Check for devices with hard-wired IRQs.
  210. */
  211. irq = orion5x_pci_map_irq(dev, slot, pin);
  212. if (irq != -1)
  213. return irq;
  214. /*
  215. * PCI IRQs are connected via GPIOs.
  216. */
  217. switch (slot - DB88F5281_PCI_SLOT0_OFFS) {
  218. case 0:
  219. return gpio_to_irq(DB88F5281_PCI_SLOT0_IRQ_PIN);
  220. case 1:
  221. case 2:
  222. return gpio_to_irq(DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN);
  223. default:
  224. return -1;
  225. }
  226. }
  227. static struct hw_pci db88f5281_pci __initdata = {
  228. .nr_controllers = 2,
  229. .preinit = db88f5281_pci_preinit,
  230. .setup = orion5x_pci_sys_setup,
  231. .scan = orion5x_pci_sys_scan_bus,
  232. .map_irq = db88f5281_pci_map_irq,
  233. };
  234. static int __init db88f5281_pci_init(void)
  235. {
  236. if (machine_is_db88f5281())
  237. pci_common_init(&db88f5281_pci);
  238. return 0;
  239. }
  240. subsys_initcall(db88f5281_pci_init);
  241. /*****************************************************************************
  242. * Ethernet
  243. ****************************************************************************/
  244. static struct mv643xx_eth_platform_data db88f5281_eth_data = {
  245. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  246. };
  247. /*****************************************************************************
  248. * RTC DS1339 on I2C bus
  249. ****************************************************************************/
  250. static struct i2c_board_info __initdata db88f5281_i2c_rtc = {
  251. I2C_BOARD_INFO("ds1339", 0x68),
  252. };
  253. /*****************************************************************************
  254. * General Setup
  255. ****************************************************************************/
  256. static unsigned int db88f5281_mpp_modes[] __initdata = {
  257. MPP0_GPIO, /* USB Over Current */
  258. MPP1_GPIO, /* USB Vbat input */
  259. MPP2_PCI_ARB, /* PCI_REQn[2] */
  260. MPP3_PCI_ARB, /* PCI_GNTn[2] */
  261. MPP4_PCI_ARB, /* PCI_REQn[3] */
  262. MPP5_PCI_ARB, /* PCI_GNTn[3] */
  263. MPP6_GPIO, /* JP0, CON17.2 */
  264. MPP7_GPIO, /* JP1, CON17.1 */
  265. MPP8_GPIO, /* JP2, CON11.2 */
  266. MPP9_GPIO, /* JP3, CON11.3 */
  267. MPP10_GPIO, /* RTC int */
  268. MPP11_GPIO, /* Baud Rate Generator */
  269. MPP12_GPIO, /* PCI int 1 */
  270. MPP13_GPIO, /* PCI int 2 */
  271. MPP14_NAND, /* NAND_REn[2] */
  272. MPP15_NAND, /* NAND_WEn[2] */
  273. MPP16_UART, /* UART1_RX */
  274. MPP17_UART, /* UART1_TX */
  275. MPP18_UART, /* UART1_CTSn */
  276. MPP19_UART, /* UART1_RTSn */
  277. 0,
  278. };
  279. static void __init db88f5281_init(void)
  280. {
  281. /*
  282. * Basic Orion setup. Need to be called early.
  283. */
  284. orion5x_init();
  285. orion5x_mpp_conf(db88f5281_mpp_modes);
  286. writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */
  287. /*
  288. * Configure peripherals.
  289. */
  290. orion5x_ehci0_init();
  291. orion5x_eth_init(&db88f5281_eth_data);
  292. orion5x_i2c_init();
  293. orion5x_uart0_init();
  294. orion5x_uart1_init();
  295. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  296. ORION_MBUS_DEVBUS_BOOT_ATTR,
  297. DB88F5281_NOR_BOOT_BASE,
  298. DB88F5281_NOR_BOOT_SIZE);
  299. platform_device_register(&db88f5281_boot_flash);
  300. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_TARGET(0),
  301. ORION_MBUS_DEVBUS_ATTR(0),
  302. DB88F5281_7SEG_BASE,
  303. DB88F5281_7SEG_SIZE);
  304. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_TARGET(1),
  305. ORION_MBUS_DEVBUS_ATTR(1),
  306. DB88F5281_NOR_BASE,
  307. DB88F5281_NOR_SIZE);
  308. platform_device_register(&db88f5281_nor_flash);
  309. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_TARGET(2),
  310. ORION_MBUS_DEVBUS_ATTR(2),
  311. DB88F5281_NAND_BASE,
  312. DB88F5281_NAND_SIZE);
  313. platform_device_register(&db88f5281_nand_flash);
  314. i2c_register_board_info(0, &db88f5281_i2c_rtc, 1);
  315. }
  316. MACHINE_START(DB88F5281, "Marvell Orion-2 Development Board")
  317. /* Maintainer: Tzachi Perelstein <tzachi@marvell.com> */
  318. .atag_offset = 0x100,
  319. .nr_irqs = ORION5X_NR_IRQS,
  320. .init_machine = db88f5281_init,
  321. .map_io = orion5x_map_io,
  322. .init_early = orion5x_init_early,
  323. .init_irq = orion5x_init_irq,
  324. .init_time = orion5x_timer_init,
  325. .restart = orion5x_restart,
  326. MACHINE_END