brcm.patch 14 KB

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