530-ap42x_support.patch 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. --- a/arch/arm/mach-ixp4xx/Kconfig
  2. +++ b/arch/arm/mach-ixp4xx/Kconfig
  3. @@ -4,6 +4,14 @@ menu "Intel IXP4xx Implementation Option
  4. comment "IXP4xx Platforms"
  5. +config MACH_AP42X
  6. + bool "Tonze AP-422/425"
  7. + select PCI
  8. + help
  9. + Say 'Y' here if you want your kernel to support Tonze's
  10. + AP-422/425 boards. For more information on this platform,
  11. + see http://tonze.com.tw
  12. +
  13. config MACH_NSLU2
  14. bool
  15. prompt "Linksys NSLU2"
  16. --- a/arch/arm/mach-ixp4xx/Makefile
  17. +++ b/arch/arm/mach-ixp4xx/Makefile
  18. @@ -5,6 +5,7 @@
  19. obj-pci-y :=
  20. obj-pci-n :=
  21. +obj-pci-$(CONFIG_MACH_AP42X) += ap42x-pci.o
  22. obj-pci-$(CONFIG_ARCH_IXDP4XX) += ixdp425-pci.o
  23. obj-pci-$(CONFIG_MACH_AVILA) += avila-pci.o
  24. obj-pci-$(CONFIG_MACH_CAMBRIA) += cambria-pci.o
  25. @@ -32,6 +33,7 @@ obj-pci-$(CONFIG_MACH_USR8200) += usr82
  26. obj-y += common.o
  27. +obj-$(CONFIG_MACH_AP42X) += ap42x-setup.o
  28. obj-$(CONFIG_ARCH_IXDP4XX) += ixdp425-setup.o
  29. obj-$(CONFIG_MACH_AVILA) += avila-setup.o
  30. obj-$(CONFIG_MACH_CAMBRIA) += cambria-setup.o
  31. --- /dev/null
  32. +++ b/arch/arm/mach-ixp4xx/ap42x-pci.c
  33. @@ -0,0 +1,63 @@
  34. +/*
  35. + * arch/arch/mach-ixp4xx/ap42x-pci.c
  36. + *
  37. + * PCI setup routines for Tonze AP-422/425
  38. + *
  39. + * Copyright (C) 2012 Imre Kaloz <kaloz@openwrt.org>
  40. + *
  41. + * based on coyote-pci.c:
  42. + * Copyright (C) 2002 Jungo Software Technologies.
  43. + * Copyright (C) 2003 MontaVista Softwrae, Inc.
  44. + *
  45. + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
  46. + *
  47. + * This program is free software; you can redistribute it and/or modify
  48. + * it under the terms of the GNU General Public License version 2 as
  49. + * published by the Free Software Foundation.
  50. + *
  51. + */
  52. +
  53. +#include <linux/kernel.h>
  54. +#include <linux/pci.h>
  55. +#include <linux/init.h>
  56. +#include <linux/irq.h>
  57. +
  58. +#include <asm/mach-types.h>
  59. +#include <mach/hardware.h>
  60. +
  61. +#include <asm/mach/pci.h>
  62. +
  63. +void __init ap42x_pci_preinit(void)
  64. +{
  65. + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
  66. + irq_set_irq_type(IRQ_IXP4XX_GPIO11, IRQ_TYPE_LEVEL_LOW);
  67. +
  68. + ixp4xx_pci_preinit();
  69. +}
  70. +
  71. +static int __init ap42x_map_irq(const struct pci_dev *dev, u8 slot,
  72. + u8 pin)
  73. +{
  74. + if (slot == 1)
  75. + return IRQ_IXP4XX_GPIO11;
  76. + else if (slot == 2)
  77. + return IRQ_IXP4XX_GPIO10;
  78. + else return -1;
  79. +}
  80. +
  81. +struct hw_pci ap42x_pci __initdata = {
  82. + .nr_controllers = 1,
  83. + .preinit = ap42x_pci_preinit,
  84. + .ops = &ixp4xx_ops,
  85. + .setup = ixp4xx_setup,
  86. + .map_irq = ap42x_map_irq,
  87. +};
  88. +
  89. +int __init ap42x_pci_init(void)
  90. +{
  91. + if (machine_is_ap42x())
  92. + pci_common_init(&ap42x_pci);
  93. + return 0;
  94. +}
  95. +
  96. +subsys_initcall(ap42x_pci_init);
  97. --- /dev/null
  98. +++ b/arch/arm/mach-ixp4xx/ap42x-setup.c
  99. @@ -0,0 +1,166 @@
  100. +/*
  101. + * arch/arm/mach-ixp4xx/ap42x-setup.c
  102. + *
  103. + * Board setup for the Tonze AP-42x boards
  104. + *
  105. + * Copyright (C) 2012 Imre Kaloz <kaloz@openwrt.org>
  106. + *
  107. + * based on coyote-setup.c:
  108. + * Copyright (C) 2003-2005 MontaVista Software, Inc.
  109. + *
  110. + * Author: Imre Kaloz <Kaloz@openwrt.org>
  111. + */
  112. +
  113. +#include <linux/kernel.h>
  114. +#include <linux/init.h>
  115. +#include <linux/device.h>
  116. +#include <linux/serial.h>
  117. +#include <linux/tty.h>
  118. +#include <linux/serial_8250.h>
  119. +#include <linux/mtd/physmap.h>
  120. +#include <linux/dma-mapping.h>
  121. +
  122. +#include <asm/types.h>
  123. +#include <asm/setup.h>
  124. +#include <asm/memory.h>
  125. +#include <mach/hardware.h>
  126. +#include <asm/irq.h>
  127. +#include <asm/mach-types.h>
  128. +#include <asm/mach/arch.h>
  129. +#include <asm/mach/flash.h>
  130. +
  131. +static struct mtd_partition ap42x_flash_partitions[] = {
  132. + {
  133. + .name = "RedBoot",
  134. + .offset = 0x00000000,
  135. + .size = 0x00080000,
  136. + }, {
  137. + .name = "linux",
  138. + .offset = 0x00080000,
  139. + .size = 0x00100000,
  140. + }, {
  141. + .name = "rootfs",
  142. + .offset = 0x00180000,
  143. + .size = 0x00660000,
  144. + }, {
  145. + .name = "FIS directory",
  146. + .offset = 0x007f8000,
  147. + .size = 0x00007000,
  148. + }, {
  149. + .name = "RedBoot config",
  150. + .offset = 0x007ff000,
  151. + .size = 0x00001000,
  152. + },
  153. +};
  154. +
  155. +static struct physmap_flash_data ap42x_flash_data = {
  156. + .width = 2,
  157. + .parts = ap42x_flash_partitions,
  158. + .nr_parts = ARRAY_SIZE(ap42x_flash_partitions),
  159. +};
  160. +
  161. +static struct resource ap42x_flash_resource = {
  162. + .flags = IORESOURCE_MEM,
  163. + .start = IXP4XX_EXP_BUS_BASE_PHYS,
  164. + .end = IXP4XX_EXP_BUS_BASE_PHYS + SZ_8M - 1,
  165. +};
  166. +
  167. +static struct platform_device ap42x_flash = {
  168. + .name = "physmap-flash",
  169. + .id = 0,
  170. + .dev = {
  171. + .platform_data = &ap42x_flash_data,
  172. + },
  173. + .num_resources = 1,
  174. + .resource = &ap42x_flash_resource,
  175. +};
  176. +
  177. +static struct resource ap42x_uart_resource = {
  178. + .start = IXP4XX_UART2_BASE_PHYS,
  179. + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  180. + .flags = IORESOURCE_MEM,
  181. +};
  182. +
  183. +static struct plat_serial8250_port ap42x_uart_data[] = {
  184. + {
  185. + .mapbase = IXP4XX_UART2_BASE_PHYS,
  186. + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  187. + .irq = IRQ_IXP4XX_UART2,
  188. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  189. + .iotype = UPIO_MEM,
  190. + .regshift = 2,
  191. + .uartclk = IXP4XX_UART_XTAL,
  192. + },
  193. + { },
  194. +};
  195. +
  196. +static struct platform_device ap42x_uart = {
  197. + .name = "serial8250",
  198. + .id = PLAT8250_DEV_PLATFORM,
  199. + .dev = {
  200. + .platform_data = ap42x_uart_data,
  201. + },
  202. + .num_resources = 1,
  203. + .resource = &ap42x_uart_resource,
  204. +};
  205. +
  206. +static struct eth_plat_info ap42x_plat_eth[] = {
  207. + {
  208. + .phy = 2,
  209. + .rxq = 3,
  210. + .txreadyq = 20,
  211. + }, {
  212. + .phy = 1,
  213. + .rxq = 4,
  214. + .txreadyq = 21,
  215. + }
  216. +};
  217. +
  218. +static struct platform_device ap42x_eth[] = {
  219. + {
  220. + .name = "ixp4xx_eth",
  221. + .id = IXP4XX_ETH_NPEB,
  222. + .dev.platform_data = ap42x_plat_eth,
  223. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  224. + }, {
  225. + .name = "ixp4xx_eth",
  226. + .id = IXP4XX_ETH_NPEC,
  227. + .dev.platform_data = ap42x_plat_eth + 1,
  228. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  229. + }
  230. +};
  231. +
  232. +static struct platform_device *ap42x_devices[] __initdata = {
  233. + &ap42x_flash,
  234. + &ap42x_uart,
  235. + &ap42x_eth[0],
  236. + &ap42x_eth[1],
  237. +};
  238. +
  239. +static void __init ap42x_init(void)
  240. +{
  241. + ixp4xx_sys_init();
  242. +
  243. + ap42x_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  244. + ap42x_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
  245. +
  246. + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
  247. + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
  248. +
  249. + platform_add_devices(ap42x_devices, ARRAY_SIZE(ap42x_devices));
  250. +}
  251. +
  252. +#ifdef CONFIG_MACH_AP42X
  253. +MACHINE_START(AP42X, "Tonze AP-422/425")
  254. + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
  255. + .map_io = ixp4xx_map_io,
  256. + .init_irq = ixp4xx_init_irq,
  257. + .init_time = ixp4xx_timer_init,
  258. + .atag_offset = 0x100,
  259. + .init_machine = ap42x_init,
  260. +#if defined(CONFIG_PCI)
  261. + .dma_zone_size = SZ_64M,
  262. +#endif
  263. + .restart = ixp4xx_restart,
  264. +MACHINE_END
  265. +#endif
  266. --- a/arch/arm/mach-ixp4xx/include/mach/uncompress.h
  267. +++ b/arch/arm/mach-ixp4xx/include/mach/uncompress.h
  268. @@ -45,7 +45,8 @@ static __inline__ void __arch_decomp_set
  269. machine_is_devixp() || machine_is_miccpt() || machine_is_mic256() ||
  270. machine_is_pronghorn() || machine_is_pronghorn_metro() ||
  271. machine_is_wrt300nv2() || machine_is_tw5334() ||
  272. - machine_is_usr8200() || machine_is_tw2662())
  273. + machine_is_usr8200() || machine_is_tw2662() ||
  274. + machine_is_ap42x())
  275. uart_base = (volatile u32*) IXP4XX_UART2_BASE_PHYS;
  276. else
  277. uart_base = (volatile u32*) IXP4XX_UART1_BASE_PHYS;