forked from uARM-Palm/uARM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevicePalmZ22.c
executable file
·165 lines (126 loc) · 3.74 KB
/
devicePalmZ22.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
//(c) uARM project https://github.com/uARM-Palm/uARM [email protected]
#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
power F0
datebook F2
address F1
center F3
up F4
down F5
left F6
right F7
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 true;
}
enum RomChipType deviceGetRomMemType(void)
{
return RomWriteIgnore;
}
uint32_t deviceGetRamSize(void)
{
return 16UL << 20;
}
enum RamTermination deviceGetRamTerminationStyle(void)
{
return RamTerminationMirror;
}
uint_fast8_t deviceGetSocRev(void)
{
return 0; //S3C2410
}
static void z22nandPrvReady(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 = 528,
.blocksPerDevice = 2048,
.pagesPerBlockLg2 = 5,
.flags = NAND_FLAG_SAMSUNG_ADDRESSED_VIA_AREAS,
.devIdLen = 2,
.devId = {0xec, 0x75},
};
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, z22nandPrvReady, sp->gpio);
weirdBusAccess = ramInit(sp->mem, 0xa0000000ul, 0x800, (uint32_t*)malloc(0x800));
if (!weirdBusAccess)
ERR("Cannot init RAM4");
//GPG1 is usb plug detect. high if inserted
socGpioSetState(sp->gpio, 113, false);
//GPE0 and 1 are usb related
//GPE9 is out and tells the charger what rate to charge at (500mA if high 100mA is low)
if (!keypadAddGpioKey(kp, SDLK_F1, 98, false))
ERR("Cannot init hardkey1 (datebook)\n");
if (!keypadAddGpioKey(kp, SDLK_F2, 97, false))
ERR("Cannot init hardkey2 (address)\n");
if (!keypadAddGpioKey(kp, SDLK_DOWN, 101, false))
ERR("Cannot init down key\n");
if (!keypadAddGpioKey(kp, SDLK_UP, 100, false))
ERR("Cannot init up 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, 99, false))
ERR("Cannot init select key\n");
if (!keypadAddGpioKey(kp, SDLK_ESCAPE, 96, false))
ERR("Cannot init power key\n");
dev->adc = (struct S3C24xxAdc*)sp->adc;
//battery is nearly full. device uses AIN0, 3:4 scale
s3c24xxAdcSetAuxAdc(dev->adc, 0, 4100 * 3 / 4);
socBootload(sp->soc, 512, dev->nand); //Z22 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 ? 200 + 38 * x / 10 : x, y >= 0 ? 880 - 34 * y / 10 : y);
}
void deviceKey(struct Device *dev, uint32_t key, bool down)
{
//nothing
}