brcm.patch 12 KB

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