root / hw / twl92230.c @ c701b35b
History | View | Annotate | Download (25.3 kB)
1 | 7e7c5e4c | balrog | /*
|
---|---|---|---|
2 | 7e7c5e4c | balrog | * TI TWL92230C energy-management companion device for the OMAP24xx.
|
3 | 7e7c5e4c | balrog | * Aka. Menelaus (N4200 MENELAUS1_V2.2)
|
4 | 7e7c5e4c | balrog | *
|
5 | 7e7c5e4c | balrog | * Copyright (C) 2008 Nokia Corporation
|
6 | 7e7c5e4c | balrog | * Written by Andrzej Zaborowski <andrew@openedhand.com>
|
7 | 7e7c5e4c | balrog | *
|
8 | 7e7c5e4c | balrog | * This program is free software; you can redistribute it and/or
|
9 | 7e7c5e4c | balrog | * modify it under the terms of the GNU General Public License as
|
10 | 7e7c5e4c | balrog | * published by the Free Software Foundation; either version 2 or
|
11 | 7e7c5e4c | balrog | * (at your option) version 3 of the License.
|
12 | 7e7c5e4c | balrog | *
|
13 | 7e7c5e4c | balrog | * This program is distributed in the hope that it will be useful,
|
14 | 7e7c5e4c | balrog | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 | 7e7c5e4c | balrog | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 | 7e7c5e4c | balrog | * GNU General Public License for more details.
|
17 | 7e7c5e4c | balrog | *
|
18 | 7e7c5e4c | balrog | * You should have received a copy of the GNU General Public License
|
19 | 7e7c5e4c | balrog | * along with this program; if not, write to the Free Software
|
20 | 7e7c5e4c | balrog | * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
21 | 7e7c5e4c | balrog | * MA 02111-1307 USA
|
22 | 7e7c5e4c | balrog | */
|
23 | 7e7c5e4c | balrog | |
24 | 7e7c5e4c | balrog | #include "hw.h" |
25 | 7e7c5e4c | balrog | #include "qemu-timer.h" |
26 | 7e7c5e4c | balrog | #include "i2c.h" |
27 | 7e7c5e4c | balrog | #include "sysemu.h" |
28 | 7e7c5e4c | balrog | #include "console.h" |
29 | 7e7c5e4c | balrog | |
30 | 7e7c5e4c | balrog | #define VERBOSE 1 |
31 | 7e7c5e4c | balrog | |
32 | 7e7c5e4c | balrog | struct menelaus_s {
|
33 | 7e7c5e4c | balrog | i2c_slave i2c; |
34 | 7e7c5e4c | balrog | qemu_irq irq; |
35 | 7e7c5e4c | balrog | |
36 | 7e7c5e4c | balrog | int firstbyte;
|
37 | 7e7c5e4c | balrog | uint8_t reg; |
38 | 7e7c5e4c | balrog | |
39 | 7e7c5e4c | balrog | uint8_t vcore[5];
|
40 | 7e7c5e4c | balrog | uint8_t dcdc[3];
|
41 | 7e7c5e4c | balrog | uint8_t ldo[8];
|
42 | 7e7c5e4c | balrog | uint8_t sleep[2];
|
43 | 7e7c5e4c | balrog | uint8_t osc; |
44 | 7e7c5e4c | balrog | uint8_t detect; |
45 | 7e7c5e4c | balrog | uint16_t mask; |
46 | 7e7c5e4c | balrog | uint16_t status; |
47 | 7e7c5e4c | balrog | uint8_t dir; |
48 | 7e7c5e4c | balrog | uint8_t inputs; |
49 | 7e7c5e4c | balrog | uint8_t outputs; |
50 | 7e7c5e4c | balrog | uint8_t bbsms; |
51 | 7e7c5e4c | balrog | uint8_t pull[4];
|
52 | 7e7c5e4c | balrog | uint8_t mmc_ctrl[3];
|
53 | 7e7c5e4c | balrog | uint8_t mmc_debounce; |
54 | 7e7c5e4c | balrog | struct {
|
55 | 7e7c5e4c | balrog | uint8_t ctrl; |
56 | 7e7c5e4c | balrog | uint16_t comp; |
57 | 7e7c5e4c | balrog | QEMUTimer *hz; |
58 | 7e7c5e4c | balrog | int64_t next; |
59 | 7e7c5e4c | balrog | struct tm tm;
|
60 | 7e7c5e4c | balrog | struct tm new;
|
61 | 7e7c5e4c | balrog | struct tm alm;
|
62 | aec454d2 | balrog | int sec_offset;
|
63 | aec454d2 | balrog | int alm_sec;
|
64 | aec454d2 | balrog | int next_comp;
|
65 | 7e7c5e4c | balrog | } rtc; |
66 | 7e7c5e4c | balrog | qemu_irq handler[3];
|
67 | 7e7c5e4c | balrog | qemu_irq *in; |
68 | 7e7c5e4c | balrog | int pwrbtn_state;
|
69 | 7e7c5e4c | balrog | qemu_irq pwrbtn; |
70 | 7e7c5e4c | balrog | }; |
71 | 7e7c5e4c | balrog | |
72 | 7e7c5e4c | balrog | static inline void menelaus_update(struct menelaus_s *s) |
73 | 7e7c5e4c | balrog | { |
74 | 7e7c5e4c | balrog | qemu_set_irq(s->irq, s->status & ~s->mask); |
75 | 7e7c5e4c | balrog | } |
76 | 7e7c5e4c | balrog | |
77 | 7e7c5e4c | balrog | static inline void menelaus_rtc_start(struct menelaus_s *s) |
78 | 7e7c5e4c | balrog | { |
79 | 7e7c5e4c | balrog | s->rtc.next =+ qemu_get_clock(rt_clock); |
80 | 7e7c5e4c | balrog | qemu_mod_timer(s->rtc.hz, s->rtc.next); |
81 | 7e7c5e4c | balrog | } |
82 | 7e7c5e4c | balrog | |
83 | 7e7c5e4c | balrog | static inline void menelaus_rtc_stop(struct menelaus_s *s) |
84 | 7e7c5e4c | balrog | { |
85 | 7e7c5e4c | balrog | qemu_del_timer(s->rtc.hz); |
86 | 7e7c5e4c | balrog | s->rtc.next =- qemu_get_clock(rt_clock); |
87 | 7e7c5e4c | balrog | if (s->rtc.next < 1) |
88 | 7e7c5e4c | balrog | s->rtc.next = 1;
|
89 | 7e7c5e4c | balrog | } |
90 | 7e7c5e4c | balrog | |
91 | 7e7c5e4c | balrog | static void menelaus_rtc_update(struct menelaus_s *s) |
92 | 7e7c5e4c | balrog | { |
93 | aec454d2 | balrog | qemu_get_timedate(&s->rtc.tm, s->rtc.sec_offset); |
94 | 7e7c5e4c | balrog | } |
95 | 7e7c5e4c | balrog | |
96 | 7e7c5e4c | balrog | static void menelaus_alm_update(struct menelaus_s *s) |
97 | 7e7c5e4c | balrog | { |
98 | 7e7c5e4c | balrog | if ((s->rtc.ctrl & 3) == 3) |
99 | aec454d2 | balrog | s->rtc.alm_sec = qemu_timedate_diff(&s->rtc.alm) - s->rtc.sec_offset; |
100 | 7e7c5e4c | balrog | } |
101 | 7e7c5e4c | balrog | |
102 | 7e7c5e4c | balrog | static void menelaus_rtc_hz(void *opaque) |
103 | 7e7c5e4c | balrog | { |
104 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) opaque; |
105 | 7e7c5e4c | balrog | |
106 | aec454d2 | balrog | s->rtc.next_comp --; |
107 | aec454d2 | balrog | s->rtc.alm_sec --; |
108 | 7e7c5e4c | balrog | s->rtc.next += 1000;
|
109 | 7e7c5e4c | balrog | qemu_mod_timer(s->rtc.hz, s->rtc.next); |
110 | 7e7c5e4c | balrog | if ((s->rtc.ctrl >> 3) & 3) { /* EVERY */ |
111 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
112 | 7e7c5e4c | balrog | if (((s->rtc.ctrl >> 3) & 3) == 1 && !s->rtc.tm.tm_sec) |
113 | 7e7c5e4c | balrog | s->status |= 1 << 8; /* RTCTMR */ |
114 | 7e7c5e4c | balrog | else if (((s->rtc.ctrl >> 3) & 3) == 2 && !s->rtc.tm.tm_min) |
115 | 7e7c5e4c | balrog | s->status |= 1 << 8; /* RTCTMR */ |
116 | 7e7c5e4c | balrog | else if (!s->rtc.tm.tm_hour) |
117 | 7e7c5e4c | balrog | s->status |= 1 << 8; /* RTCTMR */ |
118 | 7e7c5e4c | balrog | } else
|
119 | 7e7c5e4c | balrog | s->status |= 1 << 8; /* RTCTMR */ |
120 | 7e7c5e4c | balrog | if ((s->rtc.ctrl >> 1) & 1) { /* RTC_AL_EN */ |
121 | aec454d2 | balrog | if (s->rtc.alm_sec == 0) |
122 | 7e7c5e4c | balrog | s->status |= 1 << 9; /* RTCALM */ |
123 | 7e7c5e4c | balrog | /* TODO: wake-up */
|
124 | 7e7c5e4c | balrog | } |
125 | aec454d2 | balrog | if (s->rtc.next_comp <= 0) { |
126 | 7e7c5e4c | balrog | s->rtc.next -= muldiv64((int16_t) s->rtc.comp, 1000, 0x8000); |
127 | aec454d2 | balrog | s->rtc.next_comp = 3600;
|
128 | 7e7c5e4c | balrog | } |
129 | 7e7c5e4c | balrog | menelaus_update(s); |
130 | 7e7c5e4c | balrog | } |
131 | 7e7c5e4c | balrog | |
132 | 7e7c5e4c | balrog | void menelaus_reset(i2c_slave *i2c)
|
133 | 7e7c5e4c | balrog | { |
134 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) i2c; |
135 | 7e7c5e4c | balrog | s->reg = 0x00;
|
136 | 7e7c5e4c | balrog | |
137 | 7e7c5e4c | balrog | s->vcore[0] = 0x0c; /* XXX: X-loader needs 0x8c? check! */ |
138 | 7e7c5e4c | balrog | s->vcore[1] = 0x05; |
139 | 7e7c5e4c | balrog | s->vcore[2] = 0x02; |
140 | 7e7c5e4c | balrog | s->vcore[3] = 0x0c; |
141 | 7e7c5e4c | balrog | s->vcore[4] = 0x03; |
142 | 7e7c5e4c | balrog | s->dcdc[0] = 0x33; /* Depends on wiring */ |
143 | 7e7c5e4c | balrog | s->dcdc[1] = 0x03; |
144 | 7e7c5e4c | balrog | s->dcdc[2] = 0x00; |
145 | 7e7c5e4c | balrog | s->ldo[0] = 0x95; |
146 | 7e7c5e4c | balrog | s->ldo[1] = 0x7e; |
147 | 7e7c5e4c | balrog | s->ldo[2] = 0x00; |
148 | 7e7c5e4c | balrog | s->ldo[3] = 0x00; /* Depends on wiring */ |
149 | 7e7c5e4c | balrog | s->ldo[4] = 0x03; /* Depends on wiring */ |
150 | 7e7c5e4c | balrog | s->ldo[5] = 0x00; |
151 | 7e7c5e4c | balrog | s->ldo[6] = 0x00; |
152 | 7e7c5e4c | balrog | s->ldo[7] = 0x00; |
153 | 7e7c5e4c | balrog | s->sleep[0] = 0x00; |
154 | 7e7c5e4c | balrog | s->sleep[1] = 0x00; |
155 | 7e7c5e4c | balrog | s->osc = 0x01;
|
156 | 7e7c5e4c | balrog | s->detect = 0x09;
|
157 | 7e7c5e4c | balrog | s->mask = 0x0fff;
|
158 | 7e7c5e4c | balrog | s->status = 0;
|
159 | 7e7c5e4c | balrog | s->dir = 0x07;
|
160 | 7e7c5e4c | balrog | s->outputs = 0x00;
|
161 | 7e7c5e4c | balrog | s->bbsms = 0x00;
|
162 | 7e7c5e4c | balrog | s->pull[0] = 0x00; |
163 | 7e7c5e4c | balrog | s->pull[1] = 0x00; |
164 | 7e7c5e4c | balrog | s->pull[2] = 0x00; |
165 | 7e7c5e4c | balrog | s->pull[3] = 0x00; |
166 | 7e7c5e4c | balrog | s->mmc_ctrl[0] = 0x03; |
167 | 7e7c5e4c | balrog | s->mmc_ctrl[1] = 0xc0; |
168 | 7e7c5e4c | balrog | s->mmc_ctrl[2] = 0x00; |
169 | 7e7c5e4c | balrog | s->mmc_debounce = 0x05;
|
170 | 7e7c5e4c | balrog | |
171 | 7e7c5e4c | balrog | if (s->rtc.ctrl & 1) |
172 | 7e7c5e4c | balrog | menelaus_rtc_stop(s); |
173 | 7e7c5e4c | balrog | s->rtc.ctrl = 0x00;
|
174 | 7e7c5e4c | balrog | s->rtc.comp = 0x0000;
|
175 | 7e7c5e4c | balrog | s->rtc.next = 1000;
|
176 | aec454d2 | balrog | s->rtc.sec_offset = 0;
|
177 | aec454d2 | balrog | s->rtc.next_comp = 1800;
|
178 | aec454d2 | balrog | s->rtc.alm_sec = 1800;
|
179 | 7e7c5e4c | balrog | s->rtc.alm.tm_sec = 0x00;
|
180 | 7e7c5e4c | balrog | s->rtc.alm.tm_min = 0x00;
|
181 | 7e7c5e4c | balrog | s->rtc.alm.tm_hour = 0x00;
|
182 | 7e7c5e4c | balrog | s->rtc.alm.tm_mday = 0x01;
|
183 | 7e7c5e4c | balrog | s->rtc.alm.tm_mon = 0x00;
|
184 | 7e7c5e4c | balrog | s->rtc.alm.tm_year = 2004;
|
185 | 7e7c5e4c | balrog | menelaus_update(s); |
186 | 7e7c5e4c | balrog | } |
187 | 7e7c5e4c | balrog | |
188 | 7e7c5e4c | balrog | static inline uint8_t to_bcd(int val) |
189 | 7e7c5e4c | balrog | { |
190 | 7e7c5e4c | balrog | return ((val / 10) << 4) | (val % 10); |
191 | 7e7c5e4c | balrog | } |
192 | 7e7c5e4c | balrog | |
193 | 7e7c5e4c | balrog | static inline int from_bcd(uint8_t val) |
194 | 7e7c5e4c | balrog | { |
195 | 7e7c5e4c | balrog | return ((val >> 4) * 10) + (val & 0x0f); |
196 | 7e7c5e4c | balrog | } |
197 | 7e7c5e4c | balrog | |
198 | 7e7c5e4c | balrog | static void menelaus_gpio_set(void *opaque, int line, int level) |
199 | 7e7c5e4c | balrog | { |
200 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) opaque; |
201 | 7e7c5e4c | balrog | |
202 | 7e7c5e4c | balrog | /* No interrupt generated */
|
203 | 7e7c5e4c | balrog | s->inputs &= ~(1 << line);
|
204 | 7e7c5e4c | balrog | s->inputs |= level << line; |
205 | 7e7c5e4c | balrog | } |
206 | 7e7c5e4c | balrog | |
207 | 7e7c5e4c | balrog | static void menelaus_pwrbtn_set(void *opaque, int line, int level) |
208 | 7e7c5e4c | balrog | { |
209 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) opaque; |
210 | 7e7c5e4c | balrog | |
211 | 7e7c5e4c | balrog | if (!s->pwrbtn_state && level) {
|
212 | 7e7c5e4c | balrog | s->status |= 1 << 11; /* PSHBTN */ |
213 | 7e7c5e4c | balrog | menelaus_update(s); |
214 | 7e7c5e4c | balrog | } |
215 | 7e7c5e4c | balrog | s->pwrbtn_state = level; |
216 | 7e7c5e4c | balrog | } |
217 | 7e7c5e4c | balrog | |
218 | 7e7c5e4c | balrog | #define MENELAUS_REV 0x01 |
219 | 7e7c5e4c | balrog | #define MENELAUS_VCORE_CTRL1 0x02 |
220 | 7e7c5e4c | balrog | #define MENELAUS_VCORE_CTRL2 0x03 |
221 | 7e7c5e4c | balrog | #define MENELAUS_VCORE_CTRL3 0x04 |
222 | 7e7c5e4c | balrog | #define MENELAUS_VCORE_CTRL4 0x05 |
223 | 7e7c5e4c | balrog | #define MENELAUS_VCORE_CTRL5 0x06 |
224 | 7e7c5e4c | balrog | #define MENELAUS_DCDC_CTRL1 0x07 |
225 | 7e7c5e4c | balrog | #define MENELAUS_DCDC_CTRL2 0x08 |
226 | 7e7c5e4c | balrog | #define MENELAUS_DCDC_CTRL3 0x09 |
227 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL1 0x0a |
228 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL2 0x0b |
229 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL3 0x0c |
230 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL4 0x0d |
231 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL5 0x0e |
232 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL6 0x0f |
233 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL7 0x10 |
234 | 7e7c5e4c | balrog | #define MENELAUS_LDO_CTRL8 0x11 |
235 | 7e7c5e4c | balrog | #define MENELAUS_SLEEP_CTRL1 0x12 |
236 | 7e7c5e4c | balrog | #define MENELAUS_SLEEP_CTRL2 0x13 |
237 | 7e7c5e4c | balrog | #define MENELAUS_DEVICE_OFF 0x14 |
238 | 7e7c5e4c | balrog | #define MENELAUS_OSC_CTRL 0x15 |
239 | 7e7c5e4c | balrog | #define MENELAUS_DETECT_CTRL 0x16 |
240 | 7e7c5e4c | balrog | #define MENELAUS_INT_MASK1 0x17 |
241 | 7e7c5e4c | balrog | #define MENELAUS_INT_MASK2 0x18 |
242 | 7e7c5e4c | balrog | #define MENELAUS_INT_STATUS1 0x19 |
243 | 7e7c5e4c | balrog | #define MENELAUS_INT_STATUS2 0x1a |
244 | 7e7c5e4c | balrog | #define MENELAUS_INT_ACK1 0x1b |
245 | 7e7c5e4c | balrog | #define MENELAUS_INT_ACK2 0x1c |
246 | 7e7c5e4c | balrog | #define MENELAUS_GPIO_CTRL 0x1d |
247 | 7e7c5e4c | balrog | #define MENELAUS_GPIO_IN 0x1e |
248 | 7e7c5e4c | balrog | #define MENELAUS_GPIO_OUT 0x1f |
249 | 7e7c5e4c | balrog | #define MENELAUS_BBSMS 0x20 |
250 | 7e7c5e4c | balrog | #define MENELAUS_RTC_CTRL 0x21 |
251 | 7e7c5e4c | balrog | #define MENELAUS_RTC_UPDATE 0x22 |
252 | 7e7c5e4c | balrog | #define MENELAUS_RTC_SEC 0x23 |
253 | 7e7c5e4c | balrog | #define MENELAUS_RTC_MIN 0x24 |
254 | 7e7c5e4c | balrog | #define MENELAUS_RTC_HR 0x25 |
255 | 7e7c5e4c | balrog | #define MENELAUS_RTC_DAY 0x26 |
256 | 7e7c5e4c | balrog | #define MENELAUS_RTC_MON 0x27 |
257 | 7e7c5e4c | balrog | #define MENELAUS_RTC_YR 0x28 |
258 | 7e7c5e4c | balrog | #define MENELAUS_RTC_WKDAY 0x29 |
259 | 7e7c5e4c | balrog | #define MENELAUS_RTC_AL_SEC 0x2a |
260 | 7e7c5e4c | balrog | #define MENELAUS_RTC_AL_MIN 0x2b |
261 | 7e7c5e4c | balrog | #define MENELAUS_RTC_AL_HR 0x2c |
262 | 7e7c5e4c | balrog | #define MENELAUS_RTC_AL_DAY 0x2d |
263 | 7e7c5e4c | balrog | #define MENELAUS_RTC_AL_MON 0x2e |
264 | 7e7c5e4c | balrog | #define MENELAUS_RTC_AL_YR 0x2f |
265 | 7e7c5e4c | balrog | #define MENELAUS_RTC_COMP_MSB 0x30 |
266 | 7e7c5e4c | balrog | #define MENELAUS_RTC_COMP_LSB 0x31 |
267 | 7e7c5e4c | balrog | #define MENELAUS_S1_PULL_EN 0x32 |
268 | 7e7c5e4c | balrog | #define MENELAUS_S1_PULL_DIR 0x33 |
269 | 7e7c5e4c | balrog | #define MENELAUS_S2_PULL_EN 0x34 |
270 | 7e7c5e4c | balrog | #define MENELAUS_S2_PULL_DIR 0x35 |
271 | 7e7c5e4c | balrog | #define MENELAUS_MCT_CTRL1 0x36 |
272 | 7e7c5e4c | balrog | #define MENELAUS_MCT_CTRL2 0x37 |
273 | 7e7c5e4c | balrog | #define MENELAUS_MCT_CTRL3 0x38 |
274 | 7e7c5e4c | balrog | #define MENELAUS_MCT_PIN_ST 0x39 |
275 | 7e7c5e4c | balrog | #define MENELAUS_DEBOUNCE1 0x3a |
276 | 7e7c5e4c | balrog | |
277 | 7e7c5e4c | balrog | static uint8_t menelaus_read(void *opaque, uint8_t addr) |
278 | 7e7c5e4c | balrog | { |
279 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) opaque; |
280 | 7e7c5e4c | balrog | int reg = 0; |
281 | 7e7c5e4c | balrog | |
282 | 7e7c5e4c | balrog | switch (addr) {
|
283 | 7e7c5e4c | balrog | case MENELAUS_REV:
|
284 | 7e7c5e4c | balrog | return 0x22; |
285 | 7e7c5e4c | balrog | |
286 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL5: reg ++;
|
287 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL4: reg ++;
|
288 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL3: reg ++;
|
289 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL2: reg ++;
|
290 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL1:
|
291 | 7e7c5e4c | balrog | return s->vcore[reg];
|
292 | 7e7c5e4c | balrog | |
293 | 7e7c5e4c | balrog | case MENELAUS_DCDC_CTRL3: reg ++;
|
294 | 7e7c5e4c | balrog | case MENELAUS_DCDC_CTRL2: reg ++;
|
295 | 7e7c5e4c | balrog | case MENELAUS_DCDC_CTRL1:
|
296 | 7e7c5e4c | balrog | return s->dcdc[reg];
|
297 | 7e7c5e4c | balrog | |
298 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL8: reg ++;
|
299 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL7: reg ++;
|
300 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL6: reg ++;
|
301 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL5: reg ++;
|
302 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL4: reg ++;
|
303 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL3: reg ++;
|
304 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL2: reg ++;
|
305 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL1:
|
306 | 7e7c5e4c | balrog | return s->ldo[reg];
|
307 | 7e7c5e4c | balrog | |
308 | 7e7c5e4c | balrog | case MENELAUS_SLEEP_CTRL2: reg ++;
|
309 | 7e7c5e4c | balrog | case MENELAUS_SLEEP_CTRL1:
|
310 | 7e7c5e4c | balrog | return s->sleep[reg];
|
311 | 7e7c5e4c | balrog | |
312 | 7e7c5e4c | balrog | case MENELAUS_DEVICE_OFF:
|
313 | 7e7c5e4c | balrog | return 0; |
314 | 7e7c5e4c | balrog | |
315 | 7e7c5e4c | balrog | case MENELAUS_OSC_CTRL:
|
316 | 7e7c5e4c | balrog | return s->osc | (1 << 7); /* CLK32K_GOOD */ |
317 | 7e7c5e4c | balrog | |
318 | 7e7c5e4c | balrog | case MENELAUS_DETECT_CTRL:
|
319 | 7e7c5e4c | balrog | return s->detect;
|
320 | 7e7c5e4c | balrog | |
321 | 7e7c5e4c | balrog | case MENELAUS_INT_MASK1:
|
322 | 7e7c5e4c | balrog | return (s->mask >> 0) & 0xff; |
323 | 7e7c5e4c | balrog | case MENELAUS_INT_MASK2:
|
324 | 7e7c5e4c | balrog | return (s->mask >> 8) & 0xff; |
325 | 7e7c5e4c | balrog | |
326 | 7e7c5e4c | balrog | case MENELAUS_INT_STATUS1:
|
327 | 7e7c5e4c | balrog | return (s->status >> 0) & 0xff; |
328 | 7e7c5e4c | balrog | case MENELAUS_INT_STATUS2:
|
329 | 7e7c5e4c | balrog | return (s->status >> 8) & 0xff; |
330 | 7e7c5e4c | balrog | |
331 | 7e7c5e4c | balrog | case MENELAUS_INT_ACK1:
|
332 | 7e7c5e4c | balrog | case MENELAUS_INT_ACK2:
|
333 | 7e7c5e4c | balrog | return 0; |
334 | 7e7c5e4c | balrog | |
335 | 7e7c5e4c | balrog | case MENELAUS_GPIO_CTRL:
|
336 | 7e7c5e4c | balrog | return s->dir;
|
337 | 7e7c5e4c | balrog | case MENELAUS_GPIO_IN:
|
338 | 7e7c5e4c | balrog | return s->inputs | (~s->dir & s->outputs);
|
339 | 7e7c5e4c | balrog | case MENELAUS_GPIO_OUT:
|
340 | 7e7c5e4c | balrog | return s->outputs;
|
341 | 7e7c5e4c | balrog | |
342 | 7e7c5e4c | balrog | case MENELAUS_BBSMS:
|
343 | 7e7c5e4c | balrog | return s->bbsms;
|
344 | 7e7c5e4c | balrog | |
345 | 7e7c5e4c | balrog | case MENELAUS_RTC_CTRL:
|
346 | 7e7c5e4c | balrog | return s->rtc.ctrl;
|
347 | 7e7c5e4c | balrog | case MENELAUS_RTC_UPDATE:
|
348 | 7e7c5e4c | balrog | return 0x00; |
349 | 7e7c5e4c | balrog | case MENELAUS_RTC_SEC:
|
350 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
351 | 7e7c5e4c | balrog | return to_bcd(s->rtc.tm.tm_sec);
|
352 | 7e7c5e4c | balrog | case MENELAUS_RTC_MIN:
|
353 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
354 | 7e7c5e4c | balrog | return to_bcd(s->rtc.tm.tm_min);
|
355 | 7e7c5e4c | balrog | case MENELAUS_RTC_HR:
|
356 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
357 | 7e7c5e4c | balrog | if ((s->rtc.ctrl >> 2) & 1) /* MODE12_n24 */ |
358 | 7e7c5e4c | balrog | return to_bcd((s->rtc.tm.tm_hour % 12) + 1) | |
359 | 7e7c5e4c | balrog | (!!(s->rtc.tm.tm_hour >= 12) << 7); /* PM_nAM */ |
360 | 7e7c5e4c | balrog | else
|
361 | 7e7c5e4c | balrog | return to_bcd(s->rtc.tm.tm_hour);
|
362 | 7e7c5e4c | balrog | case MENELAUS_RTC_DAY:
|
363 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
364 | 7e7c5e4c | balrog | return to_bcd(s->rtc.tm.tm_mday);
|
365 | 7e7c5e4c | balrog | case MENELAUS_RTC_MON:
|
366 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
367 | 7e7c5e4c | balrog | return to_bcd(s->rtc.tm.tm_mon + 1); |
368 | 7e7c5e4c | balrog | case MENELAUS_RTC_YR:
|
369 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
370 | 7e7c5e4c | balrog | return to_bcd(s->rtc.tm.tm_year - 2000); |
371 | 7e7c5e4c | balrog | case MENELAUS_RTC_WKDAY:
|
372 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
373 | 7e7c5e4c | balrog | return to_bcd(s->rtc.tm.tm_wday);
|
374 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_SEC:
|
375 | 7e7c5e4c | balrog | return to_bcd(s->rtc.alm.tm_sec);
|
376 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_MIN:
|
377 | 7e7c5e4c | balrog | return to_bcd(s->rtc.alm.tm_min);
|
378 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_HR:
|
379 | 7e7c5e4c | balrog | if ((s->rtc.ctrl >> 2) & 1) /* MODE12_n24 */ |
380 | 7e7c5e4c | balrog | return to_bcd((s->rtc.alm.tm_hour % 12) + 1) | |
381 | 7e7c5e4c | balrog | (!!(s->rtc.alm.tm_hour >= 12) << 7);/* AL_PM_nAM */ |
382 | 7e7c5e4c | balrog | else
|
383 | 7e7c5e4c | balrog | return to_bcd(s->rtc.alm.tm_hour);
|
384 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_DAY:
|
385 | 7e7c5e4c | balrog | return to_bcd(s->rtc.alm.tm_mday);
|
386 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_MON:
|
387 | 7e7c5e4c | balrog | return to_bcd(s->rtc.alm.tm_mon + 1); |
388 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_YR:
|
389 | 7e7c5e4c | balrog | return to_bcd(s->rtc.alm.tm_year - 2000); |
390 | 7e7c5e4c | balrog | case MENELAUS_RTC_COMP_MSB:
|
391 | 7e7c5e4c | balrog | return (s->rtc.comp >> 8) & 0xff; |
392 | 7e7c5e4c | balrog | case MENELAUS_RTC_COMP_LSB:
|
393 | 7e7c5e4c | balrog | return (s->rtc.comp >> 0) & 0xff; |
394 | 7e7c5e4c | balrog | |
395 | 7e7c5e4c | balrog | case MENELAUS_S1_PULL_EN:
|
396 | 7e7c5e4c | balrog | return s->pull[0]; |
397 | 7e7c5e4c | balrog | case MENELAUS_S1_PULL_DIR:
|
398 | 7e7c5e4c | balrog | return s->pull[1]; |
399 | 7e7c5e4c | balrog | case MENELAUS_S2_PULL_EN:
|
400 | 7e7c5e4c | balrog | return s->pull[2]; |
401 | 7e7c5e4c | balrog | case MENELAUS_S2_PULL_DIR:
|
402 | 7e7c5e4c | balrog | return s->pull[3]; |
403 | 7e7c5e4c | balrog | |
404 | 7e7c5e4c | balrog | case MENELAUS_MCT_CTRL3: reg ++;
|
405 | 7e7c5e4c | balrog | case MENELAUS_MCT_CTRL2: reg ++;
|
406 | 7e7c5e4c | balrog | case MENELAUS_MCT_CTRL1:
|
407 | 7e7c5e4c | balrog | return s->mmc_ctrl[reg];
|
408 | 7e7c5e4c | balrog | case MENELAUS_MCT_PIN_ST:
|
409 | 7e7c5e4c | balrog | /* TODO: return the real Card Detect */
|
410 | 7e7c5e4c | balrog | return 0; |
411 | 7e7c5e4c | balrog | case MENELAUS_DEBOUNCE1:
|
412 | 7e7c5e4c | balrog | return s->mmc_debounce;
|
413 | 7e7c5e4c | balrog | |
414 | 7e7c5e4c | balrog | default:
|
415 | 7e7c5e4c | balrog | #ifdef VERBOSE
|
416 | 7e7c5e4c | balrog | printf("%s: unknown register %02x\n", __FUNCTION__, addr);
|
417 | 7e7c5e4c | balrog | #endif
|
418 | 7e7c5e4c | balrog | break;
|
419 | 7e7c5e4c | balrog | } |
420 | 7e7c5e4c | balrog | return 0; |
421 | 7e7c5e4c | balrog | } |
422 | 7e7c5e4c | balrog | |
423 | 7e7c5e4c | balrog | static void menelaus_write(void *opaque, uint8_t addr, uint8_t value) |
424 | 7e7c5e4c | balrog | { |
425 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) opaque; |
426 | 7e7c5e4c | balrog | int line;
|
427 | 7e7c5e4c | balrog | int reg = 0; |
428 | 7e7c5e4c | balrog | struct tm tm;
|
429 | 7e7c5e4c | balrog | |
430 | 7e7c5e4c | balrog | switch (addr) {
|
431 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL1:
|
432 | 7e7c5e4c | balrog | s->vcore[0] = (value & 0xe) | MIN(value & 0x1f, 0x12); |
433 | 7e7c5e4c | balrog | break;
|
434 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL2:
|
435 | 7e7c5e4c | balrog | s->vcore[1] = value;
|
436 | 7e7c5e4c | balrog | break;
|
437 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL3:
|
438 | 7e7c5e4c | balrog | s->vcore[2] = MIN(value & 0x1f, 0x12); |
439 | 7e7c5e4c | balrog | break;
|
440 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL4:
|
441 | 7e7c5e4c | balrog | s->vcore[3] = MIN(value & 0x1f, 0x12); |
442 | 7e7c5e4c | balrog | break;
|
443 | 7e7c5e4c | balrog | case MENELAUS_VCORE_CTRL5:
|
444 | 7e7c5e4c | balrog | s->vcore[4] = value & 3; |
445 | 7e7c5e4c | balrog | /* XXX
|
446 | 7e7c5e4c | balrog | * auto set to 3 on M_Active, nRESWARM
|
447 | 7e7c5e4c | balrog | * auto set to 0 on M_WaitOn, M_Backup
|
448 | 7e7c5e4c | balrog | */
|
449 | 7e7c5e4c | balrog | break;
|
450 | 7e7c5e4c | balrog | |
451 | 7e7c5e4c | balrog | case MENELAUS_DCDC_CTRL1:
|
452 | 7e7c5e4c | balrog | s->dcdc[0] = value & 0x3f; |
453 | 7e7c5e4c | balrog | break;
|
454 | 7e7c5e4c | balrog | case MENELAUS_DCDC_CTRL2:
|
455 | 7e7c5e4c | balrog | s->dcdc[1] = value & 0x07; |
456 | 7e7c5e4c | balrog | /* XXX
|
457 | 7e7c5e4c | balrog | * auto set to 3 on M_Active, nRESWARM
|
458 | 7e7c5e4c | balrog | * auto set to 0 on M_WaitOn, M_Backup
|
459 | 7e7c5e4c | balrog | */
|
460 | 7e7c5e4c | balrog | break;
|
461 | 7e7c5e4c | balrog | case MENELAUS_DCDC_CTRL3:
|
462 | 7e7c5e4c | balrog | s->dcdc[2] = value & 0x07; |
463 | 7e7c5e4c | balrog | break;
|
464 | 7e7c5e4c | balrog | |
465 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL1:
|
466 | 7e7c5e4c | balrog | s->ldo[0] = value;
|
467 | 7e7c5e4c | balrog | break;
|
468 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL2:
|
469 | 7e7c5e4c | balrog | s->ldo[1] = value & 0x7f; |
470 | 7e7c5e4c | balrog | /* XXX
|
471 | 7e7c5e4c | balrog | * auto set to 0x7e on M_WaitOn, M_Backup
|
472 | 7e7c5e4c | balrog | */
|
473 | 7e7c5e4c | balrog | break;
|
474 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL3:
|
475 | 7e7c5e4c | balrog | s->ldo[2] = value & 3; |
476 | 7e7c5e4c | balrog | /* XXX
|
477 | 7e7c5e4c | balrog | * auto set to 3 on M_Active, nRESWARM
|
478 | 7e7c5e4c | balrog | * auto set to 0 on M_WaitOn, M_Backup
|
479 | 7e7c5e4c | balrog | */
|
480 | 7e7c5e4c | balrog | break;
|
481 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL4:
|
482 | 7e7c5e4c | balrog | s->ldo[3] = value & 3; |
483 | 7e7c5e4c | balrog | /* XXX
|
484 | 7e7c5e4c | balrog | * auto set to 3 on M_Active, nRESWARM
|
485 | 7e7c5e4c | balrog | * auto set to 0 on M_WaitOn, M_Backup
|
486 | 7e7c5e4c | balrog | */
|
487 | 7e7c5e4c | balrog | break;
|
488 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL5:
|
489 | 7e7c5e4c | balrog | s->ldo[4] = value & 3; |
490 | 7e7c5e4c | balrog | /* XXX
|
491 | 7e7c5e4c | balrog | * auto set to 3 on M_Active, nRESWARM
|
492 | 7e7c5e4c | balrog | * auto set to 0 on M_WaitOn, M_Backup
|
493 | 7e7c5e4c | balrog | */
|
494 | 7e7c5e4c | balrog | break;
|
495 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL6:
|
496 | 7e7c5e4c | balrog | s->ldo[5] = value & 3; |
497 | 7e7c5e4c | balrog | break;
|
498 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL7:
|
499 | 7e7c5e4c | balrog | s->ldo[6] = value & 3; |
500 | 7e7c5e4c | balrog | break;
|
501 | 7e7c5e4c | balrog | case MENELAUS_LDO_CTRL8:
|
502 | 7e7c5e4c | balrog | s->ldo[7] = value & 3; |
503 | 7e7c5e4c | balrog | break;
|
504 | 7e7c5e4c | balrog | |
505 | 7e7c5e4c | balrog | case MENELAUS_SLEEP_CTRL2: reg ++;
|
506 | 7e7c5e4c | balrog | case MENELAUS_SLEEP_CTRL1:
|
507 | 7e7c5e4c | balrog | s->sleep[reg] = value; |
508 | 7e7c5e4c | balrog | break;
|
509 | 7e7c5e4c | balrog | |
510 | 7e7c5e4c | balrog | case MENELAUS_DEVICE_OFF:
|
511 | 7e7c5e4c | balrog | if (value & 1) |
512 | 7e7c5e4c | balrog | menelaus_reset(&s->i2c); |
513 | 7e7c5e4c | balrog | break;
|
514 | 7e7c5e4c | balrog | |
515 | 7e7c5e4c | balrog | case MENELAUS_OSC_CTRL:
|
516 | 7e7c5e4c | balrog | s->osc = value & 7;
|
517 | 7e7c5e4c | balrog | break;
|
518 | 7e7c5e4c | balrog | |
519 | 7e7c5e4c | balrog | case MENELAUS_DETECT_CTRL:
|
520 | 7e7c5e4c | balrog | s->detect = value & 0x7f;
|
521 | 7e7c5e4c | balrog | break;
|
522 | 7e7c5e4c | balrog | |
523 | 7e7c5e4c | balrog | case MENELAUS_INT_MASK1:
|
524 | 7e7c5e4c | balrog | s->mask &= 0xf00;
|
525 | 7e7c5e4c | balrog | s->mask |= value << 0;
|
526 | 7e7c5e4c | balrog | menelaus_update(s); |
527 | 7e7c5e4c | balrog | break;
|
528 | 7e7c5e4c | balrog | case MENELAUS_INT_MASK2:
|
529 | 7e7c5e4c | balrog | s->mask &= 0x0ff;
|
530 | 7e7c5e4c | balrog | s->mask |= value << 8;
|
531 | 7e7c5e4c | balrog | menelaus_update(s); |
532 | 7e7c5e4c | balrog | break;
|
533 | 7e7c5e4c | balrog | |
534 | 7e7c5e4c | balrog | case MENELAUS_INT_ACK1:
|
535 | 7e7c5e4c | balrog | s->status &= ~(((uint16_t) value) << 0);
|
536 | 7e7c5e4c | balrog | menelaus_update(s); |
537 | 7e7c5e4c | balrog | break;
|
538 | 7e7c5e4c | balrog | case MENELAUS_INT_ACK2:
|
539 | 7e7c5e4c | balrog | s->status &= ~(((uint16_t) value) << 8);
|
540 | 7e7c5e4c | balrog | menelaus_update(s); |
541 | 7e7c5e4c | balrog | break;
|
542 | 7e7c5e4c | balrog | |
543 | 7e7c5e4c | balrog | case MENELAUS_GPIO_CTRL:
|
544 | 7e7c5e4c | balrog | for (line = 0; line < 3; line ++) |
545 | 7e7c5e4c | balrog | if (((s->dir ^ value) >> line) & 1) |
546 | 7e7c5e4c | balrog | if (s->handler[line])
|
547 | 7e7c5e4c | balrog | qemu_set_irq(s->handler[line], |
548 | 7e7c5e4c | balrog | ((s->outputs & ~s->dir) >> line) & 1);
|
549 | 7e7c5e4c | balrog | s->dir = value & 0x67;
|
550 | 7e7c5e4c | balrog | break;
|
551 | 7e7c5e4c | balrog | case MENELAUS_GPIO_OUT:
|
552 | 7e7c5e4c | balrog | for (line = 0; line < 3; line ++) |
553 | 7e7c5e4c | balrog | if ((((s->outputs ^ value) & ~s->dir) >> line) & 1) |
554 | 7e7c5e4c | balrog | if (s->handler[line])
|
555 | 7e7c5e4c | balrog | qemu_set_irq(s->handler[line], (s->outputs >> line) & 1);
|
556 | 7e7c5e4c | balrog | s->outputs = value & 0x07;
|
557 | 7e7c5e4c | balrog | break;
|
558 | 7e7c5e4c | balrog | |
559 | 7e7c5e4c | balrog | case MENELAUS_BBSMS:
|
560 | 7e7c5e4c | balrog | s->bbsms = 0x0d;
|
561 | 7e7c5e4c | balrog | break;
|
562 | 7e7c5e4c | balrog | |
563 | 7e7c5e4c | balrog | case MENELAUS_RTC_CTRL:
|
564 | 7e7c5e4c | balrog | if ((s->rtc.ctrl ^ value) & 1) { /* RTC_EN */ |
565 | 7e7c5e4c | balrog | if (value & 1) |
566 | 7e7c5e4c | balrog | menelaus_rtc_start(s); |
567 | 7e7c5e4c | balrog | else
|
568 | 7e7c5e4c | balrog | menelaus_rtc_stop(s); |
569 | 7e7c5e4c | balrog | } |
570 | 7e7c5e4c | balrog | s->rtc.ctrl = value & 0x1f;
|
571 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
572 | 7e7c5e4c | balrog | break;
|
573 | 7e7c5e4c | balrog | case MENELAUS_RTC_UPDATE:
|
574 | 7e7c5e4c | balrog | menelaus_rtc_update(s); |
575 | 7e7c5e4c | balrog | memcpy(&tm, &s->rtc.tm, sizeof(tm));
|
576 | 7e7c5e4c | balrog | switch (value & 0xf) { |
577 | 7e7c5e4c | balrog | case 0: |
578 | 7e7c5e4c | balrog | break;
|
579 | 7e7c5e4c | balrog | case 1: |
580 | 7e7c5e4c | balrog | tm.tm_sec = s->rtc.new.tm_sec; |
581 | 7e7c5e4c | balrog | break;
|
582 | 7e7c5e4c | balrog | case 2: |
583 | 7e7c5e4c | balrog | tm.tm_min = s->rtc.new.tm_min; |
584 | 7e7c5e4c | balrog | break;
|
585 | 7e7c5e4c | balrog | case 3: |
586 | 7e7c5e4c | balrog | if (s->rtc.new.tm_hour > 23) |
587 | 7e7c5e4c | balrog | goto rtc_badness;
|
588 | 7e7c5e4c | balrog | tm.tm_hour = s->rtc.new.tm_hour; |
589 | 7e7c5e4c | balrog | break;
|
590 | 7e7c5e4c | balrog | case 4: |
591 | 7e7c5e4c | balrog | if (s->rtc.new.tm_mday < 1) |
592 | 7e7c5e4c | balrog | goto rtc_badness;
|
593 | 7e7c5e4c | balrog | /* TODO check range */
|
594 | 7e7c5e4c | balrog | tm.tm_mday = s->rtc.new.tm_mday; |
595 | 7e7c5e4c | balrog | break;
|
596 | 7e7c5e4c | balrog | case 5: |
597 | 7e7c5e4c | balrog | if (s->rtc.new.tm_mon < 0 || s->rtc.new.tm_mon > 11) |
598 | 7e7c5e4c | balrog | goto rtc_badness;
|
599 | 7e7c5e4c | balrog | tm.tm_mon = s->rtc.new.tm_mon; |
600 | 7e7c5e4c | balrog | break;
|
601 | 7e7c5e4c | balrog | case 6: |
602 | 7e7c5e4c | balrog | tm.tm_year = s->rtc.new.tm_year; |
603 | 7e7c5e4c | balrog | break;
|
604 | 7e7c5e4c | balrog | case 7: |
605 | 7e7c5e4c | balrog | /* TODO set .tm_mday instead */
|
606 | 7e7c5e4c | balrog | tm.tm_wday = s->rtc.new.tm_wday; |
607 | 7e7c5e4c | balrog | break;
|
608 | 7e7c5e4c | balrog | case 8: |
609 | 7e7c5e4c | balrog | if (s->rtc.new.tm_hour > 23) |
610 | 7e7c5e4c | balrog | goto rtc_badness;
|
611 | 7e7c5e4c | balrog | if (s->rtc.new.tm_mday < 1) |
612 | 7e7c5e4c | balrog | goto rtc_badness;
|
613 | 7e7c5e4c | balrog | if (s->rtc.new.tm_mon < 0 || s->rtc.new.tm_mon > 11) |
614 | 7e7c5e4c | balrog | goto rtc_badness;
|
615 | 7e7c5e4c | balrog | tm.tm_sec = s->rtc.new.tm_sec; |
616 | 7e7c5e4c | balrog | tm.tm_min = s->rtc.new.tm_min; |
617 | 7e7c5e4c | balrog | tm.tm_hour = s->rtc.new.tm_hour; |
618 | 7e7c5e4c | balrog | tm.tm_mday = s->rtc.new.tm_mday; |
619 | 7e7c5e4c | balrog | tm.tm_mon = s->rtc.new.tm_mon; |
620 | 7e7c5e4c | balrog | tm.tm_year = s->rtc.new.tm_year; |
621 | 7e7c5e4c | balrog | break;
|
622 | 7e7c5e4c | balrog | rtc_badness:
|
623 | 7e7c5e4c | balrog | default:
|
624 | 7e7c5e4c | balrog | fprintf(stderr, "%s: bad RTC_UPDATE value %02x\n",
|
625 | 7e7c5e4c | balrog | __FUNCTION__, value); |
626 | 7e7c5e4c | balrog | s->status |= 1 << 10; /* RTCERR */ |
627 | 7e7c5e4c | balrog | menelaus_update(s); |
628 | 7e7c5e4c | balrog | } |
629 | aec454d2 | balrog | s->rtc.sec_offset = qemu_timedate_diff(&tm); |
630 | 7e7c5e4c | balrog | break;
|
631 | 7e7c5e4c | balrog | case MENELAUS_RTC_SEC:
|
632 | 7e7c5e4c | balrog | s->rtc.tm.tm_sec = from_bcd(value & 0x7f);
|
633 | 7e7c5e4c | balrog | break;
|
634 | 7e7c5e4c | balrog | case MENELAUS_RTC_MIN:
|
635 | 7e7c5e4c | balrog | s->rtc.tm.tm_min = from_bcd(value & 0x7f);
|
636 | 7e7c5e4c | balrog | break;
|
637 | 7e7c5e4c | balrog | case MENELAUS_RTC_HR:
|
638 | 7e7c5e4c | balrog | s->rtc.tm.tm_hour = (s->rtc.ctrl & (1 << 2)) ? /* MODE12_n24 */ |
639 | 7e7c5e4c | balrog | MIN(from_bcd(value & 0x3f), 12) + ((value >> 7) ? 11 : -1) : |
640 | 7e7c5e4c | balrog | from_bcd(value & 0x3f);
|
641 | 7e7c5e4c | balrog | break;
|
642 | 7e7c5e4c | balrog | case MENELAUS_RTC_DAY:
|
643 | 7e7c5e4c | balrog | s->rtc.tm.tm_mday = from_bcd(value); |
644 | 7e7c5e4c | balrog | break;
|
645 | 7e7c5e4c | balrog | case MENELAUS_RTC_MON:
|
646 | 7e7c5e4c | balrog | s->rtc.tm.tm_mon = MAX(1, from_bcd(value)) - 1; |
647 | 7e7c5e4c | balrog | break;
|
648 | 7e7c5e4c | balrog | case MENELAUS_RTC_YR:
|
649 | 7e7c5e4c | balrog | s->rtc.tm.tm_year = 2000 + from_bcd(value);
|
650 | 7e7c5e4c | balrog | break;
|
651 | 7e7c5e4c | balrog | case MENELAUS_RTC_WKDAY:
|
652 | 7e7c5e4c | balrog | s->rtc.tm.tm_mday = from_bcd(value); |
653 | 7e7c5e4c | balrog | break;
|
654 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_SEC:
|
655 | 7e7c5e4c | balrog | s->rtc.alm.tm_sec = from_bcd(value & 0x7f);
|
656 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
657 | 7e7c5e4c | balrog | break;
|
658 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_MIN:
|
659 | 7e7c5e4c | balrog | s->rtc.alm.tm_min = from_bcd(value & 0x7f);
|
660 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
661 | 7e7c5e4c | balrog | break;
|
662 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_HR:
|
663 | 7e7c5e4c | balrog | s->rtc.alm.tm_hour = (s->rtc.ctrl & (1 << 2)) ? /* MODE12_n24 */ |
664 | 7e7c5e4c | balrog | MIN(from_bcd(value & 0x3f), 12) + ((value >> 7) ? 11 : -1) : |
665 | 7e7c5e4c | balrog | from_bcd(value & 0x3f);
|
666 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
667 | 7e7c5e4c | balrog | break;
|
668 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_DAY:
|
669 | 7e7c5e4c | balrog | s->rtc.alm.tm_mday = from_bcd(value); |
670 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
671 | 7e7c5e4c | balrog | break;
|
672 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_MON:
|
673 | 7e7c5e4c | balrog | s->rtc.alm.tm_mon = MAX(1, from_bcd(value)) - 1; |
674 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
675 | 7e7c5e4c | balrog | break;
|
676 | 7e7c5e4c | balrog | case MENELAUS_RTC_AL_YR:
|
677 | 7e7c5e4c | balrog | s->rtc.alm.tm_year = 2000 + from_bcd(value);
|
678 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
679 | 7e7c5e4c | balrog | break;
|
680 | 7e7c5e4c | balrog | case MENELAUS_RTC_COMP_MSB:
|
681 | 7e7c5e4c | balrog | s->rtc.comp &= 0xff;
|
682 | 7e7c5e4c | balrog | s->rtc.comp |= value << 8;
|
683 | 7e7c5e4c | balrog | break;
|
684 | 7e7c5e4c | balrog | case MENELAUS_RTC_COMP_LSB:
|
685 | 7e7c5e4c | balrog | s->rtc.comp &= 0xff << 8; |
686 | 7e7c5e4c | balrog | s->rtc.comp |= value; |
687 | 7e7c5e4c | balrog | break;
|
688 | 7e7c5e4c | balrog | |
689 | 7e7c5e4c | balrog | case MENELAUS_S1_PULL_EN:
|
690 | 7e7c5e4c | balrog | s->pull[0] = value;
|
691 | 7e7c5e4c | balrog | break;
|
692 | 7e7c5e4c | balrog | case MENELAUS_S1_PULL_DIR:
|
693 | 7e7c5e4c | balrog | s->pull[1] = value & 0x1f; |
694 | 7e7c5e4c | balrog | break;
|
695 | 7e7c5e4c | balrog | case MENELAUS_S2_PULL_EN:
|
696 | 7e7c5e4c | balrog | s->pull[2] = value;
|
697 | 7e7c5e4c | balrog | break;
|
698 | 7e7c5e4c | balrog | case MENELAUS_S2_PULL_DIR:
|
699 | 7e7c5e4c | balrog | s->pull[3] = value & 0x1f; |
700 | 7e7c5e4c | balrog | break;
|
701 | 7e7c5e4c | balrog | |
702 | 7e7c5e4c | balrog | case MENELAUS_MCT_CTRL1:
|
703 | 7e7c5e4c | balrog | s->mmc_ctrl[0] = value & 0x7f; |
704 | 7e7c5e4c | balrog | break;
|
705 | 7e7c5e4c | balrog | case MENELAUS_MCT_CTRL2:
|
706 | 7e7c5e4c | balrog | s->mmc_ctrl[1] = value;
|
707 | 7e7c5e4c | balrog | /* TODO update Card Detect interrupts */
|
708 | 7e7c5e4c | balrog | break;
|
709 | 7e7c5e4c | balrog | case MENELAUS_MCT_CTRL3:
|
710 | 7e7c5e4c | balrog | s->mmc_ctrl[2] = value & 0xf; |
711 | 7e7c5e4c | balrog | break;
|
712 | 7e7c5e4c | balrog | case MENELAUS_DEBOUNCE1:
|
713 | 7e7c5e4c | balrog | s->mmc_debounce = value & 0x3f;
|
714 | 7e7c5e4c | balrog | break;
|
715 | 7e7c5e4c | balrog | |
716 | 7e7c5e4c | balrog | default:
|
717 | 7e7c5e4c | balrog | #ifdef VERBOSE
|
718 | 7e7c5e4c | balrog | printf("%s: unknown register %02x\n", __FUNCTION__, addr);
|
719 | 7e7c5e4c | balrog | #endif
|
720 | 7e7c5e4c | balrog | } |
721 | 7e7c5e4c | balrog | } |
722 | 7e7c5e4c | balrog | |
723 | 7e7c5e4c | balrog | static void menelaus_event(i2c_slave *i2c, enum i2c_event event) |
724 | 7e7c5e4c | balrog | { |
725 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) i2c; |
726 | 7e7c5e4c | balrog | |
727 | 7e7c5e4c | balrog | if (event == I2C_START_SEND)
|
728 | 7e7c5e4c | balrog | s->firstbyte = 1;
|
729 | 7e7c5e4c | balrog | } |
730 | 7e7c5e4c | balrog | |
731 | 7e7c5e4c | balrog | static int menelaus_tx(i2c_slave *i2c, uint8_t data) |
732 | 7e7c5e4c | balrog | { |
733 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) i2c; |
734 | 7e7c5e4c | balrog | /* Interpret register address byte */
|
735 | 7e7c5e4c | balrog | if (s->firstbyte) {
|
736 | 7e7c5e4c | balrog | s->reg = data; |
737 | 7e7c5e4c | balrog | s->firstbyte = 0;
|
738 | 7e7c5e4c | balrog | } else
|
739 | 7e7c5e4c | balrog | menelaus_write(s, s->reg ++, data); |
740 | 7e7c5e4c | balrog | |
741 | 7e7c5e4c | balrog | return 0; |
742 | 7e7c5e4c | balrog | } |
743 | 7e7c5e4c | balrog | |
744 | 7e7c5e4c | balrog | static int menelaus_rx(i2c_slave *i2c) |
745 | 7e7c5e4c | balrog | { |
746 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) i2c; |
747 | 7e7c5e4c | balrog | |
748 | 7e7c5e4c | balrog | return menelaus_read(s, s->reg ++);
|
749 | 7e7c5e4c | balrog | } |
750 | 7e7c5e4c | balrog | |
751 | 7e7c5e4c | balrog | static void tm_put(QEMUFile *f, struct tm *tm) { |
752 | 7e7c5e4c | balrog | qemu_put_be16(f, tm->tm_sec); |
753 | 7e7c5e4c | balrog | qemu_put_be16(f, tm->tm_min); |
754 | 7e7c5e4c | balrog | qemu_put_be16(f, tm->tm_hour); |
755 | 7e7c5e4c | balrog | qemu_put_be16(f, tm->tm_mday); |
756 | 7e7c5e4c | balrog | qemu_put_be16(f, tm->tm_min); |
757 | 7e7c5e4c | balrog | qemu_put_be16(f, tm->tm_year); |
758 | 7e7c5e4c | balrog | } |
759 | 7e7c5e4c | balrog | |
760 | 7e7c5e4c | balrog | static void tm_get(QEMUFile *f, struct tm *tm) { |
761 | 7e7c5e4c | balrog | tm->tm_sec = qemu_get_be16(f); |
762 | 7e7c5e4c | balrog | tm->tm_min = qemu_get_be16(f); |
763 | 7e7c5e4c | balrog | tm->tm_hour = qemu_get_be16(f); |
764 | 7e7c5e4c | balrog | tm->tm_mday = qemu_get_be16(f); |
765 | 7e7c5e4c | balrog | tm->tm_min = qemu_get_be16(f); |
766 | 7e7c5e4c | balrog | tm->tm_year = qemu_get_be16(f); |
767 | 7e7c5e4c | balrog | } |
768 | 7e7c5e4c | balrog | |
769 | 7e7c5e4c | balrog | static void menelaus_save(QEMUFile *f, void *opaque) |
770 | 7e7c5e4c | balrog | { |
771 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) opaque; |
772 | 7e7c5e4c | balrog | |
773 | 7e7c5e4c | balrog | qemu_put_be32(f, s->firstbyte); |
774 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->reg); |
775 | 7e7c5e4c | balrog | |
776 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->vcore[0]);
|
777 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->vcore[1]);
|
778 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->vcore[2]);
|
779 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->vcore[3]);
|
780 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->vcore[4]);
|
781 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->dcdc[3]);
|
782 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->dcdc[3]);
|
783 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->dcdc[3]);
|
784 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[0]);
|
785 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[1]);
|
786 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[2]);
|
787 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[3]);
|
788 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[4]);
|
789 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[5]);
|
790 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[6]);
|
791 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->ldo[7]);
|
792 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->sleep[0]);
|
793 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->sleep[1]);
|
794 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->osc); |
795 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->detect); |
796 | 7e7c5e4c | balrog | qemu_put_be16s(f, &s->mask); |
797 | 7e7c5e4c | balrog | qemu_put_be16s(f, &s->status); |
798 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->dir); |
799 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->inputs); |
800 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->outputs); |
801 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->bbsms); |
802 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->pull[0]);
|
803 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->pull[1]);
|
804 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->pull[2]);
|
805 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->pull[3]);
|
806 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->mmc_ctrl[0]);
|
807 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->mmc_ctrl[1]);
|
808 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->mmc_ctrl[2]);
|
809 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->mmc_debounce); |
810 | 7e7c5e4c | balrog | qemu_put_8s(f, &s->rtc.ctrl); |
811 | 7e7c5e4c | balrog | qemu_put_be16s(f, &s->rtc.comp); |
812 | 7e7c5e4c | balrog | /* Should be <= 1000 */
|
813 | 7e7c5e4c | balrog | qemu_put_be16(f, s->rtc.next - qemu_get_clock(rt_clock)); |
814 | 7e7c5e4c | balrog | tm_put(f, &s->rtc.new); |
815 | 7e7c5e4c | balrog | tm_put(f, &s->rtc.alm); |
816 | 7e7c5e4c | balrog | qemu_put_byte(f, s->pwrbtn_state); |
817 | 7e7c5e4c | balrog | |
818 | 7e7c5e4c | balrog | i2c_slave_save(f, &s->i2c); |
819 | 7e7c5e4c | balrog | } |
820 | 7e7c5e4c | balrog | |
821 | 7e7c5e4c | balrog | static int menelaus_load(QEMUFile *f, void *opaque, int version_id) |
822 | 7e7c5e4c | balrog | { |
823 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) opaque; |
824 | 7e7c5e4c | balrog | |
825 | 7e7c5e4c | balrog | s->firstbyte = qemu_get_be32(f); |
826 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->reg); |
827 | 7e7c5e4c | balrog | |
828 | 7e7c5e4c | balrog | if (s->rtc.ctrl & 1) /* RTC_EN */ |
829 | 7e7c5e4c | balrog | menelaus_rtc_stop(s); |
830 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->vcore[0]);
|
831 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->vcore[1]);
|
832 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->vcore[2]);
|
833 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->vcore[3]);
|
834 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->vcore[4]);
|
835 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->dcdc[3]);
|
836 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->dcdc[3]);
|
837 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->dcdc[3]);
|
838 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[0]);
|
839 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[1]);
|
840 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[2]);
|
841 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[3]);
|
842 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[4]);
|
843 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[5]);
|
844 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[6]);
|
845 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->ldo[7]);
|
846 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->sleep[0]);
|
847 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->sleep[1]);
|
848 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->osc); |
849 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->detect); |
850 | 7e7c5e4c | balrog | qemu_get_be16s(f, &s->mask); |
851 | 7e7c5e4c | balrog | qemu_get_be16s(f, &s->status); |
852 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->dir); |
853 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->inputs); |
854 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->outputs); |
855 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->bbsms); |
856 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->pull[0]);
|
857 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->pull[1]);
|
858 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->pull[2]);
|
859 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->pull[3]);
|
860 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->mmc_ctrl[0]);
|
861 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->mmc_ctrl[1]);
|
862 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->mmc_ctrl[2]);
|
863 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->mmc_debounce); |
864 | 7e7c5e4c | balrog | qemu_get_8s(f, &s->rtc.ctrl); |
865 | 7e7c5e4c | balrog | qemu_get_be16s(f, &s->rtc.comp); |
866 | 7e7c5e4c | balrog | s->rtc.next = qemu_get_be16(f); |
867 | 7e7c5e4c | balrog | tm_get(f, &s->rtc.new); |
868 | 7e7c5e4c | balrog | tm_get(f, &s->rtc.alm); |
869 | 7e7c5e4c | balrog | s->pwrbtn_state = qemu_get_byte(f); |
870 | 7e7c5e4c | balrog | menelaus_alm_update(s); |
871 | 7e7c5e4c | balrog | menelaus_update(s); |
872 | 7e7c5e4c | balrog | if (s->rtc.ctrl & 1) /* RTC_EN */ |
873 | 7e7c5e4c | balrog | menelaus_rtc_start(s); |
874 | 7e7c5e4c | balrog | |
875 | 7e7c5e4c | balrog | i2c_slave_load(f, &s->i2c); |
876 | 7e7c5e4c | balrog | return 0; |
877 | 7e7c5e4c | balrog | } |
878 | 7e7c5e4c | balrog | |
879 | 7e7c5e4c | balrog | i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq) |
880 | 7e7c5e4c | balrog | { |
881 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) |
882 | 7e7c5e4c | balrog | i2c_slave_init(bus, 0, sizeof(struct menelaus_s)); |
883 | 7e7c5e4c | balrog | |
884 | 7e7c5e4c | balrog | s->i2c.event = menelaus_event; |
885 | 7e7c5e4c | balrog | s->i2c.recv = menelaus_rx; |
886 | 7e7c5e4c | balrog | s->i2c.send = menelaus_tx; |
887 | 7e7c5e4c | balrog | |
888 | 7e7c5e4c | balrog | s->irq = irq; |
889 | 7e7c5e4c | balrog | s->rtc.hz = qemu_new_timer(rt_clock, menelaus_rtc_hz, s); |
890 | 7e7c5e4c | balrog | s->in = qemu_allocate_irqs(menelaus_gpio_set, s, 3);
|
891 | 7e7c5e4c | balrog | s->pwrbtn = qemu_allocate_irqs(menelaus_pwrbtn_set, s, 1)[0]; |
892 | 7e7c5e4c | balrog | |
893 | 7e7c5e4c | balrog | menelaus_reset(&s->i2c); |
894 | 7e7c5e4c | balrog | |
895 | 18be5187 | pbrook | register_savevm("menelaus", -1, 0, menelaus_save, menelaus_load, s); |
896 | 7e7c5e4c | balrog | |
897 | 7e7c5e4c | balrog | return &s->i2c;
|
898 | 7e7c5e4c | balrog | } |
899 | 7e7c5e4c | balrog | |
900 | 7e7c5e4c | balrog | qemu_irq *twl92230_gpio_in_get(i2c_slave *i2c) |
901 | 7e7c5e4c | balrog | { |
902 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) i2c; |
903 | 7e7c5e4c | balrog | |
904 | 7e7c5e4c | balrog | return s->in;
|
905 | 7e7c5e4c | balrog | } |
906 | 7e7c5e4c | balrog | |
907 | 7e7c5e4c | balrog | void twl92230_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler) |
908 | 7e7c5e4c | balrog | { |
909 | 7e7c5e4c | balrog | struct menelaus_s *s = (struct menelaus_s *) i2c; |
910 | 7e7c5e4c | balrog | |
911 | 7e7c5e4c | balrog | if (line >= 3 || line < 0) { |
912 | 7e7c5e4c | balrog | fprintf(stderr, "%s: No GPO line %i\n", __FUNCTION__, line);
|
913 | 7e7c5e4c | balrog | exit(-1);
|
914 | 7e7c5e4c | balrog | } |
915 | 7e7c5e4c | balrog | s->handler[line] = handler; |
916 | 7e7c5e4c | balrog | } |