em7210.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * arch/arm/mach-iop32x/em7210.c
  3. *
  4. * Board support code for the Lanner EM7210 platforms.
  5. *
  6. * Based on arch/arm/mach-iop32x/iq31244.c file.
  7. *
  8. * Copyright (C) 2007 Arnaud Patard <arnaud.patard@rtp-net.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. */
  15. #include <linux/mm.h>
  16. #include <linux/init.h>
  17. #include <linux/kernel.h>
  18. #include <linux/pci.h>
  19. #include <linux/pm.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/serial_8250.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/i2c.h>
  25. #include <asm/hardware.h>
  26. #include <linux/io.h>
  27. #include <linux/irq.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/pci.h>
  31. #include <asm/mach/time.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/arch/time.h>
  34. static void __init em7210_timer_init(void)
  35. {
  36. /* http://www.kwaak.net/fotos/fotos-nas/slide_24.html */
  37. /* 33.333 MHz crystal. */
  38. iop_init_time(200000000);
  39. }
  40. static struct sys_timer em7210_timer = {
  41. .init = em7210_timer_init,
  42. .offset = iop_gettimeoffset,
  43. };
  44. /*
  45. * EM7210 RTC
  46. */
  47. static struct i2c_board_info __initdata em7210_i2c_devices[] = {
  48. {
  49. I2C_BOARD_INFO("rtc-rs5c372", 0x32),
  50. .type = "rs5c372a",
  51. },
  52. };
  53. /*
  54. * EM7210 I/O
  55. */
  56. static struct map_desc em7210_io_desc[] __initdata = {
  57. { /* on-board devices */
  58. .virtual = IQ31244_UART,
  59. .pfn = __phys_to_pfn(IQ31244_UART),
  60. .length = 0x00100000,
  61. .type = MT_DEVICE,
  62. },
  63. };
  64. void __init em7210_map_io(void)
  65. {
  66. iop3xx_map_io();
  67. iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc));
  68. }
  69. /*
  70. * EM7210 PCI
  71. */
  72. #define INTA IRQ_IOP32X_XINT0
  73. #define INTB IRQ_IOP32X_XINT1
  74. #define INTC IRQ_IOP32X_XINT2
  75. #define INTD IRQ_IOP32X_XINT3
  76. static int __init
  77. em7210_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  78. {
  79. static int pci_irq_table[][4] = {
  80. /*
  81. * PCI IDSEL/INTPIN->INTLINE
  82. * A B C D
  83. */
  84. {INTB, INTB, INTB, INTB}, /* console / uart */
  85. {INTA, INTA, INTA, INTA}, /* 1st 82541 */
  86. {INTD, INTD, INTD, INTD}, /* 2nd 82541 */
  87. {INTC, INTC, INTC, INTC}, /* GD31244 */
  88. {INTD, INTA, INTA, INTA}, /* mini-PCI */
  89. {INTD, INTC, INTA, INTA}, /* NEC USB */
  90. };
  91. if (pin < 1 || pin > 4)
  92. return -1;
  93. return pci_irq_table[slot % 6][pin - 1];
  94. }
  95. static struct hw_pci em7210_pci __initdata = {
  96. .swizzle = pci_std_swizzle,
  97. .nr_controllers = 1,
  98. .setup = iop3xx_pci_setup,
  99. .preinit = iop3xx_pci_preinit,
  100. .scan = iop3xx_pci_scan_bus,
  101. .map_irq = em7210_pci_map_irq,
  102. };
  103. static int __init em7210_pci_init(void)
  104. {
  105. if (machine_is_em7210())
  106. pci_common_init(&em7210_pci);
  107. return 0;
  108. }
  109. subsys_initcall(em7210_pci_init);
  110. /*
  111. * EM7210 Flash
  112. */
  113. static struct physmap_flash_data em7210_flash_data = {
  114. .width = 2,
  115. };
  116. static struct resource em7210_flash_resource = {
  117. .start = 0xf0000000,
  118. .end = 0xf1ffffff,
  119. .flags = IORESOURCE_MEM,
  120. };
  121. static struct platform_device em7210_flash_device = {
  122. .name = "physmap-flash",
  123. .id = 0,
  124. .dev = {
  125. .platform_data = &em7210_flash_data,
  126. },
  127. .num_resources = 1,
  128. .resource = &em7210_flash_resource,
  129. };
  130. /*
  131. * EM7210 UART
  132. * The physical address of the serial port is 0xfe800000,
  133. * so it can be used for physical and virtual address.
  134. */
  135. static struct plat_serial8250_port em7210_serial_port[] = {
  136. {
  137. .mapbase = IQ31244_UART,
  138. .membase = (char *)IQ31244_UART,
  139. .irq = IRQ_IOP32X_XINT1,
  140. .flags = UPF_SKIP_TEST,
  141. .iotype = UPIO_MEM,
  142. .regshift = 0,
  143. .uartclk = 1843200,
  144. },
  145. { },
  146. };
  147. static struct resource em7210_uart_resource = {
  148. .start = IQ31244_UART,
  149. .end = IQ31244_UART + 7,
  150. .flags = IORESOURCE_MEM,
  151. };
  152. static struct platform_device em7210_serial_device = {
  153. .name = "serial8250",
  154. .id = PLAT8250_DEV_PLATFORM,
  155. .dev = {
  156. .platform_data = em7210_serial_port,
  157. },
  158. .num_resources = 1,
  159. .resource = &em7210_uart_resource,
  160. };
  161. void em7210_power_off(void)
  162. {
  163. *IOP3XX_GPOE &= 0xfe;
  164. *IOP3XX_GPOD |= 0x01;
  165. }
  166. static void __init em7210_init_machine(void)
  167. {
  168. platform_device_register(&em7210_serial_device);
  169. platform_device_register(&iop3xx_i2c0_device);
  170. platform_device_register(&iop3xx_i2c1_device);
  171. platform_device_register(&em7210_flash_device);
  172. platform_device_register(&iop3xx_dma_0_channel);
  173. platform_device_register(&iop3xx_dma_1_channel);
  174. i2c_register_board_info(0, em7210_i2c_devices,
  175. ARRAY_SIZE(em7210_i2c_devices));
  176. pm_power_off = em7210_power_off;
  177. }
  178. MACHINE_START(EM7210, "Lanner EM7210")
  179. .phys_io = IQ31244_UART,
  180. .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
  181. .boot_params = 0xa0000100,
  182. .map_io = em7210_map_io,
  183. .init_irq = iop32x_init_irq,
  184. .timer = &em7210_timer,
  185. .init_machine = em7210_init_machine,
  186. MACHINE_END