1 diff -Narup linux-2.4.31-orig/arch/ppc/boot/simple/Makefile linux-2.4.31/arch/ppc/boot/simple/Makefile
2 --- linux-2.4.31-orig/arch/ppc/boot/simple/Makefile 2005-12-14 15:16:26.000000000 +0800
3 +++ linux-2.4.31/arch/ppc/boot/simple/Makefile 2006-01-15 17:28:42.000000000 +0800
4 @@ -152,6 +152,7 @@ zImage: $(ZIMAGE)
6 zImage.initrd: $(ZIMAGEINITRD)
8 + cp -f ../images/zImage.initrd.$(END) $(INSTALL_PATH)/dongle.bin
11 cp ../images/zImage.$(END) $(TFTPIMAGE)
12 diff -Narup linux-2.4.31-orig/arch/ppc/boot/simple/misc-embedded.c linux-2.4.31/arch/ppc/boot/simple/misc-embedded.c
13 --- linux-2.4.31-orig/arch/ppc/boot/simple/misc-embedded.c 2005-12-14 16:27:53.000000000 +0800
14 +++ linux-2.4.31/arch/ppc/boot/simple/misc-embedded.c 2006-01-15 17:28:42.000000000 +0800
15 @@ -221,6 +221,7 @@ load_kernel(unsigned long load_addr, int
16 gunzip(0, 0x400000, zimage_start, &zimage_size);
17 flush_instruction_cache();
19 +#ifdef CONFIG_BLK_DEV_INITRD
21 struct bi_record *rec;
22 unsigned long initrd_loc;
23 @@ -271,6 +272,31 @@ load_kernel(unsigned long load_addr, int
24 rec->size = sizeof(struct bi_record);
25 rec = (struct bi_record *)((unsigned long)rec + rec->size);
29 + /* Moving Squash Rootfs to sdram bank1 */
31 + #define MAGIC_VER_HCW 0x48435720
32 + #define MAGIC_VER_MVP 0x4D565000
33 + unsigned long *magic_hcw;
34 + unsigned long *magic_mvp;
35 + unsigned long *initrd_sz;
37 + magic_hcw = 0xa0fff200;
38 + magic_mvp = 0xa0fff204;
39 + /* if there is no magic number on new xram_start + 512 bytes, we assume
40 + * system boot first time then move boot data into new xram position. */
41 + if( *magic_hcw != MAGIC_VER_HCW && *magic_mvp != MAGIC_VER_MVP ){
42 + puts("\nMoving xram data to 0xa0fff000\n");
43 + memcpy((void*)(0xa0fff000), (void*)(0xa0f00000), 0x1000);
45 + puts("Moving initrd to 0xa0d00000\n");
46 + memcpy((void*)(0xa0d00000), &__ramdisk_begin, initrd_size);
47 + /* writing initrd size into bottom of bank1 memory */
48 + memcpy((void*)0xa0fffffc, &initrd_size, 4);
52 puts("Now booting the kernel\n");
53 serial_close(com_port);
55 diff -Narup linux-2.4.31-orig/drivers/mtd/maps/Config.in linux-2.4.31/drivers/mtd/maps/Config.in
56 --- linux-2.4.31-orig/drivers/mtd/maps/Config.in 2005-12-14 15:16:07.000000000 +0800
57 +++ linux-2.4.31/drivers/mtd/maps/Config.in 2006-01-15 17:28:22.000000000 +0800
58 @@ -45,6 +45,7 @@ if [ "$CONFIG_PPC" = "y" ]; then
59 dep_tristate ' CFI Flash device mapped on D-Box2' CONFIG_MTD_DBOX2 $CONFIG_MTD_CFI
60 dep_tristate ' CFI Flash device mapping on FlagaDM' CONFIG_MTD_CFI_FLAGADM $CONFIG_MTD_CFI
61 dep_tristate ' CFI Flash device mapped on IBM Redwood-4/5' CONFIG_MTD_REDWOOD $CONFIG_MTD_CFI
62 + dep_tristate ' SDRAM device mapping on Hauppauge MVP' CONFIG_MTD_MVP_RAM $CONFIG_MTD_CFI
65 if [ "$CONFIG_MIPS" = "y" ]; then
66 diff -Narup linux-2.4.31-orig/drivers/mtd/maps/Makefile linux-2.4.31/drivers/mtd/maps/Makefile
67 --- linux-2.4.31-orig/drivers/mtd/maps/Makefile 2005-12-14 15:16:07.000000000 +0800
68 +++ linux-2.4.31/drivers/mtd/maps/Makefile 2006-01-15 17:28:22.000000000 +0800
69 @@ -61,5 +61,6 @@ obj-$(CONFIG_MTD_REDWOOD) += redwood.o
70 obj-$(CONFIG_MTD_UCLINUX) += uclinux.o
71 obj-$(CONFIG_MTD_NETtel) += nettel.o
72 obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o
73 +obj-$(CONFIG_MTD_MVP_RAM) += ramdisk.o
75 include $(TOPDIR)/Rules.make
76 diff -Narup linux-2.4.31-orig/drivers/mtd/maps/ramdisk.c linux-2.4.31/drivers/mtd/maps/ramdisk.c
77 --- linux-2.4.31-orig/drivers/mtd/maps/ramdisk.c 1970-01-01 08:00:00.000000000 +0800
78 +++ linux-2.4.31/drivers/mtd/maps/ramdisk.c 2006-01-15 17:28:22.000000000 +0800
81 + * HCW sdram mtd Driver
83 +#include <linux/config.h>
84 +#include <linux/version.h>
86 +#include <linux/kernel.h>
87 +#include <linux/module.h>
89 +#if CONFIG_MODVERSIONS == 1
91 +#include <linux/modversions.h>
94 +#include <linux/fs.h>
96 +#include <linux/mm.h>
97 +#include <linux/init.h>
98 +#include <linux/ioport.h>
99 +#include <linux/errno.h>
100 +#include <asm/uaccess.h>
101 +#include <linux/string.h>
102 +#include <linux/slab.h>
104 +#include <linux/mtd/mtd.h>
105 +#include <linux/mtd/map.h>
106 +#include <linux/mtd/partitions.h>
110 +#define KDBG(fmt, args...) if(1) printk("<sdram-mtd>: " fmt, ## args)
113 +#define __PHYSICAL_ROOTFS_BASE 0xA0D00000
114 +#define __PHYSICAL_ROOTFS_SIZE_BASE 0xA0FFFFFC
115 +#define __PHYSICAL_ROOTFS_END_BASE 0xA0FFF000
116 +#define __PHYSICAL_TOTAL_SIZE 0x002FF000
118 +#define GetRootSize() {return (*rootfs_size)}
122 +// read/write function.
124 +static __u8 sdram_read8(struct map_info *map, unsigned long ofs)
126 + return readb(map->map_priv_1 + ofs);
129 +static __u16 sdram_read16(struct map_info *map, unsigned long ofs)
131 + return readw(map->map_priv_1 + ofs);
134 +static __u32 sdram_read32(struct map_info *map, unsigned long ofs)
136 + return readl(map->map_priv_1 + ofs);
139 +static void sdram_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
141 + memcpy(to, (void *)(map->map_priv_1 + from), len);
144 +static void sdram_write8(struct map_info *map, __u8 d, unsigned long adr)
146 + writeb(d, map->map_priv_1 + adr);
149 +static void sdram_write16(struct map_info *map, __u16 d, unsigned long adr)
151 + writew(d, map->map_priv_1 + adr);
154 +static void sdram_write32(struct map_info *map, __u32 d, unsigned long adr)
156 + writel(d, map->map_priv_1 + adr);
159 +static void sdram_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
161 + memcpy((void *)(map->map_priv_1 + to), from, len);
164 +static struct mtd_partition hcwmvp_sdram_partitions[] = {
166 + name: "HCW MediaMVP ROOT",
167 + offset: 0x00000000 ,
170 + name: "HCW MediaMVP OSD",
175 +// sdram mtd map structure.
177 +struct map_info hcwmvp_sdram_map = {
178 + name:"SDRAM MTD Device",
180 + read8: sdram_read8,
181 + read16: sdram_read16,
182 + read32: sdram_read32,
183 + copy_from: sdram_copy_from,
184 + write8: sdram_write8,
185 + write16: sdram_write16,
186 + write32: sdram_write32,
187 + copy_to: sdram_copy_to
189 +static struct mtd_info *hcwmvp_sdram_mtd=NULL;
191 +static unsigned long
197 + hcwmvp_sdram_map.map_priv_1 =
198 + (unsigned long)ioremap(__PHYSICAL_ROOTFS_BASE, __PHYSICAL_TOTAL_SIZE);
199 + if (!hcwmvp_sdram_map.map_priv_1) {
200 + KDBG("sdram-1 MTD device map failed\n");
203 + hcwmvp_sdram_map.map_priv_2 = (unsigned long)ioremap(__PHYSICAL_ROOTFS_SIZE_BASE, 4);
204 + if (!hcwmvp_sdram_map.map_priv_2) {
205 + KDBG("sdram-2 MTD device map failed\n");
209 + KDBG("SDRAM MTD(%8.8X) mapped to %08x\n", (int)__PHYSICAL_ROOTFS_BASE, (int)hcwmvp_sdram_map.map_priv_1);
218 +sdram_init_module(void)
220 + unsigned int root_size=0;
222 + * Probe & reset Device
224 + if(!sdram_init()) {
225 + KDBG("sdram Module Init Failed: Wrong Dev\n");
230 + * register mtd device
232 + hcwmvp_sdram_map.size = __PHYSICAL_TOTAL_SIZE;
233 + hcwmvp_sdram_mtd = do_map_probe("map_ram",&hcwmvp_sdram_map);
234 + if (hcwmvp_sdram_mtd) {
235 + hcwmvp_sdram_mtd->module = THIS_MODULE;
236 + //hcwmvp_sdram_mtd->erasesize = 0xF0000;
237 + //add_mtd_device(hcwmvp_sdram_mtd);
238 + root_size = in_be32((u32*)hcwmvp_sdram_map.map_priv_2);
239 + //root_size |= in_be16((u16*)(hcwmvp_sdram_map.map_priv_2+2));
240 + //KDBG("root_size =%x \n", root_size);
241 + hcwmvp_sdram_partitions[0].size = root_size;
242 + hcwmvp_sdram_partitions[1].offset = root_size;
243 + hcwmvp_sdram_partitions[1].size = __PHYSICAL_TOTAL_SIZE - root_size;
244 + add_mtd_partitions(hcwmvp_sdram_mtd, hcwmvp_sdram_partitions, 2);
247 + iounmap((void*)(hcwmvp_sdram_map.map_priv_1));
254 +sdram_cleanup_module(void)
256 + /* unregister mtd device. */
257 + //if (hcwmvp_sdram_mtd) del_mtd_device(hcwmvp_sdram_mtd);
258 + if (hcwmvp_sdram_mtd){
259 + del_mtd_partitions(hcwmvp_sdram_mtd);
260 + map_destroy(hcwmvp_sdram_mtd);
262 + if (hcwmvp_sdram_map.map_priv_1 != -1) iounmap((void *)hcwmvp_sdram_map.map_priv_1);
264 +module_init(sdram_init_module);
265 +module_exit(sdram_cleanup_module);
266 +MODULE_LICENSE("GPL");