File: s3c2410_memco.c

package info (click to toggle)
softgun 0.16-2.1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 3,964 kB
  • ctags: 15,365
  • sloc: ansic: 89,221; makefile: 173
file content (250 lines) | stat: -rw-r--r-- 5,723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
 * ----------------------------------------------------------------------
 * Emulation of S3C2410 Memory Controller
 * (C) 2007 Jochen Karrer
 *   Author: Jochen Karrer
 *
 * state: Not implemented
 *
 *  This program is free software; you can distribute it and/or modify it
 *  under the terms of the GNU General Public License (Version 2) as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope it will be useful, but WITHOUT
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
 *
 * ----------------------------------------------------
 */

#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <bus.h>
#include <signode.h>
#include <configfile.h>
#include <s3c2410_memco.h>
#include <sgstring.h>

/* Base is 0x48000000 */
#define MC_BWSCON	((base)+0x00)
#define MC_BANKON0	((base)+0x04)
#define MC_BANKON1	((base)+0x08)
#define MC_BANKON2	((base)+0x0c)
#define MC_BANKON3	((base)+0x10)
#define MC_BANKON4	((base)+0x14)
#define MC_BANKON5	((base)+0x18)
#define MC_BANKON6	((base)+0x1C)
#define MC_BANKON7	((base)+0x20)
#define MC_BANKON(n)	((base)+0x04+(n<<2))
#define MC_REFRESH	((base)+0x24) 
#define MC_BANKSIZE	((base)+0x28)
#define MC_MRSRB6	((base)+0x2c)
#define MC_MRSRB7	((base)+0x30)

typedef struct Memco {
	BusDevice bdev;
	uint32_t bwscon;
} Memco;

static uint32_t
bwscon_read(void *clientData,uint32_t address,int rqlen)
{
        Memco *mc = (Memco *) clientData;
        return mc->bwscon;
}

static void
bwscon_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static uint32_t
bankon0_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon0_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static uint32_t
bankon1_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon1_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}


static uint32_t
bankon2_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon2_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static uint32_t
bankon3_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon3_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static uint32_t
bankon4_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon4_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}


static uint32_t
bankon5_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon5_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}


static uint32_t
bankon6_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon6_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}


static uint32_t
bankon7_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
bankon7_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}


static uint32_t
refresh_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
refresh_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static uint32_t
banksize_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
banksize_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static uint32_t
mrsrb6_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
mrsrb6_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static uint32_t
mrsrb7_read(void *clientData,uint32_t address,int rqlen)
{
        return 0;
}

static void
mrsrb7_write(void *clientData,uint32_t value,uint32_t address,int rqlen)
{
}

static void
S3C2410Memco_Map(void *owner,uint32_t base,uint32_t mask,uint32_t flags)
{
        Memco *mc = (Memco*) owner;
	IOH_New32(MC_BWSCON,bwscon_read,bwscon_write,mc);
	IOH_New32(MC_BANKON0,bankon0_read,bankon0_write,mc);
	IOH_New32(MC_BANKON1,bankon1_read,bankon1_write,mc);
	IOH_New32(MC_BANKON2,bankon2_read,bankon2_write,mc);
	IOH_New32(MC_BANKON3,bankon3_read,bankon3_write,mc);
	IOH_New32(MC_BANKON4,bankon4_read,bankon4_write,mc);
	IOH_New32(MC_BANKON5,bankon5_read,bankon5_write,mc);
	IOH_New32(MC_BANKON6,bankon6_read,bankon6_write,mc);
	IOH_New32(MC_BANKON7,bankon7_read,bankon7_write,mc);
	IOH_New32(MC_REFRESH,refresh_read,refresh_write,mc);
	IOH_New32(MC_BANKSIZE,banksize_read,banksize_write,mc);
	IOH_New32(MC_MRSRB6,mrsrb6_read,mrsrb6_write,mc);
	IOH_New32(MC_MRSRB7,mrsrb7_read,mrsrb7_write,mc);
}
static void
S3C2410Memco_UnMap(void *owner,uint32_t base,uint32_t mask)
{
	IOH_Delete32(MC_BWSCON);
	IOH_Delete32(MC_BANKON0);
	IOH_Delete32(MC_BANKON1);
	IOH_Delete32(MC_BANKON2);
	IOH_Delete32(MC_BANKON3);
	IOH_Delete32(MC_BANKON4);
	IOH_Delete32(MC_BANKON5);
	IOH_Delete32(MC_BANKON6);
	IOH_Delete32(MC_BANKON7);
	IOH_Delete32(MC_REFRESH);
	IOH_Delete32(MC_BANKSIZE);
	IOH_Delete32(MC_MRSRB6);
	IOH_Delete32(MC_MRSRB7);
}
BusDevice * 
S3C2410_MemcoNew(const char *name) 
{
	Memco *mc = sg_calloc(Memco);
	mc->bdev.first_mapping=NULL;
        mc->bdev.Map=S3C2410Memco_Map;
        mc->bdev.UnMap=S3C2410Memco_UnMap;
        mc->bdev.owner=mc;
        mc->bdev.hw_flags=MEM_FLAG_WRITABLE|MEM_FLAG_READABLE;
	return &mc->bdev;
}