brcm.patch 12 KB

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