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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * $Id: iq80310.c,v 1.1.1.1 2004-04-15 01:51:48 phoenix Exp $
3
 *
4
 * Mapping for the Intel XScale IQ80310 evaluation board
5
 *
6
 * Author:      Nicolas Pitre
7
 * Copyright:   (C) 2001 MontaVista Software Inc.
8
 *
9
 * This program is free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License version 2 as
11
 * published by the Free Software Foundation.
12
 */
13
 
14
#include <linux/module.h>
15
#include <linux/types.h>
16
#include <linux/kernel.h>
17
#include <asm/io.h>
18
#include <linux/mtd/mtd.h>
19
#include <linux/mtd/map.h>
20
#include <linux/mtd/partitions.h>
21
 
22
 
23
#define WINDOW_ADDR     0
24
#define WINDOW_SIZE     8*1024*1024
25
#define BUSWIDTH        1
26
 
27
static struct mtd_info *mymtd;
28
 
29
static __u8 iq80310_read8(struct map_info *map, unsigned long ofs)
30
{
31
        return *(__u8 *)(map->map_priv_1 + ofs);
32
}
33
 
34
static __u16 iq80310_read16(struct map_info *map, unsigned long ofs)
35
{
36
        return *(__u16 *)(map->map_priv_1 + ofs);
37
}
38
 
39
static __u32 iq80310_read32(struct map_info *map, unsigned long ofs)
40
{
41
        return *(__u32 *)(map->map_priv_1 + ofs);
42
}
43
 
44
static void iq80310_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
45
{
46
        memcpy(to, (void *)(map->map_priv_1 + from), len);
47
}
48
 
49
static void iq80310_write8(struct map_info *map, __u8 d, unsigned long adr)
50
{
51
        *(__u8 *)(map->map_priv_1 + adr) = d;
52
}
53
 
54
static void iq80310_write16(struct map_info *map, __u16 d, unsigned long adr)
55
{
56
        *(__u16 *)(map->map_priv_1 + adr) = d;
57
}
58
 
59
static void iq80310_write32(struct map_info *map, __u32 d, unsigned long adr)
60
{
61
        *(__u32 *)(map->map_priv_1 + adr) = d;
62
}
63
 
64
static void iq80310_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
65
{
66
        memcpy((void *)(map->map_priv_1 + to), from, len);
67
}
68
 
69
static struct map_info iq80310_map = {
70
        name: "IQ80310 flash",
71
        size: WINDOW_SIZE,
72
        buswidth: BUSWIDTH,
73
        read8:          iq80310_read8,
74
        read16:         iq80310_read16,
75
        read32:         iq80310_read32,
76
        copy_from:      iq80310_copy_from,
77
        write8:         iq80310_write8,
78
        write16:        iq80310_write16,
79
        write32:        iq80310_write32,
80
        copy_to:        iq80310_copy_to
81
};
82
 
83
static struct mtd_partition iq80310_partitions[4] = {
84
        {
85
                name:           "Firmware",
86
                size:           0x00080000,
87
                offset:         0,
88
                mask_flags:     MTD_WRITEABLE  /* force read-only */
89
        },{
90
                name:           "Kernel",
91
                size:           0x000a0000,
92
                offset:         0x00080000,
93
        },{
94
                name:           "Filesystem",
95
                size:           0x00600000,
96
                offset:         0x00120000
97
        },{
98
                name:           "RedBoot",
99
                size:           0x000e0000,
100
                offset:         0x00720000,
101
                mask_flags:     MTD_WRITEABLE
102
        }
103
};
104
 
105
#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
106
 
107
static struct mtd_info *mymtd;
108
static struct mtd_partition *parsed_parts;
109
 
110
extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
111
 
112
static int __init init_iq80310(void)
113
{
114
        struct mtd_partition *parts;
115
        int nb_parts = 0;
116
        int parsed_nr_parts = 0;
117
        char *part_type = "static";
118
 
119
        iq80310_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
120
        if (!iq80310_map.map_priv_1) {
121
                printk("Failed to ioremap\n");
122
                return -EIO;
123
        }
124
        mymtd = do_map_probe("cfi_probe", &iq80310_map);
125
        if (!mymtd) {
126
                iounmap((void *)iq80310_map.map_priv_1);
127
                return -ENXIO;
128
        }
129
        mymtd->module = THIS_MODULE;
130
 
131
#ifdef CONFIG_MTD_REDBOOT_PARTS
132
        if (parsed_nr_parts == 0) {
133
                int ret = parse_redboot_partitions(mymtd, &parsed_parts);
134
 
135
                if (ret > 0) {
136
                        part_type = "RedBoot";
137
                        parsed_nr_parts = ret;
138
                }
139
        }
140
#endif
141
 
142
        if (parsed_nr_parts > 0) {
143
                parts = parsed_parts;
144
                nb_parts = parsed_nr_parts;
145
        } else {
146
                parts = iq80310_partitions;
147
                nb_parts = NB_OF(iq80310_partitions);
148
        }
149
        printk(KERN_NOTICE "Using %s partition definition\n", part_type);
150
        add_mtd_partitions(mymtd, parts, nb_parts);
151
        return 0;
152
}
153
 
154
static void __exit cleanup_iq80310(void)
155
{
156
        if (mymtd) {
157
                del_mtd_partitions(mymtd);
158
                map_destroy(mymtd);
159
                if (parsed_parts)
160
                        kfree(parsed_parts);
161
        }
162
        if (iq80310_map.map_priv_1)
163
                iounmap((void *)iq80310_map.map_priv_1);
164
}
165
 
166
module_init(init_iq80310);
167
module_exit(cleanup_iq80310);
168
 
169
 
170
MODULE_LICENSE("GPL");
171
MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
172
MODULE_DESCRIPTION("MTD map driver for Intel XScale IQ80310 evaluation board");

powered by: WebSVN 2.1.0

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