brcm.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. diff -Nur linux-2.6.39.4.orig/arch/mips/Kconfig linux-2.6.39.4/arch/mips/Kconfig
  2. --- linux-2.6.39.4.orig/arch/mips/Kconfig 2011-08-03 21:43:28.000000000 +0200
  3. +++ linux-2.6.39.4/arch/mips/Kconfig 2012-01-17 20:37:12.000000000 +0100
  4. @@ -103,6 +103,12 @@
  5. select GENERIC_GPIO
  6. select SYS_HAS_EARLY_PRINTK
  7. select CFE
  8. + select SYS_SUPPORTS_ZBOOT_UART16550
  9. + select HAVE_KERNEL_GZIP
  10. + select HAVE_KERNEL_BZIP2
  11. + select HAVE_KERNEL_LZMA
  12. + select HAVE_KERNEL_XZ
  13. + select HAVE_KERNEL_LZO
  14. help
  15. Support for BCM47XX based boards
  16. diff -Nur linux-2.6.39.4.orig/arch/mips/Makefile linux-2.6.39.4/arch/mips/Makefile
  17. --- linux-2.6.39.4.orig/arch/mips/Makefile 2011-08-03 21:43:28.000000000 +0200
  18. +++ linux-2.6.39.4/arch/mips/Makefile 2012-01-17 20:35:09.000000000 +0100
  19. @@ -76,6 +76,7 @@
  20. all-$(CONFIG_BOOT_ELF32) := $(vmlinux-32)
  21. all-$(CONFIG_BOOT_ELF64) := $(vmlinux-64)
  22. all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
  23. +all-$(CONFIG_BCM47XX) += vmlinuz.elf
  24. #
  25. # GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel
  26. @@ -276,7 +277,7 @@
  27. $(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) arch/mips/boot/$@
  28. # boot/compressed
  29. -vmlinuz vmlinuz.bin vmlinuz.ecoff vmlinuz.srec: $(vmlinux-32) FORCE
  30. +vmlinuz vmlinuz.bin vmlinuz.ecoff vmlinuz.srec vmlinuz.elf: $(vmlinux-32) FORCE
  31. $(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
  32. VMLINUX_LOAD_ADDRESS=$(load-y) 32bit-bfd=$(32bit-bfd) $@
  33. @@ -313,6 +314,7 @@
  34. echo ' vmlinuz.ecoff - ECOFF zboot image'
  35. echo ' vmlinuz.bin - Raw binary zboot image'
  36. echo ' vmlinuz.srec - SREC zboot image'
  37. + echo ' vmlinuz.elf - ELF self-relocating zboot image'
  38. echo
  39. echo ' These will be default as appropriate for a configured platform.'
  40. endef
  41. diff -Nur linux-2.6.39.4.orig/arch/mips/bcm47xx/Makefile linux-2.6.39.4/arch/mips/bcm47xx/Makefile
  42. --- linux-2.6.39.4.orig/arch/mips/bcm47xx/Makefile 2011-08-03 21:43:28.000000000 +0200
  43. +++ linux-2.6.39.4/arch/mips/bcm47xx/Makefile 2012-01-17 20:35:09.000000000 +0100
  44. @@ -3,4 +3,4 @@
  45. # under Linux.
  46. #
  47. -obj-y := gpio.o irq.o nvram.o prom.o serial.o setup.o time.o wgt634u.o
  48. +obj-y := gpio.o irq.o nvram.o prom.o serial.o setup.o time.o platform.o
  49. diff -Nur linux-2.6.39.4.orig/arch/mips/bcm47xx/platform.c linux-2.6.39.4/arch/mips/bcm47xx/platform.c
  50. --- linux-2.6.39.4.orig/arch/mips/bcm47xx/platform.c 1970-01-01 01:00:00.000000000 +0100
  51. +++ linux-2.6.39.4/arch/mips/bcm47xx/platform.c 2012-01-17 20:35:09.000000000 +0100
  52. @@ -0,0 +1,146 @@
  53. +/*
  54. + * This file is subject to the terms and conditions of the GNU General Public
  55. + * License. See the file "COPYING" in the main directory of this archive
  56. + * for more details.
  57. + *
  58. + * Copyright (C) 2010, 2011 Waldemar Brodkorb <wbx@openadk.org>
  59. + * Copyright © 2007, 2011 Thorsten Glaser <tg@freewrt.org>
  60. + */
  61. +
  62. +#include <linux/platform_device.h>
  63. +#include <linux/module.h>
  64. +#include <linux/mtd/physmap.h>
  65. +#include <linux/ssb/ssb.h>
  66. +
  67. +#include <asm/mach-bcm47xx/bcm47xx.h>
  68. +#include <asm/mach-bcm47xx/nvram.h>
  69. +
  70. +#define CFGFS_FLASH_SIZE (128 * 1024)
  71. +
  72. +static struct mtd_partition bcm47xx_partitions[] = {
  73. +#define SLOT_CFE 0
  74. + {
  75. + .name = "cfe",
  76. + .offset = 0,
  77. + .size = BCM47XX_OVERRIDE_CFESIZE,
  78. + .mask_flags = MTD_WRITEABLE /* force read-only */
  79. + },
  80. +#define SLOT_LINUX 1
  81. + {
  82. + .name = "linux",
  83. + .offset = 0,
  84. + .size = 0,
  85. + },
  86. +#define SLOT_ROOTFS 2
  87. + {
  88. + .name = "rootfs",
  89. + .offset = 0,
  90. + .size = 0,
  91. + },
  92. +#define SLOT_CFGFS 3
  93. + {
  94. + .name = "cfgfs",
  95. + .offset = 0,
  96. + .size = 0,
  97. + },
  98. +#define SLOT_NVRAM 4
  99. + {
  100. + .name = "nvram",
  101. + .offset = 0,
  102. + .size = 0,
  103. + },
  104. +};
  105. +
  106. +static struct physmap_flash_data bcm47xx_flash_data = {
  107. + .parts = bcm47xx_partitions,
  108. + .nr_parts = ARRAY_SIZE(bcm47xx_partitions)
  109. +};
  110. +
  111. +static struct resource bcm47xx_flash_resource = {
  112. + .flags = IORESOURCE_MEM,
  113. +};
  114. +
  115. +static struct platform_device bcm47xx_flash = {
  116. + .name = "physmap-flash",
  117. + .id = 0,
  118. + .dev = { .platform_data = &bcm47xx_flash_data, },
  119. + .resource = &bcm47xx_flash_resource,
  120. + .num_resources = 1,
  121. +};
  122. +
  123. +static struct platform_device *bcm47xx_devices[] __initdata = {
  124. + &bcm47xx_flash,
  125. +};
  126. +
  127. +struct bcm47xx_trx_header {
  128. +#define BCM47XX_TRX_MAGIC 0x30524448
  129. + u32 magic;
  130. + u32 len;
  131. + u32 crc32;
  132. + u32 flag_version;
  133. + u32 offsets[3];
  134. +};
  135. +
  136. +#define UPTODOWN(slot, psize) do { \
  137. + posn -= psize; left -= psize; \
  138. + bcm47xx_partitions[slot].offset = posn; \
  139. + bcm47xx_partitions[slot].size = psize; \
  140. +} while (/* CONSTCOND */ 0)
  141. +
  142. +static int __init bcm47xx_register_devices(void)
  143. +{
  144. + u32 flash_size;
  145. + size_t left, posn;
  146. + struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
  147. + struct bcm47xx_trx_header *trx_hdr;
  148. +
  149. + trx_hdr = (void *)KSEG1ADDR(mcore->flash_window + BCM47XX_OVERRIDE_CFESIZE);
  150. +
  151. + /* devices might have 2, 4 or 8 MB flash size */
  152. +#ifdef BCM47XX_OVERRIDE_FLASHSIZE
  153. + flash_size = BCM47XX_OVERRIDE_FLASHSIZE;
  154. + mcore->flash_window_size = flash_size;
  155. +#define BCM47XX_OVERRODE_FLASHSIZE " (overridden)"
  156. +#else
  157. + flash_size = mcore->flash_window_size;
  158. +#define BCM47XX_OVERRODE_FLASHSIZE ""
  159. +#endif
  160. + printk(KERN_INFO "FLASH SIZE%s: %x\n", BCM47XX_OVERRODE_FLASHSIZE,
  161. + flash_size);
  162. +
  163. + left = flash_size - BCM47XX_OVERRIDE_CFESIZE;
  164. + posn = flash_size;
  165. + UPTODOWN(SLOT_NVRAM, BCM47XX_OVERRIDE_NVRAMSIZE);
  166. + UPTODOWN(SLOT_CFGFS, CFGFS_FLASH_SIZE);
  167. + bcm47xx_partitions[SLOT_LINUX].offset = BCM47XX_OVERRIDE_CFESIZE;
  168. + bcm47xx_partitions[SLOT_LINUX].size = left;
  169. +
  170. + if (trx_hdr->magic == BCM47XX_TRX_MAGIC) {
  171. + bcm47xx_partitions[SLOT_ROOTFS].offset =
  172. + bcm47xx_partitions[SLOT_LINUX].offset +
  173. + trx_hdr->offsets[1];
  174. + bcm47xx_partitions[SLOT_ROOTFS].size =
  175. + bcm47xx_partitions[SLOT_LINUX].size -
  176. + trx_hdr->offsets[1];
  177. + } else
  178. + printk("bcm47xx/platform: no TRX header found\n");
  179. +
  180. + printk(KERN_INFO "=== Flash map dump ===\n");
  181. + for (posn = 0; posn < bcm47xx_flash_data.nr_parts; ++posn)
  182. + printk(KERN_INFO " #%u %08X @%08X '%s'\n",
  183. + (unsigned int)posn,
  184. + (unsigned int)bcm47xx_partitions[posn].size,
  185. + (unsigned int)bcm47xx_partitions[posn].offset,
  186. + bcm47xx_partitions[posn].name);
  187. + printk(KERN_INFO "=== Hope this works, have a nice day\n");
  188. +
  189. + bcm47xx_flash_data.width = mcore->flash_buswidth;
  190. + bcm47xx_flash_resource.start = mcore->flash_window;
  191. + bcm47xx_flash_resource.end = mcore->flash_window
  192. + + mcore->flash_window_size
  193. + - 1;
  194. + return platform_add_devices(bcm47xx_devices,
  195. + ARRAY_SIZE(bcm47xx_devices));
  196. +}
  197. +
  198. +device_initcall(bcm47xx_register_devices);
  199. diff -Nur linux-2.6.39.4.orig/arch/mips/boot/compressed/Makefile linux-2.6.39.4/arch/mips/boot/compressed/Makefile
  200. --- linux-2.6.39.4.orig/arch/mips/boot/compressed/Makefile 2011-08-03 21:43:28.000000000 +0200
  201. +++ linux-2.6.39.4/arch/mips/boot/compressed/Makefile 2012-01-17 20:35:09.000000000 +0100
  202. @@ -58,8 +58,13 @@
  203. # Calculate the load address of the compressed kernel image
  204. hostprogs-y := calc_vmlinuz_load_addr
  205. +ifdef CONFIG_BCM47XX
  206. +# XXX just after CFE, just pray the address is static
  207. +VMLINUZ_LOAD_ADDRESS = 0xffffffff80900000
  208. +else
  209. VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
  210. $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
  211. +endif
  212. vmlinuzobjs-y += $(obj)/piggy.o
  213. @@ -105,4 +110,12 @@
  214. vmlinuz.srec: vmlinuz
  215. $(call cmd,objcopy)
  216. -clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}
  217. +AFLAGS_selfreloc.o := -DVMLINUZ_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS)
  218. +CPPFLAGS_selfreloc.lds := $(KBUILD_CFLAGS)
  219. +
  220. +arch/mips/boot/compressed/selfreloc.o: arch/mips/boot/compressed/selfreloc.S vmlinuz.bin FORCE
  221. +
  222. +vmlinuz.elf: arch/mips/boot/compressed/selfreloc.o arch/mips/boot/compressed/selfreloc.lds FORCE
  223. + $(LD) $(LDFLAGS) -T arch/mips/boot/compressed/selfreloc.lds arch/mips/boot/compressed/selfreloc.o -o $@
  224. +
  225. +clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec,elf} $(objtree)/arch/mips/boot/compressed/selfreloc.{o,lds}
  226. diff -Nur linux-2.6.39.4.orig/arch/mips/boot/compressed/selfreloc.S linux-2.6.39.4/arch/mips/boot/compressed/selfreloc.S
  227. --- linux-2.6.39.4.orig/arch/mips/boot/compressed/selfreloc.S 1970-01-01 01:00:00.000000000 +0100
  228. +++ linux-2.6.39.4/arch/mips/boot/compressed/selfreloc.S 2012-01-17 20:35:09.000000000 +0100
  229. @@ -0,0 +1,54 @@
  230. +/*-
  231. + * written 2011 by Thorsten Glaser <tg@freewrt.org> based on
  232. + * arch/mips/boot/compressed/head.S
  233. + */
  234. +
  235. +#include <asm/asm.h>
  236. +#include <asm/regdef.h>
  237. +
  238. + .set noreorder
  239. + .cprestore
  240. +
  241. + .text
  242. + LEAF(selfreloc_start)
  243. +selfreloc_start:
  244. + /* Save boot rom start args */
  245. + move s0, a0
  246. + move s1, a1
  247. + move s2, a2
  248. + move s3, a3
  249. +
  250. + /* Copy code to the correct place */
  251. + PTR_LI a0, VMLINUZ_LOAD_ADDRESS
  252. + PTR_LA a1, imgbeg
  253. + PTR_LA a2, imgend
  254. +1: lw t0, 0(a1)
  255. + sw t0, 0(a0)
  256. + add a1, 4
  257. + add a0, 4
  258. + blt a1, a2, 1b
  259. + nop
  260. +
  261. + /* Restore boot rom start args */
  262. + move a0, s0
  263. + move a1, s1
  264. + move a2, s2
  265. + move a3, s3
  266. +
  267. + /* Jump to the code at its new location */
  268. + PTR_LI k0, VMLINUZ_LOAD_ADDRESS
  269. + jr k0
  270. + nop
  271. +
  272. + /* Just in case we come back… */
  273. +3:
  274. + b 3b
  275. + nop
  276. + END(selfreloc_start)
  277. +
  278. + .globl imgbeg
  279. + .p2align 2
  280. +imgbeg: .incbin "vmlinuz.bin"
  281. + .globl imgend
  282. + .p2align 2
  283. +imgend:
  284. diff -Nur linux-2.6.39.4.orig/arch/mips/boot/compressed/selfreloc.lds.S linux-2.6.39.4/arch/mips/boot/compressed/selfreloc.lds.S
  285. --- linux-2.6.39.4.orig/arch/mips/boot/compressed/selfreloc.lds.S 1970-01-01 01:00:00.000000000 +0100
  286. +++ linux-2.6.39.4/arch/mips/boot/compressed/selfreloc.lds.S 2012-01-17 20:35:09.000000000 +0100
  287. @@ -0,0 +1,39 @@
  288. +/*-
  289. + * written 2010 by Thorsten Glaser <tg@debian.org> based on
  290. + * arch/mips/kernel/vmlinux.lds and arch/mips/boot/compressed/ld.script
  291. + */
  292. +
  293. +#include <asm/asm-offsets.h>
  294. +#include <asm/page.h>
  295. +#include <asm-generic/vmlinux.lds.h>
  296. +
  297. +#undef mips
  298. +#define mips mips
  299. +OUTPUT_ARCH(mips)
  300. +ENTRY(selfreloc_start)
  301. +PHDRS {
  302. + text PT_LOAD FLAGS(7); /* RWX */
  303. +}
  304. +SECTIONS
  305. +{
  306. + . = VMLINUX_LOAD_ADDRESS;
  307. + .text : {
  308. + *(.text)
  309. + *(.text.*)
  310. + *(.rodata)
  311. + *(.rodata.*)
  312. + *(.data)
  313. + *(.data.*)
  314. + *(.bss)
  315. + *(.bss.*)
  316. + } :text
  317. + /DISCARD/ : {
  318. + *(.MIPS.options)
  319. + *(.options)
  320. + *(.pdr)
  321. + *(.reginfo)
  322. + *(.comment)
  323. + *(.note)
  324. + *(.gnu.attributes)
  325. + }
  326. +}
  327. diff -Nur linux-2.6.39.4.orig/arch/mips/boot/compressed/uart-16550.c linux-2.6.39.4/arch/mips/boot/compressed/uart-16550.c
  328. --- linux-2.6.39.4.orig/arch/mips/boot/compressed/uart-16550.c 2011-08-03 21:43:28.000000000 +0200
  329. +++ linux-2.6.39.4/arch/mips/boot/compressed/uart-16550.c 2012-01-17 20:35:09.000000000 +0100
  330. @@ -18,6 +18,11 @@
  331. #define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
  332. #endif
  333. +#ifdef CONFIG_BCM47XX
  334. +#define UART_BASE 0x18000300
  335. +#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
  336. +#endif
  337. +
  338. #ifndef PORT
  339. #error please define the serial port address for your own machine
  340. #endif
  341. diff -Nur linux-2.6.39.4.orig/drivers/ssb/driver_mipscore.c linux-2.6.39.4/drivers/ssb/driver_mipscore.c
  342. --- linux-2.6.39.4.orig/drivers/ssb/driver_mipscore.c 2011-08-03 21:43:28.000000000 +0200
  343. +++ linux-2.6.39.4/drivers/ssb/driver_mipscore.c 2012-01-17 20:35:09.000000000 +0100
  344. @@ -190,10 +190,11 @@
  345. {
  346. struct ssb_bus *bus = mcore->dev->bus;
  347. + printk("Check for vendor with value: %d", bus->chipco.dev->id.vendor);
  348. mcore->flash_buswidth = 2;
  349. if (bus->chipco.dev) {
  350. mcore->flash_window = 0x1c000000;
  351. - mcore->flash_window_size = 0x02000000;
  352. + mcore->flash_window_size = 0x00800000;
  353. if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
  354. & SSB_CHIPCO_CFG_DS16) == 0)
  355. mcore->flash_buswidth = 1;
  356. diff -Nur linux-2.6.39.4.orig/init/Kconfig linux-2.6.39.4/init/Kconfig
  357. --- linux-2.6.39.4.orig/init/Kconfig 2011-08-03 21:43:28.000000000 +0200
  358. +++ linux-2.6.39.4/init/Kconfig 2012-01-17 20:35:09.000000000 +0100
  359. @@ -156,6 +156,7 @@
  360. config KERNEL_GZIP
  361. bool "Gzip"
  362. depends on HAVE_KERNEL_GZIP
  363. + select DECOMPRESS_GZIP
  364. help
  365. The old and tried gzip compression. It provides a good balance
  366. between compression ratio and decompression speed.
  367. @@ -163,6 +164,7 @@
  368. config KERNEL_BZIP2
  369. bool "Bzip2"
  370. depends on HAVE_KERNEL_BZIP2
  371. + select DECOMPRESS_BZIP2
  372. help
  373. Its compression ratio and speed is intermediate.
  374. Decompression speed is slowest among the three. The kernel
  375. @@ -173,6 +175,7 @@
  376. config KERNEL_LZMA
  377. bool "LZMA"
  378. depends on HAVE_KERNEL_LZMA
  379. + select DECOMPRESS_LZMA
  380. help
  381. The most recent compression algorithm.
  382. Its ratio is best, decompression speed is between the other
  383. @@ -197,6 +200,7 @@
  384. config KERNEL_LZO
  385. bool "LZO"
  386. depends on HAVE_KERNEL_LZO
  387. + select DECOMPRESS_LZO
  388. help
  389. Its compression ratio is the poorest among the 4. The kernel
  390. size is about 10% bigger than gzip; however its speed