brcm.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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 11:00:54.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 = &ssb_bcm47xx.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. diff -Nur linux-3.5.orig//arch/mips/boot/compressed/decompress.c linux-3.5/arch/mips/boot/compressed/decompress.c
  161. --- linux-3.5.orig//arch/mips/boot/compressed/decompress.c 2012-07-21 22:58:29.000000000 +0200
  162. +++ linux-3.5/arch/mips/boot/compressed/decompress.c 2012-07-31 11:00:54.000000000 +0200
  163. @@ -43,7 +43,7 @@
  164. /* activate the code for pre-boot environment */
  165. #define STATIC static
  166. -#ifdef CONFIG_KERNEL_GZIP
  167. +#if defined(CONFIG_KERNEL_GZIP) || defined(CONFIG_KERNEL_XZ)
  168. void *memcpy(void *dest, const void *src, size_t n)
  169. {
  170. int i;
  171. @@ -54,6 +54,8 @@
  172. d[i] = s[i];
  173. return dest;
  174. }
  175. +#endif
  176. +#ifdef CONFIG_KERNEL_GZIP
  177. #include "../../../../lib/decompress_inflate.c"
  178. #endif
  179. @@ -78,6 +80,10 @@
  180. #include "../../../../lib/decompress_unlzo.c"
  181. #endif
  182. +#ifdef CONFIG_KERNEL_XZ
  183. +#include "../../../../lib/decompress_unxz.c"
  184. +#endif
  185. +
  186. void decompress_kernel(unsigned long boot_heap_start)
  187. {
  188. unsigned long zimage_start, zimage_size;
  189. diff -Nur linux-3.5.orig//arch/mips/boot/compressed/Makefile linux-3.5/arch/mips/boot/compressed/Makefile
  190. --- linux-3.5.orig//arch/mips/boot/compressed/Makefile 2012-07-21 22:58:29.000000000 +0200
  191. +++ linux-3.5/arch/mips/boot/compressed/Makefile 2012-07-31 11:00:54.000000000 +0200
  192. @@ -44,6 +44,7 @@
  193. tool_$(CONFIG_KERNEL_BZIP2) = bzip2
  194. tool_$(CONFIG_KERNEL_LZMA) = lzma
  195. tool_$(CONFIG_KERNEL_LZO) = lzo
  196. +tool_$(CONFIG_KERNEL_XZ) = xzkern
  197. targets += vmlinux.bin.z
  198. $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
  199. @@ -58,8 +59,13 @@
  200. # Calculate the load address of the compressed kernel image
  201. hostprogs-y := calc_vmlinuz_load_addr
  202. +ifdef CONFIG_BCM47XX
  203. +# XXX just after CFE, just pray the address is static
  204. +VMLINUZ_LOAD_ADDRESS = 0xffffffff80900000
  205. +else
  206. VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
  207. $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
  208. +endif
  209. vmlinuzobjs-y += $(obj)/piggy.o
  210. @@ -105,4 +111,12 @@
  211. vmlinuz.srec: vmlinuz
  212. $(call cmd,objcopy)
  213. -clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}
  214. +AFLAGS_selfreloc.o := -DVMLINUZ_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS)
  215. +CPPFLAGS_selfreloc.lds := $(KBUILD_CFLAGS)
  216. +
  217. +arch/mips/boot/compressed/selfreloc.o: arch/mips/boot/compressed/selfreloc.S vmlinuz.bin FORCE
  218. +
  219. +vmlinuz.elf: arch/mips/boot/compressed/selfreloc.o arch/mips/boot/compressed/selfreloc.lds FORCE
  220. + $(LD) $(LDFLAGS) -T arch/mips/boot/compressed/selfreloc.lds arch/mips/boot/compressed/selfreloc.o -o $@
  221. +
  222. +clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec,elf} $(objtree)/arch/mips/boot/compressed/selfreloc.{o,lds}
  223. diff -Nur linux-3.5.orig//arch/mips/boot/compressed/selfreloc.lds.S linux-3.5/arch/mips/boot/compressed/selfreloc.lds.S
  224. --- linux-3.5.orig//arch/mips/boot/compressed/selfreloc.lds.S 1970-01-01 01:00:00.000000000 +0100
  225. +++ linux-3.5/arch/mips/boot/compressed/selfreloc.lds.S 2012-07-31 11:00:54.000000000 +0200
  226. @@ -0,0 +1,39 @@
  227. +/*-
  228. + * written 2010 by Thorsten Glaser <tg@debian.org> based on
  229. + * arch/mips/kernel/vmlinux.lds and arch/mips/boot/compressed/ld.script
  230. + */
  231. +
  232. +#include <asm/asm-offsets.h>
  233. +#include <asm/page.h>
  234. +#include <asm-generic/vmlinux.lds.h>
  235. +
  236. +#undef mips
  237. +#define mips mips
  238. +OUTPUT_ARCH(mips)
  239. +ENTRY(selfreloc_start)
  240. +PHDRS {
  241. + text PT_LOAD FLAGS(7); /* RWX */
  242. +}
  243. +SECTIONS
  244. +{
  245. + . = VMLINUX_LOAD_ADDRESS;
  246. + .text : {
  247. + *(.text)
  248. + *(.text.*)
  249. + *(.rodata)
  250. + *(.rodata.*)
  251. + *(.data)
  252. + *(.data.*)
  253. + *(.bss)
  254. + *(.bss.*)
  255. + } :text
  256. + /DISCARD/ : {
  257. + *(.MIPS.options)
  258. + *(.options)
  259. + *(.pdr)
  260. + *(.reginfo)
  261. + *(.comment)
  262. + *(.note)
  263. + *(.gnu.attributes)
  264. + }
  265. +}
  266. diff -Nur linux-3.5.orig//arch/mips/boot/compressed/selfreloc.S linux-3.5/arch/mips/boot/compressed/selfreloc.S
  267. --- linux-3.5.orig//arch/mips/boot/compressed/selfreloc.S 1970-01-01 01:00:00.000000000 +0100
  268. +++ linux-3.5/arch/mips/boot/compressed/selfreloc.S 2012-07-31 11:00:54.000000000 +0200
  269. @@ -0,0 +1,54 @@
  270. +/*-
  271. + * written 2011 by Thorsten Glaser <tg@freewrt.org> based on
  272. + * arch/mips/boot/compressed/head.S
  273. + */
  274. +
  275. +#include <asm/asm.h>
  276. +#include <asm/regdef.h>
  277. +
  278. + .set noreorder
  279. + .cprestore
  280. +
  281. + .text
  282. + LEAF(selfreloc_start)
  283. +selfreloc_start:
  284. + /* Save boot rom start args */
  285. + move s0, a0
  286. + move s1, a1
  287. + move s2, a2
  288. + move s3, a3
  289. +
  290. + /* Copy code to the correct place */
  291. + PTR_LI a0, VMLINUZ_LOAD_ADDRESS
  292. + PTR_LA a1, imgbeg
  293. + PTR_LA a2, imgend
  294. +1: lw t0, 0(a1)
  295. + sw t0, 0(a0)
  296. + add a1, 4
  297. + add a0, 4
  298. + blt a1, a2, 1b
  299. + nop
  300. +
  301. + /* Restore boot rom start args */
  302. + move a0, s0
  303. + move a1, s1
  304. + move a2, s2
  305. + move a3, s3
  306. +
  307. + /* Jump to the code at its new location */
  308. + PTR_LI k0, VMLINUZ_LOAD_ADDRESS
  309. + jr k0
  310. + nop
  311. +
  312. + /* Just in case we come back… */
  313. +3:
  314. + b 3b
  315. + nop
  316. + END(selfreloc_start)
  317. +
  318. + .globl imgbeg
  319. + .p2align 2
  320. +imgbeg: .incbin "vmlinuz.bin"
  321. + .globl imgend
  322. + .p2align 2
  323. +imgend:
  324. diff -Nur linux-3.5.orig//arch/mips/boot/compressed/uart-16550.c linux-3.5/arch/mips/boot/compressed/uart-16550.c
  325. --- linux-3.5.orig//arch/mips/boot/compressed/uart-16550.c 2012-07-21 22:58:29.000000000 +0200
  326. +++ linux-3.5/arch/mips/boot/compressed/uart-16550.c 2012-07-31 11:00:54.000000000 +0200
  327. @@ -18,6 +18,11 @@
  328. #define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
  329. #endif
  330. +#ifdef CONFIG_BCM47XX
  331. +#define UART_BASE 0x18000300
  332. +#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
  333. +#endif
  334. +
  335. #ifndef PORT
  336. #error please define the serial port address for your own machine
  337. #endif
  338. diff -Nur linux-3.5.orig//arch/mips/Kconfig linux-3.5/arch/mips/Kconfig
  339. --- linux-3.5.orig//arch/mips/Kconfig 2012-07-21 22:58:29.000000000 +0200
  340. +++ linux-3.5/arch/mips/Kconfig 2012-07-31 11:00:54.000000000 +0200
  341. @@ -107,6 +107,12 @@
  342. select GENERIC_GPIO
  343. select SYS_HAS_EARLY_PRINTK
  344. select CFE
  345. + select SYS_SUPPORTS_ZBOOT_UART16550
  346. + select HAVE_KERNEL_GZIP
  347. + select HAVE_KERNEL_BZIP2
  348. + select HAVE_KERNEL_LZMA
  349. + select HAVE_KERNEL_XZ
  350. + select HAVE_KERNEL_LZO
  351. help
  352. Support for BCM47XX based boards
  353. diff -Nur linux-3.5.orig//arch/mips/Makefile linux-3.5/arch/mips/Makefile
  354. --- linux-3.5.orig//arch/mips/Makefile 2012-07-21 22:58:29.000000000 +0200
  355. +++ linux-3.5/arch/mips/Makefile 2012-07-31 11:00:54.000000000 +0200
  356. @@ -76,6 +76,7 @@
  357. all-$(CONFIG_BOOT_ELF32) := $(vmlinux-32)
  358. all-$(CONFIG_BOOT_ELF64) := $(vmlinux-64)
  359. all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
  360. +all-$(CONFIG_BCM47XX) += vmlinuz.elf
  361. #
  362. # GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel
  363. @@ -277,7 +278,7 @@
  364. $(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) arch/mips/boot/$@
  365. # boot/compressed
  366. -vmlinuz vmlinuz.bin vmlinuz.ecoff vmlinuz.srec: $(vmlinux-32) FORCE
  367. +vmlinuz vmlinuz.bin vmlinuz.ecoff vmlinuz.srec vmlinuz.elf: $(vmlinux-32) FORCE
  368. $(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
  369. VMLINUX_LOAD_ADDRESS=$(load-y) 32bit-bfd=$(32bit-bfd) $@
  370. @@ -316,6 +317,7 @@
  371. echo ' vmlinuz.ecoff - ECOFF zboot image'
  372. echo ' vmlinuz.bin - Raw binary zboot image'
  373. echo ' vmlinuz.srec - SREC zboot image'
  374. + echo ' vmlinuz.elf - ELF self-relocating zboot image'
  375. echo
  376. echo ' These will be default as appropriate for a configured platform.'
  377. endef
  378. diff -Nur linux-3.5.orig//drivers/ssb/driver_mipscore.c linux-3.5/drivers/ssb/driver_mipscore.c
  379. --- linux-3.5.orig//drivers/ssb/driver_mipscore.c 2012-07-21 22:58:29.000000000 +0200
  380. +++ linux-3.5/drivers/ssb/driver_mipscore.c 2012-07-31 11:00:54.000000000 +0200
  381. @@ -190,10 +190,11 @@
  382. {
  383. struct ssb_bus *bus = mcore->dev->bus;
  384. + printk("Check for vendor with value: %d", bus->chipco.dev->id.vendor);
  385. mcore->flash_buswidth = 2;
  386. if (bus->chipco.dev) {
  387. mcore->flash_window = 0x1c000000;
  388. - mcore->flash_window_size = 0x02000000;
  389. + mcore->flash_window_size = 0x00800000;
  390. if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
  391. & SSB_CHIPCO_CFG_DS16) == 0)
  392. mcore->flash_buswidth = 1;
  393. diff -Nur linux-3.5.orig//init/Kconfig linux-3.5/init/Kconfig
  394. --- linux-3.5.orig//init/Kconfig 2012-07-21 22:58:29.000000000 +0200
  395. +++ linux-3.5/init/Kconfig 2012-07-31 11:00:54.000000000 +0200
  396. @@ -158,6 +158,7 @@
  397. config KERNEL_GZIP
  398. bool "Gzip"
  399. depends on HAVE_KERNEL_GZIP
  400. + select DECOMPRESS_GZIP
  401. help
  402. The old and tried gzip compression. It provides a good balance
  403. between compression ratio and decompression speed.
  404. @@ -165,6 +166,7 @@
  405. config KERNEL_BZIP2
  406. bool "Bzip2"
  407. depends on HAVE_KERNEL_BZIP2
  408. + select DECOMPRESS_BZIP2
  409. help
  410. Its compression ratio and speed is intermediate.
  411. Decompression speed is slowest among the choices. The kernel
  412. @@ -175,6 +177,7 @@
  413. config KERNEL_LZMA
  414. bool "LZMA"
  415. depends on HAVE_KERNEL_LZMA
  416. + select DECOMPRESS_LZMA
  417. help
  418. This compression algorithm's ratio is best. Decompression speed
  419. is between gzip and bzip2. Compression is slowest.
  420. @@ -183,6 +186,7 @@
  421. config KERNEL_XZ
  422. bool "XZ"
  423. depends on HAVE_KERNEL_XZ
  424. + select DECOMPRESS_XZ
  425. help
  426. XZ uses the LZMA2 algorithm and instruction set specific
  427. BCJ filters which can improve compression ratio of executable
  428. @@ -198,6 +202,7 @@
  429. config KERNEL_LZO
  430. bool "LZO"
  431. depends on HAVE_KERNEL_LZO
  432. + select DECOMPRESS_LZO
  433. help
  434. Its compression ratio is the poorest among the choices. The kernel
  435. size is about 10% bigger than gzip; however its speed
  436. diff -Nur linux-3.5.orig//lib/xz/xz_stream.h linux-3.5/lib/xz/xz_stream.h
  437. --- linux-3.5.orig//lib/xz/xz_stream.h 2012-07-21 22:58:29.000000000 +0200
  438. +++ linux-3.5/lib/xz/xz_stream.h 2012-07-31 11:00:54.000000000 +0200
  439. @@ -40,7 +40,12 @@
  440. * compressed size of the file to less than 256 MiB and may also weaken
  441. * error detection slightly.
  442. */
  443. +
  444. +#ifdef __mips__
  445. +typedef uint32_t vli_type;
  446. +#else
  447. typedef uint64_t vli_type;
  448. +#endif
  449. #define VLI_MAX ((vli_type)-1 / 2)
  450. #define VLI_UNKNOWN ((vli_type)-1)