]> git.vomp.tv Git - makedevenv.git/blob - kernel/patches-2.4.31/sdram-bank1.patch
Initial import
[makedevenv.git] / kernel / patches-2.4.31 / sdram-bank1.patch
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)
5         rm -f zvmlinux
6  zImage.initrd: $(ZIMAGEINITRD)
7         rm -f zvmlinux.initrd
8 +       cp -f ../images/zImage.initrd.$(END) $(INSTALL_PATH)/dongle.bin
9  
10  znetboot: zImage
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();
18         puts("done.\n");
19 +#ifdef CONFIG_BLK_DEV_INITRD
20         {
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);
26         }
27 +#else
28 +       {
29 +               /* Moving Squash Rootfs to sdram bank1 */
30 +               if(initrd_size){
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;
36 +                       
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);       
44 +                       }
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);
49 +               }
50 +       }
51 +#endif
52         puts("Now booting the kernel\n");
53         serial_close(com_port);
54  
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
63  fi
64  
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
74  
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
79 @@ -0,0 +1,187 @@
80 +/*
81 + * HCW sdram mtd Driver
82 + */
83 +#include <linux/config.h>
84 +#include <linux/version.h>
85 +
86 +#include <linux/kernel.h>
87 +#include <linux/module.h>
88 +
89 +#if CONFIG_MODVERSIONS == 1
90 +#define MODVERSIONS
91 +#include <linux/modversions.h>
92 +#endif
93 +
94 +#include <linux/fs.h>
95 +#include <asm/io.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>
103 +
104 +#include <linux/mtd/mtd.h>
105 +#include <linux/mtd/map.h>
106 +#include <linux/mtd/partitions.h>
107 +
108 +#include <asm/io.h>
109 +
110 +#define KDBG(fmt, args...) if(1) printk("<sdram-mtd>: " fmt, ## args)
111 +
112 +
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
117 +
118 +#define GetRootSize()  {return (*rootfs_size)}
119 +
120 +
121 +//
122 +// read/write function.
123 +//
124 +static __u8 sdram_read8(struct map_info *map, unsigned long ofs)
125 +{
126 +       return readb(map->map_priv_1 + ofs);
127 +}
128 +
129 +static __u16 sdram_read16(struct map_info *map, unsigned long ofs)
130 +{
131 +       return readw(map->map_priv_1 + ofs);
132 +}
133 +
134 +static __u32 sdram_read32(struct map_info *map, unsigned long ofs)
135 +{
136 +       return readl(map->map_priv_1 + ofs);
137 +}
138 +
139 +static void sdram_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
140 +{
141 +       memcpy(to, (void *)(map->map_priv_1 + from), len);
142 +}      
143 +
144 +static void sdram_write8(struct map_info *map, __u8 d, unsigned long adr)
145 +{
146 +       writeb(d, map->map_priv_1 + adr);
147 +}
148 +
149 +static void sdram_write16(struct map_info *map, __u16 d, unsigned long adr)
150 +{
151 +       writew(d, map->map_priv_1 + adr);
152 +}
153 +
154 +static void sdram_write32(struct map_info *map, __u32 d, unsigned long adr)
155 +{
156 +       writel(d, map->map_priv_1 + adr);
157 +}
158 +
159 +static void sdram_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
160 +{
161 +       memcpy((void *)(map->map_priv_1 + to), from, len);
162 +}
163 +
164 +static struct mtd_partition hcwmvp_sdram_partitions[] = {
165 +       {
166 +               name: "HCW MediaMVP ROOT",      
167 +               offset: 0x00000000      ,
168 +       },
169 +       {
170 +               name: "HCW MediaMVP OSD",
171 +       },
172 +};
173 +
174 +//
175 +// sdram mtd map structure.
176 +//
177 +struct map_info hcwmvp_sdram_map = {
178 +       name:"SDRAM MTD Device",
179 +       buswidth: 2,
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
188 +};
189 +static struct mtd_info *hcwmvp_sdram_mtd=NULL;
190 +
191 +static unsigned long 
192 +sdram_init(void)
193 +{
194 +       /*
195 +        * I/O Remap
196 +        */
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");
201 +               return 0;
202 +       }
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");
206 +               return 0;
207 +       }
208 +       
209 +       KDBG("SDRAM MTD(%8.8X) mapped to %08x\n", (int)__PHYSICAL_ROOTFS_BASE, (int)hcwmvp_sdram_map.map_priv_1);
210 +
211 +       return 1;
212 +}
213 +
214 +/*
215 + * module interface
216 + */
217 +static int __init
218 +sdram_init_module(void)
219 +{
220 +       unsigned int root_size=0;
221 +       /*
222 +        * Probe & reset Device
223 +        */
224 +       if(!sdram_init()) {
225 +               KDBG("sdram Module Init Failed: Wrong Dev\n");
226 +               return -1;
227 +       }
228 +       
229 +       /*
230 +        * register mtd device 
231 +        */
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);
245 +       }
246 +       else{
247 +               iounmap((void*)(hcwmvp_sdram_map.map_priv_1));
248 +       }
249 +
250 +       return 0;
251 +}
252 +
253 +static void __exit
254 +sdram_cleanup_module(void)
255 +{
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);
261 +       }
262 +       if (hcwmvp_sdram_map.map_priv_1 != -1) iounmap((void *)hcwmvp_sdram_map.map_priv_1);
263 +}
264 +module_init(sdram_init_module);
265 +module_exit(sdram_cleanup_module);
266 +MODULE_LICENSE("GPL");