1
0

brcm.patch 12 KB

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