db88f5281-setup.c 9.6 KB

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