db88f5281-setup.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /*
  2. * arch/arm/mach-orion/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/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/pci.h>
  16. #include <linux/irq.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/mtd/nand.h>
  19. #include <linux/timer.h>
  20. #include <linux/mv643xx_eth.h>
  21. #include <linux/i2c.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/gpio.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/pci.h>
  26. #include <asm/arch/orion.h>
  27. #include <asm/arch/platform.h>
  28. #include "common.h"
  29. /*****************************************************************************
  30. * DB-88F5281 on board devices
  31. ****************************************************************************/
  32. /*
  33. * 512K NOR flash Device bus boot chip select
  34. */
  35. #define DB88F5281_NOR_BOOT_BASE 0xf4000000
  36. #define DB88F5281_NOR_BOOT_SIZE SZ_512K
  37. /*
  38. * 7-Segment on Device bus chip select 0
  39. */
  40. #define DB88F5281_7SEG_BASE 0xfa000000
  41. #define DB88F5281_7SEG_SIZE SZ_1K
  42. /*
  43. * 32M NOR flash on Device bus chip select 1
  44. */
  45. #define DB88F5281_NOR_BASE 0xfc000000
  46. #define DB88F5281_NOR_SIZE SZ_32M
  47. /*
  48. * 32M NAND flash on Device bus chip select 2
  49. */
  50. #define DB88F5281_NAND_BASE 0xfa800000
  51. #define DB88F5281_NAND_SIZE SZ_1K
  52. /*
  53. * PCI
  54. */
  55. #define DB88F5281_PCI_SLOT0_OFFS 7
  56. #define DB88F5281_PCI_SLOT0_IRQ_PIN 12
  57. #define DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN 13
  58. /*****************************************************************************
  59. * 512M NOR Flash on Device bus Boot CS
  60. ****************************************************************************/
  61. static struct physmap_flash_data db88f5281_boot_flash_data = {
  62. .width = 1, /* 8 bit bus width */
  63. };
  64. static struct resource db88f5281_boot_flash_resource = {
  65. .flags = IORESOURCE_MEM,
  66. .start = DB88F5281_NOR_BOOT_BASE,
  67. .end = DB88F5281_NOR_BOOT_BASE + DB88F5281_NOR_BOOT_SIZE - 1,
  68. };
  69. static struct platform_device db88f5281_boot_flash = {
  70. .name = "physmap-flash",
  71. .id = 0,
  72. .dev = {
  73. .platform_data = &db88f5281_boot_flash_data,
  74. },
  75. .num_resources = 1,
  76. .resource = &db88f5281_boot_flash_resource,
  77. };
  78. /*****************************************************************************
  79. * 32M NOR Flash on Device bus CS1
  80. ****************************************************************************/
  81. static struct physmap_flash_data db88f5281_nor_flash_data = {
  82. .width = 4, /* 32 bit bus width */
  83. };
  84. static struct resource db88f5281_nor_flash_resource = {
  85. .flags = IORESOURCE_MEM,
  86. .start = DB88F5281_NOR_BASE,
  87. .end = DB88F5281_NOR_BASE + DB88F5281_NOR_SIZE - 1,
  88. };
  89. static struct platform_device db88f5281_nor_flash = {
  90. .name = "physmap-flash",
  91. .id = 1,
  92. .dev = {
  93. .platform_data = &db88f5281_nor_flash_data,
  94. },
  95. .num_resources = 1,
  96. .resource = &db88f5281_nor_flash_resource,
  97. };
  98. /*****************************************************************************
  99. * 32M NAND Flash on Device bus CS2
  100. ****************************************************************************/
  101. static struct mtd_partition db88f5281_nand_parts[] = {
  102. {
  103. .name = "kernel",
  104. .offset = 0,
  105. .size = SZ_2M,
  106. },
  107. {
  108. .name = "root",
  109. .offset = SZ_2M,
  110. .size = (SZ_16M - SZ_2M),
  111. },
  112. {
  113. .name = "user",
  114. .offset = SZ_16M,
  115. .size = SZ_8M,
  116. },
  117. {
  118. .name = "recovery",
  119. .offset = (SZ_16M + SZ_8M),
  120. .size = SZ_8M,
  121. },
  122. };
  123. static struct resource db88f5281_nand_resource = {
  124. .flags = IORESOURCE_MEM,
  125. .start = DB88F5281_NAND_BASE,
  126. .end = DB88F5281_NAND_BASE + DB88F5281_NAND_SIZE - 1,
  127. };
  128. static struct orion_nand_data db88f5281_nand_data = {
  129. .parts = db88f5281_nand_parts,
  130. .nr_parts = ARRAY_SIZE(db88f5281_nand_parts),
  131. .cle = 0,
  132. .ale = 1,
  133. .width = 8,
  134. };
  135. static struct platform_device db88f5281_nand_flash = {
  136. .name = "orion_nand",
  137. .id = -1,
  138. .dev = {
  139. .platform_data = &db88f5281_nand_data,
  140. },
  141. .resource = &db88f5281_nand_resource,
  142. .num_resources = 1,
  143. };
  144. /*****************************************************************************
  145. * 7-Segment on Device bus CS0
  146. * Dummy counter every 2 sec
  147. ****************************************************************************/
  148. static void __iomem *db88f5281_7seg;
  149. static struct timer_list db88f5281_timer;
  150. static void db88f5281_7seg_event(unsigned long data)
  151. {
  152. static int count = 0;
  153. writel(0, db88f5281_7seg + (count << 4));
  154. count = (count + 1) & 7;
  155. mod_timer(&db88f5281_timer, jiffies + 2 * HZ);
  156. }
  157. static int __init db88f5281_7seg_init(void)
  158. {
  159. if (machine_is_db88f5281()) {
  160. db88f5281_7seg = ioremap(DB88F5281_7SEG_BASE,
  161. DB88F5281_7SEG_SIZE);
  162. if (!db88f5281_7seg) {
  163. printk(KERN_ERR "Failed to ioremap db88f5281_7seg\n");
  164. return -EIO;
  165. }
  166. setup_timer(&db88f5281_timer, db88f5281_7seg_event, 0);
  167. mod_timer(&db88f5281_timer, jiffies + 2 * HZ);
  168. }
  169. return 0;
  170. }
  171. __initcall(db88f5281_7seg_init);
  172. /*****************************************************************************
  173. * PCI
  174. ****************************************************************************/
  175. void __init db88f5281_pci_preinit(void)
  176. {
  177. int pin;
  178. /*
  179. * Configure PCI GPIO IRQ pins
  180. */
  181. pin = DB88F5281_PCI_SLOT0_IRQ_PIN;
  182. if (gpio_request(pin, "PCI Int1") == 0) {
  183. if (gpio_direction_input(pin) == 0) {
  184. set_irq_type(gpio_to_irq(pin), IRQT_LOW);
  185. } else {
  186. printk(KERN_ERR "db88f5281_pci_preinit faield to "
  187. "set_irq_type pin %d\n", pin);
  188. gpio_free(pin);
  189. }
  190. } else {
  191. printk(KERN_ERR "db88f5281_pci_preinit failed to gpio_request %d\n", pin);
  192. }
  193. pin = DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN;
  194. if (gpio_request(pin, "PCI Int2") == 0) {
  195. if (gpio_direction_input(pin) == 0) {
  196. set_irq_type(gpio_to_irq(pin), IRQT_LOW);
  197. } else {
  198. printk(KERN_ERR "db88f5281_pci_preinit faield "
  199. "to set_irq_type pin %d\n", pin);
  200. gpio_free(pin);
  201. }
  202. } else {
  203. printk(KERN_ERR "db88f5281_pci_preinit failed to gpio_request %d\n", pin);
  204. }
  205. }
  206. static int __init db88f5281_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  207. {
  208. /*
  209. * PCIE IRQ is connected internally (not GPIO)
  210. */
  211. if (dev->bus->number == orion_pcie_local_bus_nr())
  212. return IRQ_ORION_PCIE0_INT;
  213. /*
  214. * PCI IRQs are connected via GPIOs
  215. */
  216. switch (slot - DB88F5281_PCI_SLOT0_OFFS) {
  217. case 0:
  218. return gpio_to_irq(DB88F5281_PCI_SLOT0_IRQ_PIN);
  219. case 1:
  220. case 2:
  221. return gpio_to_irq(DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN);
  222. default:
  223. return -1;
  224. }
  225. }
  226. static struct hw_pci db88f5281_pci __initdata = {
  227. .nr_controllers = 2,
  228. .preinit = db88f5281_pci_preinit,
  229. .swizzle = pci_std_swizzle,
  230. .setup = orion_pci_sys_setup,
  231. .scan = orion_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 = 8,
  246. .force_phy_addr = 1,
  247. };
  248. /*****************************************************************************
  249. * RTC DS1339 on I2C bus
  250. ****************************************************************************/
  251. static struct i2c_board_info __initdata db88f5281_i2c_rtc = {
  252. .driver_name = "rtc-ds1307",
  253. .type = "ds1339",
  254. .addr = 0x68,
  255. };
  256. /*****************************************************************************
  257. * General Setup
  258. ****************************************************************************/
  259. static struct platform_device *db88f5281_devs[] __initdata = {
  260. &db88f5281_boot_flash,
  261. &db88f5281_nor_flash,
  262. &db88f5281_nand_flash,
  263. };
  264. static void __init db88f5281_init(void)
  265. {
  266. /*
  267. * Basic Orion setup. Need to be called early.
  268. */
  269. orion_init();
  270. /*
  271. * Setup the CPU address decode windows for our on-board devices
  272. */
  273. orion_setup_cpu_win(ORION_DEV_BOOT, DB88F5281_NOR_BOOT_BASE,
  274. DB88F5281_NOR_BOOT_SIZE, -1);
  275. orion_setup_cpu_win(ORION_DEV0, DB88F5281_7SEG_BASE,
  276. DB88F5281_7SEG_SIZE, -1);
  277. orion_setup_cpu_win(ORION_DEV1, DB88F5281_NOR_BASE,
  278. DB88F5281_NOR_SIZE, -1);
  279. orion_setup_cpu_win(ORION_DEV2, DB88F5281_NAND_BASE,
  280. DB88F5281_NAND_SIZE, -1);
  281. /*
  282. * Setup Multiplexing Pins:
  283. * MPP0: GPIO (USB Over Current) MPP1: GPIO (USB Vbat input)
  284. * MPP2: PCI_REQn[2] MPP3: PCI_GNTn[2]
  285. * MPP4: PCI_REQn[3] MPP5: PCI_GNTn[3]
  286. * MPP6: GPIO (JP0, CON17.2) MPP7: GPIO (JP1, CON17.1)
  287. * MPP8: GPIO (JP2, CON11.2) MPP9: GPIO (JP3, CON11.3)
  288. * MPP10: GPIO (RTC int) MPP11: GPIO (Baud Rate Generator)
  289. * MPP12: GPIO (PCI int 1) MPP13: GPIO (PCI int 2)
  290. * MPP14: NAND_REn[2] MPP15: NAND_WEn[2]
  291. * MPP16: UART1_RX MPP17: UART1_TX
  292. * MPP18: UART1_CTS MPP19: UART1_RTS
  293. * MPP-DEV: DEV_D[16:31]
  294. */
  295. orion_write(MPP_0_7_CTRL, 0x00222203);
  296. orion_write(MPP_8_15_CTRL, 0x44000000);
  297. orion_write(MPP_16_19_CTRL, 0);
  298. orion_write(MPP_DEV_CTRL, 0);
  299. orion_gpio_set_valid_pins(0x00003fc3);
  300. platform_add_devices(db88f5281_devs, ARRAY_SIZE(db88f5281_devs));
  301. i2c_register_board_info(0, &db88f5281_i2c_rtc, 1);
  302. orion_eth_init(&db88f5281_eth_data);
  303. }
  304. MACHINE_START(DB88F5281, "Marvell Orion-2 Development Board")
  305. /* Maintainer: Tzachi Perelstein <tzachi@marvell.com> */
  306. .phys_io = ORION_REGS_PHYS_BASE,
  307. .io_pg_offst = ((ORION_REGS_VIRT_BASE) >> 18) & 0xfffc,
  308. .boot_params = 0x00000100,
  309. .init_machine = db88f5281_init,
  310. .map_io = orion_map_io,
  311. .init_irq = orion_init_irq,
  312. .timer = &orion_timer,
  313. MACHINE_END