180-tw5334_support.patch 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. --- a/arch/arm/mach-ixp4xx/Kconfig
  2. +++ b/arch/arm/mach-ixp4xx/Kconfig
  3. @@ -160,6 +160,14 @@ config ARCH_PRPMC1100
  4. PrPCM1100 Processor Mezanine Module. For more information on
  5. this platform, see <file:Documentation/arm/IXP4xx>.
  6. +config MACH_TW5334
  7. + bool "Titan Wireless TW-533-4"
  8. + select PCI
  9. + help
  10. + Say 'Y' here if you want your kernel to support the Titan
  11. + Wireless TW533-4. For more information on this platform,
  12. + see http://openwrt.org
  13. +
  14. config MACH_NAS100D
  15. bool
  16. prompt "NAS100D"
  17. --- a/arch/arm/mach-ixp4xx/Makefile
  18. +++ b/arch/arm/mach-ixp4xx/Makefile
  19. @@ -24,6 +24,7 @@ obj-pci-$(CONFIG_MACH_SIDEWINDER) += sid
  20. obj-pci-$(CONFIG_MACH_COMPEXWP18) += ixdp425-pci.o
  21. obj-pci-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-pci.o
  22. obj-pci-$(CONFIG_MACH_AP1000) += ixdp425-pci.o
  23. +obj-pci-$(CONFIG_MACH_TW5334) += tw5334-pci.o
  24. obj-y += common.o
  25. @@ -49,6 +50,7 @@ obj-$(CONFIG_MACH_SIDEWINDER) += sidewin
  26. obj-$(CONFIG_MACH_COMPEXWP18) += compex42x-setup.o
  27. obj-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-setup.o
  28. obj-$(CONFIG_MACH_AP1000) += ap1000-setup.o
  29. +obj-$(CONFIG_MACH_TW5334) += tw5334-setup.o
  30. obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
  31. obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
  32. --- a/arch/arm/mach-ixp4xx/include/mach/uncompress.h
  33. +++ b/arch/arm/mach-ixp4xx/include/mach/uncompress.h
  34. @@ -44,7 +44,7 @@ static __inline__ void __arch_decomp_set
  35. machine_is_gateway7001() || machine_is_wg302v2() ||
  36. machine_is_devixp() || machine_is_miccpt() || machine_is_mic256() ||
  37. machine_is_pronghorn() || machine_is_pronghorn_metro() ||
  38. - machine_is_wrt300nv2())
  39. + machine_is_wrt300nv2() || machine_is_tw5334())
  40. uart_base = (volatile u32*) IXP4XX_UART2_BASE_PHYS;
  41. else
  42. uart_base = (volatile u32*) IXP4XX_UART1_BASE_PHYS;
  43. --- /dev/null
  44. +++ b/arch/arm/mach-ixp4xx/tw5334-pci.c
  45. @@ -0,0 +1,68 @@
  46. +/*
  47. + * arch/arch/mach-ixp4xx/tw5334-pci.c
  48. + *
  49. + * PCI setup routines for the Titan Wireless TW-533-4
  50. + *
  51. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  52. + *
  53. + * based on coyote-pci.c:
  54. + * Copyright (C) 2002 Jungo Software Technologies.
  55. + * Copyright (C) 2003 MontaVista Softwrae, Inc.
  56. + *
  57. + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
  58. + *
  59. + * This program is free software; you can redistribute it and/or modify
  60. + * it under the terms of the GNU General Public License version 2 as
  61. + * published by the Free Software Foundation.
  62. + *
  63. + */
  64. +
  65. +#include <linux/kernel.h>
  66. +#include <linux/pci.h>
  67. +#include <linux/init.h>
  68. +#include <linux/irq.h>
  69. +
  70. +#include <asm/mach-types.h>
  71. +#include <mach/hardware.h>
  72. +
  73. +#include <asm/mach/pci.h>
  74. +
  75. +void __init tw5334_pci_preinit(void)
  76. +{
  77. + irq_set_irq_type(IRQ_IXP4XX_GPIO6, IRQ_TYPE_LEVEL_LOW);
  78. + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_LEVEL_LOW);
  79. + irq_set_irq_type(IRQ_IXP4XX_GPIO1, IRQ_TYPE_LEVEL_LOW);
  80. + irq_set_irq_type(IRQ_IXP4XX_GPIO0, IRQ_TYPE_LEVEL_LOW);
  81. +
  82. + ixp4xx_pci_preinit();
  83. +}
  84. +
  85. +static int __init tw5334_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  86. +{
  87. + if (slot == 12)
  88. + return IRQ_IXP4XX_GPIO6;
  89. + else if (slot == 13)
  90. + return IRQ_IXP4XX_GPIO2;
  91. + else if (slot == 14)
  92. + return IRQ_IXP4XX_GPIO1;
  93. + else if (slot == 15)
  94. + return IRQ_IXP4XX_GPIO0;
  95. + else return -1;
  96. +}
  97. +
  98. +struct hw_pci tw5334_pci __initdata = {
  99. + .nr_controllers = 1,
  100. + .preinit = tw5334_pci_preinit,
  101. + .ops = &ixp4xx_ops,
  102. + .setup = ixp4xx_setup,
  103. + .map_irq = tw5334_map_irq,
  104. +};
  105. +
  106. +int __init tw5334_pci_init(void)
  107. +{
  108. + if (machine_is_tw5334())
  109. + pci_common_init(&tw5334_pci);
  110. + return 0;
  111. +}
  112. +
  113. +subsys_initcall(tw5334_pci_init);
  114. --- /dev/null
  115. +++ b/arch/arm/mach-ixp4xx/tw5334-setup.c
  116. @@ -0,0 +1,167 @@
  117. +/*
  118. + * arch/arm/mach-ixp4xx/tw5334-setup.c
  119. + *
  120. + * Board setup for the Titan Wireless TW-533-4
  121. + *
  122. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  123. + *
  124. + * based on coyote-setup.c:
  125. + * Copyright (C) 2003-2005 MontaVista Software, Inc.
  126. + *
  127. + * Author: Imre Kaloz <Kaloz@openwrt.org>
  128. + */
  129. +
  130. +#include <linux/if_ether.h>
  131. +#include <linux/kernel.h>
  132. +#include <linux/init.h>
  133. +#include <linux/device.h>
  134. +#include <linux/serial.h>
  135. +#include <linux/tty.h>
  136. +#include <linux/serial_8250.h>
  137. +#include <linux/slab.h>
  138. +
  139. +#include <asm/types.h>
  140. +#include <asm/setup.h>
  141. +#include <asm/memory.h>
  142. +#include <mach/hardware.h>
  143. +#include <asm/irq.h>
  144. +#include <asm/mach-types.h>
  145. +#include <asm/mach/arch.h>
  146. +#include <asm/mach/flash.h>
  147. +
  148. +static struct flash_platform_data tw5334_flash_data = {
  149. + .map_name = "cfi_probe",
  150. + .width = 2,
  151. +};
  152. +
  153. +static struct resource tw5334_flash_resource = {
  154. + .flags = IORESOURCE_MEM,
  155. +};
  156. +
  157. +static struct platform_device tw5334_flash = {
  158. + .name = "IXP4XX-Flash",
  159. + .id = 0,
  160. + .dev = {
  161. + .platform_data = &tw5334_flash_data,
  162. + },
  163. + .num_resources = 1,
  164. + .resource = &tw5334_flash_resource,
  165. +};
  166. +
  167. +static struct resource tw5334_uart_resource = {
  168. + .start = IXP4XX_UART2_BASE_PHYS,
  169. + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  170. + .flags = IORESOURCE_MEM,
  171. +};
  172. +
  173. +static struct plat_serial8250_port tw5334_uart_data[] = {
  174. + {
  175. + .mapbase = IXP4XX_UART2_BASE_PHYS,
  176. + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  177. + .irq = IRQ_IXP4XX_UART2,
  178. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  179. + .iotype = UPIO_MEM,
  180. + .regshift = 2,
  181. + .uartclk = IXP4XX_UART_XTAL,
  182. + },
  183. + { },
  184. +};
  185. +
  186. +static struct platform_device tw5334_uart = {
  187. + .name = "serial8250",
  188. + .id = PLAT8250_DEV_PLATFORM,
  189. + .dev = {
  190. + .platform_data = tw5334_uart_data,
  191. + },
  192. + .num_resources = 1,
  193. + .resource = &tw5334_uart_resource,
  194. +};
  195. +
  196. +/* Built-in 10/100 Ethernet MAC interfaces */
  197. +static struct eth_plat_info tw5334_plat_eth[] = {
  198. + {
  199. + .phy = 0,
  200. + .rxq = 3,
  201. + .txreadyq = 20,
  202. + }, {
  203. + .phy = 1,
  204. + .rxq = 4,
  205. + .txreadyq = 21,
  206. + }
  207. +};
  208. +
  209. +static struct platform_device tw5334_eth[] = {
  210. + {
  211. + .name = "ixp4xx_eth",
  212. + .id = IXP4XX_ETH_NPEB,
  213. + .dev.platform_data = tw5334_plat_eth,
  214. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  215. + }, {
  216. + .name = "ixp4xx_eth",
  217. + .id = IXP4XX_ETH_NPEC,
  218. + .dev.platform_data = tw5334_plat_eth + 1,
  219. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  220. + }
  221. +};
  222. +
  223. +static struct platform_device *tw5334_devices[] __initdata = {
  224. + &tw5334_flash,
  225. + &tw5334_uart,
  226. + &tw5334_eth[0],
  227. + &tw5334_eth[1],
  228. +};
  229. +
  230. +static void __init tw5334_init(void)
  231. +{
  232. + uint8_t __iomem *f;
  233. + int i;
  234. +
  235. + ixp4xx_sys_init();
  236. +
  237. + tw5334_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  238. + tw5334_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(tw5334_devices, ARRAY_SIZE(tw5334_devices));
  244. +
  245. + /*
  246. + * Map in a portion of the flash and read the MAC addresses.
  247. + * Since it is stored in BE in the flash itself, we need to
  248. + * byteswap it if we're in LE mode.
  249. + */
  250. + f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000);
  251. + if (f) {
  252. + for (i = 0; i < 6; i++) {
  253. +#ifdef __ARMEB__
  254. + tw5334_plat_eth[0].hwaddr[i] = readb(f + 0xFC0422 + i);
  255. + tw5334_plat_eth[1].hwaddr[i] = readb(f + 0xFC043B + i);
  256. +#else
  257. + tw5334_plat_eth[0].hwaddr[i] = readb(f + 0xFC0422 + (i^3));
  258. + tw5334_plat_eth[1].hwaddr[i] = readb(f + 0xFC043B + (i^3));
  259. +#endif
  260. + }
  261. + iounmap(f);
  262. + }
  263. +
  264. + printk(KERN_INFO "TW-533-4: Using MAC address %pM for port 0\n",
  265. + tw5334_plat_eth[0].hwaddr);
  266. + printk(KERN_INFO "TW-533-4: Using MAC address %pM for port 1\n",
  267. + tw5334_plat_eth[1].hwaddr);
  268. +}
  269. +
  270. +#ifdef CONFIG_MACH_TW5334
  271. +MACHINE_START(TW5334, "Titan Wireless TW-533-4")
  272. + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
  273. + .map_io = ixp4xx_map_io,
  274. + .init_irq = ixp4xx_init_irq,
  275. + .init_time = ixp4xx_timer_init,
  276. + .atag_offset = 0x0100,
  277. + .init_machine = tw5334_init,
  278. +#if defined(CONFIG_PCI)
  279. + .dma_zone_size = SZ_64M,
  280. +#endif
  281. + .restart = ixp4xx_restart,
  282. +MACHINE_END
  283. +#endif