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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * $Id: mbx860.c,v 1.1.1.1 2004-04-15 01:51:52 phoenix Exp $
3
 *
4
 * Handle mapping of the flash on MBX860 boards
5
 *
6
 * Author:      Anton Todorov
7
 * Copyright:   (C) 2001 Emness Technology
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
 
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
 
23
 
24
#define WINDOW_ADDR 0xfe000000
25
#define WINDOW_SIZE 0x00200000
26
 
27
/* Flash / Partition sizing */
28
#define MAX_SIZE_KiB              8192
29
#define BOOT_PARTITION_SIZE_KiB    512
30
#define KERNEL_PARTITION_SIZE_KiB 5632
31
#define APP_PARTITION_SIZE_KiB    2048
32
 
33
#define NUM_PARTITIONS 3
34
 
35
/* partition_info gives details on the logical partitions that the split the
36
 * single flash device into. If the size if zero we use up to the end of the
37
 * device. */
38
static struct mtd_partition partition_info[]={
39
        { name: "MBX flash BOOT partition",
40
        offset: 0,
41
        size:   BOOT_PARTITION_SIZE_KiB*1024 },
42
        { name: "MBX flash DATA partition",
43
        offset: BOOT_PARTITION_SIZE_KiB*1024,
44
        size: (KERNEL_PARTITION_SIZE_KiB)*1024 },
45
        { name: "MBX flash APPLICATION partition",
46
        offset: (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 }
47
};
48
 
49
 
50
static struct mtd_info *mymtd;
51
 
52
__u8 mbx_read8(struct map_info *map, unsigned long ofs)
53
{
54
        return readb(map->map_priv_1 + ofs);
55
}
56
 
57
__u16 mbx_read16(struct map_info *map, unsigned long ofs)
58
{
59
        return readw(map->map_priv_1 + ofs);
60
}
61
 
62
__u32 mbx_read32(struct map_info *map, unsigned long ofs)
63
{
64
        return readl(map->map_priv_1 + ofs);
65
}
66
 
67
void mbx_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
68
{
69
        memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
70
}
71
 
72
void mbx_write8(struct map_info *map, __u8 d, unsigned long adr)
73
{
74
        writeb(d, map->map_priv_1 + adr);
75
}
76
 
77
void mbx_write16(struct map_info *map, __u16 d, unsigned long adr)
78
{
79
        writew(d, map->map_priv_1 + adr);
80
}
81
 
82
void mbx_write32(struct map_info *map, __u32 d, unsigned long adr)
83
{
84
        writel(d, map->map_priv_1 + adr);
85
}
86
 
87
void mbx_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
88
{
89
        memcpy_toio((void *)(map->map_priv_1 + to), from, len);
90
}
91
 
92
struct map_info mbx_map = {
93
        name: "MBX flash",
94
        size: WINDOW_SIZE,
95
        buswidth: 4,
96
        read8: mbx_read8,
97
        read16: mbx_read16,
98
        read32: mbx_read32,
99
        copy_from: mbx_copy_from,
100
        write8: mbx_write8,
101
        write16: mbx_write16,
102
        write32: mbx_write32,
103
        copy_to: mbx_copy_to
104
};
105
 
106
int __init init_mbx(void)
107
{
108
        printk(KERN_NOTICE "Motorola MBX flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
109
        mbx_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
110
 
111
        if (!mbx_map.map_priv_1) {
112
                printk("Failed to ioremap\n");
113
                return -EIO;
114
        }
115
        mymtd = do_map_probe("jedec_probe", &mbx_map);
116
        if (mymtd) {
117
                mymtd->module = THIS_MODULE;
118
                add_mtd_device(mymtd);
119
                add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
120
                return 0;
121
        }
122
 
123
        iounmap((void *)mbx_map.map_priv_1);
124
        return -ENXIO;
125
}
126
 
127
static void __exit cleanup_mbx(void)
128
{
129
        if (mymtd) {
130
                del_mtd_device(mymtd);
131
                map_destroy(mymtd);
132
        }
133
        if (mbx_map.map_priv_1) {
134
                iounmap((void *)mbx_map.map_priv_1);
135
                mbx_map.map_priv_1 = 0;
136
        }
137
}
138
 
139
module_init(init_mbx);
140
module_exit(cleanup_mbx);
141
 
142
MODULE_AUTHOR("Anton Todorov <a.todorov@emness.com>");
143
MODULE_DESCRIPTION("MTD map driver for Motorola MBX860 board");
144
MODULE_LICENSE("GPL");

powered by: WebSVN 2.1.0

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