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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [mtd/] [maps/] [solutionengine.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: solutionengine.c,v 1.1.1.1 2004-04-15 01:51:49 phoenix Exp $
3
 *
4
 * Flash and EPROM on Hitachi Solution Engine and similar boards.
5
 *
6
 * (C) 2001 Red Hat, Inc.
7
 *
8
 * GPL'd
9
 */
10
 
11
#include <linux/module.h>
12
#include <linux/types.h>
13
#include <linux/kernel.h>
14
#include <asm/io.h>
15
#include <linux/mtd/mtd.h>
16
#include <linux/mtd/map.h>
17
#include <linux/mtd/partitions.h>
18
#include <linux/config.h>
19
 
20
 
21
extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
22
 
23
__u32 soleng_read32(struct map_info *map, unsigned long ofs)
24
{
25
        return __raw_readl(map->map_priv_1 + ofs);
26
}
27
 
28
void soleng_write32(struct map_info *map, __u32 d, unsigned long adr)
29
{
30
        __raw_writel(d, map->map_priv_1 + adr);
31
        mb();
32
}
33
 
34
void soleng_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
35
{
36
        memcpy_fromio(to, map->map_priv_1 + from, len);
37
}
38
 
39
 
40
static struct mtd_info *flash_mtd;
41
static struct mtd_info *eprom_mtd;
42
 
43
static struct mtd_partition *parsed_parts;
44
 
45
struct map_info soleng_eprom_map = {
46
        name: "Solution Engine EPROM",
47
        size: 0x400000,
48
        buswidth: 4,
49
        copy_from: soleng_copy_from,
50
};
51
 
52
struct map_info soleng_flash_map = {
53
        name: "Solution Engine FLASH",
54
        size: 0x400000,
55
        buswidth: 4,
56
        read32: soleng_read32,
57
        copy_from: soleng_copy_from,
58
        write32: soleng_write32,
59
};
60
 
61
#ifdef CONFIG_MTD_SUPERH_RESERVE
62
static struct mtd_partition superh_se_partitions[] = {
63
        /* Reserved for boot code, read-only */
64
        {
65
                name: "flash_boot",
66
                offset: 0x00000000,
67
                size: CONFIG_MTD_SUPERH_RESERVE,
68
                mask_flags: MTD_WRITEABLE,
69
        },
70
        /* All else is writable (e.g. JFFS) */
71
        {
72
                name: "Flash FS",
73
                offset: MTDPART_OFS_NXTBLK,
74
                size: MTDPART_SIZ_FULL,
75
        }
76
};
77
#endif /* CONFIG_MTD_SUPERH_RESERVE */
78
 
79
static int __init init_soleng_maps(void)
80
{
81
        int nr_parts = 0;
82
 
83
        /* First probe at offset 0 */
84
        soleng_flash_map.map_priv_1 = P2SEGADDR(0);
85
        soleng_eprom_map.map_priv_1 = P1SEGADDR(0x01000000);
86
 
87
        printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
88
        flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
89
        if (!flash_mtd) {
90
                /* Not there. Try swapping */
91
                printk(KERN_NOTICE "Probing for flash chips at 0x01000000:\n");
92
                soleng_flash_map.map_priv_1 = P2SEGADDR(0x01000000);
93
                soleng_eprom_map.map_priv_1 = P1SEGADDR(0);
94
                flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
95
                if (!flash_mtd) {
96
                        /* Eep. */
97
                        printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
98
                        return -ENXIO;
99
                }
100
        }
101
        printk(KERN_NOTICE "Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n",
102
               soleng_flash_map.map_priv_1 & 0x1fffffff,
103
               soleng_eprom_map.map_priv_1 & 0x1fffffff);
104
        flash_mtd->module = THIS_MODULE;
105
 
106
        eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
107
        if (eprom_mtd) {
108
                eprom_mtd->module = THIS_MODULE;
109
                add_mtd_device(eprom_mtd);
110
        }
111
 
112
#ifdef CONFIG_MTD_REDBOOT_PARTS
113
        nr_parts = parse_redboot_partitions(flash_mtd, &parsed_parts);
114
        if (nr_parts > 0)
115
                printk(KERN_NOTICE "Found RedBoot partition table.\n");
116
        else if (nr_parts < 0)
117
                printk(KERN_NOTICE "Error looking for RedBoot partitions.\n");
118
#endif /* CONFIG_MTD_REDBOOT_PARTS */
119
#if CONFIG_MTD_SUPERH_RESERVE
120
        if (nr_parts == 0) {
121
                printk(KERN_NOTICE "Using configured partition at 0x%08x.\n",
122
                       CONFIG_MTD_SUPERH_RESERVE);
123
                parsed_parts = superh_se_partitions;
124
                nr_parts = sizeof(superh_se_partitions)/sizeof(*parsed_parts);
125
        }
126
#endif /* CONFIG_MTD_SUPERH_RESERVE */
127
 
128
        if (nr_parts > 0)
129
                add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
130
        else
131
                add_mtd_device(flash_mtd);
132
 
133
        return 0;
134
}
135
 
136
static void __exit cleanup_soleng_maps(void)
137
{
138
        if (eprom_mtd) {
139
                del_mtd_device(eprom_mtd);
140
                map_destroy(eprom_mtd);
141
        }
142
 
143
        if (parsed_parts)
144
                del_mtd_partitions(flash_mtd);
145
        else
146
                del_mtd_device(flash_mtd);
147
        map_destroy(flash_mtd);
148
}
149
 
150
module_init(init_soleng_maps);
151
module_exit(cleanup_soleng_maps);
152
 
153
MODULE_LICENSE("GPL");
154
MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
155
MODULE_DESCRIPTION("MTD map driver for Hitachi SolutionEngine (and similar) boards");
156
 

powered by: WebSVN 2.1.0

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