115-sidewinder_support.patch 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. From 95dac4a842a3c66f69f949b48f9075e16275f77b Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Sun, 30 Jun 2013 15:48:47 +0200
  4. Subject: [PATCH 07/36] 115-sidewinder_support.patch
  5. ---
  6. arch/arm/mach-ixp4xx/Kconfig | 10 +-
  7. arch/arm/mach-ixp4xx/Makefile | 2 +
  8. arch/arm/mach-ixp4xx/sidewinder-pci.c | 68 ++++++++++++++
  9. arch/arm/mach-ixp4xx/sidewinder-setup.c | 151 +++++++++++++++++++++++++++++++
  10. 4 files changed, 230 insertions(+), 1 deletion(-)
  11. create mode 100644 arch/arm/mach-ixp4xx/sidewinder-pci.c
  12. create mode 100644 arch/arm/mach-ixp4xx/sidewinder-setup.c
  13. --- a/arch/arm/mach-ixp4xx/Kconfig
  14. +++ b/arch/arm/mach-ixp4xx/Kconfig
  15. @@ -77,6 +77,14 @@ config MACH_PRONGHORN
  16. config MACH_PRONGHORNMETRO
  17. def_bool MACH_PRONGHORN
  18. +config MACH_SIDEWINDER
  19. + bool "ADI Sidewinder"
  20. + select PCI
  21. + help
  22. + Say 'Y' here if you want your kernel to support the ADI
  23. + Engineering Sidewinder board. For more information on this
  24. + platform, see http://www.adiengineering.com
  25. +
  26. config ARCH_IXDP425
  27. bool "IXDP425"
  28. help
  29. @@ -173,7 +181,7 @@ config MACH_ARCOM_VULCAN
  30. #
  31. config CPU_IXP46X
  32. bool
  33. - depends on MACH_IXDP465
  34. + depends on MACH_IXDP465 || MACH_SIDEWINDER
  35. default y
  36. config CPU_IXP43X
  37. --- a/arch/arm/mach-ixp4xx/Makefile
  38. +++ b/arch/arm/mach-ixp4xx/Makefile
  39. @@ -20,6 +20,7 @@ obj-pci-$(CONFIG_MACH_WG302V2) += wg302
  40. obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
  41. obj-pci-$(CONFIG_MACH_ARCOM_VULCAN) += vulcan-pci.o
  42. obj-pci-$(CONFIG_MACH_PRONGHORN) += pronghorn-pci.o
  43. +obj-pci-$(CONFIG_MACH_SIDEWINDER) += sidewinder-pci.o
  44. obj-y += common.o
  45. @@ -41,6 +42,7 @@ obj-$(CONFIG_MACH_FSG) += fsg-setup.o
  46. obj-$(CONFIG_MACH_GORAMO_MLR) += goramo_mlr.o
  47. obj-$(CONFIG_MACH_ARCOM_VULCAN) += vulcan-setup.o
  48. obj-$(CONFIG_MACH_PRONGHORN) += pronghorn-setup.o
  49. +obj-$(CONFIG_MACH_SIDEWINDER) += sidewinder-setup.o
  50. obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
  51. obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
  52. --- /dev/null
  53. +++ b/arch/arm/mach-ixp4xx/sidewinder-pci.c
  54. @@ -0,0 +1,67 @@
  55. +/*
  56. + * arch/arch/mach-ixp4xx/pronghornmetro-pci.c
  57. + *
  58. + * PCI setup routines for ADI Engineering Sidewinder
  59. + *
  60. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  61. + *
  62. + * based on coyote-pci.c:
  63. + * Copyright (C) 2002 Jungo Software Technologies.
  64. + * Copyright (C) 2003 MontaVista Softwrae, Inc.
  65. + *
  66. + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
  67. + *
  68. + * This program is free software; you can redistribute it and/or modify
  69. + * it under the terms of the GNU General Public License version 2 as
  70. + * published by the Free Software Foundation.
  71. + *
  72. + */
  73. +
  74. +#include <linux/kernel.h>
  75. +#include <linux/pci.h>
  76. +#include <linux/init.h>
  77. +#include <linux/irq.h>
  78. +
  79. +#include <asm/mach-types.h>
  80. +#include <mach/hardware.h>
  81. +#include <asm/irq.h>
  82. +
  83. +#include <asm/mach/pci.h>
  84. +
  85. +void __init sidewinder_pci_preinit(void)
  86. +{
  87. + irq_set_irq_type(IRQ_IXP4XX_GPIO11, IRQ_TYPE_LEVEL_LOW);
  88. + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
  89. + irq_set_irq_type(IRQ_IXP4XX_GPIO9, IRQ_TYPE_LEVEL_LOW);
  90. +
  91. + ixp4xx_pci_preinit();
  92. +}
  93. +
  94. +static int __init sidewinder_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  95. +{
  96. + if (slot == 1)
  97. + return IRQ_IXP4XX_GPIO11;
  98. + else if (slot == 2)
  99. + return IRQ_IXP4XX_GPIO10;
  100. + else if (slot == 3)
  101. + return IRQ_IXP4XX_GPIO9;
  102. + else
  103. + return -1;
  104. +}
  105. +
  106. +struct hw_pci sidewinder_pci __initdata = {
  107. + .nr_controllers = 1,
  108. + .preinit = sidewinder_pci_preinit,
  109. + .ops = &ixp4xx_ops,
  110. + .setup = ixp4xx_setup,
  111. + .map_irq = sidewinder_map_irq,
  112. +};
  113. +
  114. +int __init sidewinder_pci_init(void)
  115. +{
  116. + if (machine_is_sidewinder())
  117. + pci_common_init(&sidewinder_pci);
  118. + return 0;
  119. +}
  120. +
  121. +subsys_initcall(sidewinder_pci_init);
  122. --- /dev/null
  123. +++ b/arch/arm/mach-ixp4xx/sidewinder-setup.c
  124. @@ -0,0 +1,155 @@
  125. +/*
  126. + * arch/arm/mach-ixp4xx/sidewinder-setup.c
  127. + *
  128. + * Board setup for the ADI Engineering Sidewinder
  129. + *
  130. + * Copyright (C) 2008 Imre Kaloz <Kaloz@openwrt.org>
  131. + *
  132. + * based on coyote-setup.c:
  133. + * Copyright (C) 2003-2005 MontaVista Software, Inc.
  134. + *
  135. + * Author: Imre Kaloz <Kaloz@openwrt.org>
  136. + */
  137. +
  138. +#include <linux/kernel.h>
  139. +#include <linux/serial.h>
  140. +#include <linux/serial_8250.h>
  141. +#include <linux/dma-mapping.h>
  142. +
  143. +#include <asm/mach-types.h>
  144. +#include <asm/mach/arch.h>
  145. +#include <asm/mach/flash.h>
  146. +
  147. +static struct flash_platform_data sidewinder_flash_data = {
  148. + .map_name = "cfi_probe",
  149. + .width = 2,
  150. +};
  151. +
  152. +static struct resource sidewinder_flash_resource = {
  153. + .flags = IORESOURCE_MEM,
  154. +};
  155. +
  156. +static struct platform_device sidewinder_flash = {
  157. + .name = "IXP4XX-Flash",
  158. + .id = 0,
  159. + .dev = {
  160. + .platform_data = &sidewinder_flash_data,
  161. + },
  162. + .num_resources = 1,
  163. + .resource = &sidewinder_flash_resource,
  164. +};
  165. +
  166. +static struct resource sidewinder_uart_resources[] = {
  167. + {
  168. + .start = IXP4XX_UART1_BASE_PHYS,
  169. + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  170. + .flags = IORESOURCE_MEM,
  171. + },
  172. + {
  173. + .start = IXP4XX_UART2_BASE_PHYS,
  174. + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  175. + .flags = IORESOURCE_MEM,
  176. + }
  177. +};
  178. +
  179. +static struct plat_serial8250_port sidewinder_uart_data[] = {
  180. + {
  181. + .mapbase = IXP4XX_UART1_BASE_PHYS,
  182. + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  183. + .irq = IRQ_IXP4XX_UART1,
  184. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  185. + .iotype = UPIO_MEM,
  186. + .regshift = 2,
  187. + .uartclk = IXP4XX_UART_XTAL,
  188. + },
  189. + {
  190. + .mapbase = IXP4XX_UART2_BASE_PHYS,
  191. + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  192. + .irq = IRQ_IXP4XX_UART2,
  193. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  194. + .iotype = UPIO_MEM,
  195. + .regshift = 2,
  196. + .uartclk = IXP4XX_UART_XTAL,
  197. + },
  198. + { },
  199. +};
  200. +
  201. +static struct platform_device sidewinder_uart = {
  202. + .name = "serial8250",
  203. + .id = PLAT8250_DEV_PLATFORM,
  204. + .dev = {
  205. + .platform_data = sidewinder_uart_data,
  206. + },
  207. + .num_resources = ARRAY_SIZE(sidewinder_uart_resources),
  208. + .resource = sidewinder_uart_resources,
  209. +};
  210. +
  211. +static struct eth_plat_info sidewinder_plat_eth[] = {
  212. + {
  213. + .phy = 5,
  214. + .rxq = 3,
  215. + .txreadyq = 20,
  216. + }, {
  217. + .phy = IXP4XX_ETH_PHY_MAX_ADDR,
  218. + .phy_mask = 0x1e,
  219. + .rxq = 4,
  220. + .txreadyq = 21,
  221. + }, {
  222. + .phy = 31,
  223. + .rxq = 2,
  224. + .txreadyq = 19,
  225. + }
  226. +};
  227. +
  228. +static struct platform_device sidewinder_eth[] = {
  229. + {
  230. + .name = "ixp4xx_eth",
  231. + .id = IXP4XX_ETH_NPEB,
  232. + .dev.platform_data = sidewinder_plat_eth,
  233. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  234. + }, {
  235. + .name = "ixp4xx_eth",
  236. + .id = IXP4XX_ETH_NPEC,
  237. + .dev.platform_data = sidewinder_plat_eth + 1,
  238. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  239. + }, {
  240. + .name = "ixp4xx_eth",
  241. + .id = IXP4XX_ETH_NPEA,
  242. + .dev.platform_data = sidewinder_plat_eth + 2,
  243. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  244. + }
  245. +};
  246. +
  247. +static struct platform_device *sidewinder_devices[] __initdata = {
  248. + &sidewinder_flash,
  249. + &sidewinder_uart,
  250. + &sidewinder_eth[0],
  251. + &sidewinder_eth[1],
  252. + &sidewinder_eth[2],
  253. +};
  254. +
  255. +static void __init sidewinder_init(void)
  256. +{
  257. + ixp4xx_sys_init();
  258. +
  259. + sidewinder_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  260. + sidewinder_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_64M - 1;
  261. +
  262. + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
  263. + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
  264. +
  265. + platform_add_devices(sidewinder_devices, ARRAY_SIZE(sidewinder_devices));
  266. +}
  267. +
  268. +MACHINE_START(SIDEWINDER, "ADI Engineering Sidewinder")
  269. + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
  270. + .map_io = ixp4xx_map_io,
  271. + .init_irq = ixp4xx_init_irq,
  272. + .init_time = ixp4xx_timer_init,
  273. + .atag_offset = 0x0100,
  274. + .init_machine = sidewinder_init,
  275. +#if defined(CONFIG_PCI)
  276. + .dma_zone_size = SZ_64M,
  277. +#endif
  278. + .restart = ixp4xx_restart,
  279. +MACHINE_END