avila-setup.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/arm/mach-ixp4xx/avila-setup.c
  4. *
  5. * Gateworks Avila board-setup
  6. *
  7. * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
  8. *
  9. * Based on ixdp-setup.c
  10. * Copyright (C) 2003-2005 MontaVista Software, Inc.
  11. *
  12. * Author: Deepak Saxena <dsaxena@plexity.net>
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/device.h>
  17. #include <linux/serial.h>
  18. #include <linux/tty.h>
  19. #include <linux/serial_8250.h>
  20. #include <linux/gpio/machine.h>
  21. #include <asm/types.h>
  22. #include <asm/setup.h>
  23. #include <asm/memory.h>
  24. #include <mach/hardware.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/flash.h>
  29. #define AVILA_SDA_PIN 7
  30. #define AVILA_SCL_PIN 6
  31. static struct flash_platform_data avila_flash_data = {
  32. .map_name = "cfi_probe",
  33. .width = 2,
  34. };
  35. static struct resource avila_flash_resource = {
  36. .flags = IORESOURCE_MEM,
  37. };
  38. static struct platform_device avila_flash = {
  39. .name = "IXP4XX-Flash",
  40. .id = 0,
  41. .dev = {
  42. .platform_data = &avila_flash_data,
  43. },
  44. .num_resources = 1,
  45. .resource = &avila_flash_resource,
  46. };
  47. static struct gpiod_lookup_table avila_i2c_gpiod_table = {
  48. .dev_id = "i2c-gpio.0",
  49. .table = {
  50. GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SDA_PIN,
  51. NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  52. GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SCL_PIN,
  53. NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  54. },
  55. };
  56. static struct platform_device avila_i2c_gpio = {
  57. .name = "i2c-gpio",
  58. .id = 0,
  59. .dev = {
  60. .platform_data = NULL,
  61. },
  62. };
  63. static struct resource avila_uart_resources[] = {
  64. {
  65. .start = IXP4XX_UART1_BASE_PHYS,
  66. .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  67. .flags = IORESOURCE_MEM
  68. },
  69. {
  70. .start = IXP4XX_UART2_BASE_PHYS,
  71. .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  72. .flags = IORESOURCE_MEM
  73. }
  74. };
  75. static struct plat_serial8250_port avila_uart_data[] = {
  76. {
  77. .mapbase = IXP4XX_UART1_BASE_PHYS,
  78. .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  79. .irq = IRQ_IXP4XX_UART1,
  80. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  81. .iotype = UPIO_MEM,
  82. .regshift = 2,
  83. .uartclk = IXP4XX_UART_XTAL,
  84. },
  85. {
  86. .mapbase = IXP4XX_UART2_BASE_PHYS,
  87. .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  88. .irq = IRQ_IXP4XX_UART2,
  89. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  90. .iotype = UPIO_MEM,
  91. .regshift = 2,
  92. .uartclk = IXP4XX_UART_XTAL,
  93. },
  94. { },
  95. };
  96. static struct platform_device avila_uart = {
  97. .name = "serial8250",
  98. .id = PLAT8250_DEV_PLATFORM,
  99. .dev.platform_data = avila_uart_data,
  100. .num_resources = 2,
  101. .resource = avila_uart_resources
  102. };
  103. static struct resource avila_pata_resources[] = {
  104. {
  105. .flags = IORESOURCE_MEM
  106. },
  107. {
  108. .flags = IORESOURCE_MEM,
  109. },
  110. {
  111. .name = "intrq",
  112. .start = IRQ_IXP4XX_GPIO12,
  113. .end = IRQ_IXP4XX_GPIO12,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct ixp4xx_pata_data avila_pata_data = {
  118. .cs0_bits = 0xbfff0043,
  119. .cs1_bits = 0xbfff0043,
  120. };
  121. static struct platform_device avila_pata = {
  122. .name = "pata_ixp4xx_cf",
  123. .id = 0,
  124. .dev.platform_data = &avila_pata_data,
  125. .num_resources = ARRAY_SIZE(avila_pata_resources),
  126. .resource = avila_pata_resources,
  127. };
  128. static struct platform_device *avila_devices[] __initdata = {
  129. &avila_i2c_gpio,
  130. &avila_flash,
  131. &avila_uart
  132. };
  133. static void __init avila_init(void)
  134. {
  135. ixp4xx_sys_init();
  136. avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  137. avila_flash_resource.end =
  138. IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
  139. gpiod_add_lookup_table(&avila_i2c_gpiod_table);
  140. platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
  141. avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
  142. avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
  143. avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
  144. avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
  145. avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
  146. avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
  147. platform_device_register(&avila_pata);
  148. }
  149. MACHINE_START(AVILA, "Gateworks Avila Network Platform")
  150. /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
  151. .map_io = ixp4xx_map_io,
  152. .init_early = ixp4xx_init_early,
  153. .init_irq = ixp4xx_init_irq,
  154. .init_time = ixp4xx_timer_init,
  155. .atag_offset = 0x100,
  156. .init_machine = avila_init,
  157. #if defined(CONFIG_PCI)
  158. .dma_zone_size = SZ_64M,
  159. #endif
  160. .restart = ixp4xx_restart,
  161. MACHINE_END
  162. /*
  163. * Loft is functionally equivalent to Avila except that it has a
  164. * different number for the maximum PCI devices. The MACHINE
  165. * structure below is identical to Avila except for the comment.
  166. */
  167. #ifdef CONFIG_MACH_LOFT
  168. MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
  169. /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
  170. .map_io = ixp4xx_map_io,
  171. .init_early = ixp4xx_init_early,
  172. .init_irq = ixp4xx_init_irq,
  173. .init_time = ixp4xx_timer_init,
  174. .atag_offset = 0x100,
  175. .init_machine = avila_init,
  176. #if defined(CONFIG_PCI)
  177. .dma_zone_size = SZ_64M,
  178. #endif
  179. .restart = ixp4xx_restart,
  180. MACHINE_END
  181. #endif