520-tw2662_support.patch 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. --- a/arch/arm/mach-ixp4xx/Kconfig
  2. +++ b/arch/arm/mach-ixp4xx/Kconfig
  3. @@ -176,6 +176,15 @@ config ARCH_PRPMC1100
  4. PrPCM1100 Processor Mezanine Module. For more information on
  5. this platform, see <file:Documentation/arm/IXP4xx>.
  6. +config MACH_TW2662
  7. + bool "Titan Wireless TW-266-2"
  8. + select PCI
  9. + help
  10. + Say 'Y' here if you want your kernel to support the Titan
  11. + Wireless TW266-2. For more information on this platform,
  12. + see http://openwrt.org
  13. +
  14. +
  15. config MACH_TW5334
  16. bool "Titan Wireless TW-533-4"
  17. select PCI
  18. --- a/arch/arm/mach-ixp4xx/Makefile
  19. +++ b/arch/arm/mach-ixp4xx/Makefile
  20. @@ -25,6 +25,7 @@ obj-pci-$(CONFIG_MACH_SIDEWINDER) += sid
  21. obj-pci-$(CONFIG_MACH_COMPEXWP18) += ixdp425-pci.o
  22. obj-pci-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-pci.o
  23. obj-pci-$(CONFIG_MACH_AP1000) += ixdp425-pci.o
  24. +obj-pci-$(CONFIG_MACH_TW2662) += tw2662-pci.o
  25. obj-pci-$(CONFIG_MACH_TW5334) += tw5334-pci.o
  26. obj-pci-$(CONFIG_MACH_MI424WR) += mi424wr-pci.o
  27. obj-pci-$(CONFIG_MACH_USR8200) += usr8200-pci.o
  28. @@ -54,6 +55,7 @@ obj-$(CONFIG_MACH_SIDEWINDER) += sidewin
  29. obj-$(CONFIG_MACH_COMPEXWP18) += compex42x-setup.o
  30. obj-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-setup.o
  31. obj-$(CONFIG_MACH_AP1000) += ap1000-setup.o
  32. +obj-$(CONFIG_MACH_TW2662) += tw2662-setup.o
  33. obj-$(CONFIG_MACH_TW5334) += tw5334-setup.o
  34. obj-$(CONFIG_MACH_MI424WR) += mi424wr-setup.o
  35. obj-$(CONFIG_MACH_USR8200) += usr8200-setup.o
  36. --- a/arch/arm/mach-ixp4xx/include/mach/uncompress.h
  37. +++ b/arch/arm/mach-ixp4xx/include/mach/uncompress.h
  38. @@ -45,7 +45,7 @@ static __inline__ void __arch_decomp_set
  39. machine_is_devixp() || machine_is_miccpt() || machine_is_mic256() ||
  40. machine_is_pronghorn() || machine_is_pronghorn_metro() ||
  41. machine_is_wrt300nv2() || machine_is_tw5334() ||
  42. - machine_is_usr8200())
  43. + machine_is_usr8200() || machine_is_tw2662())
  44. uart_base = (volatile u32*) IXP4XX_UART2_BASE_PHYS;
  45. else
  46. uart_base = (volatile u32*) IXP4XX_UART1_BASE_PHYS;
  47. --- /dev/null
  48. +++ b/arch/arm/mach-ixp4xx/tw2662-pci.c
  49. @@ -0,0 +1,67 @@
  50. +/*
  51. + * arch/arm/mach-ixp4xx/tw2662-pci.c
  52. + *
  53. + * PCI setup routines for Tiran Wireless TW-266-2 platform
  54. + *
  55. + * Copyright (C) 2002 Jungo Software Technologies.
  56. + * Copyright (C) 2003 MontaVista Softwrae, Inc.
  57. + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
  58. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  59. + *
  60. + * Maintainer: Deepak Saxena <dsaxena@mvista.com>
  61. + * Maintainer: Alexandros C. Couloumbis <alex@ozo.com>
  62. + *
  63. + * This program is free software; you can redistribute it and/or modify
  64. + * it under the terms of the GNU General Public License version 2 as
  65. + * published by the Free Software Foundation.
  66. + *
  67. + */
  68. +
  69. +#include <linux/kernel.h>
  70. +#include <linux/pci.h>
  71. +#include <linux/init.h>
  72. +#include <linux/irq.h>
  73. +#include <asm/mach-types.h>
  74. +#include <mach/hardware.h>
  75. +#include <asm/irq.h>
  76. +#include <asm/mach/pci.h>
  77. +
  78. +#define SLOT0_DEVID 1
  79. +#define SLOT1_DEVID 3
  80. +
  81. +/* PCI controller GPIO to IRQ pin mappings */
  82. +#define SLOT0_INTA 11
  83. +#define SLOT1_INTA 9
  84. +
  85. +void __init tw2662_pci_preinit(void)
  86. +{
  87. + irq_set_irq_type(IXP4XX_GPIO_IRQ(SLOT0_INTA), IRQ_TYPE_LEVEL_LOW);
  88. + irq_set_irq_type(IXP4XX_GPIO_IRQ(SLOT1_INTA), IRQ_TYPE_LEVEL_LOW);
  89. + ixp4xx_pci_preinit();
  90. +}
  91. +
  92. +static int __init tw2662_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  93. +{
  94. + if (slot == SLOT0_DEVID)
  95. + return IXP4XX_GPIO_IRQ(SLOT0_INTA);
  96. + else if (slot == SLOT1_DEVID)
  97. + return IXP4XX_GPIO_IRQ(SLOT1_INTA);
  98. + else return -1;
  99. +}
  100. +
  101. +struct hw_pci tw2662_pci __initdata = {
  102. + .nr_controllers = 1,
  103. + .preinit = tw2662_pci_preinit,
  104. + .ops = &ixp4xx_ops,
  105. + .setup = ixp4xx_setup,
  106. + .map_irq = tw2662_map_irq,
  107. +};
  108. +
  109. +int __init tw2662_pci_init(void)
  110. +{
  111. + if (machine_is_tw2662())
  112. + pci_common_init(&tw2662_pci);
  113. + return 0;
  114. +}
  115. +
  116. +subsys_initcall(tw2662_pci_init);
  117. --- /dev/null
  118. +++ b/arch/arm/mach-ixp4xx/tw2662-setup.c
  119. @@ -0,0 +1,197 @@
  120. +/*
  121. + * arch/arm/mach-ixp4xx/tw2662-setup.c
  122. + *
  123. + * Titan Wireless TW-266-2
  124. + *
  125. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  126. + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
  127. + *
  128. + * based on ap1000-setup.c:
  129. + * Author: Imre Kaloz <Kaloz@openwrt.org>
  130. + */
  131. +
  132. +#include <linux/if_ether.h>
  133. +#include <linux/kernel.h>
  134. +#include <linux/init.h>
  135. +#include <linux/device.h>
  136. +#include <linux/serial.h>
  137. +#include <linux/tty.h>
  138. +#include <linux/serial_8250.h>
  139. +#include <linux/slab.h>
  140. +#include <linux/netdevice.h>
  141. +#include <linux/etherdevice.h>
  142. +#include <linux/platform_device.h>
  143. +
  144. +#include <asm/io.h>
  145. +#include <asm/types.h>
  146. +#include <asm/setup.h>
  147. +#include <asm/memory.h>
  148. +#include <mach/hardware.h>
  149. +#include <asm/mach-types.h>
  150. +#include <asm/irq.h>
  151. +#include <asm/mach/arch.h>
  152. +#include <asm/mach/flash.h>
  153. +
  154. +/* gpio mask used by platform device */
  155. +#define TW2662_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7)
  156. +
  157. +static struct flash_platform_data tw2662_flash_data = {
  158. + .map_name = "cfi_probe",
  159. + .width = 2,
  160. +};
  161. +
  162. +static struct resource tw2662_flash_resource = {
  163. + .flags = IORESOURCE_MEM,
  164. +};
  165. +
  166. +static struct platform_device tw2662_flash = {
  167. + .name = "IXP4XX-Flash",
  168. + .id = 0,
  169. + .dev = {
  170. + .platform_data = &tw2662_flash_data,
  171. + },
  172. + .num_resources = 1,
  173. + .resource = &tw2662_flash_resource,
  174. +};
  175. +
  176. +static struct resource tw2662_uart_resources[] = {
  177. + {
  178. + .start = IXP4XX_UART1_BASE_PHYS,
  179. + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
  180. + .flags = IORESOURCE_MEM
  181. + },
  182. + {
  183. + .start = IXP4XX_UART2_BASE_PHYS,
  184. + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
  185. + .flags = IORESOURCE_MEM
  186. + }
  187. +};
  188. +
  189. +static struct plat_serial8250_port tw2662_uart_data[] = {
  190. + {
  191. + .mapbase = IXP4XX_UART1_BASE_PHYS,
  192. + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
  193. + .irq = IRQ_IXP4XX_UART1,
  194. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  195. + .iotype = UPIO_MEM,
  196. + .regshift = 2,
  197. + .uartclk = IXP4XX_UART_XTAL,
  198. + },
  199. + {
  200. + .mapbase = IXP4XX_UART2_BASE_PHYS,
  201. + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
  202. + .irq = IRQ_IXP4XX_UART2,
  203. + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  204. + .iotype = UPIO_MEM,
  205. + .regshift = 2,
  206. + .uartclk = IXP4XX_UART_XTAL,
  207. + },
  208. + { },
  209. +};
  210. +
  211. +static struct platform_device tw2662_uart = {
  212. + .name = "serial8250",
  213. + .id = PLAT8250_DEV_PLATFORM,
  214. + .dev.platform_data = tw2662_uart_data,
  215. + .num_resources = 2,
  216. + .resource = tw2662_uart_resources
  217. +};
  218. +
  219. +/* Built-in 10/100 Ethernet MAC interfaces */
  220. +static struct eth_plat_info tw2662_plat_eth[] = {
  221. + {
  222. + .phy = 3,
  223. + .rxq = 3,
  224. + .txreadyq = 20,
  225. + }, {
  226. + .phy = 1,
  227. + .rxq = 4,
  228. + .txreadyq = 21,
  229. + }
  230. +};
  231. +
  232. +static struct platform_device tw2662_eth[] = {
  233. + {
  234. + .name = "ixp4xx_eth",
  235. + .id = IXP4XX_ETH_NPEB,
  236. + .dev.platform_data = tw2662_plat_eth,
  237. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  238. + }, {
  239. + .name = "ixp4xx_eth",
  240. + .id = IXP4XX_ETH_NPEC,
  241. + .dev.platform_data = tw2662_plat_eth + 1,
  242. + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
  243. + }
  244. +};
  245. +
  246. +
  247. +static struct platform_device *tw2662_devices[] __initdata = {
  248. + &tw2662_flash,
  249. + &tw2662_uart,
  250. + &tw2662_eth[0],
  251. + &tw2662_eth[1],
  252. +};
  253. +
  254. +static char tw2662_mem_fixup[] __initdata = "mem=64M ";
  255. +
  256. +static void __init tw2662_fixup(struct tag *tags, char **cmdline,
  257. + struct meminfo *mi)
  258. +{
  259. + struct tag *t = tags;
  260. + char *p = *cmdline;
  261. +
  262. + /* Find the end of the tags table, taking note of any cmdline tag. */
  263. + for (; t->hdr.size; t = tag_next(t)) {
  264. + if (t->hdr.tag == ATAG_CMDLINE) {
  265. + p = t->u.cmdline.cmdline;
  266. + }
  267. + }
  268. +
  269. + /* Overwrite the end of the table with a new cmdline tag. */
  270. + t->hdr.tag = ATAG_CMDLINE;
  271. + t->hdr.size = (sizeof (struct tag_header) +
  272. + strlen(tw2662_mem_fixup) + strlen(p) + 1 + 4) >> 2;
  273. + strlcpy(t->u.cmdline.cmdline, tw2662_mem_fixup, COMMAND_LINE_SIZE);
  274. + strlcpy(t->u.cmdline.cmdline + strlen(tw2662_mem_fixup), p,
  275. + COMMAND_LINE_SIZE - strlen(tw2662_mem_fixup));
  276. +
  277. + /* Terminate the table. */
  278. + t = tag_next(t);
  279. + t->hdr.tag = ATAG_NONE;
  280. + t->hdr.size = 0;
  281. +}
  282. +
  283. +static void __init tw2662_init(void)
  284. +{
  285. + ixp4xx_sys_init();
  286. +
  287. + tw2662_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
  288. + tw2662_flash_resource.end =
  289. + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
  290. +
  291. + platform_add_devices(tw2662_devices, ARRAY_SIZE(tw2662_devices));
  292. +
  293. + if (!(is_valid_ether_addr(tw2662_plat_eth[0].hwaddr)))
  294. + random_ether_addr(tw2662_plat_eth[0].hwaddr);
  295. + if (!(is_valid_ether_addr(tw2662_plat_eth[1].hwaddr))) {
  296. + memcpy(tw2662_plat_eth[1].hwaddr, tw2662_plat_eth[0].hwaddr, ETH_ALEN);
  297. + tw2662_plat_eth[1].hwaddr[5] = (tw2662_plat_eth[0].hwaddr[5] + 1);
  298. + }
  299. +
  300. +}
  301. +
  302. +#ifdef CONFIG_MACH_TW2662
  303. +MACHINE_START(TW2662, "Titan Wireless TW-266-2")
  304. + /* Maintainer: Alexandros C. Couloumbis <alex@ozo.com> */
  305. + .fixup = tw2662_fixup,
  306. + .map_io = ixp4xx_map_io,
  307. + .init_irq = ixp4xx_init_irq,
  308. + .init_time = ixp4xx_timer_init,
  309. + .atag_offset = 0x0100,
  310. + .init_machine = tw2662_init,
  311. +#if defined(CONFIG_PCI)
  312. + .dma_zone_size = SZ_64M,
  313. +#endif
  314. + .restart = ixp4xx_restart,
  315. +MACHINE_END
  316. +#endif