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

Subversion Repositories or1k

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

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

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Flash device on lasat 100 and 200 boards
3
 *
4
 * Presumably (C) 2002 Brian Murphy <brian@murphy.dk> or whoever he
5
 * works for.
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License version
9
 * 2 as published by the Free Software Foundation.
10
 *
11
 * $Id: lasat.c,v 1.1.1.1 2004-04-15 01:51:46 phoenix Exp $
12
 *
13
 */
14
 
15
#include <linux/module.h>
16
#include <linux/types.h>
17
#include <linux/kernel.h>
18
#include <asm/io.h>
19
#include <linux/mtd/mtd.h>
20
#include <linux/mtd/map.h>
21
#include <linux/mtd/partitions.h>
22
#include <linux/config.h>
23
#include <asm/lasat/lasat.h>
24
#include <asm/lasat/lasat_mtd.h>
25
 
26
static struct mtd_info *mymtd;
27
 
28
static __u8 sp_read8(struct map_info *map, unsigned long ofs)
29
{
30
        return __raw_readb(map->map_priv_1 + ofs);
31
}
32
 
33
static __u16 sp_read16(struct map_info *map, unsigned long ofs)
34
{
35
        return __raw_readw(map->map_priv_1 + ofs);
36
}
37
 
38
static __u32 sp_read32(struct map_info *map, unsigned long ofs)
39
{
40
        return __raw_readl(map->map_priv_1 + ofs);
41
}
42
 
43
static void sp_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
44
{
45
        memcpy_fromio(to, map->map_priv_1 + from, len);
46
}
47
 
48
static void sp_write8(struct map_info *map, __u8 d, unsigned long adr)
49
{
50
        __raw_writeb(d, map->map_priv_1 + adr);
51
        mb();
52
}
53
 
54
static void sp_write16(struct map_info *map, __u16 d, unsigned long adr)
55
{
56
        __raw_writew(d, map->map_priv_1 + adr);
57
        mb();
58
}
59
 
60
static void sp_write32(struct map_info *map, __u32 d, unsigned long adr)
61
{
62
        __raw_writel(d, map->map_priv_1 + adr);
63
        mb();
64
}
65
 
66
static void sp_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
67
{
68
        memcpy_toio(map->map_priv_1 + to, from, len);
69
}
70
 
71
static struct map_info sp_map = {
72
        .name = "SP flash",
73
        .buswidth = 4,
74
        .read8 = sp_read8,
75
        .read16 = sp_read16,
76
        .read32 = sp_read32,
77
        .copy_from = sp_copy_from,
78
        .write8 = sp_write8,
79
        .write16 = sp_write16,
80
        .write32 = sp_write32,
81
        .copy_to = sp_copy_to
82
};
83
 
84
static struct mtd_partition partition_info[LASAT_MTD_LAST];
85
static char *lasat_mtd_partnames[] = {"Bootloader", "Service", "Normal", "Filesystem", "Config"};
86
 
87
static int __init init_sp(void)
88
{
89
        int i;
90
        /* this does not play well with the old flash code which
91
         * protects and uprotects the flash when necessary */
92
        printk(KERN_NOTICE "Unprotecting flash\n");
93
        *lasat_misc->flash_wp_reg |= 1 << lasat_misc->flash_wp_bit;
94
 
95
        sp_map.map_priv_1 = lasat_flash_partition_start(LASAT_MTD_BOOTLOADER);
96
        sp_map.size = lasat_board_info.li_flash_size;
97
 
98
        printk(KERN_NOTICE "sp flash device: %lx at %lx\n",
99
                        sp_map.size, sp_map.map_priv_1);
100
 
101
        for (i=0; i < LASAT_MTD_LAST; i++)
102
                partition_info[i].name = lasat_mtd_partnames[i];
103
 
104
        mymtd = do_map_probe("cfi_probe", &sp_map);
105
        if (mymtd) {
106
                u32 size, offset = 0;
107
 
108
                mymtd->module = THIS_MODULE;
109
 
110
                for (i=0; i < LASAT_MTD_LAST; i++) {
111
                        size = lasat_flash_partition_size(i);
112
                        partition_info[i].size = size;
113
                        partition_info[i].offset = offset;
114
                        offset += size;
115
                }
116
 
117
                add_mtd_partitions( mymtd, partition_info, LASAT_MTD_LAST );
118
                return 0;
119
        }
120
 
121
        return -ENXIO;
122
}
123
 
124
static void __exit cleanup_sp(void)
125
{
126
        if (mymtd) {
127
                del_mtd_partitions(mymtd);
128
                map_destroy(mymtd);
129
        }
130
        if (sp_map.map_priv_1) {
131
                sp_map.map_priv_1 = 0;
132
        }
133
}
134
 
135
module_init(init_sp);
136
module_exit(cleanup_sp);
137
 
138
MODULE_LICENSE("GPL");
139
MODULE_AUTHOR("Brian Murphy <brian@murphy.dk>");
140
MODULE_DESCRIPTION("Lasat Safepipe/Masquerade MTD map driver");

powered by: WebSVN 2.1.0

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