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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *      pnc2000.c - mapper for Photron PNC-2000 board.
3
 *
4
 * Copyright (C) 2000 Crossnet Co. <info@crossnet.co.jp>
5
 *
6
 * This code is GPL
7
 *
8
 * $Id: pnc2000.c,v 1.1.1.1 2004-04-15 01:51:54 phoenix Exp $
9
 */
10
 
11
#include <linux/module.h>
12
#include <linux/types.h>
13
#include <linux/kernel.h>
14
 
15
#include <linux/mtd/mtd.h>
16
#include <linux/mtd/map.h>
17
#include <linux/mtd/partitions.h>
18
 
19
 
20
#define WINDOW_ADDR 0xbf000000
21
#define WINDOW_SIZE 0x00400000
22
 
23
/*
24
 * MAP DRIVER STUFF
25
 */
26
 
27
__u8 pnc_read8(struct map_info *map, unsigned long ofs)
28
{
29
  return *(__u8 *)(WINDOW_ADDR + ofs);
30
}
31
 
32
__u16 pnc_read16(struct map_info *map, unsigned long ofs)
33
{
34
  return *(__u16 *)(WINDOW_ADDR + ofs);
35
}
36
 
37
__u32 pnc_read32(struct map_info *map, unsigned long ofs)
38
{
39
  return *(volatile unsigned int *)(WINDOW_ADDR + ofs);
40
}
41
 
42
void pnc_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
43
{
44
  memcpy(to, (void *)(WINDOW_ADDR + from), len);
45
}
46
 
47
void pnc_write8(struct map_info *map, __u8 d, unsigned long adr)
48
{
49
  *(__u8 *)(WINDOW_ADDR + adr) = d;
50
}
51
 
52
void pnc_write16(struct map_info *map, __u16 d, unsigned long adr)
53
{
54
  *(__u16 *)(WINDOW_ADDR + adr) = d;
55
}
56
 
57
void pnc_write32(struct map_info *map, __u32 d, unsigned long adr)
58
{
59
  *(__u32 *)(WINDOW_ADDR + adr) = d;
60
}
61
 
62
void pnc_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
63
{
64
  memcpy((void *)(WINDOW_ADDR + to), from, len);
65
}
66
 
67
struct map_info pnc_map = {
68
        name: "PNC-2000",
69
        size: WINDOW_SIZE,
70
        buswidth: 4,
71
        read8: pnc_read8,
72
        read16: pnc_read16,
73
        read32: pnc_read32,
74
        copy_from: pnc_copy_from,
75
        write8: pnc_write8,
76
        write16: pnc_write16,
77
        write32: pnc_write32,
78
        copy_to: pnc_copy_to
79
};
80
 
81
 
82
/*
83
 * MTD 'PARTITIONING' STUFF
84
 */
85
static struct mtd_partition pnc_partitions[3] = {
86
        {
87
                name: "PNC-2000 boot firmware",
88
                size: 0x20000,
89
                offset: 0
90
        },
91
        {
92
                name: "PNC-2000 kernel",
93
                size: 0x1a0000,
94
                offset: 0x20000
95
        },
96
        {
97
                name: "PNC-2000 filesystem",
98
                size: 0x240000,
99
                offset: 0x1c0000
100
        }
101
};
102
 
103
/*
104
 * This is the master MTD device for which all the others are just
105
 * auto-relocating aliases.
106
 */
107
static struct mtd_info *mymtd;
108
 
109
int __init init_pnc2000(void)
110
{
111
        printk(KERN_NOTICE "Photron PNC-2000 flash mapping: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
112
 
113
        mymtd = do_map_probe("cfi_probe", &pnc_map);
114
        if (mymtd) {
115
                mymtd->module = THIS_MODULE;
116
                return add_mtd_partitions(mymtd, pnc_partitions, 3);
117
        }
118
 
119
        return -ENXIO;
120
}
121
 
122
static void __exit cleanup_pnc2000(void)
123
{
124
        if (mymtd) {
125
                del_mtd_partitions(mymtd);
126
                map_destroy(mymtd);
127
        }
128
}
129
 
130
module_init(init_pnc2000);
131
module_exit(cleanup_pnc2000);
132
 
133
MODULE_LICENSE("GPL");
134
MODULE_AUTHOR("Crossnet Co. <info@crossnet.co.jp>");
135
MODULE_DESCRIPTION("MTD map driver for Photron PNC-2000 board");

powered by: WebSVN 2.1.0

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