-
Notifications
You must be signed in to change notification settings - Fork 8
/
deviceAceecaPDA32.c
executable file
·171 lines (133 loc) · 4.14 KB
/
deviceAceecaPDA32.c
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
//(c) uARM project https://github.com/uARM-Palm/uARM uARM@dmitry.gr
#include <stdlib.h>
#include "s3c24xx_ADC.h"
#include "SDL2/SDL.h"
#include "device.h"
#include "util.h"
#include "nand.h"
#include "RAM.h"
/*
GPIO CONFIG:
56000000 005e03ff 0041fc00
56000010 0000002a 000007fa 00000007
56000020 aaaa02a8 0000eef1 0000ff1e
56000030 00000000 0000ffff 00000000
56000040 01155400 0000ec7f 000037e6
56000050 0000aaaa 000000ff 000000ff
56000060 ff000008 0000effc 0000f007
56000070 00140aaa 000001ef 000001ff
56000080 00010333 00000000 22222222 222222f2
56000090 22222222 00000000
560000a0 00000000 00fffd00 00000000 0000000b
560000b0 32410002 00000000 300bee08
all active low, except as noted
power F0 (active high)
hard1 F1
up F2
down F3
left F6
right F7
center G0
resetBTN G1 (active high) //YES!
GPIOA 0..31
GPIOB 32..47
GPIOC 48..63
GPIOD 64..79
GPIOE 80..95
GPIOF 96..111
GPIOG 112..127
GPIOH 128..143
*/
////touch lef tot right is cb to 32d. top to bottom is 370 to 085
struct Device {
struct S3C24xxAdc *adc;
struct NAND *nand;
};
bool deviceHasGrafArea(void)
{
return false;
}
enum RomChipType deviceGetRomMemType(void)
{
return RomWriteIgnore;
}
uint32_t deviceGetRamSize(void)
{
return 64UL << 20;
}
enum RamTermination deviceGetRamTerminationStyle(void)
{
return RamTerminationMirror;
}
uint_fast8_t deviceGetSocRev(void)
{
return 1; //S3C2440
}
static void pda32nandPrvReady(void *userData, bool ready)
{
struct SocGpio *gpio = (struct SocGpio*)userData;
socGpioSetState(gpio, 161, ready);
}
struct Device* deviceSetup(struct SocPeriphs *sp, struct Keypad *kp, struct VSD *vsd, FILE* nandFile)
{
static const struct NandSpecs nandSpecs = {
.bytesPerPage = 2112,
.blocksPerDevice = 1024,
.pagesPerBlockLg2 = 6,
.flags = NAND_HAS_SECOND_READ_CMD,
.devIdLen = 5,
.devId = {0xec, 0xf1, 0x00, 0x95, 0x40},
};
struct ArmRam *weirdBusAccess;
struct Device *dev;
dev = (struct Device*)malloc(sizeof(*dev));
if (!dev)
ERR("cannot alloc device");
sp->nand = dev->nand = nandInit(nandFile, &nandSpecs, pda32nandPrvReady, sp->gpio);
weirdBusAccess = ramInit(sp->mem, 0xa0000000ul, 0x800, (uint32_t*)malloc(0x800));
if (!weirdBusAccess)
ERR("Cannot init RAM4");
//NAND config
socGpioSetState(sp->gpio, 162, true); //NCON= 1 (large page NAND)
socGpioSetState(sp->gpio, 125, true); //G13 = 1 (2Kbyte page)
socGpioSetState(sp->gpio, 126, false); //G14 = 0 (4 address bytes)
socGpioSetState(sp->gpio, 127, false); //G15 = 0 (8-bit bus)
//GPB7 is charge detect. low if charging
socGpioSetState(sp->gpio, 39, true);
//GPG8 is SD detect (active low)
socGpioSetState(sp->gpio, 120, true);
//GPJ9 is SD write protect (high if protected)
socGpioSetState(sp->gpio, 153, true);
if (!keypadAddGpioKey(kp, SDLK_ESCAPE, 96, true))
ERR("Cannot init power key\n");
if (!keypadAddGpioKey(kp, SDLK_F1, 97, false))
ERR("Cannot init hardkey1 (brightness)\n");
if (!keypadAddGpioKey(kp, SDLK_UP, 98, false))
ERR("Cannot init up key\n");
if (!keypadAddGpioKey(kp, SDLK_DOWN, 99, false))
ERR("Cannot init down key\n");
if (!keypadAddGpioKey(kp, SDLK_LEFT, 102, false))
ERR("Cannot init left key\n");
if (!keypadAddGpioKey(kp, SDLK_RIGHT, 103, false))
ERR("Cannot init right key\n");
if (!keypadAddGpioKey(kp, SDLK_RETURN, 112, false))
ERR("Cannot init select key\n");
if (!keypadAddGpioKey(kp, SDLK_F12, 113, true)) //reset button
ERR("Cannot init reset key\n");
dev->adc = (struct S3C24xxAdc*)sp->adc;
//battery is nearly full. device uses AIN0, 1:3.2 scale
s3c24xxAdcSetAuxAdc(dev->adc, 0, 4100UL * 10 / 32);
socBootload(sp->soc, 2048 | 0xc0000000ul, dev->nand); //PDA32 boots from NAND directly
return dev;
}
void devicePeriodic(struct Device *dev, uint32_t cycles)
{
}
void deviceTouch(struct Device *dev, int x, int y)
{
s3c24xxAdcSetPenPos(dev->adc, x >= 0 ? 85 + 2 * x : x, y >= 0 ? 780 - 14 * y / 10 : y);
}
void deviceKey(struct Device *dev, uint32_t key, bool down)
{
//nothing
}