105-wg302v1_support.patch 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. --- a/arch/arm/configs/ixp4xx_defconfig
  2. +++ b/arch/arm/configs/ixp4xx_defconfig
  3. @@ -13,6 +13,7 @@ CONFIG_MACH_AVILA=y
  4. CONFIG_MACH_LOFT=y
  5. CONFIG_ARCH_ADI_COYOTE=y
  6. CONFIG_MACH_GATEWAY7001=y
  7. +CONFIG_MACH_WG302V1=y
  8. CONFIG_MACH_WG302V2=y
  9. CONFIG_ARCH_IXDP425=y
  10. CONFIG_MACH_IXDPG425=y
  11. --- a/arch/arm/mach-ixp4xx/Kconfig
  12. +++ b/arch/arm/mach-ixp4xx/Kconfig
  13. @@ -45,6 +45,14 @@ config MACH_GATEWAY7001
  14. 7001 Access Point. For more information on this platform,
  15. see http://openwrt.org
  16. +config MACH_WG302V1
  17. + bool "Netgear WG302 v1 / WAG302 v1"
  18. + select PCI
  19. + help
  20. + Say 'Y' here if you want your kernel to support Netgear's
  21. + WG302 v1 or WAG302 v1 Access Points. For more information
  22. + on this platform, see http://openwrt.org
  23. +
  24. config MACH_WG302V2
  25. bool "Netgear WG302 v2 / WAG302 v2"
  26. select PCI
  27. --- a/arch/arm/mach-ixp4xx/Makefile
  28. +++ b/arch/arm/mach-ixp4xx/Makefile
  29. @@ -15,6 +15,7 @@ obj-pci-$(CONFIG_MACH_NSLU2) += nslu2-p
  30. obj-pci-$(CONFIG_MACH_NAS100D) += nas100d-pci.o
  31. obj-pci-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o
  32. obj-pci-$(CONFIG_MACH_GATEWAY7001) += gateway7001-pci.o
  33. +obj-pci-$(CONFIG_MACH_WG302V1) += wg302v1-pci.o
  34. obj-pci-$(CONFIG_MACH_WG302V2) += wg302v2-pci.o
  35. obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
  36. obj-pci-$(CONFIG_MACH_ARCOM_VULCAN) += vulcan-pci.o
  37. @@ -33,6 +34,7 @@ obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.
  38. obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o
  39. obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o
  40. obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
  41. +obj-$(CONFIG_MACH_WG302V1) += wg302v1-setup.o
  42. obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
  43. obj-$(CONFIG_MACH_FSG) += fsg-setup.o
  44. obj-$(CONFIG_MACH_GORAMO_MLR) += goramo_mlr.o
  45. --- /dev/null
  46. +++ b/arch/arm/mach-ixp4xx/wg302v1-pci.c
  47. @@ -0,0 +1,63 @@
  48. +/*
  49. + * arch/arch/mach-ixp4xx/wg302v1-pci.c
  50. + *
  51. + * PCI setup routines for the Netgear WG302 v1 and WAG302 v1
  52. + *
  53. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  54. + *
  55. + * based on coyote-pci.c:
  56. + * Copyright (C) 2002 Jungo Software Technologies.
  57. + * Copyright (C) 2003 MontaVista Software, Inc.
  58. + *
  59. + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
  60. + *
  61. + * This program is free software; you can redistribute it and/or modify
  62. + * it under the terms of the GNU General Public License version 2 as
  63. + * published by the Free Software Foundation.
  64. + *
  65. + */
  66. +
  67. +#include <linux/kernel.h>
  68. +#include <linux/pci.h>
  69. +#include <linux/init.h>
  70. +#include <linux/irq.h>
  71. +
  72. +#include <asm/mach-types.h>
  73. +#include <mach/hardware.h>
  74. +
  75. +#include <asm/mach/pci.h>
  76. +
  77. +void __init wg302v1_pci_preinit(void)
  78. +{
  79. + irq_set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW);
  80. + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
  81. +
  82. + ixp4xx_pci_preinit();
  83. +}
  84. +
  85. +static int __init wg302v1_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  86. +{
  87. + if (slot == 1)
  88. + return IRQ_IXP4XX_GPIO8;
  89. + else if (slot == 2)
  90. + return IRQ_IXP4XX_GPIO10;
  91. + else
  92. + return -1;
  93. +}
  94. +
  95. +struct hw_pci wg302v1_pci __initdata = {
  96. + .nr_controllers = 1,
  97. + .preinit = wg302v1_pci_preinit,
  98. + .ops = &ixp4xx_ops,
  99. + .setup = ixp4xx_setup,
  100. + .map_irq = wg302v1_map_irq,
  101. +};
  102. +
  103. +int __init wg302v1_pci_init(void)
  104. +{
  105. + if (machine_is_wg302v1())
  106. + pci_common_init(&wg302v1_pci);
  107. + return 0;
  108. +}
  109. +
  110. +subsys_initcall(wg302v1_pci_init);
  111. --- /dev/null
  112. +++ b/arch/arm/mach-ixp4xx/wg302v1-setup.c
  113. @@ -0,0 +1,147 @@
  114. +/*
  115. + * arch/arm/mach-ixp4xx/wg302v1-setup.c
  116. + *
  117. + * Board setup for the Netgear WG302 v1 and WAG302 v1
  118. + *
  119. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  120. + *
  121. + * based on coyote-setup.c:
  122. + * Copyright (C) 2003-2005 MontaVista Software, Inc.
  123. + *
  124. + * Author: Imre Kaloz <kaloz@openwrt.org>
  125. + *
  126. + */
  127. +
  128. +#include <linux/kernel.h>
  129. +#include <linux/init.h>
  130. +#include <linux/device.h>
  131. +#include <linux/serial.h>
  132. +#include <linux/tty.h>
  133. +#include <linux/serial_8250.h>
  134. +#include <linux/slab.h>
  135. +#include <linux/types.h>
  136. +#include <linux/memory.h>
  137. +#include <linux/dma-mapping.h>
  138. +
  139. +#include <asm/setup.h>
  140. +#include <mach/hardware.h>
  141. +#include <asm/irq.h>
  142. +#include <asm/mach-types.h>
  143. +#include <asm/mach/arch.h>
  144. +#include <asm/mach/flash.h>
  145. +
  146. +static struct flash_platform_data wg302v1_flash_data = {
  147. + .map_name = "cfi_probe",
  148. + .width = 2,
  149. +};
  150. +
  151. +static struct resource wg302v1_flash_resource = {
  152. + .flags = IORESOURCE_MEM,
  153. +};
  154. +
  155. +static struct platform_device wg302v1_flash = {
  156. + .name = "IXP4XX-Flash",
  157. + .id = 0,
  158. + .dev = {
  159. + .platform_data = &wg302v1_flash_data,
  160. + },
  161. + .num_resources = 1,
  162. + .resource = &wg302v1_flash_resource,
  163. +};
  164. +
  165. +static struct resource wg302v1_uart_resources[] = {
  166. + {
  167. + .start = IXP4XX_UART1_BASE_PHYS,
  168. + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  169. + .flags = IORESOURCE_MEM,
  170. + },
  171. + {
  172. + .start = IXP4XX_UART2_BASE_PHYS,
  173. + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  174. + .flags = IORESOURCE_MEM,
  175. + }
  176. +};
  177. +
  178. +static struct plat_serial8250_port wg302v1_uart_data[] = {
  179. + {
  180. + .mapbase = IXP4XX_UART1_BASE_PHYS,
  181. + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  182. + .irq = IRQ_IXP4XX_UART1,
  183. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  184. + .iotype = UPIO_MEM,
  185. + .regshift = 2,
  186. + .uartclk = IXP4XX_UART_XTAL,
  187. + },
  188. + {
  189. + .mapbase = IXP4XX_UART2_BASE_PHYS,
  190. + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  191. + .irq = IRQ_IXP4XX_UART2,
  192. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  193. + .iotype = UPIO_MEM,
  194. + .regshift = 2,
  195. + .uartclk = IXP4XX_UART_XTAL,
  196. + },
  197. + { },
  198. +};
  199. +
  200. +static struct platform_device wg302v1_uart = {
  201. + .name = "serial8250",
  202. + .id = PLAT8250_DEV_PLATFORM,
  203. + .dev = {
  204. + .platform_data = wg302v1_uart_data,
  205. + },
  206. + .num_resources = 2,
  207. + .resource = wg302v1_uart_resources,
  208. +};
  209. +
  210. +static struct eth_plat_info wg302v1_plat_eth[] = {
  211. + {
  212. + .phy = 30,
  213. + .rxq = 3,
  214. + .txreadyq = 20,
  215. + }
  216. +};
  217. +
  218. +static struct platform_device wg302v1_eth[] = {
  219. + {
  220. + .name = "ixp4xx_eth",
  221. + .id = IXP4XX_ETH_NPEB,
  222. + .dev.platform_data = wg302v1_plat_eth,
  223. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  224. + }
  225. +};
  226. +
  227. +static struct platform_device *wg302v1_devices[] __initdata = {
  228. + &wg302v1_flash,
  229. + &wg302v1_uart,
  230. + &wg302v1_eth[0],
  231. +};
  232. +
  233. +static void __init wg302v1_init(void)
  234. +{
  235. + ixp4xx_sys_init();
  236. +
  237. + wg302v1_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  238. + wg302v1_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
  239. +
  240. + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
  241. + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
  242. +
  243. + platform_add_devices(wg302v1_devices, ARRAY_SIZE(wg302v1_devices));
  244. +}
  245. +
  246. +#ifdef CONFIG_MACH_WG302V1
  247. +MACHINE_START(WG302V1, "Netgear WG302 v1 / WAG302 v1")
  248. + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
  249. + .fixup = wg302v1_fixup,
  250. + .map_io = ixp4xx_map_io,
  251. + .init_irq = ixp4xx_init_irq,
  252. + .init_time = ixp4xx_timer_init,
  253. + .atag_offset = 0x0100,
  254. + .init_machine = wg302v1_init,
  255. +#if defined(CONFIG_PCI)
  256. + .dma_zone_size = SZ_64M,
  257. +#endif
  258. + .restart = ixp4xx_restart,
  259. +MACHINE_END
  260. +#endif