OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [mtd/] [maps/] [redwood.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * $Id:
3
 *
4
 * redwood.c - mapper for IBM Redwood-4/5 board.
5
 *
6
 * Copyright 2001 MontaVista Softare Inc.
7
 *
8
 * This program is free software; you can redistribute  it and/or modify it
9
 *  under  the terms of  the GNU General  Public License as published by the
10
 *  Free Software Foundation;  either version 2 of the  License, or (at your
11
 *  option) any later version.
12
 *
13
 *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
14
 *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
15
 *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
16
 *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
17
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
 *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
19
 *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
 *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
21
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
 *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
 *
24
 *  You should have received a copy of the  GNU General Public License along
25
 *  with this program; if not, write  to the Free Software Foundation, Inc.,
26
 *  675 Mass Ave, Cambridge, MA 02139, USA.
27
 *
28
 *  History: 12/17/2001 - Armin
29
 *              migrated to use do_map_probe
30
 *
31
 */
32
 
33
#include <linux/module.h>
34
#include <linux/types.h>
35
#include <linux/kernel.h>
36
 
37
#include <linux/mtd/mtd.h>
38
#include <linux/mtd/map.h>
39
#include <linux/mtd/partitions.h>
40
 
41
#include <asm/io.h>
42
 
43
#define WINDOW_ADDR 0xffc00000
44
#define WINDOW_SIZE 0x00400000
45
 
46
__u8 redwood_flash_read8(struct map_info *map, unsigned long ofs)
47
{
48
        return *(__u8 *)(map->map_priv_1 + ofs);
49
}
50
 
51
__u16 redwood_flash_read16(struct map_info *map, unsigned long ofs)
52
{
53
        return *(__u16 *)(map->map_priv_1 + ofs);
54
}
55
 
56
__u32 redwood_flash_read32(struct map_info *map, unsigned long ofs)
57
{
58
        return *(volatile unsigned int *)(map->map_priv_1 + ofs);
59
}
60
 
61
void redwood_flash_copy_from(struct map_info *map, void *to,
62
                             unsigned long from, ssize_t len)
63
{
64
        memcpy(to, (void *)(map->map_priv_1 + from), len);
65
}
66
 
67
void redwood_flash_write8(struct map_info *map, __u8 d, unsigned long adr)
68
{
69
        *(__u8 *)(map->map_priv_1 + adr) = d;
70
}
71
 
72
void redwood_flash_write16(struct map_info *map, __u16 d, unsigned long adr)
73
{
74
        *(__u16 *)(map->map_priv_1 + adr) = d;
75
}
76
 
77
void redwood_flash_write32(struct map_info *map, __u32 d, unsigned long adr)
78
{
79
        *(__u32 *)(map->map_priv_1 + adr) = d;
80
}
81
 
82
void redwood_flash_copy_to(struct map_info *map, unsigned long to,
83
                           const void *from, ssize_t len)
84
{
85
        memcpy((void *)(map->map_priv_1 + to), from, len);
86
}
87
 
88
struct map_info redwood_flash_map = {
89
        name: "IBM Redwood",
90
        size: WINDOW_SIZE,
91
        buswidth: 2,
92
        read8: redwood_flash_read8,
93
        read16: redwood_flash_read16,
94
        read32: redwood_flash_read32,
95
        copy_from: redwood_flash_copy_from,
96
        write8: redwood_flash_write8,
97
        write16: redwood_flash_write16,
98
        write32: redwood_flash_write32,
99
        copy_to: redwood_flash_copy_to
100
};
101
 
102
 
103
static struct mtd_partition redwood_flash_partitions[] = {
104
        {
105
                name: "Redwood OpenBIOS Vital Product Data",
106
                offset: 0,
107
                size:   0x10000,
108
                mask_flags: MTD_WRITEABLE       /* force read-only */
109
        },
110
        {
111
                name: "Redwood kernel",
112
                offset: 0x10000,
113
                size:   0x200000 - 0x10000
114
        },
115
        {
116
                name: "Redwood OpenBIOS non-volatile storage",
117
                offset: 0x200000,
118
                size:   0x10000,
119
                mask_flags: MTD_WRITEABLE       /* force read-only */
120
        },
121
        {
122
                name: "Redwood filesystem",
123
                offset: 0x210000,
124
                size:   0x200000 - (0x10000 + 0x20000)
125
        },
126
        {
127
                name: "Redwood OpenBIOS",
128
                offset: 0x3e0000,
129
                size:   0x20000,
130
                mask_flags: MTD_WRITEABLE       /* force read-only */
131
        }
132
};
133
#define NUM_REDWOOD_FLASH_PARTITIONS \
134
        (sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0]))
135
 
136
static struct mtd_info *redwood_mtd;
137
 
138
int __init init_redwood_flash(void)
139
{
140
        printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
141
               WINDOW_SIZE, WINDOW_ADDR);
142
 
143
        redwood_flash_map.map_priv_1 =
144
                (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
145
 
146
        if (!redwood_flash_map.map_priv_1) {
147
                printk("init_redwood_flash: failed to ioremap\n");
148
                return -EIO;
149
        }
150
 
151
        redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map);
152
 
153
        if (redwood_mtd) {
154
                redwood_mtd->module = THIS_MODULE;
155
                return add_mtd_partitions(redwood_mtd,
156
                                          redwood_flash_partitions,
157
                                          NUM_REDWOOD_FLASH_PARTITIONS);
158
        }
159
 
160
        return -ENXIO;
161
}
162
 
163
static void __exit cleanup_redwood_flash(void)
164
{
165
        if (redwood_mtd) {
166
                del_mtd_partitions(redwood_mtd);
167
                iounmap((void *)redwood_flash_map.map_priv_1);
168
                map_destroy(redwood_mtd);
169
        }
170
}
171
 
172
module_init(init_redwood_flash);
173
module_exit(cleanup_redwood_flash);

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.