brcm.patch 14 KB

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