Fix brcm63xx support. Now a kernel is booting, detecting the flash, and can probably...
[openwrt.git] / target / linux / brcm63xx-2.6 / patches / 040-bcm963xx_flashmap.patch
1 diff -urN linux-2.6.16.7/drivers/mtd/maps/bcm963xx.c linux-2.6.16.7-brcm63xx/drivers/mtd/maps/bcm963xx.c
2 --- linux-2.6.16.7/drivers/mtd/maps/bcm963xx.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.16.7-brcm63xx/drivers/mtd/maps/bcm963xx.c 2006-07-07 22:00:36.000000000 +0200
4 @@ -0,0 +1,106 @@
5 +/*
6 + * A simple flash mapping code for BCM963xx board flash memory
7 + * It is simple because it only treats all the flash memory as ROM
8 + * It is used with chips/map_rom.c
9 + *
10 + * Song Wang (songw@broadcom.com)
11 + */
12 +
13 +#include <linux/module.h>
14 +#include <linux/types.h>
15 +#include <linux/kernel.h>
16 +#include <linux/init.h>
17 +#include <asm/io.h>
18 +#include <linux/mtd/mtd.h>
19 +#include <linux/mtd/map.h>
20 +#include <linux/config.h>
21 +
22 +#include <board.h>
23 +#include <bcmTag.h>
24 +#define VERSION "1.0"
25 +
26 +extern PFILE_TAG kerSysImageTagGet(void);
27 +
28 +static struct mtd_info *mymtd;
29 +
30 +static map_word brcm_physmap_read16(struct map_info *map, unsigned long ofs)
31 +{
32 + map_word val;
33 +
34 + val.x[0] = __raw_readw(map->map_priv_1 + ofs);
35 +
36 + return val;
37 +}
38 +
39 +static void brcm_physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
40 +{
41 + memcpy_fromio(to, map->map_priv_1 + from, len);
42 +}
43 +
44 +static struct map_info brcm_physmap_map = {
45 + .name = "Physically mapped flash",
46 + .bankwidth = 2,
47 + .read = brcm_physmap_read16,
48 + .copy_from = brcm_physmap_copy_from
49 +};
50 +
51 +static int __init init_brcm_physmap(void)
52 +{
53 + PFILE_TAG pTag = NULL;
54 + u_int32_t rootfs_addr, kernel_addr;
55 + FLASH_ADDR_INFO info;
56 +
57 + printk("bcm963xx_mtd driver v%s\n", VERSION);
58 + kerSysFlashAddrInfoGet( &info );
59 +
60 + /* Read the flash memory map from flash memory. */
61 + if (!(pTag = kerSysImageTagGet())) {
62 + printk("Failed to read image tag from flash\n");
63 + return -EIO;
64 + }
65 +
66 + rootfs_addr = (u_int32_t) simple_strtoul(pTag->rootfsAddress, NULL, 10);
67 + kernel_addr = (u_int32_t) simple_strtoul(pTag->kernelAddress, NULL, 10);
68 +
69 + brcm_physmap_map.size = kernel_addr - rootfs_addr;
70 + brcm_physmap_map.map_priv_1 = (unsigned long)rootfs_addr;
71 +
72 + if (!brcm_physmap_map.map_priv_1) {
73 + printk("Wrong rootfs starting address\n");
74 + return -EIO;
75 + }
76 +
77 + if (brcm_physmap_map.size <= 0) {
78 + printk("Wrong rootfs size\n");
79 + return -EIO;
80 + }
81 +
82 + mymtd = do_map_probe("map_rom", &brcm_physmap_map);
83 + if (mymtd) {
84 + mymtd->owner = THIS_MODULE;
85 + add_mtd_device(mymtd);
86 +
87 + return 0;
88 + }
89 +
90 + return -ENXIO;
91 +}
92 +
93 +static void __exit cleanup_brcm_physmap(void)
94 +{
95 + if (mymtd) {
96 + del_mtd_device(mymtd);
97 + map_destroy(mymtd);
98 + }
99 + if (brcm_physmap_map.map_priv_1) {
100 + brcm_physmap_map.map_priv_1 = 0;
101 + }
102 +}
103 +
104 +module_init(init_brcm_physmap);
105 +module_exit(cleanup_brcm_physmap);
106 +
107 +
108 +MODULE_LICENSE("GPL");
109 +MODULE_AUTHOR("Song Wang songw@broadcom.com");
110 +MODULE_DESCRIPTION("Configurable MTD map driver for read-only root file system");
111 diff -urN linux-2.6.16.7/drivers/mtd/maps/Kconfig linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Kconfig
112 --- linux-2.6.16.7/drivers/mtd/maps/Kconfig 2006-04-17 23:53:25.000000000 +0200
113 +++ linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Kconfig 2006-07-07 22:02:13.000000000 +0200
114 @@ -224,6 +224,13 @@
115 Flash memory access on 4G Systems MTX-1 Board. If you have one of
116 these boards and would like to use the flash chips on it, say 'Y'.
117
118 +config MTD_BCM963XX
119 + tristate "BCM963xx Flash device"
120 + depends on MIPS && MIPS_BRCM
121 + help
122 + This driver seems to detect and provide a valid flash map to the system
123 + of course, it needs checking and testing.
124 +
125 config MTD_DILNETPC
126 tristate "CFI Flash device mapped on DIL/Net PC"
127 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
128 diff -urN linux-2.6.16.7/drivers/mtd/maps/Makefile linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Makefile
129 --- linux-2.6.16.7/drivers/mtd/maps/Makefile 2006-04-17 23:53:25.000000000 +0200
130 +++ linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Makefile 2006-07-07 22:01:29.000000000 +0200
131 @@ -71,3 +71,4 @@
132 obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
133 obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
134 obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
135 +obj-$(CONFIG_MTD_BCM963XX) += bcm963xx.o
This page took 0.056544 seconds and 5 git commands to generate.