brcm.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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-26 21:54:17.727672777 +0200
  12. @@ -0,0 +1,147 @@
  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 NVRAM_FLASH_SIZE 0x10000
  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 = 0x40000, /* 256k */
  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 + 0x40000);
  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 - 0x40000;
  125. + posn = flash_size;
  126. + UPTODOWN(SLOT_NVRAM, NVRAM_FLASH_SIZE);
  127. + UPTODOWN(SLOT_CFGFS, CFGFS_FLASH_SIZE);
  128. + bcm47xx_partitions[SLOT_LINUX].offset = 0x40000;
  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-2.6.37.orig/arch/mips/boot/compressed/Makefile linux-2.6.37/arch/mips/boot/compressed/Makefile
  161. --- linux-2.6.37.orig/arch/mips/boot/compressed/Makefile 2011-01-05 01:50:19.000000000 +0100
  162. +++ linux-2.6.37/arch/mips/boot/compressed/Makefile 2011-04-26 20:44:04.607661119 +0200
  163. @@ -58,8 +58,13 @@
  164. # Calculate the load address of the compressed kernel image
  165. hostprogs-y := calc_vmlinuz_load_addr
  166. +ifdef CONFIG_BCM47XX
  167. +# XXX just after CFE, just pray the address is static
  168. +VMLINUZ_LOAD_ADDRESS = 0xffffffff80480000
  169. +else
  170. VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
  171. $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
  172. +endif
  173. vmlinuzobjs-y += $(obj)/piggy.o
  174. @@ -105,4 +110,12 @@
  175. vmlinuz.srec: vmlinuz
  176. $(call cmd,objcopy)
  177. -clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}
  178. +AFLAGS_selfreloc.o := -DVMLINUZ_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS)
  179. +CPPFLAGS_selfreloc.lds := $(KBUILD_CFLAGS)
  180. +
  181. +arch/mips/boot/compressed/selfreloc.o: arch/mips/boot/compressed/selfreloc.S vmlinuz.bin FORCE
  182. +
  183. +vmlinuz.elf: arch/mips/boot/compressed/selfreloc.o arch/mips/boot/compressed/selfreloc.lds FORCE
  184. + $(LD) $(LDFLAGS) -T arch/mips/boot/compressed/selfreloc.lds arch/mips/boot/compressed/selfreloc.o -o $@
  185. +
  186. +clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec,elf} $(objtree)/arch/mips/boot/compressed/selfreloc.{o,lds}
  187. 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
  188. --- linux-2.6.37.orig/arch/mips/boot/compressed/selfreloc.lds.S 1970-01-01 01:00:00.000000000 +0100
  189. +++ linux-2.6.37/arch/mips/boot/compressed/selfreloc.lds.S 2011-04-26 20:26:20.347764678 +0200
  190. @@ -0,0 +1,39 @@
  191. +/*-
  192. + * written 2010 by Thorsten Glaser <tg@debian.org> based on
  193. + * arch/mips/kernel/vmlinux.lds and arch/mips/boot/compressed/ld.script
  194. + */
  195. +
  196. +#include <asm/asm-offsets.h>
  197. +#include <asm/page.h>
  198. +#include <asm-generic/vmlinux.lds.h>
  199. +
  200. +#undef mips
  201. +#define mips mips
  202. +OUTPUT_ARCH(mips)
  203. +ENTRY(selfreloc_start)
  204. +PHDRS {
  205. + text PT_LOAD FLAGS(7); /* RWX */
  206. +}
  207. +SECTIONS
  208. +{
  209. + . = VMLINUX_LOAD_ADDRESS;
  210. + .text : {
  211. + *(.text)
  212. + *(.text.*)
  213. + *(.rodata)
  214. + *(.rodata.*)
  215. + *(.data)
  216. + *(.data.*)
  217. + *(.bss)
  218. + *(.bss.*)
  219. + } :text
  220. + /DISCARD/ : {
  221. + *(.MIPS.options)
  222. + *(.options)
  223. + *(.pdr)
  224. + *(.reginfo)
  225. + *(.comment)
  226. + *(.note)
  227. + *(.gnu.attributes)
  228. + }
  229. +}
  230. diff -Nur linux-2.6.37.orig/arch/mips/boot/compressed/selfreloc.S linux-2.6.37/arch/mips/boot/compressed/selfreloc.S
  231. --- linux-2.6.37.orig/arch/mips/boot/compressed/selfreloc.S 1970-01-01 01:00:00.000000000 +0100
  232. +++ linux-2.6.37/arch/mips/boot/compressed/selfreloc.S 2011-04-26 20:26:20.197673829 +0200
  233. @@ -0,0 +1,54 @@
  234. +/*-
  235. + * written 2011 by Thorsten Glaser <tg@freewrt.org> based on
  236. + * arch/mips/boot/compressed/head.S
  237. + */
  238. +
  239. +#include <asm/asm.h>
  240. +#include <asm/regdef.h>
  241. +
  242. + .set noreorder
  243. + .cprestore
  244. +
  245. + .text
  246. + LEAF(selfreloc_start)
  247. +selfreloc_start:
  248. + /* Save boot rom start args */
  249. + move s0, a0
  250. + move s1, a1
  251. + move s2, a2
  252. + move s3, a3
  253. +
  254. + /* Copy code to the correct place */
  255. + PTR_LI a0, VMLINUZ_LOAD_ADDRESS
  256. + PTR_LA a1, imgbeg
  257. + PTR_LA a2, imgend
  258. +1: lw t0, 0(a1)
  259. + sw t0, 0(a0)
  260. + add a1, 4
  261. + add a0, 4
  262. + blt a1, a2, 1b
  263. + nop
  264. +
  265. + /* Restore boot rom start args */
  266. + move a0, s0
  267. + move a1, s1
  268. + move a2, s2
  269. + move a3, s3
  270. +
  271. + /* Jump to the code at its new location */
  272. + PTR_LI k0, VMLINUZ_LOAD_ADDRESS
  273. + jr k0
  274. + nop
  275. +
  276. + /* Just in case we come back… */
  277. +3:
  278. + b 3b
  279. + nop
  280. + END(selfreloc_start)
  281. +
  282. + .globl imgbeg
  283. + .p2align 2
  284. +imgbeg: .incbin "vmlinuz.bin"
  285. + .globl imgend
  286. + .p2align 2
  287. +imgend:
  288. 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
  289. --- linux-2.6.37.orig/arch/mips/boot/compressed/uart-16550.c 2011-01-05 01:50:19.000000000 +0100
  290. +++ linux-2.6.37/arch/mips/boot/compressed/uart-16550.c 2011-04-26 20:26:20.467673519 +0200
  291. @@ -18,6 +18,11 @@
  292. #define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
  293. #endif
  294. +#ifdef CONFIG_BCM47XX
  295. +#define UART_BASE 0x18000300
  296. +#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
  297. +#endif
  298. +
  299. #ifndef PORT
  300. #error please define the serial port address for your own machine
  301. #endif
  302. diff -Nur linux-2.6.37.orig/arch/mips/Kconfig linux-2.6.37/arch/mips/Kconfig
  303. --- linux-2.6.37.orig/arch/mips/Kconfig 2011-01-05 01:50:19.000000000 +0100
  304. +++ linux-2.6.37/arch/mips/Kconfig 2011-04-26 20:26:19.637668480 +0200
  305. @@ -84,6 +84,7 @@
  306. select GENERIC_GPIO
  307. select SYS_HAS_EARLY_PRINTK
  308. select CFE
  309. + select SYS_SUPPORTS_ZBOOT_UART16550
  310. help
  311. Support for BCM47XX based boards
  312. diff -Nur linux-2.6.37.orig/arch/mips/Makefile linux-2.6.37/arch/mips/Makefile
  313. --- linux-2.6.37.orig/arch/mips/Makefile 2011-01-05 01:50:19.000000000 +0100
  314. +++ linux-2.6.37/arch/mips/Makefile 2011-04-26 20:26:19.647661042 +0200
  315. @@ -76,6 +76,7 @@
  316. all-$(CONFIG_BOOT_ELF32) := $(vmlinux-32)
  317. all-$(CONFIG_BOOT_ELF64) := $(vmlinux-64)
  318. all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
  319. +all-$(CONFIG_BCM47XX) += vmlinuz.elf
  320. #
  321. # GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel
  322. @@ -276,7 +277,7 @@
  323. $(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) arch/mips/boot/$@
  324. # boot/compressed
  325. -vmlinuz vmlinuz.bin vmlinuz.ecoff vmlinuz.srec: $(vmlinux-32) FORCE
  326. +vmlinuz vmlinuz.bin vmlinuz.ecoff vmlinuz.srec vmlinuz.elf: $(vmlinux-32) FORCE
  327. $(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
  328. VMLINUX_LOAD_ADDRESS=$(load-y) 32bit-bfd=$(32bit-bfd) $@
  329. @@ -313,6 +314,7 @@
  330. echo ' vmlinuz.ecoff - ECOFF zboot image'
  331. echo ' vmlinuz.bin - Raw binary zboot image'
  332. echo ' vmlinuz.srec - SREC zboot image'
  333. + echo ' vmlinuz.elf - ELF self-relocating zboot image'
  334. echo
  335. echo ' These will be default as apropriate for a configured platform.'
  336. endef
  337. diff -Nur linux-2.6.37.orig/drivers/ssb/driver_mipscore.c linux-2.6.37/drivers/ssb/driver_mipscore.c
  338. --- linux-2.6.37.orig/drivers/ssb/driver_mipscore.c 2011-01-05 01:50:19.000000000 +0100
  339. +++ linux-2.6.37/drivers/ssb/driver_mipscore.c 2011-04-26 20:26:20.597672444 +0200
  340. @@ -190,10 +190,11 @@
  341. {
  342. struct ssb_bus *bus = mcore->dev->bus;
  343. + printk("Check for vendor with value: %d", bus->chipco.dev->id.vendor);
  344. mcore->flash_buswidth = 2;
  345. if (bus->chipco.dev) {
  346. mcore->flash_window = 0x1c000000;
  347. - mcore->flash_window_size = 0x02000000;
  348. + mcore->flash_window_size = 0x00800000;
  349. if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
  350. & SSB_CHIPCO_CFG_DS16) == 0)
  351. mcore->flash_buswidth = 1;
  352. diff -Nur linux-2.6.37.orig/init/Kconfig linux-2.6.37/init/Kconfig
  353. --- linux-2.6.37.orig/init/Kconfig 2011-01-05 01:50:19.000000000 +0100
  354. +++ linux-2.6.37/init/Kconfig 2011-04-26 20:26:20.727673059 +0200
  355. @@ -158,6 +158,7 @@
  356. config KERNEL_GZIP
  357. bool "Gzip"
  358. depends on HAVE_KERNEL_GZIP
  359. + select DECOMPRESS_GZIP
  360. help
  361. The old and tried gzip compression. It provides a good balance
  362. between compression ratio and decompression speed.
  363. @@ -165,6 +166,7 @@
  364. config KERNEL_BZIP2
  365. bool "Bzip2"
  366. depends on HAVE_KERNEL_BZIP2
  367. + select DECOMPRESS_BZIP2
  368. help
  369. Its compression ratio and speed is intermediate.
  370. Decompression speed is slowest among the three. The kernel
  371. @@ -175,6 +177,7 @@
  372. config KERNEL_LZMA
  373. bool "LZMA"
  374. depends on HAVE_KERNEL_LZMA
  375. + select DECOMPRESS_LZMA
  376. help
  377. The most recent compression algorithm.
  378. Its ratio is best, decompression speed is between the other
  379. @@ -184,6 +187,7 @@
  380. config KERNEL_LZO
  381. bool "LZO"
  382. depends on HAVE_KERNEL_LZO
  383. + select DECOMPRESS_LZO
  384. help
  385. Its compression ratio is the poorest among the 4. The kernel
  386. size is about 10% bigger than gzip; however its speed