root / hw / musicpal.c @ 1673ad51
History | View | Annotate | Download (43.8 kB)
1 | 24859b68 | balrog | /*
|
---|---|---|---|
2 | 24859b68 | balrog | * Marvell MV88W8618 / Freecom MusicPal emulation.
|
3 | 24859b68 | balrog | *
|
4 | 24859b68 | balrog | * Copyright (c) 2008 Jan Kiszka
|
5 | 24859b68 | balrog | *
|
6 | 24859b68 | balrog | * This code is licenced under the GNU GPL v2.
|
7 | 24859b68 | balrog | */
|
8 | 24859b68 | balrog | |
9 | b47b50fa | Paul Brook | #include "sysbus.h" |
10 | 24859b68 | balrog | #include "arm-misc.h" |
11 | 24859b68 | balrog | #include "devices.h" |
12 | 24859b68 | balrog | #include "net.h" |
13 | 24859b68 | balrog | #include "sysemu.h" |
14 | 24859b68 | balrog | #include "boards.h" |
15 | 24859b68 | balrog | #include "pc.h" |
16 | 24859b68 | balrog | #include "qemu-timer.h" |
17 | 24859b68 | balrog | #include "block.h" |
18 | 24859b68 | balrog | #include "flash.h" |
19 | 24859b68 | balrog | #include "console.h" |
20 | 24859b68 | balrog | #include "i2c.h" |
21 | 24859b68 | balrog | |
22 | 718ec0be | malc | #define MP_MISC_BASE 0x80002000 |
23 | 718ec0be | malc | #define MP_MISC_SIZE 0x00001000 |
24 | 718ec0be | malc | |
25 | 24859b68 | balrog | #define MP_ETH_BASE 0x80008000 |
26 | 24859b68 | balrog | #define MP_ETH_SIZE 0x00001000 |
27 | 24859b68 | balrog | |
28 | 718ec0be | malc | #define MP_WLAN_BASE 0x8000C000 |
29 | 718ec0be | malc | #define MP_WLAN_SIZE 0x00000800 |
30 | 718ec0be | malc | |
31 | 24859b68 | balrog | #define MP_UART1_BASE 0x8000C840 |
32 | 24859b68 | balrog | #define MP_UART2_BASE 0x8000C940 |
33 | 24859b68 | balrog | |
34 | 718ec0be | malc | #define MP_GPIO_BASE 0x8000D000 |
35 | 718ec0be | malc | #define MP_GPIO_SIZE 0x00001000 |
36 | 718ec0be | malc | |
37 | 24859b68 | balrog | #define MP_FLASHCFG_BASE 0x90006000 |
38 | 24859b68 | balrog | #define MP_FLASHCFG_SIZE 0x00001000 |
39 | 24859b68 | balrog | |
40 | 24859b68 | balrog | #define MP_AUDIO_BASE 0x90007000 |
41 | 24859b68 | balrog | |
42 | 24859b68 | balrog | #define MP_PIC_BASE 0x90008000 |
43 | 24859b68 | balrog | #define MP_PIC_SIZE 0x00001000 |
44 | 24859b68 | balrog | |
45 | 24859b68 | balrog | #define MP_PIT_BASE 0x90009000 |
46 | 24859b68 | balrog | #define MP_PIT_SIZE 0x00001000 |
47 | 24859b68 | balrog | |
48 | 24859b68 | balrog | #define MP_LCD_BASE 0x9000c000 |
49 | 24859b68 | balrog | #define MP_LCD_SIZE 0x00001000 |
50 | 24859b68 | balrog | |
51 | 24859b68 | balrog | #define MP_SRAM_BASE 0xC0000000 |
52 | 24859b68 | balrog | #define MP_SRAM_SIZE 0x00020000 |
53 | 24859b68 | balrog | |
54 | 24859b68 | balrog | #define MP_RAM_DEFAULT_SIZE 32*1024*1024 |
55 | 24859b68 | balrog | #define MP_FLASH_SIZE_MAX 32*1024*1024 |
56 | 24859b68 | balrog | |
57 | 24859b68 | balrog | #define MP_TIMER1_IRQ 4 |
58 | b47b50fa | Paul Brook | #define MP_TIMER2_IRQ 5 |
59 | b47b50fa | Paul Brook | #define MP_TIMER3_IRQ 6 |
60 | 24859b68 | balrog | #define MP_TIMER4_IRQ 7 |
61 | 24859b68 | balrog | #define MP_EHCI_IRQ 8 |
62 | 24859b68 | balrog | #define MP_ETH_IRQ 9 |
63 | 24859b68 | balrog | #define MP_UART1_IRQ 11 |
64 | 24859b68 | balrog | #define MP_UART2_IRQ 11 |
65 | 24859b68 | balrog | #define MP_GPIO_IRQ 12 |
66 | 24859b68 | balrog | #define MP_RTC_IRQ 28 |
67 | 24859b68 | balrog | #define MP_AUDIO_IRQ 30 |
68 | 24859b68 | balrog | |
69 | 24859b68 | balrog | /* Wolfson 8750 I2C address */
|
70 | 24859b68 | balrog | #define MP_WM_ADDR 0x34 |
71 | 24859b68 | balrog | |
72 | 24859b68 | balrog | /* Ethernet register offsets */
|
73 | 24859b68 | balrog | #define MP_ETH_SMIR 0x010 |
74 | 24859b68 | balrog | #define MP_ETH_PCXR 0x408 |
75 | 24859b68 | balrog | #define MP_ETH_SDCMR 0x448 |
76 | 24859b68 | balrog | #define MP_ETH_ICR 0x450 |
77 | 24859b68 | balrog | #define MP_ETH_IMR 0x458 |
78 | 24859b68 | balrog | #define MP_ETH_FRDP0 0x480 |
79 | 24859b68 | balrog | #define MP_ETH_FRDP1 0x484 |
80 | 24859b68 | balrog | #define MP_ETH_FRDP2 0x488 |
81 | 24859b68 | balrog | #define MP_ETH_FRDP3 0x48C |
82 | 24859b68 | balrog | #define MP_ETH_CRDP0 0x4A0 |
83 | 24859b68 | balrog | #define MP_ETH_CRDP1 0x4A4 |
84 | 24859b68 | balrog | #define MP_ETH_CRDP2 0x4A8 |
85 | 24859b68 | balrog | #define MP_ETH_CRDP3 0x4AC |
86 | 24859b68 | balrog | #define MP_ETH_CTDP0 0x4E0 |
87 | 24859b68 | balrog | #define MP_ETH_CTDP1 0x4E4 |
88 | 24859b68 | balrog | #define MP_ETH_CTDP2 0x4E8 |
89 | 24859b68 | balrog | #define MP_ETH_CTDP3 0x4EC |
90 | 24859b68 | balrog | |
91 | 24859b68 | balrog | /* MII PHY access */
|
92 | 24859b68 | balrog | #define MP_ETH_SMIR_DATA 0x0000FFFF |
93 | 24859b68 | balrog | #define MP_ETH_SMIR_ADDR 0x03FF0000 |
94 | 24859b68 | balrog | #define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */ |
95 | 24859b68 | balrog | #define MP_ETH_SMIR_RDVALID (1 << 27) |
96 | 24859b68 | balrog | |
97 | 24859b68 | balrog | /* PHY registers */
|
98 | 24859b68 | balrog | #define MP_ETH_PHY1_BMSR 0x00210000 |
99 | 24859b68 | balrog | #define MP_ETH_PHY1_PHYSID1 0x00410000 |
100 | 24859b68 | balrog | #define MP_ETH_PHY1_PHYSID2 0x00610000 |
101 | 24859b68 | balrog | |
102 | 24859b68 | balrog | #define MP_PHY_BMSR_LINK 0x0004 |
103 | 24859b68 | balrog | #define MP_PHY_BMSR_AUTONEG 0x0008 |
104 | 24859b68 | balrog | |
105 | 24859b68 | balrog | #define MP_PHY_88E3015 0x01410E20 |
106 | 24859b68 | balrog | |
107 | 24859b68 | balrog | /* TX descriptor status */
|
108 | 24859b68 | balrog | #define MP_ETH_TX_OWN (1 << 31) |
109 | 24859b68 | balrog | |
110 | 24859b68 | balrog | /* RX descriptor status */
|
111 | 24859b68 | balrog | #define MP_ETH_RX_OWN (1 << 31) |
112 | 24859b68 | balrog | |
113 | 24859b68 | balrog | /* Interrupt cause/mask bits */
|
114 | 24859b68 | balrog | #define MP_ETH_IRQ_RX_BIT 0 |
115 | 24859b68 | balrog | #define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT) |
116 | 24859b68 | balrog | #define MP_ETH_IRQ_TXHI_BIT 2 |
117 | 24859b68 | balrog | #define MP_ETH_IRQ_TXLO_BIT 3 |
118 | 24859b68 | balrog | |
119 | 24859b68 | balrog | /* Port config bits */
|
120 | 24859b68 | balrog | #define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */ |
121 | 24859b68 | balrog | |
122 | 24859b68 | balrog | /* SDMA command bits */
|
123 | 24859b68 | balrog | #define MP_ETH_CMD_TXHI (1 << 23) |
124 | 24859b68 | balrog | #define MP_ETH_CMD_TXLO (1 << 22) |
125 | 24859b68 | balrog | |
126 | 24859b68 | balrog | typedef struct mv88w8618_tx_desc { |
127 | 24859b68 | balrog | uint32_t cmdstat; |
128 | 24859b68 | balrog | uint16_t res; |
129 | 24859b68 | balrog | uint16_t bytes; |
130 | 24859b68 | balrog | uint32_t buffer; |
131 | 24859b68 | balrog | uint32_t next; |
132 | 24859b68 | balrog | } mv88w8618_tx_desc; |
133 | 24859b68 | balrog | |
134 | 24859b68 | balrog | typedef struct mv88w8618_rx_desc { |
135 | 24859b68 | balrog | uint32_t cmdstat; |
136 | 24859b68 | balrog | uint16_t bytes; |
137 | 24859b68 | balrog | uint16_t buffer_size; |
138 | 24859b68 | balrog | uint32_t buffer; |
139 | 24859b68 | balrog | uint32_t next; |
140 | 24859b68 | balrog | } mv88w8618_rx_desc; |
141 | 24859b68 | balrog | |
142 | 24859b68 | balrog | typedef struct mv88w8618_eth_state { |
143 | b47b50fa | Paul Brook | SysBusDevice busdev; |
144 | 24859b68 | balrog | qemu_irq irq; |
145 | 24859b68 | balrog | uint32_t smir; |
146 | 24859b68 | balrog | uint32_t icr; |
147 | 24859b68 | balrog | uint32_t imr; |
148 | b946a153 | aliguori | int mmio_index;
|
149 | d5b61ddd | Jan Kiszka | uint32_t vlan_header; |
150 | 930c8682 | pbrook | uint32_t tx_queue[2];
|
151 | 930c8682 | pbrook | uint32_t rx_queue[4];
|
152 | 930c8682 | pbrook | uint32_t frx_queue[4];
|
153 | 930c8682 | pbrook | uint32_t cur_rx[4];
|
154 | 24859b68 | balrog | VLANClientState *vc; |
155 | 4c91cd28 | Gerd Hoffmann | NICConf conf; |
156 | 24859b68 | balrog | } mv88w8618_eth_state; |
157 | 24859b68 | balrog | |
158 | 930c8682 | pbrook | static void eth_rx_desc_put(uint32_t addr, mv88w8618_rx_desc *desc) |
159 | 930c8682 | pbrook | { |
160 | 930c8682 | pbrook | cpu_to_le32s(&desc->cmdstat); |
161 | 930c8682 | pbrook | cpu_to_le16s(&desc->bytes); |
162 | 930c8682 | pbrook | cpu_to_le16s(&desc->buffer_size); |
163 | 930c8682 | pbrook | cpu_to_le32s(&desc->buffer); |
164 | 930c8682 | pbrook | cpu_to_le32s(&desc->next); |
165 | 930c8682 | pbrook | cpu_physical_memory_write(addr, (void *)desc, sizeof(*desc)); |
166 | 930c8682 | pbrook | } |
167 | 930c8682 | pbrook | |
168 | 930c8682 | pbrook | static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc) |
169 | 930c8682 | pbrook | { |
170 | 930c8682 | pbrook | cpu_physical_memory_read(addr, (void *)desc, sizeof(*desc)); |
171 | 930c8682 | pbrook | le32_to_cpus(&desc->cmdstat); |
172 | 930c8682 | pbrook | le16_to_cpus(&desc->bytes); |
173 | 930c8682 | pbrook | le16_to_cpus(&desc->buffer_size); |
174 | 930c8682 | pbrook | le32_to_cpus(&desc->buffer); |
175 | 930c8682 | pbrook | le32_to_cpus(&desc->next); |
176 | 930c8682 | pbrook | } |
177 | 930c8682 | pbrook | |
178 | e3f5ec2b | Mark McLoughlin | static int eth_can_receive(VLANClientState *vc) |
179 | 24859b68 | balrog | { |
180 | 24859b68 | balrog | return 1; |
181 | 24859b68 | balrog | } |
182 | 24859b68 | balrog | |
183 | 4f1c942b | Mark McLoughlin | static ssize_t eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size) |
184 | 24859b68 | balrog | { |
185 | e3f5ec2b | Mark McLoughlin | mv88w8618_eth_state *s = vc->opaque; |
186 | 930c8682 | pbrook | uint32_t desc_addr; |
187 | 930c8682 | pbrook | mv88w8618_rx_desc desc; |
188 | 24859b68 | balrog | int i;
|
189 | 24859b68 | balrog | |
190 | 24859b68 | balrog | for (i = 0; i < 4; i++) { |
191 | 930c8682 | pbrook | desc_addr = s->cur_rx[i]; |
192 | 49fedd0d | Jan Kiszka | if (!desc_addr) {
|
193 | 24859b68 | balrog | continue;
|
194 | 49fedd0d | Jan Kiszka | } |
195 | 24859b68 | balrog | do {
|
196 | 930c8682 | pbrook | eth_rx_desc_get(desc_addr, &desc); |
197 | 930c8682 | pbrook | if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
|
198 | 930c8682 | pbrook | cpu_physical_memory_write(desc.buffer + s->vlan_header, |
199 | 930c8682 | pbrook | buf, size); |
200 | 930c8682 | pbrook | desc.bytes = size + s->vlan_header; |
201 | 930c8682 | pbrook | desc.cmdstat &= ~MP_ETH_RX_OWN; |
202 | 930c8682 | pbrook | s->cur_rx[i] = desc.next; |
203 | 24859b68 | balrog | |
204 | 24859b68 | balrog | s->icr |= MP_ETH_IRQ_RX; |
205 | 49fedd0d | Jan Kiszka | if (s->icr & s->imr) {
|
206 | 24859b68 | balrog | qemu_irq_raise(s->irq); |
207 | 49fedd0d | Jan Kiszka | } |
208 | 930c8682 | pbrook | eth_rx_desc_put(desc_addr, &desc); |
209 | 4f1c942b | Mark McLoughlin | return size;
|
210 | 24859b68 | balrog | } |
211 | 930c8682 | pbrook | desc_addr = desc.next; |
212 | 930c8682 | pbrook | } while (desc_addr != s->rx_queue[i]);
|
213 | 24859b68 | balrog | } |
214 | 4f1c942b | Mark McLoughlin | return size;
|
215 | 24859b68 | balrog | } |
216 | 24859b68 | balrog | |
217 | 930c8682 | pbrook | static void eth_tx_desc_put(uint32_t addr, mv88w8618_tx_desc *desc) |
218 | 930c8682 | pbrook | { |
219 | 930c8682 | pbrook | cpu_to_le32s(&desc->cmdstat); |
220 | 930c8682 | pbrook | cpu_to_le16s(&desc->res); |
221 | 930c8682 | pbrook | cpu_to_le16s(&desc->bytes); |
222 | 930c8682 | pbrook | cpu_to_le32s(&desc->buffer); |
223 | 930c8682 | pbrook | cpu_to_le32s(&desc->next); |
224 | 930c8682 | pbrook | cpu_physical_memory_write(addr, (void *)desc, sizeof(*desc)); |
225 | 930c8682 | pbrook | } |
226 | 930c8682 | pbrook | |
227 | 930c8682 | pbrook | static void eth_tx_desc_get(uint32_t addr, mv88w8618_tx_desc *desc) |
228 | 930c8682 | pbrook | { |
229 | 930c8682 | pbrook | cpu_physical_memory_read(addr, (void *)desc, sizeof(*desc)); |
230 | 930c8682 | pbrook | le32_to_cpus(&desc->cmdstat); |
231 | 930c8682 | pbrook | le16_to_cpus(&desc->res); |
232 | 930c8682 | pbrook | le16_to_cpus(&desc->bytes); |
233 | 930c8682 | pbrook | le32_to_cpus(&desc->buffer); |
234 | 930c8682 | pbrook | le32_to_cpus(&desc->next); |
235 | 930c8682 | pbrook | } |
236 | 930c8682 | pbrook | |
237 | 24859b68 | balrog | static void eth_send(mv88w8618_eth_state *s, int queue_index) |
238 | 24859b68 | balrog | { |
239 | 930c8682 | pbrook | uint32_t desc_addr = s->tx_queue[queue_index]; |
240 | 930c8682 | pbrook | mv88w8618_tx_desc desc; |
241 | 930c8682 | pbrook | uint8_t buf[2048];
|
242 | 930c8682 | pbrook | int len;
|
243 | 930c8682 | pbrook | |
244 | 2e87c5b9 | Jan Kiszka | if (!desc_addr) {
|
245 | 2e87c5b9 | Jan Kiszka | return;
|
246 | 2e87c5b9 | Jan Kiszka | } |
247 | 24859b68 | balrog | do {
|
248 | 930c8682 | pbrook | eth_tx_desc_get(desc_addr, &desc); |
249 | 930c8682 | pbrook | if (desc.cmdstat & MP_ETH_TX_OWN) {
|
250 | 930c8682 | pbrook | len = desc.bytes; |
251 | 930c8682 | pbrook | if (len < 2048) { |
252 | 930c8682 | pbrook | cpu_physical_memory_read(desc.buffer, buf, len); |
253 | 930c8682 | pbrook | qemu_send_packet(s->vc, buf, len); |
254 | 930c8682 | pbrook | } |
255 | 930c8682 | pbrook | desc.cmdstat &= ~MP_ETH_TX_OWN; |
256 | 24859b68 | balrog | s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
|
257 | 930c8682 | pbrook | eth_tx_desc_put(desc_addr, &desc); |
258 | 24859b68 | balrog | } |
259 | 930c8682 | pbrook | desc_addr = desc.next; |
260 | 930c8682 | pbrook | } while (desc_addr != s->tx_queue[queue_index]);
|
261 | 24859b68 | balrog | } |
262 | 24859b68 | balrog | |
263 | c227f099 | Anthony Liguori | static uint32_t mv88w8618_eth_read(void *opaque, target_phys_addr_t offset) |
264 | 24859b68 | balrog | { |
265 | 24859b68 | balrog | mv88w8618_eth_state *s = opaque; |
266 | 24859b68 | balrog | |
267 | 24859b68 | balrog | switch (offset) {
|
268 | 24859b68 | balrog | case MP_ETH_SMIR:
|
269 | 24859b68 | balrog | if (s->smir & MP_ETH_SMIR_OPCODE) {
|
270 | 24859b68 | balrog | switch (s->smir & MP_ETH_SMIR_ADDR) {
|
271 | 24859b68 | balrog | case MP_ETH_PHY1_BMSR:
|
272 | 24859b68 | balrog | return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
|
273 | 24859b68 | balrog | MP_ETH_SMIR_RDVALID; |
274 | 24859b68 | balrog | case MP_ETH_PHY1_PHYSID1:
|
275 | 24859b68 | balrog | return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID; |
276 | 24859b68 | balrog | case MP_ETH_PHY1_PHYSID2:
|
277 | 24859b68 | balrog | return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID; |
278 | 24859b68 | balrog | default:
|
279 | 24859b68 | balrog | return MP_ETH_SMIR_RDVALID;
|
280 | 24859b68 | balrog | } |
281 | 24859b68 | balrog | } |
282 | 24859b68 | balrog | return 0; |
283 | 24859b68 | balrog | |
284 | 24859b68 | balrog | case MP_ETH_ICR:
|
285 | 24859b68 | balrog | return s->icr;
|
286 | 24859b68 | balrog | |
287 | 24859b68 | balrog | case MP_ETH_IMR:
|
288 | 24859b68 | balrog | return s->imr;
|
289 | 24859b68 | balrog | |
290 | 24859b68 | balrog | case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
|
291 | 930c8682 | pbrook | return s->frx_queue[(offset - MP_ETH_FRDP0)/4]; |
292 | 24859b68 | balrog | |
293 | 24859b68 | balrog | case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
|
294 | 930c8682 | pbrook | return s->rx_queue[(offset - MP_ETH_CRDP0)/4]; |
295 | 24859b68 | balrog | |
296 | 24859b68 | balrog | case MP_ETH_CTDP0 ... MP_ETH_CTDP3:
|
297 | 930c8682 | pbrook | return s->tx_queue[(offset - MP_ETH_CTDP0)/4]; |
298 | 24859b68 | balrog | |
299 | 24859b68 | balrog | default:
|
300 | 24859b68 | balrog | return 0; |
301 | 24859b68 | balrog | } |
302 | 24859b68 | balrog | } |
303 | 24859b68 | balrog | |
304 | c227f099 | Anthony Liguori | static void mv88w8618_eth_write(void *opaque, target_phys_addr_t offset, |
305 | 24859b68 | balrog | uint32_t value) |
306 | 24859b68 | balrog | { |
307 | 24859b68 | balrog | mv88w8618_eth_state *s = opaque; |
308 | 24859b68 | balrog | |
309 | 24859b68 | balrog | switch (offset) {
|
310 | 24859b68 | balrog | case MP_ETH_SMIR:
|
311 | 24859b68 | balrog | s->smir = value; |
312 | 24859b68 | balrog | break;
|
313 | 24859b68 | balrog | |
314 | 24859b68 | balrog | case MP_ETH_PCXR:
|
315 | 24859b68 | balrog | s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2; |
316 | 24859b68 | balrog | break;
|
317 | 24859b68 | balrog | |
318 | 24859b68 | balrog | case MP_ETH_SDCMR:
|
319 | 49fedd0d | Jan Kiszka | if (value & MP_ETH_CMD_TXHI) {
|
320 | 24859b68 | balrog | eth_send(s, 1);
|
321 | 49fedd0d | Jan Kiszka | } |
322 | 49fedd0d | Jan Kiszka | if (value & MP_ETH_CMD_TXLO) {
|
323 | 24859b68 | balrog | eth_send(s, 0);
|
324 | 49fedd0d | Jan Kiszka | } |
325 | 49fedd0d | Jan Kiszka | if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) {
|
326 | 24859b68 | balrog | qemu_irq_raise(s->irq); |
327 | 49fedd0d | Jan Kiszka | } |
328 | 24859b68 | balrog | break;
|
329 | 24859b68 | balrog | |
330 | 24859b68 | balrog | case MP_ETH_ICR:
|
331 | 24859b68 | balrog | s->icr &= value; |
332 | 24859b68 | balrog | break;
|
333 | 24859b68 | balrog | |
334 | 24859b68 | balrog | case MP_ETH_IMR:
|
335 | 24859b68 | balrog | s->imr = value; |
336 | 49fedd0d | Jan Kiszka | if (s->icr & s->imr) {
|
337 | 24859b68 | balrog | qemu_irq_raise(s->irq); |
338 | 49fedd0d | Jan Kiszka | } |
339 | 24859b68 | balrog | break;
|
340 | 24859b68 | balrog | |
341 | 24859b68 | balrog | case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
|
342 | 930c8682 | pbrook | s->frx_queue[(offset - MP_ETH_FRDP0)/4] = value;
|
343 | 24859b68 | balrog | break;
|
344 | 24859b68 | balrog | |
345 | 24859b68 | balrog | case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
|
346 | 24859b68 | balrog | s->rx_queue[(offset - MP_ETH_CRDP0)/4] =
|
347 | 930c8682 | pbrook | s->cur_rx[(offset - MP_ETH_CRDP0)/4] = value;
|
348 | 24859b68 | balrog | break;
|
349 | 24859b68 | balrog | |
350 | 24859b68 | balrog | case MP_ETH_CTDP0 ... MP_ETH_CTDP3:
|
351 | 930c8682 | pbrook | s->tx_queue[(offset - MP_ETH_CTDP0)/4] = value;
|
352 | 24859b68 | balrog | break;
|
353 | 24859b68 | balrog | } |
354 | 24859b68 | balrog | } |
355 | 24859b68 | balrog | |
356 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const mv88w8618_eth_readfn[] = { |
357 | 24859b68 | balrog | mv88w8618_eth_read, |
358 | 24859b68 | balrog | mv88w8618_eth_read, |
359 | 24859b68 | balrog | mv88w8618_eth_read |
360 | 24859b68 | balrog | }; |
361 | 24859b68 | balrog | |
362 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const mv88w8618_eth_writefn[] = { |
363 | 24859b68 | balrog | mv88w8618_eth_write, |
364 | 24859b68 | balrog | mv88w8618_eth_write, |
365 | 24859b68 | balrog | mv88w8618_eth_write |
366 | 24859b68 | balrog | }; |
367 | 24859b68 | balrog | |
368 | b946a153 | aliguori | static void eth_cleanup(VLANClientState *vc) |
369 | b946a153 | aliguori | { |
370 | b946a153 | aliguori | mv88w8618_eth_state *s = vc->opaque; |
371 | b946a153 | aliguori | |
372 | 4c91cd28 | Gerd Hoffmann | s->vc = NULL;
|
373 | b946a153 | aliguori | } |
374 | b946a153 | aliguori | |
375 | 81a322d4 | Gerd Hoffmann | static int mv88w8618_eth_init(SysBusDevice *dev) |
376 | 24859b68 | balrog | { |
377 | b47b50fa | Paul Brook | mv88w8618_eth_state *s = FROM_SYSBUS(mv88w8618_eth_state, dev); |
378 | 0ae18cee | aliguori | |
379 | b47b50fa | Paul Brook | sysbus_init_irq(dev, &s->irq); |
380 | 4c91cd28 | Gerd Hoffmann | s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, |
381 | 4c91cd28 | Gerd Hoffmann | s->conf.vlan, s->conf.peer, |
382 | 4c91cd28 | Gerd Hoffmann | dev->qdev.info->name, dev->qdev.id, |
383 | 463af534 | Mark McLoughlin | eth_can_receive, eth_receive, NULL,
|
384 | 4c91cd28 | Gerd Hoffmann | NULL, eth_cleanup, s);
|
385 | 1eed09cb | Avi Kivity | s->mmio_index = cpu_register_io_memory(mv88w8618_eth_readfn, |
386 | b946a153 | aliguori | mv88w8618_eth_writefn, s); |
387 | b47b50fa | Paul Brook | sysbus_init_mmio(dev, MP_ETH_SIZE, s->mmio_index); |
388 | 81a322d4 | Gerd Hoffmann | return 0; |
389 | 24859b68 | balrog | } |
390 | 24859b68 | balrog | |
391 | d5b61ddd | Jan Kiszka | static const VMStateDescription mv88w8618_eth_vmsd = { |
392 | d5b61ddd | Jan Kiszka | .name = "mv88w8618_eth",
|
393 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
394 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
395 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
396 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
397 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(smir, mv88w8618_eth_state), |
398 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(icr, mv88w8618_eth_state), |
399 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(imr, mv88w8618_eth_state), |
400 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(vlan_header, mv88w8618_eth_state), |
401 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2),
|
402 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4),
|
403 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4),
|
404 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4),
|
405 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
406 | d5b61ddd | Jan Kiszka | } |
407 | d5b61ddd | Jan Kiszka | }; |
408 | d5b61ddd | Jan Kiszka | |
409 | d5b61ddd | Jan Kiszka | static SysBusDeviceInfo mv88w8618_eth_info = {
|
410 | d5b61ddd | Jan Kiszka | .init = mv88w8618_eth_init, |
411 | d5b61ddd | Jan Kiszka | .qdev.name = "mv88w8618_eth",
|
412 | d5b61ddd | Jan Kiszka | .qdev.size = sizeof(mv88w8618_eth_state),
|
413 | d5b61ddd | Jan Kiszka | .qdev.vmsd = &mv88w8618_eth_vmsd, |
414 | 4c91cd28 | Gerd Hoffmann | .qdev.props = (Property[]) { |
415 | 4c91cd28 | Gerd Hoffmann | DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf), |
416 | 4c91cd28 | Gerd Hoffmann | DEFINE_PROP_END_OF_LIST(), |
417 | 4c91cd28 | Gerd Hoffmann | }, |
418 | d5b61ddd | Jan Kiszka | }; |
419 | d5b61ddd | Jan Kiszka | |
420 | 24859b68 | balrog | /* LCD register offsets */
|
421 | 24859b68 | balrog | #define MP_LCD_IRQCTRL 0x180 |
422 | 24859b68 | balrog | #define MP_LCD_IRQSTAT 0x184 |
423 | 24859b68 | balrog | #define MP_LCD_SPICTRL 0x1ac |
424 | 24859b68 | balrog | #define MP_LCD_INST 0x1bc |
425 | 24859b68 | balrog | #define MP_LCD_DATA 0x1c0 |
426 | 24859b68 | balrog | |
427 | 24859b68 | balrog | /* Mode magics */
|
428 | 24859b68 | balrog | #define MP_LCD_SPI_DATA 0x00100011 |
429 | 24859b68 | balrog | #define MP_LCD_SPI_CMD 0x00104011 |
430 | 24859b68 | balrog | #define MP_LCD_SPI_INVALID 0x00000000 |
431 | 24859b68 | balrog | |
432 | 24859b68 | balrog | /* Commmands */
|
433 | 24859b68 | balrog | #define MP_LCD_INST_SETPAGE0 0xB0 |
434 | 24859b68 | balrog | /* ... */
|
435 | 24859b68 | balrog | #define MP_LCD_INST_SETPAGE7 0xB7 |
436 | 24859b68 | balrog | |
437 | 24859b68 | balrog | #define MP_LCD_TEXTCOLOR 0xe0e0ff /* RRGGBB */ |
438 | 24859b68 | balrog | |
439 | 24859b68 | balrog | typedef struct musicpal_lcd_state { |
440 | b47b50fa | Paul Brook | SysBusDevice busdev; |
441 | 343ec8e4 | Benoit Canet | uint32_t brightness; |
442 | 24859b68 | balrog | uint32_t mode; |
443 | 24859b68 | balrog | uint32_t irqctrl; |
444 | d5b61ddd | Jan Kiszka | uint32_t page; |
445 | d5b61ddd | Jan Kiszka | uint32_t page_off; |
446 | 24859b68 | balrog | DisplayState *ds; |
447 | 24859b68 | balrog | uint8_t video_ram[128*64/8]; |
448 | 24859b68 | balrog | } musicpal_lcd_state; |
449 | 24859b68 | balrog | |
450 | 343ec8e4 | Benoit Canet | static uint8_t scale_lcd_color(musicpal_lcd_state *s, uint8_t col)
|
451 | 24859b68 | balrog | { |
452 | 343ec8e4 | Benoit Canet | switch (s->brightness) {
|
453 | 343ec8e4 | Benoit Canet | case 7: |
454 | 343ec8e4 | Benoit Canet | return col;
|
455 | 343ec8e4 | Benoit Canet | case 0: |
456 | 24859b68 | balrog | return 0; |
457 | 24859b68 | balrog | default:
|
458 | 343ec8e4 | Benoit Canet | return (col * s->brightness) / 7; |
459 | 24859b68 | balrog | } |
460 | 24859b68 | balrog | } |
461 | 24859b68 | balrog | |
462 | 0266f2c7 | balrog | #define SET_LCD_PIXEL(depth, type) \
|
463 | 0266f2c7 | balrog | static inline void glue(set_lcd_pixel, depth) \ |
464 | 0266f2c7 | balrog | (musicpal_lcd_state *s, int x, int y, type col) \ |
465 | 0266f2c7 | balrog | { \ |
466 | 0266f2c7 | balrog | int dx, dy; \
|
467 | 0e1f5a0c | aliguori | type *pixel = &((type *) ds_get_data(s->ds))[(y * 128 * 3 + x) * 3]; \ |
468 | 0266f2c7 | balrog | \ |
469 | 0266f2c7 | balrog | for (dy = 0; dy < 3; dy++, pixel += 127 * 3) \ |
470 | 0266f2c7 | balrog | for (dx = 0; dx < 3; dx++, pixel++) \ |
471 | 0266f2c7 | balrog | *pixel = col; \ |
472 | 24859b68 | balrog | } |
473 | 0266f2c7 | balrog | SET_LCD_PIXEL(8, uint8_t)
|
474 | 0266f2c7 | balrog | SET_LCD_PIXEL(16, uint16_t)
|
475 | 0266f2c7 | balrog | SET_LCD_PIXEL(32, uint32_t)
|
476 | 0266f2c7 | balrog | |
477 | 0266f2c7 | balrog | #include "pixel_ops.h" |
478 | 24859b68 | balrog | |
479 | 24859b68 | balrog | static void lcd_refresh(void *opaque) |
480 | 24859b68 | balrog | { |
481 | 24859b68 | balrog | musicpal_lcd_state *s = opaque; |
482 | 0266f2c7 | balrog | int x, y, col;
|
483 | 24859b68 | balrog | |
484 | 0e1f5a0c | aliguori | switch (ds_get_bits_per_pixel(s->ds)) {
|
485 | 0266f2c7 | balrog | case 0: |
486 | 0266f2c7 | balrog | return;
|
487 | 0266f2c7 | balrog | #define LCD_REFRESH(depth, func) \
|
488 | 0266f2c7 | balrog | case depth: \
|
489 | 343ec8e4 | Benoit Canet | col = func(scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 16) & 0xff), \ |
490 | 343ec8e4 | Benoit Canet | scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 8) & 0xff), \ |
491 | 343ec8e4 | Benoit Canet | scale_lcd_color(s, MP_LCD_TEXTCOLOR & 0xff)); \
|
492 | 49fedd0d | Jan Kiszka | for (x = 0; x < 128; x++) { \ |
493 | 49fedd0d | Jan Kiszka | for (y = 0; y < 64; y++) { \ |
494 | 49fedd0d | Jan Kiszka | if (s->video_ram[x + (y/8)*128] & (1 << (y % 8))) { \ |
495 | 0266f2c7 | balrog | glue(set_lcd_pixel, depth)(s, x, y, col); \ |
496 | 49fedd0d | Jan Kiszka | } else { \
|
497 | 0266f2c7 | balrog | glue(set_lcd_pixel, depth)(s, x, y, 0); \
|
498 | 49fedd0d | Jan Kiszka | } \ |
499 | 49fedd0d | Jan Kiszka | } \ |
500 | 49fedd0d | Jan Kiszka | } \ |
501 | 0266f2c7 | balrog | break;
|
502 | 0266f2c7 | balrog | LCD_REFRESH(8, rgb_to_pixel8)
|
503 | 0266f2c7 | balrog | LCD_REFRESH(16, rgb_to_pixel16)
|
504 | bf9b48af | aliguori | LCD_REFRESH(32, (is_surface_bgr(s->ds->surface) ?
|
505 | bf9b48af | aliguori | rgb_to_pixel32bgr : rgb_to_pixel32)) |
506 | 0266f2c7 | balrog | default:
|
507 | 2ac71179 | Paul Brook | hw_error("unsupported colour depth %i\n",
|
508 | 0e1f5a0c | aliguori | ds_get_bits_per_pixel(s->ds)); |
509 | 0266f2c7 | balrog | } |
510 | 24859b68 | balrog | |
511 | 24859b68 | balrog | dpy_update(s->ds, 0, 0, 128*3, 64*3); |
512 | 24859b68 | balrog | } |
513 | 24859b68 | balrog | |
514 | 167bc3d2 | balrog | static void lcd_invalidate(void *opaque) |
515 | 167bc3d2 | balrog | { |
516 | 167bc3d2 | balrog | } |
517 | 167bc3d2 | balrog | |
518 | 343ec8e4 | Benoit Canet | static void musicpal_lcd_gpio_brigthness_in(void *opaque, int irq, int level) |
519 | 343ec8e4 | Benoit Canet | { |
520 | 243cd13c | Jan Kiszka | musicpal_lcd_state *s = opaque; |
521 | 343ec8e4 | Benoit Canet | s->brightness &= ~(1 << irq);
|
522 | 343ec8e4 | Benoit Canet | s->brightness |= level << irq; |
523 | 343ec8e4 | Benoit Canet | } |
524 | 343ec8e4 | Benoit Canet | |
525 | c227f099 | Anthony Liguori | static uint32_t musicpal_lcd_read(void *opaque, target_phys_addr_t offset) |
526 | 24859b68 | balrog | { |
527 | 24859b68 | balrog | musicpal_lcd_state *s = opaque; |
528 | 24859b68 | balrog | |
529 | 24859b68 | balrog | switch (offset) {
|
530 | 24859b68 | balrog | case MP_LCD_IRQCTRL:
|
531 | 24859b68 | balrog | return s->irqctrl;
|
532 | 24859b68 | balrog | |
533 | 24859b68 | balrog | default:
|
534 | 24859b68 | balrog | return 0; |
535 | 24859b68 | balrog | } |
536 | 24859b68 | balrog | } |
537 | 24859b68 | balrog | |
538 | c227f099 | Anthony Liguori | static void musicpal_lcd_write(void *opaque, target_phys_addr_t offset, |
539 | 24859b68 | balrog | uint32_t value) |
540 | 24859b68 | balrog | { |
541 | 24859b68 | balrog | musicpal_lcd_state *s = opaque; |
542 | 24859b68 | balrog | |
543 | 24859b68 | balrog | switch (offset) {
|
544 | 24859b68 | balrog | case MP_LCD_IRQCTRL:
|
545 | 24859b68 | balrog | s->irqctrl = value; |
546 | 24859b68 | balrog | break;
|
547 | 24859b68 | balrog | |
548 | 24859b68 | balrog | case MP_LCD_SPICTRL:
|
549 | 49fedd0d | Jan Kiszka | if (value == MP_LCD_SPI_DATA || value == MP_LCD_SPI_CMD) {
|
550 | 24859b68 | balrog | s->mode = value; |
551 | 49fedd0d | Jan Kiszka | } else {
|
552 | 24859b68 | balrog | s->mode = MP_LCD_SPI_INVALID; |
553 | 49fedd0d | Jan Kiszka | } |
554 | 24859b68 | balrog | break;
|
555 | 24859b68 | balrog | |
556 | 24859b68 | balrog | case MP_LCD_INST:
|
557 | 24859b68 | balrog | if (value >= MP_LCD_INST_SETPAGE0 && value <= MP_LCD_INST_SETPAGE7) {
|
558 | 24859b68 | balrog | s->page = value - MP_LCD_INST_SETPAGE0; |
559 | 24859b68 | balrog | s->page_off = 0;
|
560 | 24859b68 | balrog | } |
561 | 24859b68 | balrog | break;
|
562 | 24859b68 | balrog | |
563 | 24859b68 | balrog | case MP_LCD_DATA:
|
564 | 24859b68 | balrog | if (s->mode == MP_LCD_SPI_CMD) {
|
565 | 24859b68 | balrog | if (value >= MP_LCD_INST_SETPAGE0 &&
|
566 | 24859b68 | balrog | value <= MP_LCD_INST_SETPAGE7) { |
567 | 24859b68 | balrog | s->page = value - MP_LCD_INST_SETPAGE0; |
568 | 24859b68 | balrog | s->page_off = 0;
|
569 | 24859b68 | balrog | } |
570 | 24859b68 | balrog | } else if (s->mode == MP_LCD_SPI_DATA) { |
571 | 24859b68 | balrog | s->video_ram[s->page*128 + s->page_off] = value;
|
572 | 24859b68 | balrog | s->page_off = (s->page_off + 1) & 127; |
573 | 24859b68 | balrog | } |
574 | 24859b68 | balrog | break;
|
575 | 24859b68 | balrog | } |
576 | 24859b68 | balrog | } |
577 | 24859b68 | balrog | |
578 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const musicpal_lcd_readfn[] = { |
579 | 24859b68 | balrog | musicpal_lcd_read, |
580 | 24859b68 | balrog | musicpal_lcd_read, |
581 | 24859b68 | balrog | musicpal_lcd_read |
582 | 24859b68 | balrog | }; |
583 | 24859b68 | balrog | |
584 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const musicpal_lcd_writefn[] = { |
585 | 24859b68 | balrog | musicpal_lcd_write, |
586 | 24859b68 | balrog | musicpal_lcd_write, |
587 | 24859b68 | balrog | musicpal_lcd_write |
588 | 24859b68 | balrog | }; |
589 | 24859b68 | balrog | |
590 | 81a322d4 | Gerd Hoffmann | static int musicpal_lcd_init(SysBusDevice *dev) |
591 | 24859b68 | balrog | { |
592 | b47b50fa | Paul Brook | musicpal_lcd_state *s = FROM_SYSBUS(musicpal_lcd_state, dev); |
593 | 24859b68 | balrog | int iomemtype;
|
594 | 24859b68 | balrog | |
595 | 343ec8e4 | Benoit Canet | s->brightness = 7;
|
596 | 343ec8e4 | Benoit Canet | |
597 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(musicpal_lcd_readfn, |
598 | 24859b68 | balrog | musicpal_lcd_writefn, s); |
599 | b47b50fa | Paul Brook | sysbus_init_mmio(dev, MP_LCD_SIZE, iomemtype); |
600 | 24859b68 | balrog | |
601 | 3023f332 | aliguori | s->ds = graphic_console_init(lcd_refresh, lcd_invalidate, |
602 | 3023f332 | aliguori | NULL, NULL, s); |
603 | 3023f332 | aliguori | qemu_console_resize(s->ds, 128*3, 64*3); |
604 | 343ec8e4 | Benoit Canet | |
605 | 343ec8e4 | Benoit Canet | qdev_init_gpio_in(&dev->qdev, musicpal_lcd_gpio_brigthness_in, 3);
|
606 | 81a322d4 | Gerd Hoffmann | |
607 | 81a322d4 | Gerd Hoffmann | return 0; |
608 | 24859b68 | balrog | } |
609 | 24859b68 | balrog | |
610 | d5b61ddd | Jan Kiszka | static const VMStateDescription musicpal_lcd_vmsd = { |
611 | d5b61ddd | Jan Kiszka | .name = "musicpal_lcd",
|
612 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
613 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
614 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
615 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
616 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(brightness, musicpal_lcd_state), |
617 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(mode, musicpal_lcd_state), |
618 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(irqctrl, musicpal_lcd_state), |
619 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(page, musicpal_lcd_state), |
620 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(page_off, musicpal_lcd_state), |
621 | d5b61ddd | Jan Kiszka | VMSTATE_BUFFER(video_ram, musicpal_lcd_state), |
622 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
623 | d5b61ddd | Jan Kiszka | } |
624 | d5b61ddd | Jan Kiszka | }; |
625 | d5b61ddd | Jan Kiszka | |
626 | d5b61ddd | Jan Kiszka | static SysBusDeviceInfo musicpal_lcd_info = {
|
627 | d5b61ddd | Jan Kiszka | .init = musicpal_lcd_init, |
628 | d5b61ddd | Jan Kiszka | .qdev.name = "musicpal_lcd",
|
629 | d5b61ddd | Jan Kiszka | .qdev.size = sizeof(musicpal_lcd_state),
|
630 | d5b61ddd | Jan Kiszka | .qdev.vmsd = &musicpal_lcd_vmsd, |
631 | d5b61ddd | Jan Kiszka | }; |
632 | d5b61ddd | Jan Kiszka | |
633 | 24859b68 | balrog | /* PIC register offsets */
|
634 | 24859b68 | balrog | #define MP_PIC_STATUS 0x00 |
635 | 24859b68 | balrog | #define MP_PIC_ENABLE_SET 0x08 |
636 | 24859b68 | balrog | #define MP_PIC_ENABLE_CLR 0x0C |
637 | 24859b68 | balrog | |
638 | 24859b68 | balrog | typedef struct mv88w8618_pic_state |
639 | 24859b68 | balrog | { |
640 | b47b50fa | Paul Brook | SysBusDevice busdev; |
641 | 24859b68 | balrog | uint32_t level; |
642 | 24859b68 | balrog | uint32_t enabled; |
643 | 24859b68 | balrog | qemu_irq parent_irq; |
644 | 24859b68 | balrog | } mv88w8618_pic_state; |
645 | 24859b68 | balrog | |
646 | 24859b68 | balrog | static void mv88w8618_pic_update(mv88w8618_pic_state *s) |
647 | 24859b68 | balrog | { |
648 | 24859b68 | balrog | qemu_set_irq(s->parent_irq, (s->level & s->enabled)); |
649 | 24859b68 | balrog | } |
650 | 24859b68 | balrog | |
651 | 24859b68 | balrog | static void mv88w8618_pic_set_irq(void *opaque, int irq, int level) |
652 | 24859b68 | balrog | { |
653 | 24859b68 | balrog | mv88w8618_pic_state *s = opaque; |
654 | 24859b68 | balrog | |
655 | 49fedd0d | Jan Kiszka | if (level) {
|
656 | 24859b68 | balrog | s->level |= 1 << irq;
|
657 | 49fedd0d | Jan Kiszka | } else {
|
658 | 24859b68 | balrog | s->level &= ~(1 << irq);
|
659 | 49fedd0d | Jan Kiszka | } |
660 | 24859b68 | balrog | mv88w8618_pic_update(s); |
661 | 24859b68 | balrog | } |
662 | 24859b68 | balrog | |
663 | c227f099 | Anthony Liguori | static uint32_t mv88w8618_pic_read(void *opaque, target_phys_addr_t offset) |
664 | 24859b68 | balrog | { |
665 | 24859b68 | balrog | mv88w8618_pic_state *s = opaque; |
666 | 24859b68 | balrog | |
667 | 24859b68 | balrog | switch (offset) {
|
668 | 24859b68 | balrog | case MP_PIC_STATUS:
|
669 | 24859b68 | balrog | return s->level & s->enabled;
|
670 | 24859b68 | balrog | |
671 | 24859b68 | balrog | default:
|
672 | 24859b68 | balrog | return 0; |
673 | 24859b68 | balrog | } |
674 | 24859b68 | balrog | } |
675 | 24859b68 | balrog | |
676 | c227f099 | Anthony Liguori | static void mv88w8618_pic_write(void *opaque, target_phys_addr_t offset, |
677 | 24859b68 | balrog | uint32_t value) |
678 | 24859b68 | balrog | { |
679 | 24859b68 | balrog | mv88w8618_pic_state *s = opaque; |
680 | 24859b68 | balrog | |
681 | 24859b68 | balrog | switch (offset) {
|
682 | 24859b68 | balrog | case MP_PIC_ENABLE_SET:
|
683 | 24859b68 | balrog | s->enabled |= value; |
684 | 24859b68 | balrog | break;
|
685 | 24859b68 | balrog | |
686 | 24859b68 | balrog | case MP_PIC_ENABLE_CLR:
|
687 | 24859b68 | balrog | s->enabled &= ~value; |
688 | 24859b68 | balrog | s->level &= ~value; |
689 | 24859b68 | balrog | break;
|
690 | 24859b68 | balrog | } |
691 | 24859b68 | balrog | mv88w8618_pic_update(s); |
692 | 24859b68 | balrog | } |
693 | 24859b68 | balrog | |
694 | d5b61ddd | Jan Kiszka | static void mv88w8618_pic_reset(DeviceState *d) |
695 | 24859b68 | balrog | { |
696 | d5b61ddd | Jan Kiszka | mv88w8618_pic_state *s = FROM_SYSBUS(mv88w8618_pic_state, |
697 | d5b61ddd | Jan Kiszka | sysbus_from_qdev(d)); |
698 | 24859b68 | balrog | |
699 | 24859b68 | balrog | s->level = 0;
|
700 | 24859b68 | balrog | s->enabled = 0;
|
701 | 24859b68 | balrog | } |
702 | 24859b68 | balrog | |
703 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const mv88w8618_pic_readfn[] = { |
704 | 24859b68 | balrog | mv88w8618_pic_read, |
705 | 24859b68 | balrog | mv88w8618_pic_read, |
706 | 24859b68 | balrog | mv88w8618_pic_read |
707 | 24859b68 | balrog | }; |
708 | 24859b68 | balrog | |
709 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const mv88w8618_pic_writefn[] = { |
710 | 24859b68 | balrog | mv88w8618_pic_write, |
711 | 24859b68 | balrog | mv88w8618_pic_write, |
712 | 24859b68 | balrog | mv88w8618_pic_write |
713 | 24859b68 | balrog | }; |
714 | 24859b68 | balrog | |
715 | 81a322d4 | Gerd Hoffmann | static int mv88w8618_pic_init(SysBusDevice *dev) |
716 | 24859b68 | balrog | { |
717 | b47b50fa | Paul Brook | mv88w8618_pic_state *s = FROM_SYSBUS(mv88w8618_pic_state, dev); |
718 | 24859b68 | balrog | int iomemtype;
|
719 | 24859b68 | balrog | |
720 | 067a3ddc | Paul Brook | qdev_init_gpio_in(&dev->qdev, mv88w8618_pic_set_irq, 32);
|
721 | b47b50fa | Paul Brook | sysbus_init_irq(dev, &s->parent_irq); |
722 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(mv88w8618_pic_readfn, |
723 | 24859b68 | balrog | mv88w8618_pic_writefn, s); |
724 | b47b50fa | Paul Brook | sysbus_init_mmio(dev, MP_PIC_SIZE, iomemtype); |
725 | 81a322d4 | Gerd Hoffmann | return 0; |
726 | 24859b68 | balrog | } |
727 | 24859b68 | balrog | |
728 | d5b61ddd | Jan Kiszka | static const VMStateDescription mv88w8618_pic_vmsd = { |
729 | d5b61ddd | Jan Kiszka | .name = "mv88w8618_pic",
|
730 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
731 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
732 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
733 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
734 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(level, mv88w8618_pic_state), |
735 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(enabled, mv88w8618_pic_state), |
736 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
737 | d5b61ddd | Jan Kiszka | } |
738 | d5b61ddd | Jan Kiszka | }; |
739 | d5b61ddd | Jan Kiszka | |
740 | d5b61ddd | Jan Kiszka | static SysBusDeviceInfo mv88w8618_pic_info = {
|
741 | d5b61ddd | Jan Kiszka | .init = mv88w8618_pic_init, |
742 | d5b61ddd | Jan Kiszka | .qdev.name = "mv88w8618_pic",
|
743 | d5b61ddd | Jan Kiszka | .qdev.size = sizeof(mv88w8618_pic_state),
|
744 | d5b61ddd | Jan Kiszka | .qdev.reset = mv88w8618_pic_reset, |
745 | d5b61ddd | Jan Kiszka | .qdev.vmsd = &mv88w8618_pic_vmsd, |
746 | d5b61ddd | Jan Kiszka | }; |
747 | d5b61ddd | Jan Kiszka | |
748 | 24859b68 | balrog | /* PIT register offsets */
|
749 | 24859b68 | balrog | #define MP_PIT_TIMER1_LENGTH 0x00 |
750 | 24859b68 | balrog | /* ... */
|
751 | 24859b68 | balrog | #define MP_PIT_TIMER4_LENGTH 0x0C |
752 | 24859b68 | balrog | #define MP_PIT_CONTROL 0x10 |
753 | 24859b68 | balrog | #define MP_PIT_TIMER1_VALUE 0x14 |
754 | 24859b68 | balrog | /* ... */
|
755 | 24859b68 | balrog | #define MP_PIT_TIMER4_VALUE 0x20 |
756 | 24859b68 | balrog | #define MP_BOARD_RESET 0x34 |
757 | 24859b68 | balrog | |
758 | 24859b68 | balrog | /* Magic board reset value (probably some watchdog behind it) */
|
759 | 24859b68 | balrog | #define MP_BOARD_RESET_MAGIC 0x10000 |
760 | 24859b68 | balrog | |
761 | 24859b68 | balrog | typedef struct mv88w8618_timer_state { |
762 | b47b50fa | Paul Brook | ptimer_state *ptimer; |
763 | 24859b68 | balrog | uint32_t limit; |
764 | 24859b68 | balrog | int freq;
|
765 | 24859b68 | balrog | qemu_irq irq; |
766 | 24859b68 | balrog | } mv88w8618_timer_state; |
767 | 24859b68 | balrog | |
768 | 24859b68 | balrog | typedef struct mv88w8618_pit_state { |
769 | b47b50fa | Paul Brook | SysBusDevice busdev; |
770 | b47b50fa | Paul Brook | mv88w8618_timer_state timer[4];
|
771 | 24859b68 | balrog | } mv88w8618_pit_state; |
772 | 24859b68 | balrog | |
773 | 24859b68 | balrog | static void mv88w8618_timer_tick(void *opaque) |
774 | 24859b68 | balrog | { |
775 | 24859b68 | balrog | mv88w8618_timer_state *s = opaque; |
776 | 24859b68 | balrog | |
777 | 24859b68 | balrog | qemu_irq_raise(s->irq); |
778 | 24859b68 | balrog | } |
779 | 24859b68 | balrog | |
780 | b47b50fa | Paul Brook | static void mv88w8618_timer_init(SysBusDevice *dev, mv88w8618_timer_state *s, |
781 | b47b50fa | Paul Brook | uint32_t freq) |
782 | 24859b68 | balrog | { |
783 | 24859b68 | balrog | QEMUBH *bh; |
784 | 24859b68 | balrog | |
785 | b47b50fa | Paul Brook | sysbus_init_irq(dev, &s->irq); |
786 | 24859b68 | balrog | s->freq = freq; |
787 | 24859b68 | balrog | |
788 | 24859b68 | balrog | bh = qemu_bh_new(mv88w8618_timer_tick, s); |
789 | b47b50fa | Paul Brook | s->ptimer = ptimer_init(bh); |
790 | 24859b68 | balrog | } |
791 | 24859b68 | balrog | |
792 | c227f099 | Anthony Liguori | static uint32_t mv88w8618_pit_read(void *opaque, target_phys_addr_t offset) |
793 | 24859b68 | balrog | { |
794 | 24859b68 | balrog | mv88w8618_pit_state *s = opaque; |
795 | 24859b68 | balrog | mv88w8618_timer_state *t; |
796 | 24859b68 | balrog | |
797 | 24859b68 | balrog | switch (offset) {
|
798 | 24859b68 | balrog | case MP_PIT_TIMER1_VALUE ... MP_PIT_TIMER4_VALUE:
|
799 | b47b50fa | Paul Brook | t = &s->timer[(offset-MP_PIT_TIMER1_VALUE) >> 2];
|
800 | b47b50fa | Paul Brook | return ptimer_get_count(t->ptimer);
|
801 | 24859b68 | balrog | |
802 | 24859b68 | balrog | default:
|
803 | 24859b68 | balrog | return 0; |
804 | 24859b68 | balrog | } |
805 | 24859b68 | balrog | } |
806 | 24859b68 | balrog | |
807 | c227f099 | Anthony Liguori | static void mv88w8618_pit_write(void *opaque, target_phys_addr_t offset, |
808 | 24859b68 | balrog | uint32_t value) |
809 | 24859b68 | balrog | { |
810 | 24859b68 | balrog | mv88w8618_pit_state *s = opaque; |
811 | 24859b68 | balrog | mv88w8618_timer_state *t; |
812 | 24859b68 | balrog | int i;
|
813 | 24859b68 | balrog | |
814 | 24859b68 | balrog | switch (offset) {
|
815 | 24859b68 | balrog | case MP_PIT_TIMER1_LENGTH ... MP_PIT_TIMER4_LENGTH:
|
816 | b47b50fa | Paul Brook | t = &s->timer[offset >> 2];
|
817 | 24859b68 | balrog | t->limit = value; |
818 | c88d6bde | Jan Kiszka | if (t->limit > 0) { |
819 | c88d6bde | Jan Kiszka | ptimer_set_limit(t->ptimer, t->limit, 1);
|
820 | c88d6bde | Jan Kiszka | } else {
|
821 | c88d6bde | Jan Kiszka | ptimer_stop(t->ptimer); |
822 | c88d6bde | Jan Kiszka | } |
823 | 24859b68 | balrog | break;
|
824 | 24859b68 | balrog | |
825 | 24859b68 | balrog | case MP_PIT_CONTROL:
|
826 | 24859b68 | balrog | for (i = 0; i < 4; i++) { |
827 | c88d6bde | Jan Kiszka | t = &s->timer[i]; |
828 | c88d6bde | Jan Kiszka | if (value & 0xf && t->limit > 0) { |
829 | b47b50fa | Paul Brook | ptimer_set_limit(t->ptimer, t->limit, 0);
|
830 | b47b50fa | Paul Brook | ptimer_set_freq(t->ptimer, t->freq); |
831 | b47b50fa | Paul Brook | ptimer_run(t->ptimer, 0);
|
832 | c88d6bde | Jan Kiszka | } else {
|
833 | c88d6bde | Jan Kiszka | ptimer_stop(t->ptimer); |
834 | 24859b68 | balrog | } |
835 | 24859b68 | balrog | value >>= 4;
|
836 | 24859b68 | balrog | } |
837 | 24859b68 | balrog | break;
|
838 | 24859b68 | balrog | |
839 | 24859b68 | balrog | case MP_BOARD_RESET:
|
840 | 49fedd0d | Jan Kiszka | if (value == MP_BOARD_RESET_MAGIC) {
|
841 | 24859b68 | balrog | qemu_system_reset_request(); |
842 | 49fedd0d | Jan Kiszka | } |
843 | 24859b68 | balrog | break;
|
844 | 24859b68 | balrog | } |
845 | 24859b68 | balrog | } |
846 | 24859b68 | balrog | |
847 | d5b61ddd | Jan Kiszka | static void mv88w8618_pit_reset(DeviceState *d) |
848 | c88d6bde | Jan Kiszka | { |
849 | d5b61ddd | Jan Kiszka | mv88w8618_pit_state *s = FROM_SYSBUS(mv88w8618_pit_state, |
850 | d5b61ddd | Jan Kiszka | sysbus_from_qdev(d)); |
851 | c88d6bde | Jan Kiszka | int i;
|
852 | c88d6bde | Jan Kiszka | |
853 | c88d6bde | Jan Kiszka | for (i = 0; i < 4; i++) { |
854 | c88d6bde | Jan Kiszka | ptimer_stop(s->timer[i].ptimer); |
855 | c88d6bde | Jan Kiszka | s->timer[i].limit = 0;
|
856 | c88d6bde | Jan Kiszka | } |
857 | c88d6bde | Jan Kiszka | } |
858 | c88d6bde | Jan Kiszka | |
859 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const mv88w8618_pit_readfn[] = { |
860 | 24859b68 | balrog | mv88w8618_pit_read, |
861 | 24859b68 | balrog | mv88w8618_pit_read, |
862 | 24859b68 | balrog | mv88w8618_pit_read |
863 | 24859b68 | balrog | }; |
864 | 24859b68 | balrog | |
865 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const mv88w8618_pit_writefn[] = { |
866 | 24859b68 | balrog | mv88w8618_pit_write, |
867 | 24859b68 | balrog | mv88w8618_pit_write, |
868 | 24859b68 | balrog | mv88w8618_pit_write |
869 | 24859b68 | balrog | }; |
870 | 24859b68 | balrog | |
871 | 81a322d4 | Gerd Hoffmann | static int mv88w8618_pit_init(SysBusDevice *dev) |
872 | 24859b68 | balrog | { |
873 | 24859b68 | balrog | int iomemtype;
|
874 | b47b50fa | Paul Brook | mv88w8618_pit_state *s = FROM_SYSBUS(mv88w8618_pit_state, dev); |
875 | b47b50fa | Paul Brook | int i;
|
876 | 24859b68 | balrog | |
877 | 24859b68 | balrog | /* Letting them all run at 1 MHz is likely just a pragmatic
|
878 | 24859b68 | balrog | * simplification. */
|
879 | b47b50fa | Paul Brook | for (i = 0; i < 4; i++) { |
880 | b47b50fa | Paul Brook | mv88w8618_timer_init(dev, &s->timer[i], 1000000);
|
881 | b47b50fa | Paul Brook | } |
882 | 24859b68 | balrog | |
883 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(mv88w8618_pit_readfn, |
884 | 24859b68 | balrog | mv88w8618_pit_writefn, s); |
885 | b47b50fa | Paul Brook | sysbus_init_mmio(dev, MP_PIT_SIZE, iomemtype); |
886 | 81a322d4 | Gerd Hoffmann | return 0; |
887 | 24859b68 | balrog | } |
888 | 24859b68 | balrog | |
889 | d5b61ddd | Jan Kiszka | static const VMStateDescription mv88w8618_timer_vmsd = { |
890 | d5b61ddd | Jan Kiszka | .name = "timer",
|
891 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
892 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
893 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
894 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
895 | d5b61ddd | Jan Kiszka | VMSTATE_PTIMER(ptimer, mv88w8618_timer_state), |
896 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(limit, mv88w8618_timer_state), |
897 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
898 | d5b61ddd | Jan Kiszka | } |
899 | d5b61ddd | Jan Kiszka | }; |
900 | d5b61ddd | Jan Kiszka | |
901 | d5b61ddd | Jan Kiszka | static const VMStateDescription mv88w8618_pit_vmsd = { |
902 | d5b61ddd | Jan Kiszka | .name = "mv88w8618_pit",
|
903 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
904 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
905 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
906 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
907 | d5b61ddd | Jan Kiszka | VMSTATE_STRUCT_ARRAY(timer, mv88w8618_pit_state, 4, 1, |
908 | d5b61ddd | Jan Kiszka | mv88w8618_timer_vmsd, mv88w8618_timer_state), |
909 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
910 | d5b61ddd | Jan Kiszka | } |
911 | d5b61ddd | Jan Kiszka | }; |
912 | d5b61ddd | Jan Kiszka | |
913 | c88d6bde | Jan Kiszka | static SysBusDeviceInfo mv88w8618_pit_info = {
|
914 | c88d6bde | Jan Kiszka | .init = mv88w8618_pit_init, |
915 | c88d6bde | Jan Kiszka | .qdev.name = "mv88w8618_pit",
|
916 | c88d6bde | Jan Kiszka | .qdev.size = sizeof(mv88w8618_pit_state),
|
917 | c88d6bde | Jan Kiszka | .qdev.reset = mv88w8618_pit_reset, |
918 | d5b61ddd | Jan Kiszka | .qdev.vmsd = &mv88w8618_pit_vmsd, |
919 | c88d6bde | Jan Kiszka | }; |
920 | c88d6bde | Jan Kiszka | |
921 | 24859b68 | balrog | /* Flash config register offsets */
|
922 | 24859b68 | balrog | #define MP_FLASHCFG_CFGR0 0x04 |
923 | 24859b68 | balrog | |
924 | 24859b68 | balrog | typedef struct mv88w8618_flashcfg_state { |
925 | b47b50fa | Paul Brook | SysBusDevice busdev; |
926 | 24859b68 | balrog | uint32_t cfgr0; |
927 | 24859b68 | balrog | } mv88w8618_flashcfg_state; |
928 | 24859b68 | balrog | |
929 | 24859b68 | balrog | static uint32_t mv88w8618_flashcfg_read(void *opaque, |
930 | c227f099 | Anthony Liguori | target_phys_addr_t offset) |
931 | 24859b68 | balrog | { |
932 | 24859b68 | balrog | mv88w8618_flashcfg_state *s = opaque; |
933 | 24859b68 | balrog | |
934 | 24859b68 | balrog | switch (offset) {
|
935 | 24859b68 | balrog | case MP_FLASHCFG_CFGR0:
|
936 | 24859b68 | balrog | return s->cfgr0;
|
937 | 24859b68 | balrog | |
938 | 24859b68 | balrog | default:
|
939 | 24859b68 | balrog | return 0; |
940 | 24859b68 | balrog | } |
941 | 24859b68 | balrog | } |
942 | 24859b68 | balrog | |
943 | c227f099 | Anthony Liguori | static void mv88w8618_flashcfg_write(void *opaque, target_phys_addr_t offset, |
944 | 24859b68 | balrog | uint32_t value) |
945 | 24859b68 | balrog | { |
946 | 24859b68 | balrog | mv88w8618_flashcfg_state *s = opaque; |
947 | 24859b68 | balrog | |
948 | 24859b68 | balrog | switch (offset) {
|
949 | 24859b68 | balrog | case MP_FLASHCFG_CFGR0:
|
950 | 24859b68 | balrog | s->cfgr0 = value; |
951 | 24859b68 | balrog | break;
|
952 | 24859b68 | balrog | } |
953 | 24859b68 | balrog | } |
954 | 24859b68 | balrog | |
955 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const mv88w8618_flashcfg_readfn[] = { |
956 | 24859b68 | balrog | mv88w8618_flashcfg_read, |
957 | 24859b68 | balrog | mv88w8618_flashcfg_read, |
958 | 24859b68 | balrog | mv88w8618_flashcfg_read |
959 | 24859b68 | balrog | }; |
960 | 24859b68 | balrog | |
961 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const mv88w8618_flashcfg_writefn[] = { |
962 | 24859b68 | balrog | mv88w8618_flashcfg_write, |
963 | 24859b68 | balrog | mv88w8618_flashcfg_write, |
964 | 24859b68 | balrog | mv88w8618_flashcfg_write |
965 | 24859b68 | balrog | }; |
966 | 24859b68 | balrog | |
967 | 81a322d4 | Gerd Hoffmann | static int mv88w8618_flashcfg_init(SysBusDevice *dev) |
968 | 24859b68 | balrog | { |
969 | 24859b68 | balrog | int iomemtype;
|
970 | b47b50fa | Paul Brook | mv88w8618_flashcfg_state *s = FROM_SYSBUS(mv88w8618_flashcfg_state, dev); |
971 | 24859b68 | balrog | |
972 | 24859b68 | balrog | s->cfgr0 = 0xfffe4285; /* Default as set by U-Boot for 8 MB flash */ |
973 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(mv88w8618_flashcfg_readfn, |
974 | 49fedd0d | Jan Kiszka | mv88w8618_flashcfg_writefn, s); |
975 | b47b50fa | Paul Brook | sysbus_init_mmio(dev, MP_FLASHCFG_SIZE, iomemtype); |
976 | 81a322d4 | Gerd Hoffmann | return 0; |
977 | 24859b68 | balrog | } |
978 | 24859b68 | balrog | |
979 | d5b61ddd | Jan Kiszka | static const VMStateDescription mv88w8618_flashcfg_vmsd = { |
980 | d5b61ddd | Jan Kiszka | .name = "mv88w8618_flashcfg",
|
981 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
982 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
983 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
984 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
985 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(cfgr0, mv88w8618_flashcfg_state), |
986 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
987 | d5b61ddd | Jan Kiszka | } |
988 | d5b61ddd | Jan Kiszka | }; |
989 | d5b61ddd | Jan Kiszka | |
990 | d5b61ddd | Jan Kiszka | static SysBusDeviceInfo mv88w8618_flashcfg_info = {
|
991 | d5b61ddd | Jan Kiszka | .init = mv88w8618_flashcfg_init, |
992 | d5b61ddd | Jan Kiszka | .qdev.name = "mv88w8618_flashcfg",
|
993 | d5b61ddd | Jan Kiszka | .qdev.size = sizeof(mv88w8618_flashcfg_state),
|
994 | d5b61ddd | Jan Kiszka | .qdev.vmsd = &mv88w8618_flashcfg_vmsd, |
995 | d5b61ddd | Jan Kiszka | }; |
996 | d5b61ddd | Jan Kiszka | |
997 | 718ec0be | malc | /* Misc register offsets */
|
998 | 718ec0be | malc | #define MP_MISC_BOARD_REVISION 0x18 |
999 | 718ec0be | malc | |
1000 | 718ec0be | malc | #define MP_BOARD_REVISION 0x31 |
1001 | 718ec0be | malc | |
1002 | c227f099 | Anthony Liguori | static uint32_t musicpal_misc_read(void *opaque, target_phys_addr_t offset) |
1003 | 718ec0be | malc | { |
1004 | 718ec0be | malc | switch (offset) {
|
1005 | 718ec0be | malc | case MP_MISC_BOARD_REVISION:
|
1006 | 718ec0be | malc | return MP_BOARD_REVISION;
|
1007 | 718ec0be | malc | |
1008 | 718ec0be | malc | default:
|
1009 | 718ec0be | malc | return 0; |
1010 | 718ec0be | malc | } |
1011 | 718ec0be | malc | } |
1012 | 718ec0be | malc | |
1013 | c227f099 | Anthony Liguori | static void musicpal_misc_write(void *opaque, target_phys_addr_t offset, |
1014 | 718ec0be | malc | uint32_t value) |
1015 | 718ec0be | malc | { |
1016 | 718ec0be | malc | } |
1017 | 718ec0be | malc | |
1018 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const musicpal_misc_readfn[] = { |
1019 | 718ec0be | malc | musicpal_misc_read, |
1020 | 718ec0be | malc | musicpal_misc_read, |
1021 | 718ec0be | malc | musicpal_misc_read, |
1022 | 718ec0be | malc | }; |
1023 | 718ec0be | malc | |
1024 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const musicpal_misc_writefn[] = { |
1025 | 718ec0be | malc | musicpal_misc_write, |
1026 | 718ec0be | malc | musicpal_misc_write, |
1027 | 718ec0be | malc | musicpal_misc_write, |
1028 | 718ec0be | malc | }; |
1029 | 718ec0be | malc | |
1030 | 718ec0be | malc | static void musicpal_misc_init(void) |
1031 | 718ec0be | malc | { |
1032 | 718ec0be | malc | int iomemtype;
|
1033 | 718ec0be | malc | |
1034 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(musicpal_misc_readfn, |
1035 | 718ec0be | malc | musicpal_misc_writefn, NULL);
|
1036 | 718ec0be | malc | cpu_register_physical_memory(MP_MISC_BASE, MP_MISC_SIZE, iomemtype); |
1037 | 718ec0be | malc | } |
1038 | 718ec0be | malc | |
1039 | 718ec0be | malc | /* WLAN register offsets */
|
1040 | 718ec0be | malc | #define MP_WLAN_MAGIC1 0x11c |
1041 | 718ec0be | malc | #define MP_WLAN_MAGIC2 0x124 |
1042 | 718ec0be | malc | |
1043 | c227f099 | Anthony Liguori | static uint32_t mv88w8618_wlan_read(void *opaque, target_phys_addr_t offset) |
1044 | 718ec0be | malc | { |
1045 | 718ec0be | malc | switch (offset) {
|
1046 | 718ec0be | malc | /* Workaround to allow loading the binary-only wlandrv.ko crap
|
1047 | 718ec0be | malc | * from the original Freecom firmware. */
|
1048 | 718ec0be | malc | case MP_WLAN_MAGIC1:
|
1049 | 718ec0be | malc | return ~3; |
1050 | 718ec0be | malc | case MP_WLAN_MAGIC2:
|
1051 | 718ec0be | malc | return -1; |
1052 | 718ec0be | malc | |
1053 | 718ec0be | malc | default:
|
1054 | 718ec0be | malc | return 0; |
1055 | 718ec0be | malc | } |
1056 | 718ec0be | malc | } |
1057 | 718ec0be | malc | |
1058 | c227f099 | Anthony Liguori | static void mv88w8618_wlan_write(void *opaque, target_phys_addr_t offset, |
1059 | 718ec0be | malc | uint32_t value) |
1060 | 718ec0be | malc | { |
1061 | 718ec0be | malc | } |
1062 | 718ec0be | malc | |
1063 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const mv88w8618_wlan_readfn[] = { |
1064 | 718ec0be | malc | mv88w8618_wlan_read, |
1065 | 718ec0be | malc | mv88w8618_wlan_read, |
1066 | 718ec0be | malc | mv88w8618_wlan_read, |
1067 | 718ec0be | malc | }; |
1068 | 718ec0be | malc | |
1069 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const mv88w8618_wlan_writefn[] = { |
1070 | 718ec0be | malc | mv88w8618_wlan_write, |
1071 | 718ec0be | malc | mv88w8618_wlan_write, |
1072 | 718ec0be | malc | mv88w8618_wlan_write, |
1073 | 718ec0be | malc | }; |
1074 | 718ec0be | malc | |
1075 | 81a322d4 | Gerd Hoffmann | static int mv88w8618_wlan_init(SysBusDevice *dev) |
1076 | 718ec0be | malc | { |
1077 | 718ec0be | malc | int iomemtype;
|
1078 | 24859b68 | balrog | |
1079 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(mv88w8618_wlan_readfn, |
1080 | 718ec0be | malc | mv88w8618_wlan_writefn, NULL);
|
1081 | b47b50fa | Paul Brook | sysbus_init_mmio(dev, MP_WLAN_SIZE, iomemtype); |
1082 | 81a322d4 | Gerd Hoffmann | return 0; |
1083 | 718ec0be | malc | } |
1084 | 24859b68 | balrog | |
1085 | 718ec0be | malc | /* GPIO register offsets */
|
1086 | 718ec0be | malc | #define MP_GPIO_OE_LO 0x008 |
1087 | 718ec0be | malc | #define MP_GPIO_OUT_LO 0x00c |
1088 | 718ec0be | malc | #define MP_GPIO_IN_LO 0x010 |
1089 | 708afdf3 | Jan Kiszka | #define MP_GPIO_IER_LO 0x014 |
1090 | 708afdf3 | Jan Kiszka | #define MP_GPIO_IMR_LO 0x018 |
1091 | 718ec0be | malc | #define MP_GPIO_ISR_LO 0x020 |
1092 | 718ec0be | malc | #define MP_GPIO_OE_HI 0x508 |
1093 | 718ec0be | malc | #define MP_GPIO_OUT_HI 0x50c |
1094 | 718ec0be | malc | #define MP_GPIO_IN_HI 0x510 |
1095 | 708afdf3 | Jan Kiszka | #define MP_GPIO_IER_HI 0x514 |
1096 | 708afdf3 | Jan Kiszka | #define MP_GPIO_IMR_HI 0x518 |
1097 | 718ec0be | malc | #define MP_GPIO_ISR_HI 0x520 |
1098 | 24859b68 | balrog | |
1099 | 24859b68 | balrog | /* GPIO bits & masks */
|
1100 | 24859b68 | balrog | #define MP_GPIO_LCD_BRIGHTNESS 0x00070000 |
1101 | 24859b68 | balrog | #define MP_GPIO_I2C_DATA_BIT 29 |
1102 | 24859b68 | balrog | #define MP_GPIO_I2C_CLOCK_BIT 30 |
1103 | 24859b68 | balrog | |
1104 | 24859b68 | balrog | /* LCD brightness bits in GPIO_OE_HI */
|
1105 | 24859b68 | balrog | #define MP_OE_LCD_BRIGHTNESS 0x0007 |
1106 | 24859b68 | balrog | |
1107 | 343ec8e4 | Benoit Canet | typedef struct musicpal_gpio_state { |
1108 | 343ec8e4 | Benoit Canet | SysBusDevice busdev; |
1109 | 343ec8e4 | Benoit Canet | uint32_t lcd_brightness; |
1110 | 343ec8e4 | Benoit Canet | uint32_t out_state; |
1111 | 343ec8e4 | Benoit Canet | uint32_t in_state; |
1112 | 708afdf3 | Jan Kiszka | uint32_t ier; |
1113 | 708afdf3 | Jan Kiszka | uint32_t imr; |
1114 | 343ec8e4 | Benoit Canet | uint32_t isr; |
1115 | 343ec8e4 | Benoit Canet | qemu_irq irq; |
1116 | 708afdf3 | Jan Kiszka | qemu_irq out[5]; /* 3 brightness out + 2 lcd (data and clock ) */ |
1117 | 343ec8e4 | Benoit Canet | } musicpal_gpio_state; |
1118 | 343ec8e4 | Benoit Canet | |
1119 | 343ec8e4 | Benoit Canet | static void musicpal_gpio_brightness_update(musicpal_gpio_state *s) { |
1120 | 343ec8e4 | Benoit Canet | int i;
|
1121 | 343ec8e4 | Benoit Canet | uint32_t brightness; |
1122 | 343ec8e4 | Benoit Canet | |
1123 | 343ec8e4 | Benoit Canet | /* compute brightness ratio */
|
1124 | 343ec8e4 | Benoit Canet | switch (s->lcd_brightness) {
|
1125 | 343ec8e4 | Benoit Canet | case 0x00000007: |
1126 | 343ec8e4 | Benoit Canet | brightness = 0;
|
1127 | 343ec8e4 | Benoit Canet | break;
|
1128 | 343ec8e4 | Benoit Canet | |
1129 | 343ec8e4 | Benoit Canet | case 0x00020000: |
1130 | 343ec8e4 | Benoit Canet | brightness = 1;
|
1131 | 343ec8e4 | Benoit Canet | break;
|
1132 | 343ec8e4 | Benoit Canet | |
1133 | 343ec8e4 | Benoit Canet | case 0x00020001: |
1134 | 343ec8e4 | Benoit Canet | brightness = 2;
|
1135 | 343ec8e4 | Benoit Canet | break;
|
1136 | 343ec8e4 | Benoit Canet | |
1137 | 343ec8e4 | Benoit Canet | case 0x00040000: |
1138 | 343ec8e4 | Benoit Canet | brightness = 3;
|
1139 | 343ec8e4 | Benoit Canet | break;
|
1140 | 343ec8e4 | Benoit Canet | |
1141 | 343ec8e4 | Benoit Canet | case 0x00010006: |
1142 | 343ec8e4 | Benoit Canet | brightness = 4;
|
1143 | 343ec8e4 | Benoit Canet | break;
|
1144 | 343ec8e4 | Benoit Canet | |
1145 | 343ec8e4 | Benoit Canet | case 0x00020005: |
1146 | 343ec8e4 | Benoit Canet | brightness = 5;
|
1147 | 343ec8e4 | Benoit Canet | break;
|
1148 | 343ec8e4 | Benoit Canet | |
1149 | 343ec8e4 | Benoit Canet | case 0x00040003: |
1150 | 343ec8e4 | Benoit Canet | brightness = 6;
|
1151 | 343ec8e4 | Benoit Canet | break;
|
1152 | 343ec8e4 | Benoit Canet | |
1153 | 343ec8e4 | Benoit Canet | case 0x00030004: |
1154 | 343ec8e4 | Benoit Canet | default:
|
1155 | 343ec8e4 | Benoit Canet | brightness = 7;
|
1156 | 343ec8e4 | Benoit Canet | } |
1157 | 343ec8e4 | Benoit Canet | |
1158 | 343ec8e4 | Benoit Canet | /* set lcd brightness GPIOs */
|
1159 | 49fedd0d | Jan Kiszka | for (i = 0; i <= 2; i++) { |
1160 | 343ec8e4 | Benoit Canet | qemu_set_irq(s->out[i], (brightness >> i) & 1);
|
1161 | 49fedd0d | Jan Kiszka | } |
1162 | 343ec8e4 | Benoit Canet | } |
1163 | 343ec8e4 | Benoit Canet | |
1164 | 708afdf3 | Jan Kiszka | static void musicpal_gpio_pin_event(void *opaque, int pin, int level) |
1165 | 343ec8e4 | Benoit Canet | { |
1166 | 243cd13c | Jan Kiszka | musicpal_gpio_state *s = opaque; |
1167 | 708afdf3 | Jan Kiszka | uint32_t mask = 1 << pin;
|
1168 | 708afdf3 | Jan Kiszka | uint32_t delta = level << pin; |
1169 | 708afdf3 | Jan Kiszka | uint32_t old = s->in_state & mask; |
1170 | 343ec8e4 | Benoit Canet | |
1171 | 708afdf3 | Jan Kiszka | s->in_state &= ~mask; |
1172 | 708afdf3 | Jan Kiszka | s->in_state |= delta; |
1173 | 343ec8e4 | Benoit Canet | |
1174 | 708afdf3 | Jan Kiszka | if ((old ^ delta) &&
|
1175 | 708afdf3 | Jan Kiszka | ((level && (s->imr & mask)) || (!level && (s->ier & mask)))) { |
1176 | 708afdf3 | Jan Kiszka | s->isr = mask; |
1177 | 708afdf3 | Jan Kiszka | qemu_irq_raise(s->irq); |
1178 | 343ec8e4 | Benoit Canet | } |
1179 | 343ec8e4 | Benoit Canet | } |
1180 | 343ec8e4 | Benoit Canet | |
1181 | c227f099 | Anthony Liguori | static uint32_t musicpal_gpio_read(void *opaque, target_phys_addr_t offset) |
1182 | 24859b68 | balrog | { |
1183 | 243cd13c | Jan Kiszka | musicpal_gpio_state *s = opaque; |
1184 | 343ec8e4 | Benoit Canet | |
1185 | 24859b68 | balrog | switch (offset) {
|
1186 | 24859b68 | balrog | case MP_GPIO_OE_HI: /* used for LCD brightness control */ |
1187 | 343ec8e4 | Benoit Canet | return s->lcd_brightness & MP_OE_LCD_BRIGHTNESS;
|
1188 | 24859b68 | balrog | |
1189 | 24859b68 | balrog | case MP_GPIO_OUT_LO:
|
1190 | 343ec8e4 | Benoit Canet | return s->out_state & 0xFFFF; |
1191 | 24859b68 | balrog | case MP_GPIO_OUT_HI:
|
1192 | 343ec8e4 | Benoit Canet | return s->out_state >> 16; |
1193 | 24859b68 | balrog | |
1194 | 24859b68 | balrog | case MP_GPIO_IN_LO:
|
1195 | 343ec8e4 | Benoit Canet | return s->in_state & 0xFFFF; |
1196 | 24859b68 | balrog | case MP_GPIO_IN_HI:
|
1197 | 343ec8e4 | Benoit Canet | return s->in_state >> 16; |
1198 | 24859b68 | balrog | |
1199 | 708afdf3 | Jan Kiszka | case MP_GPIO_IER_LO:
|
1200 | 708afdf3 | Jan Kiszka | return s->ier & 0xFFFF; |
1201 | 708afdf3 | Jan Kiszka | case MP_GPIO_IER_HI:
|
1202 | 708afdf3 | Jan Kiszka | return s->ier >> 16; |
1203 | 708afdf3 | Jan Kiszka | |
1204 | 708afdf3 | Jan Kiszka | case MP_GPIO_IMR_LO:
|
1205 | 708afdf3 | Jan Kiszka | return s->imr & 0xFFFF; |
1206 | 708afdf3 | Jan Kiszka | case MP_GPIO_IMR_HI:
|
1207 | 708afdf3 | Jan Kiszka | return s->imr >> 16; |
1208 | 708afdf3 | Jan Kiszka | |
1209 | 24859b68 | balrog | case MP_GPIO_ISR_LO:
|
1210 | 343ec8e4 | Benoit Canet | return s->isr & 0xFFFF; |
1211 | 24859b68 | balrog | case MP_GPIO_ISR_HI:
|
1212 | 343ec8e4 | Benoit Canet | return s->isr >> 16; |
1213 | 24859b68 | balrog | |
1214 | 24859b68 | balrog | default:
|
1215 | 24859b68 | balrog | return 0; |
1216 | 24859b68 | balrog | } |
1217 | 24859b68 | balrog | } |
1218 | 24859b68 | balrog | |
1219 | c227f099 | Anthony Liguori | static void musicpal_gpio_write(void *opaque, target_phys_addr_t offset, |
1220 | 718ec0be | malc | uint32_t value) |
1221 | 24859b68 | balrog | { |
1222 | 243cd13c | Jan Kiszka | musicpal_gpio_state *s = opaque; |
1223 | 24859b68 | balrog | switch (offset) {
|
1224 | 24859b68 | balrog | case MP_GPIO_OE_HI: /* used for LCD brightness control */ |
1225 | 343ec8e4 | Benoit Canet | s->lcd_brightness = (s->lcd_brightness & MP_GPIO_LCD_BRIGHTNESS) | |
1226 | 24859b68 | balrog | (value & MP_OE_LCD_BRIGHTNESS); |
1227 | 343ec8e4 | Benoit Canet | musicpal_gpio_brightness_update(s); |
1228 | 24859b68 | balrog | break;
|
1229 | 24859b68 | balrog | |
1230 | 24859b68 | balrog | case MP_GPIO_OUT_LO:
|
1231 | 343ec8e4 | Benoit Canet | s->out_state = (s->out_state & 0xFFFF0000) | (value & 0xFFFF); |
1232 | 24859b68 | balrog | break;
|
1233 | 24859b68 | balrog | case MP_GPIO_OUT_HI:
|
1234 | 343ec8e4 | Benoit Canet | s->out_state = (s->out_state & 0xFFFF) | (value << 16); |
1235 | 343ec8e4 | Benoit Canet | s->lcd_brightness = (s->lcd_brightness & 0xFFFF) |
|
1236 | 343ec8e4 | Benoit Canet | (s->out_state & MP_GPIO_LCD_BRIGHTNESS); |
1237 | 343ec8e4 | Benoit Canet | musicpal_gpio_brightness_update(s); |
1238 | d074769c | Andrzej Zaborowski | qemu_set_irq(s->out[3], (s->out_state >> MP_GPIO_I2C_DATA_BIT) & 1); |
1239 | d074769c | Andrzej Zaborowski | qemu_set_irq(s->out[4], (s->out_state >> MP_GPIO_I2C_CLOCK_BIT) & 1); |
1240 | 24859b68 | balrog | break;
|
1241 | 24859b68 | balrog | |
1242 | 708afdf3 | Jan Kiszka | case MP_GPIO_IER_LO:
|
1243 | 708afdf3 | Jan Kiszka | s->ier = (s->ier & 0xFFFF0000) | (value & 0xFFFF); |
1244 | 708afdf3 | Jan Kiszka | break;
|
1245 | 708afdf3 | Jan Kiszka | case MP_GPIO_IER_HI:
|
1246 | 708afdf3 | Jan Kiszka | s->ier = (s->ier & 0xFFFF) | (value << 16); |
1247 | 708afdf3 | Jan Kiszka | break;
|
1248 | 708afdf3 | Jan Kiszka | |
1249 | 708afdf3 | Jan Kiszka | case MP_GPIO_IMR_LO:
|
1250 | 708afdf3 | Jan Kiszka | s->imr = (s->imr & 0xFFFF0000) | (value & 0xFFFF); |
1251 | 708afdf3 | Jan Kiszka | break;
|
1252 | 708afdf3 | Jan Kiszka | case MP_GPIO_IMR_HI:
|
1253 | 708afdf3 | Jan Kiszka | s->imr = (s->imr & 0xFFFF) | (value << 16); |
1254 | 708afdf3 | Jan Kiszka | break;
|
1255 | 24859b68 | balrog | } |
1256 | 24859b68 | balrog | } |
1257 | 24859b68 | balrog | |
1258 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const musicpal_gpio_readfn[] = { |
1259 | 718ec0be | malc | musicpal_gpio_read, |
1260 | 718ec0be | malc | musicpal_gpio_read, |
1261 | 718ec0be | malc | musicpal_gpio_read, |
1262 | 718ec0be | malc | }; |
1263 | 718ec0be | malc | |
1264 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const musicpal_gpio_writefn[] = { |
1265 | 718ec0be | malc | musicpal_gpio_write, |
1266 | 718ec0be | malc | musicpal_gpio_write, |
1267 | 718ec0be | malc | musicpal_gpio_write, |
1268 | 718ec0be | malc | }; |
1269 | 718ec0be | malc | |
1270 | d5b61ddd | Jan Kiszka | static void musicpal_gpio_reset(DeviceState *d) |
1271 | 718ec0be | malc | { |
1272 | d5b61ddd | Jan Kiszka | musicpal_gpio_state *s = FROM_SYSBUS(musicpal_gpio_state, |
1273 | d5b61ddd | Jan Kiszka | sysbus_from_qdev(d)); |
1274 | 30624c92 | Jan Kiszka | |
1275 | 30624c92 | Jan Kiszka | s->lcd_brightness = 0;
|
1276 | 30624c92 | Jan Kiszka | s->out_state = 0;
|
1277 | 343ec8e4 | Benoit Canet | s->in_state = 0xffffffff;
|
1278 | 708afdf3 | Jan Kiszka | s->ier = 0;
|
1279 | 708afdf3 | Jan Kiszka | s->imr = 0;
|
1280 | 343ec8e4 | Benoit Canet | s->isr = 0;
|
1281 | 343ec8e4 | Benoit Canet | } |
1282 | 343ec8e4 | Benoit Canet | |
1283 | 81a322d4 | Gerd Hoffmann | static int musicpal_gpio_init(SysBusDevice *dev) |
1284 | 343ec8e4 | Benoit Canet | { |
1285 | 343ec8e4 | Benoit Canet | musicpal_gpio_state *s = FROM_SYSBUS(musicpal_gpio_state, dev); |
1286 | 718ec0be | malc | int iomemtype;
|
1287 | 718ec0be | malc | |
1288 | 343ec8e4 | Benoit Canet | sysbus_init_irq(dev, &s->irq); |
1289 | 343ec8e4 | Benoit Canet | |
1290 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(musicpal_gpio_readfn, |
1291 | 343ec8e4 | Benoit Canet | musicpal_gpio_writefn, s); |
1292 | 343ec8e4 | Benoit Canet | sysbus_init_mmio(dev, MP_GPIO_SIZE, iomemtype); |
1293 | 343ec8e4 | Benoit Canet | |
1294 | d5b61ddd | Jan Kiszka | musicpal_gpio_reset(&dev->qdev); |
1295 | 343ec8e4 | Benoit Canet | |
1296 | 708afdf3 | Jan Kiszka | qdev_init_gpio_out(&dev->qdev, s->out, ARRAY_SIZE(s->out)); |
1297 | 708afdf3 | Jan Kiszka | |
1298 | 708afdf3 | Jan Kiszka | qdev_init_gpio_in(&dev->qdev, musicpal_gpio_pin_event, 32);
|
1299 | 81a322d4 | Gerd Hoffmann | |
1300 | 81a322d4 | Gerd Hoffmann | return 0; |
1301 | 718ec0be | malc | } |
1302 | 718ec0be | malc | |
1303 | d5b61ddd | Jan Kiszka | static const VMStateDescription musicpal_gpio_vmsd = { |
1304 | d5b61ddd | Jan Kiszka | .name = "musicpal_gpio",
|
1305 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
1306 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
1307 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
1308 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
1309 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(lcd_brightness, musicpal_gpio_state), |
1310 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(out_state, musicpal_gpio_state), |
1311 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(in_state, musicpal_gpio_state), |
1312 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(ier, musicpal_gpio_state), |
1313 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(imr, musicpal_gpio_state), |
1314 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(isr, musicpal_gpio_state), |
1315 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
1316 | d5b61ddd | Jan Kiszka | } |
1317 | d5b61ddd | Jan Kiszka | }; |
1318 | d5b61ddd | Jan Kiszka | |
1319 | 30624c92 | Jan Kiszka | static SysBusDeviceInfo musicpal_gpio_info = {
|
1320 | 30624c92 | Jan Kiszka | .init = musicpal_gpio_init, |
1321 | 30624c92 | Jan Kiszka | .qdev.name = "musicpal_gpio",
|
1322 | 30624c92 | Jan Kiszka | .qdev.size = sizeof(musicpal_gpio_state),
|
1323 | 30624c92 | Jan Kiszka | .qdev.reset = musicpal_gpio_reset, |
1324 | d5b61ddd | Jan Kiszka | .qdev.vmsd = &musicpal_gpio_vmsd, |
1325 | 30624c92 | Jan Kiszka | }; |
1326 | 30624c92 | Jan Kiszka | |
1327 | 24859b68 | balrog | /* Keyboard codes & masks */
|
1328 | 7c6ce4ba | balrog | #define KEY_RELEASED 0x80 |
1329 | 24859b68 | balrog | #define KEY_CODE 0x7f |
1330 | 24859b68 | balrog | |
1331 | 24859b68 | balrog | #define KEYCODE_TAB 0x0f |
1332 | 24859b68 | balrog | #define KEYCODE_ENTER 0x1c |
1333 | 24859b68 | balrog | #define KEYCODE_F 0x21 |
1334 | 24859b68 | balrog | #define KEYCODE_M 0x32 |
1335 | 24859b68 | balrog | |
1336 | 24859b68 | balrog | #define KEYCODE_EXTENDED 0xe0 |
1337 | 24859b68 | balrog | #define KEYCODE_UP 0x48 |
1338 | 24859b68 | balrog | #define KEYCODE_DOWN 0x50 |
1339 | 24859b68 | balrog | #define KEYCODE_LEFT 0x4b |
1340 | 24859b68 | balrog | #define KEYCODE_RIGHT 0x4d |
1341 | 24859b68 | balrog | |
1342 | 708afdf3 | Jan Kiszka | #define MP_KEY_WHEEL_VOL (1 << 0) |
1343 | 343ec8e4 | Benoit Canet | #define MP_KEY_WHEEL_VOL_INV (1 << 1) |
1344 | 343ec8e4 | Benoit Canet | #define MP_KEY_WHEEL_NAV (1 << 2) |
1345 | 343ec8e4 | Benoit Canet | #define MP_KEY_WHEEL_NAV_INV (1 << 3) |
1346 | 343ec8e4 | Benoit Canet | #define MP_KEY_BTN_FAVORITS (1 << 4) |
1347 | 343ec8e4 | Benoit Canet | #define MP_KEY_BTN_MENU (1 << 5) |
1348 | 343ec8e4 | Benoit Canet | #define MP_KEY_BTN_VOLUME (1 << 6) |
1349 | 343ec8e4 | Benoit Canet | #define MP_KEY_BTN_NAVIGATION (1 << 7) |
1350 | 343ec8e4 | Benoit Canet | |
1351 | 343ec8e4 | Benoit Canet | typedef struct musicpal_key_state { |
1352 | 343ec8e4 | Benoit Canet | SysBusDevice busdev; |
1353 | 343ec8e4 | Benoit Canet | uint32_t kbd_extended; |
1354 | 708afdf3 | Jan Kiszka | uint32_t pressed_keys; |
1355 | 708afdf3 | Jan Kiszka | qemu_irq out[8];
|
1356 | 343ec8e4 | Benoit Canet | } musicpal_key_state; |
1357 | 343ec8e4 | Benoit Canet | |
1358 | 24859b68 | balrog | static void musicpal_key_event(void *opaque, int keycode) |
1359 | 24859b68 | balrog | { |
1360 | 243cd13c | Jan Kiszka | musicpal_key_state *s = opaque; |
1361 | 24859b68 | balrog | uint32_t event = 0;
|
1362 | 343ec8e4 | Benoit Canet | int i;
|
1363 | 24859b68 | balrog | |
1364 | 24859b68 | balrog | if (keycode == KEYCODE_EXTENDED) {
|
1365 | 343ec8e4 | Benoit Canet | s->kbd_extended = 1;
|
1366 | 24859b68 | balrog | return;
|
1367 | 24859b68 | balrog | } |
1368 | 24859b68 | balrog | |
1369 | 49fedd0d | Jan Kiszka | if (s->kbd_extended) {
|
1370 | 24859b68 | balrog | switch (keycode & KEY_CODE) {
|
1371 | 24859b68 | balrog | case KEYCODE_UP:
|
1372 | 343ec8e4 | Benoit Canet | event = MP_KEY_WHEEL_NAV | MP_KEY_WHEEL_NAV_INV; |
1373 | 24859b68 | balrog | break;
|
1374 | 24859b68 | balrog | |
1375 | 24859b68 | balrog | case KEYCODE_DOWN:
|
1376 | 343ec8e4 | Benoit Canet | event = MP_KEY_WHEEL_NAV; |
1377 | 24859b68 | balrog | break;
|
1378 | 24859b68 | balrog | |
1379 | 24859b68 | balrog | case KEYCODE_LEFT:
|
1380 | 343ec8e4 | Benoit Canet | event = MP_KEY_WHEEL_VOL | MP_KEY_WHEEL_VOL_INV; |
1381 | 24859b68 | balrog | break;
|
1382 | 24859b68 | balrog | |
1383 | 24859b68 | balrog | case KEYCODE_RIGHT:
|
1384 | 343ec8e4 | Benoit Canet | event = MP_KEY_WHEEL_VOL; |
1385 | 24859b68 | balrog | break;
|
1386 | 24859b68 | balrog | } |
1387 | 49fedd0d | Jan Kiszka | } else {
|
1388 | 24859b68 | balrog | switch (keycode & KEY_CODE) {
|
1389 | 24859b68 | balrog | case KEYCODE_F:
|
1390 | 343ec8e4 | Benoit Canet | event = MP_KEY_BTN_FAVORITS; |
1391 | 24859b68 | balrog | break;
|
1392 | 24859b68 | balrog | |
1393 | 24859b68 | balrog | case KEYCODE_TAB:
|
1394 | 343ec8e4 | Benoit Canet | event = MP_KEY_BTN_VOLUME; |
1395 | 24859b68 | balrog | break;
|
1396 | 24859b68 | balrog | |
1397 | 24859b68 | balrog | case KEYCODE_ENTER:
|
1398 | 343ec8e4 | Benoit Canet | event = MP_KEY_BTN_NAVIGATION; |
1399 | 24859b68 | balrog | break;
|
1400 | 24859b68 | balrog | |
1401 | 24859b68 | balrog | case KEYCODE_M:
|
1402 | 343ec8e4 | Benoit Canet | event = MP_KEY_BTN_MENU; |
1403 | 24859b68 | balrog | break;
|
1404 | 24859b68 | balrog | } |
1405 | 7c6ce4ba | balrog | /* Do not repeat already pressed buttons */
|
1406 | 708afdf3 | Jan Kiszka | if (!(keycode & KEY_RELEASED) && (s->pressed_keys & event)) {
|
1407 | 7c6ce4ba | balrog | event = 0;
|
1408 | 708afdf3 | Jan Kiszka | } |
1409 | 7c6ce4ba | balrog | } |
1410 | 24859b68 | balrog | |
1411 | 7c6ce4ba | balrog | if (event) {
|
1412 | 708afdf3 | Jan Kiszka | /* Raise GPIO pin first if repeating a key */
|
1413 | 708afdf3 | Jan Kiszka | if (!(keycode & KEY_RELEASED) && (s->pressed_keys & event)) {
|
1414 | 708afdf3 | Jan Kiszka | for (i = 0; i <= 7; i++) { |
1415 | 708afdf3 | Jan Kiszka | if (event & (1 << i)) { |
1416 | 708afdf3 | Jan Kiszka | qemu_set_irq(s->out[i], 1);
|
1417 | 708afdf3 | Jan Kiszka | } |
1418 | 708afdf3 | Jan Kiszka | } |
1419 | 708afdf3 | Jan Kiszka | } |
1420 | 708afdf3 | Jan Kiszka | for (i = 0; i <= 7; i++) { |
1421 | 708afdf3 | Jan Kiszka | if (event & (1 << i)) { |
1422 | 708afdf3 | Jan Kiszka | qemu_set_irq(s->out[i], !!(keycode & KEY_RELEASED)); |
1423 | 708afdf3 | Jan Kiszka | } |
1424 | 708afdf3 | Jan Kiszka | } |
1425 | 7c6ce4ba | balrog | if (keycode & KEY_RELEASED) {
|
1426 | 708afdf3 | Jan Kiszka | s->pressed_keys &= ~event; |
1427 | 7c6ce4ba | balrog | } else {
|
1428 | 708afdf3 | Jan Kiszka | s->pressed_keys |= event; |
1429 | 7c6ce4ba | balrog | } |
1430 | 24859b68 | balrog | } |
1431 | 24859b68 | balrog | |
1432 | 343ec8e4 | Benoit Canet | s->kbd_extended = 0;
|
1433 | 343ec8e4 | Benoit Canet | } |
1434 | 343ec8e4 | Benoit Canet | |
1435 | 81a322d4 | Gerd Hoffmann | static int musicpal_key_init(SysBusDevice *dev) |
1436 | 343ec8e4 | Benoit Canet | { |
1437 | 343ec8e4 | Benoit Canet | musicpal_key_state *s = FROM_SYSBUS(musicpal_key_state, dev); |
1438 | 343ec8e4 | Benoit Canet | |
1439 | 343ec8e4 | Benoit Canet | sysbus_init_mmio(dev, 0x0, 0); |
1440 | 343ec8e4 | Benoit Canet | |
1441 | 343ec8e4 | Benoit Canet | s->kbd_extended = 0;
|
1442 | 708afdf3 | Jan Kiszka | s->pressed_keys = 0;
|
1443 | 343ec8e4 | Benoit Canet | |
1444 | 708afdf3 | Jan Kiszka | qdev_init_gpio_out(&dev->qdev, s->out, ARRAY_SIZE(s->out)); |
1445 | 343ec8e4 | Benoit Canet | |
1446 | 343ec8e4 | Benoit Canet | qemu_add_kbd_event_handler(musicpal_key_event, s); |
1447 | 81a322d4 | Gerd Hoffmann | |
1448 | 81a322d4 | Gerd Hoffmann | return 0; |
1449 | 24859b68 | balrog | } |
1450 | 24859b68 | balrog | |
1451 | d5b61ddd | Jan Kiszka | static const VMStateDescription musicpal_key_vmsd = { |
1452 | d5b61ddd | Jan Kiszka | .name = "musicpal_key",
|
1453 | d5b61ddd | Jan Kiszka | .version_id = 1,
|
1454 | d5b61ddd | Jan Kiszka | .minimum_version_id = 1,
|
1455 | d5b61ddd | Jan Kiszka | .minimum_version_id_old = 1,
|
1456 | d5b61ddd | Jan Kiszka | .fields = (VMStateField[]) { |
1457 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(kbd_extended, musicpal_key_state), |
1458 | d5b61ddd | Jan Kiszka | VMSTATE_UINT32(pressed_keys, musicpal_key_state), |
1459 | d5b61ddd | Jan Kiszka | VMSTATE_END_OF_LIST() |
1460 | d5b61ddd | Jan Kiszka | } |
1461 | d5b61ddd | Jan Kiszka | }; |
1462 | d5b61ddd | Jan Kiszka | |
1463 | d5b61ddd | Jan Kiszka | static SysBusDeviceInfo musicpal_key_info = {
|
1464 | d5b61ddd | Jan Kiszka | .init = musicpal_key_init, |
1465 | d5b61ddd | Jan Kiszka | .qdev.name = "musicpal_key",
|
1466 | d5b61ddd | Jan Kiszka | .qdev.size = sizeof(musicpal_key_state),
|
1467 | d5b61ddd | Jan Kiszka | .qdev.vmsd = &musicpal_key_vmsd, |
1468 | d5b61ddd | Jan Kiszka | }; |
1469 | d5b61ddd | Jan Kiszka | |
1470 | 24859b68 | balrog | static struct arm_boot_info musicpal_binfo = { |
1471 | 24859b68 | balrog | .loader_start = 0x0,
|
1472 | 24859b68 | balrog | .board_id = 0x20e,
|
1473 | 24859b68 | balrog | }; |
1474 | 24859b68 | balrog | |
1475 | c227f099 | Anthony Liguori | static void musicpal_init(ram_addr_t ram_size, |
1476 | 3023f332 | aliguori | const char *boot_device, |
1477 | 24859b68 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
1478 | 24859b68 | balrog | const char *initrd_filename, const char *cpu_model) |
1479 | 24859b68 | balrog | { |
1480 | 24859b68 | balrog | CPUState *env; |
1481 | b47b50fa | Paul Brook | qemu_irq *cpu_pic; |
1482 | b47b50fa | Paul Brook | qemu_irq pic[32];
|
1483 | b47b50fa | Paul Brook | DeviceState *dev; |
1484 | d074769c | Andrzej Zaborowski | DeviceState *i2c_dev; |
1485 | 343ec8e4 | Benoit Canet | DeviceState *lcd_dev; |
1486 | 343ec8e4 | Benoit Canet | DeviceState *key_dev; |
1487 | d074769c | Andrzej Zaborowski | #ifdef HAS_AUDIO
|
1488 | d074769c | Andrzej Zaborowski | DeviceState *wm8750_dev; |
1489 | d074769c | Andrzej Zaborowski | SysBusDevice *s; |
1490 | d074769c | Andrzej Zaborowski | #endif
|
1491 | d074769c | Andrzej Zaborowski | i2c_bus *i2c; |
1492 | b47b50fa | Paul Brook | int i;
|
1493 | 24859b68 | balrog | unsigned long flash_size; |
1494 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
1495 | c227f099 | Anthony Liguori | ram_addr_t sram_off; |
1496 | 24859b68 | balrog | |
1497 | 49fedd0d | Jan Kiszka | if (!cpu_model) {
|
1498 | 24859b68 | balrog | cpu_model = "arm926";
|
1499 | 49fedd0d | Jan Kiszka | } |
1500 | 24859b68 | balrog | env = cpu_init(cpu_model); |
1501 | 24859b68 | balrog | if (!env) {
|
1502 | 24859b68 | balrog | fprintf(stderr, "Unable to find CPU definition\n");
|
1503 | 24859b68 | balrog | exit(1);
|
1504 | 24859b68 | balrog | } |
1505 | b47b50fa | Paul Brook | cpu_pic = arm_pic_init_cpu(env); |
1506 | 24859b68 | balrog | |
1507 | 24859b68 | balrog | /* For now we use a fixed - the original - RAM size */
|
1508 | 24859b68 | balrog | cpu_register_physical_memory(0, MP_RAM_DEFAULT_SIZE,
|
1509 | 24859b68 | balrog | qemu_ram_alloc(MP_RAM_DEFAULT_SIZE)); |
1510 | 24859b68 | balrog | |
1511 | 24859b68 | balrog | sram_off = qemu_ram_alloc(MP_SRAM_SIZE); |
1512 | 24859b68 | balrog | cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off); |
1513 | 24859b68 | balrog | |
1514 | b47b50fa | Paul Brook | dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
|
1515 | b47b50fa | Paul Brook | cpu_pic[ARM_PIC_CPU_IRQ]); |
1516 | b47b50fa | Paul Brook | for (i = 0; i < 32; i++) { |
1517 | 067a3ddc | Paul Brook | pic[i] = qdev_get_gpio_in(dev, i); |
1518 | b47b50fa | Paul Brook | } |
1519 | b47b50fa | Paul Brook | sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, pic[MP_TIMER1_IRQ],
|
1520 | b47b50fa | Paul Brook | pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ], |
1521 | b47b50fa | Paul Brook | pic[MP_TIMER4_IRQ], NULL);
|
1522 | 24859b68 | balrog | |
1523 | 49fedd0d | Jan Kiszka | if (serial_hds[0]) { |
1524 | b6cd0ea1 | aurel32 | serial_mm_init(MP_UART1_BASE, 2, pic[MP_UART1_IRQ], 1825000, |
1525 | 24859b68 | balrog | serial_hds[0], 1); |
1526 | 49fedd0d | Jan Kiszka | } |
1527 | 49fedd0d | Jan Kiszka | if (serial_hds[1]) { |
1528 | b6cd0ea1 | aurel32 | serial_mm_init(MP_UART2_BASE, 2, pic[MP_UART2_IRQ], 1825000, |
1529 | 24859b68 | balrog | serial_hds[1], 1); |
1530 | 49fedd0d | Jan Kiszka | } |
1531 | 24859b68 | balrog | |
1532 | 24859b68 | balrog | /* Register flash */
|
1533 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, 0); |
1534 | 751c6a17 | Gerd Hoffmann | if (dinfo) {
|
1535 | 751c6a17 | Gerd Hoffmann | flash_size = bdrv_getlength(dinfo->bdrv); |
1536 | 24859b68 | balrog | if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 && |
1537 | 24859b68 | balrog | flash_size != 32*1024*1024) { |
1538 | 24859b68 | balrog | fprintf(stderr, "Invalid flash image size\n");
|
1539 | 24859b68 | balrog | exit(1);
|
1540 | 24859b68 | balrog | } |
1541 | 24859b68 | balrog | |
1542 | 24859b68 | balrog | /*
|
1543 | 24859b68 | balrog | * The original U-Boot accesses the flash at 0xFE000000 instead of
|
1544 | 24859b68 | balrog | * 0xFF800000 (if there is 8 MB flash). So remap flash access if the
|
1545 | 24859b68 | balrog | * image is smaller than 32 MB.
|
1546 | 24859b68 | balrog | */
|
1547 | 24859b68 | balrog | pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size),
|
1548 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, 0x10000,
|
1549 | 24859b68 | balrog | (flash_size + 0xffff) >> 16, |
1550 | 24859b68 | balrog | MP_FLASH_SIZE_MAX / flash_size, |
1551 | 24859b68 | balrog | 2, 0x00BF, 0x236D, 0x0000, 0x0000, |
1552 | 24859b68 | balrog | 0x5555, 0x2AAA); |
1553 | 24859b68 | balrog | } |
1554 | b47b50fa | Paul Brook | sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL); |
1555 | 24859b68 | balrog | |
1556 | b47b50fa | Paul Brook | qemu_check_nic_model(&nd_table[0], "mv88w8618"); |
1557 | b47b50fa | Paul Brook | dev = qdev_create(NULL, "mv88w8618_eth"); |
1558 | 4c91cd28 | Gerd Hoffmann | qdev_set_nic_properties(dev, &nd_table[0]);
|
1559 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
1560 | b47b50fa | Paul Brook | sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
|
1561 | b47b50fa | Paul Brook | sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);
|
1562 | 24859b68 | balrog | |
1563 | b47b50fa | Paul Brook | sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL); |
1564 | 718ec0be | malc | |
1565 | 718ec0be | malc | musicpal_misc_init(); |
1566 | 343ec8e4 | Benoit Canet | |
1567 | 343ec8e4 | Benoit Canet | dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
|
1568 | 3cd035d8 | Paul Brook | i2c_dev = sysbus_create_simple("gpio_i2c", 0, NULL); |
1569 | d074769c | Andrzej Zaborowski | i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
|
1570 | d074769c | Andrzej Zaborowski | |
1571 | 343ec8e4 | Benoit Canet | lcd_dev = sysbus_create_simple("musicpal_lcd", MP_LCD_BASE, NULL); |
1572 | 343ec8e4 | Benoit Canet | key_dev = sysbus_create_simple("musicpal_key", 0, NULL); |
1573 | 343ec8e4 | Benoit Canet | |
1574 | d074769c | Andrzej Zaborowski | /* I2C read data */
|
1575 | 708afdf3 | Jan Kiszka | qdev_connect_gpio_out(i2c_dev, 0,
|
1576 | 708afdf3 | Jan Kiszka | qdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT)); |
1577 | d074769c | Andrzej Zaborowski | /* I2C data */
|
1578 | d074769c | Andrzej Zaborowski | qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0)); |
1579 | d074769c | Andrzej Zaborowski | /* I2C clock */
|
1580 | d074769c | Andrzej Zaborowski | qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1)); |
1581 | d074769c | Andrzej Zaborowski | |
1582 | 49fedd0d | Jan Kiszka | for (i = 0; i < 3; i++) { |
1583 | 343ec8e4 | Benoit Canet | qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(lcd_dev, i)); |
1584 | 49fedd0d | Jan Kiszka | } |
1585 | 708afdf3 | Jan Kiszka | for (i = 0; i < 4; i++) { |
1586 | 708afdf3 | Jan Kiszka | qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 8));
|
1587 | 708afdf3 | Jan Kiszka | } |
1588 | 708afdf3 | Jan Kiszka | for (i = 4; i < 8; i++) { |
1589 | 708afdf3 | Jan Kiszka | qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
|
1590 | 708afdf3 | Jan Kiszka | } |
1591 | 24859b68 | balrog | |
1592 | d074769c | Andrzej Zaborowski | #ifdef HAS_AUDIO
|
1593 | d074769c | Andrzej Zaborowski | wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
|
1594 | d074769c | Andrzej Zaborowski | dev = qdev_create(NULL, "mv88w8618_audio"); |
1595 | d074769c | Andrzej Zaborowski | s = sysbus_from_qdev(dev); |
1596 | d074769c | Andrzej Zaborowski | qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
|
1597 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
1598 | d074769c | Andrzej Zaborowski | sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
|
1599 | d074769c | Andrzej Zaborowski | sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
|
1600 | d074769c | Andrzej Zaborowski | #endif
|
1601 | d074769c | Andrzej Zaborowski | |
1602 | 24859b68 | balrog | musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE; |
1603 | 24859b68 | balrog | musicpal_binfo.kernel_filename = kernel_filename; |
1604 | 24859b68 | balrog | musicpal_binfo.kernel_cmdline = kernel_cmdline; |
1605 | 24859b68 | balrog | musicpal_binfo.initrd_filename = initrd_filename; |
1606 | b0f6edb1 | balrog | arm_load_kernel(env, &musicpal_binfo); |
1607 | 24859b68 | balrog | } |
1608 | 24859b68 | balrog | |
1609 | f80f9ec9 | Anthony Liguori | static QEMUMachine musicpal_machine = {
|
1610 | 4b32e168 | aliguori | .name = "musicpal",
|
1611 | 4b32e168 | aliguori | .desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)",
|
1612 | 4b32e168 | aliguori | .init = musicpal_init, |
1613 | 24859b68 | balrog | }; |
1614 | b47b50fa | Paul Brook | |
1615 | f80f9ec9 | Anthony Liguori | static void musicpal_machine_init(void) |
1616 | f80f9ec9 | Anthony Liguori | { |
1617 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&musicpal_machine); |
1618 | f80f9ec9 | Anthony Liguori | } |
1619 | f80f9ec9 | Anthony Liguori | |
1620 | f80f9ec9 | Anthony Liguori | machine_init(musicpal_machine_init); |
1621 | f80f9ec9 | Anthony Liguori | |
1622 | b47b50fa | Paul Brook | static void musicpal_register_devices(void) |
1623 | b47b50fa | Paul Brook | { |
1624 | d5b61ddd | Jan Kiszka | sysbus_register_withprop(&mv88w8618_pic_info); |
1625 | c88d6bde | Jan Kiszka | sysbus_register_withprop(&mv88w8618_pit_info); |
1626 | d5b61ddd | Jan Kiszka | sysbus_register_withprop(&mv88w8618_flashcfg_info); |
1627 | d5b61ddd | Jan Kiszka | sysbus_register_withprop(&mv88w8618_eth_info); |
1628 | b47b50fa | Paul Brook | sysbus_register_dev("mv88w8618_wlan", sizeof(SysBusDevice), |
1629 | b47b50fa | Paul Brook | mv88w8618_wlan_init); |
1630 | d5b61ddd | Jan Kiszka | sysbus_register_withprop(&musicpal_lcd_info); |
1631 | 30624c92 | Jan Kiszka | sysbus_register_withprop(&musicpal_gpio_info); |
1632 | d5b61ddd | Jan Kiszka | sysbus_register_withprop(&musicpal_key_info); |
1633 | b47b50fa | Paul Brook | } |
1634 | b47b50fa | Paul Brook | |
1635 | b47b50fa | Paul Brook | device_init(musicpal_register_devices) |