Commit 718ec0be53bae7a4451587e0fd09becc94593c7e
1 parent
43e860ef
musicpal: Reorganize IO memory handling (Jan Kiszka)
The new MMIO interface requires non-overlapping slots. Reorganize the musicpal accordingly, fixing a regression for the Ethernet emulation. Signed-off-by: Jan Kiszka <jan.kiszka@web.de> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6803 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
139 additions
and
50 deletions
hw/musicpal.c
| ... | ... | @@ -20,12 +20,21 @@ |
| 20 | 20 | #include "audio/audio.h" |
| 21 | 21 | #include "i2c.h" |
| 22 | 22 | |
| 23 | +#define MP_MISC_BASE 0x80002000 | |
| 24 | +#define MP_MISC_SIZE 0x00001000 | |
| 25 | + | |
| 23 | 26 | #define MP_ETH_BASE 0x80008000 |
| 24 | 27 | #define MP_ETH_SIZE 0x00001000 |
| 25 | 28 | |
| 29 | +#define MP_WLAN_BASE 0x8000C000 | |
| 30 | +#define MP_WLAN_SIZE 0x00000800 | |
| 31 | + | |
| 26 | 32 | #define MP_UART1_BASE 0x8000C840 |
| 27 | 33 | #define MP_UART2_BASE 0x8000C940 |
| 28 | 34 | |
| 35 | +#define MP_GPIO_BASE 0x8000D000 | |
| 36 | +#define MP_GPIO_SIZE 0x00001000 | |
| 37 | + | |
| 29 | 38 | #define MP_FLASHCFG_BASE 0x90006000 |
| 30 | 39 | #define MP_FLASHCFG_SIZE 0x00001000 |
| 31 | 40 | |
| ... | ... | @@ -429,7 +438,7 @@ static CPUWriteMemoryFunc *musicpal_audio_writefn[] = { |
| 429 | 438 | musicpal_audio_write |
| 430 | 439 | }; |
| 431 | 440 | |
| 432 | -static i2c_interface *musicpal_audio_init(uint32_t base, qemu_irq irq) | |
| 441 | +static i2c_interface *musicpal_audio_init(qemu_irq irq) | |
| 433 | 442 | { |
| 434 | 443 | AudioState *audio; |
| 435 | 444 | musicpal_audio_state *s; |
| ... | ... | @@ -457,14 +466,14 @@ static i2c_interface *musicpal_audio_init(uint32_t base, qemu_irq irq) |
| 457 | 466 | |
| 458 | 467 | iomemtype = cpu_register_io_memory(0, musicpal_audio_readfn, |
| 459 | 468 | musicpal_audio_writefn, s); |
| 460 | - cpu_register_physical_memory(base, MP_AUDIO_SIZE, iomemtype); | |
| 469 | + cpu_register_physical_memory(MP_AUDIO_BASE, MP_AUDIO_SIZE, iomemtype); | |
| 461 | 470 | |
| 462 | 471 | qemu_register_reset(musicpal_audio_reset, s); |
| 463 | 472 | |
| 464 | 473 | return i2c; |
| 465 | 474 | } |
| 466 | 475 | #else /* !HAS_AUDIO */ |
| 467 | -static i2c_interface *musicpal_audio_init(uint32_t base, qemu_irq irq) | |
| 476 | +static i2c_interface *musicpal_audio_init(qemu_irq irq) | |
| 468 | 477 | { |
| 469 | 478 | return NULL; |
| 470 | 479 | } |
| ... | ... | @@ -899,7 +908,7 @@ static CPUWriteMemoryFunc *musicpal_lcd_writefn[] = { |
| 899 | 908 | musicpal_lcd_write |
| 900 | 909 | }; |
| 901 | 910 | |
| 902 | -static void musicpal_lcd_init(uint32_t base) | |
| 911 | +static void musicpal_lcd_init(void) | |
| 903 | 912 | { |
| 904 | 913 | musicpal_lcd_state *s; |
| 905 | 914 | int iomemtype; |
| ... | ... | @@ -907,7 +916,7 @@ static void musicpal_lcd_init(uint32_t base) |
| 907 | 916 | s = qemu_mallocz(sizeof(musicpal_lcd_state)); |
| 908 | 917 | iomemtype = cpu_register_io_memory(0, musicpal_lcd_readfn, |
| 909 | 918 | musicpal_lcd_writefn, s); |
| 910 | - cpu_register_physical_memory(base, MP_LCD_SIZE, iomemtype); | |
| 919 | + cpu_register_physical_memory(MP_LCD_BASE, MP_LCD_SIZE, iomemtype); | |
| 911 | 920 | |
| 912 | 921 | s->ds = graphic_console_init(lcd_refresh, lcd_invalidate, |
| 913 | 922 | NULL, NULL, s); |
| ... | ... | @@ -1195,20 +1204,102 @@ static void mv88w8618_flashcfg_init(uint32_t base) |
| 1195 | 1204 | cpu_register_physical_memory(base, MP_FLASHCFG_SIZE, iomemtype); |
| 1196 | 1205 | } |
| 1197 | 1206 | |
| 1198 | -/* Various registers in the 0x80000000 domain */ | |
| 1199 | -#define MP_BOARD_REVISION 0x2018 | |
| 1207 | +/* Misc register offsets */ | |
| 1208 | +#define MP_MISC_BOARD_REVISION 0x18 | |
| 1209 | + | |
| 1210 | +#define MP_BOARD_REVISION 0x31 | |
| 1211 | + | |
| 1212 | +static uint32_t musicpal_misc_read(void *opaque, target_phys_addr_t offset) | |
| 1213 | +{ | |
| 1214 | + switch (offset) { | |
| 1215 | + case MP_MISC_BOARD_REVISION: | |
| 1216 | + return MP_BOARD_REVISION; | |
| 1217 | + | |
| 1218 | + default: | |
| 1219 | + return 0; | |
| 1220 | + } | |
| 1221 | +} | |
| 1222 | + | |
| 1223 | +static void musicpal_misc_write(void *opaque, target_phys_addr_t offset, | |
| 1224 | + uint32_t value) | |
| 1225 | +{ | |
| 1226 | +} | |
| 1227 | + | |
| 1228 | +static CPUReadMemoryFunc *musicpal_misc_readfn[] = { | |
| 1229 | + musicpal_misc_read, | |
| 1230 | + musicpal_misc_read, | |
| 1231 | + musicpal_misc_read, | |
| 1232 | +}; | |
| 1233 | + | |
| 1234 | +static CPUWriteMemoryFunc *musicpal_misc_writefn[] = { | |
| 1235 | + musicpal_misc_write, | |
| 1236 | + musicpal_misc_write, | |
| 1237 | + musicpal_misc_write, | |
| 1238 | +}; | |
| 1239 | + | |
| 1240 | +static void musicpal_misc_init(void) | |
| 1241 | +{ | |
| 1242 | + int iomemtype; | |
| 1243 | + | |
| 1244 | + iomemtype = cpu_register_io_memory(0, musicpal_misc_readfn, | |
| 1245 | + musicpal_misc_writefn, NULL); | |
| 1246 | + cpu_register_physical_memory(MP_MISC_BASE, MP_MISC_SIZE, iomemtype); | |
| 1247 | +} | |
| 1248 | + | |
| 1249 | +/* WLAN register offsets */ | |
| 1250 | +#define MP_WLAN_MAGIC1 0x11c | |
| 1251 | +#define MP_WLAN_MAGIC2 0x124 | |
| 1252 | + | |
| 1253 | +static uint32_t mv88w8618_wlan_read(void *opaque, target_phys_addr_t offset) | |
| 1254 | +{ | |
| 1255 | + switch (offset) { | |
| 1256 | + /* Workaround to allow loading the binary-only wlandrv.ko crap | |
| 1257 | + * from the original Freecom firmware. */ | |
| 1258 | + case MP_WLAN_MAGIC1: | |
| 1259 | + return ~3; | |
| 1260 | + case MP_WLAN_MAGIC2: | |
| 1261 | + return -1; | |
| 1262 | + | |
| 1263 | + default: | |
| 1264 | + return 0; | |
| 1265 | + } | |
| 1266 | +} | |
| 1267 | + | |
| 1268 | +static void mv88w8618_wlan_write(void *opaque, target_phys_addr_t offset, | |
| 1269 | + uint32_t value) | |
| 1270 | +{ | |
| 1271 | +} | |
| 1272 | + | |
| 1273 | +static CPUReadMemoryFunc *mv88w8618_wlan_readfn[] = { | |
| 1274 | + mv88w8618_wlan_read, | |
| 1275 | + mv88w8618_wlan_read, | |
| 1276 | + mv88w8618_wlan_read, | |
| 1277 | +}; | |
| 1278 | + | |
| 1279 | +static CPUWriteMemoryFunc *mv88w8618_wlan_writefn[] = { | |
| 1280 | + mv88w8618_wlan_write, | |
| 1281 | + mv88w8618_wlan_write, | |
| 1282 | + mv88w8618_wlan_write, | |
| 1283 | +}; | |
| 1284 | + | |
| 1285 | +static void mv88w8618_wlan_init(uint32_t base) | |
| 1286 | +{ | |
| 1287 | + int iomemtype; | |
| 1200 | 1288 | |
| 1201 | -#define MP_WLAN_MAGIC1 0xc11c | |
| 1202 | -#define MP_WLAN_MAGIC2 0xc124 | |
| 1289 | + iomemtype = cpu_register_io_memory(0, mv88w8618_wlan_readfn, | |
| 1290 | + mv88w8618_wlan_writefn, NULL); | |
| 1291 | + cpu_register_physical_memory(base, MP_WLAN_SIZE, iomemtype); | |
| 1292 | +} | |
| 1203 | 1293 | |
| 1204 | -#define MP_GPIO_OE_LO 0xd008 | |
| 1205 | -#define MP_GPIO_OUT_LO 0xd00c | |
| 1206 | -#define MP_GPIO_IN_LO 0xd010 | |
| 1207 | -#define MP_GPIO_ISR_LO 0xd020 | |
| 1208 | -#define MP_GPIO_OE_HI 0xd508 | |
| 1209 | -#define MP_GPIO_OUT_HI 0xd50c | |
| 1210 | -#define MP_GPIO_IN_HI 0xd510 | |
| 1211 | -#define MP_GPIO_ISR_HI 0xd520 | |
| 1294 | +/* GPIO register offsets */ | |
| 1295 | +#define MP_GPIO_OE_LO 0x008 | |
| 1296 | +#define MP_GPIO_OUT_LO 0x00c | |
| 1297 | +#define MP_GPIO_IN_LO 0x010 | |
| 1298 | +#define MP_GPIO_ISR_LO 0x020 | |
| 1299 | +#define MP_GPIO_OE_HI 0x508 | |
| 1300 | +#define MP_GPIO_OUT_HI 0x50c | |
| 1301 | +#define MP_GPIO_IN_HI 0x510 | |
| 1302 | +#define MP_GPIO_ISR_HI 0x520 | |
| 1212 | 1303 | |
| 1213 | 1304 | /* GPIO bits & masks */ |
| 1214 | 1305 | #define MP_GPIO_WHEEL_VOL (1 << 8) |
| ... | ... | @@ -1227,12 +1318,9 @@ static void mv88w8618_flashcfg_init(uint32_t base) |
| 1227 | 1318 | /* LCD brightness bits in GPIO_OE_HI */ |
| 1228 | 1319 | #define MP_OE_LCD_BRIGHTNESS 0x0007 |
| 1229 | 1320 | |
| 1230 | -static uint32_t musicpal_read(void *opaque, target_phys_addr_t offset) | |
| 1321 | +static uint32_t musicpal_gpio_read(void *opaque, target_phys_addr_t offset) | |
| 1231 | 1322 | { |
| 1232 | 1323 | switch (offset) { |
| 1233 | - case MP_BOARD_REVISION: | |
| 1234 | - return 0x0031; | |
| 1235 | - | |
| 1236 | 1324 | case MP_GPIO_OE_HI: /* used for LCD brightness control */ |
| 1237 | 1325 | return lcd_brightness & MP_OE_LCD_BRIGHTNESS; |
| 1238 | 1326 | |
| ... | ... | @@ -1254,20 +1342,13 @@ static uint32_t musicpal_read(void *opaque, target_phys_addr_t offset) |
| 1254 | 1342 | case MP_GPIO_ISR_HI: |
| 1255 | 1343 | return gpio_isr >> 16; |
| 1256 | 1344 | |
| 1257 | - /* Workaround to allow loading the binary-only wlandrv.ko crap | |
| 1258 | - * from the original Freecom firmware. */ | |
| 1259 | - case MP_WLAN_MAGIC1: | |
| 1260 | - return ~3; | |
| 1261 | - case MP_WLAN_MAGIC2: | |
| 1262 | - return -1; | |
| 1263 | - | |
| 1264 | 1345 | default: |
| 1265 | 1346 | return 0; |
| 1266 | 1347 | } |
| 1267 | 1348 | } |
| 1268 | 1349 | |
| 1269 | -static void musicpal_write(void *opaque, target_phys_addr_t offset, | |
| 1270 | - uint32_t value) | |
| 1350 | +static void musicpal_gpio_write(void *opaque, target_phys_addr_t offset, | |
| 1351 | + uint32_t value) | |
| 1271 | 1352 | { |
| 1272 | 1353 | switch (offset) { |
| 1273 | 1354 | case MP_GPIO_OE_HI: /* used for LCD brightness control */ |
| ... | ... | @@ -1290,6 +1371,27 @@ static void musicpal_write(void *opaque, target_phys_addr_t offset, |
| 1290 | 1371 | } |
| 1291 | 1372 | } |
| 1292 | 1373 | |
| 1374 | +static CPUReadMemoryFunc *musicpal_gpio_readfn[] = { | |
| 1375 | + musicpal_gpio_read, | |
| 1376 | + musicpal_gpio_read, | |
| 1377 | + musicpal_gpio_read, | |
| 1378 | +}; | |
| 1379 | + | |
| 1380 | +static CPUWriteMemoryFunc *musicpal_gpio_writefn[] = { | |
| 1381 | + musicpal_gpio_write, | |
| 1382 | + musicpal_gpio_write, | |
| 1383 | + musicpal_gpio_write, | |
| 1384 | +}; | |
| 1385 | + | |
| 1386 | +static void musicpal_gpio_init(void) | |
| 1387 | +{ | |
| 1388 | + int iomemtype; | |
| 1389 | + | |
| 1390 | + iomemtype = cpu_register_io_memory(0, musicpal_gpio_readfn, | |
| 1391 | + musicpal_gpio_writefn, NULL); | |
| 1392 | + cpu_register_physical_memory(MP_GPIO_BASE, MP_GPIO_SIZE, iomemtype); | |
| 1393 | +} | |
| 1394 | + | |
| 1293 | 1395 | /* Keyboard codes & masks */ |
| 1294 | 1396 | #define KEY_RELEASED 0x80 |
| 1295 | 1397 | #define KEY_CODE 0x7f |
| ... | ... | @@ -1370,18 +1472,6 @@ static void musicpal_key_event(void *opaque, int keycode) |
| 1370 | 1472 | kbd_extended = 0; |
| 1371 | 1473 | } |
| 1372 | 1474 | |
| 1373 | -static CPUReadMemoryFunc *musicpal_readfn[] = { | |
| 1374 | - musicpal_read, | |
| 1375 | - musicpal_read, | |
| 1376 | - musicpal_read, | |
| 1377 | -}; | |
| 1378 | - | |
| 1379 | -static CPUWriteMemoryFunc *musicpal_writefn[] = { | |
| 1380 | - musicpal_write, | |
| 1381 | - musicpal_write, | |
| 1382 | - musicpal_write, | |
| 1383 | -}; | |
| 1384 | - | |
| 1385 | 1475 | static struct arm_boot_info musicpal_binfo = { |
| 1386 | 1476 | .loader_start = 0x0, |
| 1387 | 1477 | .board_id = 0x20e, |
| ... | ... | @@ -1395,7 +1485,6 @@ static void musicpal_init(ram_addr_t ram_size, int vga_ram_size, |
| 1395 | 1485 | CPUState *env; |
| 1396 | 1486 | qemu_irq *pic; |
| 1397 | 1487 | int index; |
| 1398 | - int iomemtype; | |
| 1399 | 1488 | unsigned long flash_size; |
| 1400 | 1489 | |
| 1401 | 1490 | if (!cpu_model) |
| ... | ... | @@ -1415,11 +1504,6 @@ static void musicpal_init(ram_addr_t ram_size, int vga_ram_size, |
| 1415 | 1504 | sram_off = qemu_ram_alloc(MP_SRAM_SIZE); |
| 1416 | 1505 | cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off); |
| 1417 | 1506 | |
| 1418 | - /* Catch various stuff not handled by separate subsystems */ | |
| 1419 | - iomemtype = cpu_register_io_memory(0, musicpal_readfn, | |
| 1420 | - musicpal_writefn, env); | |
| 1421 | - cpu_register_physical_memory(0x80000000, 0x10000, iomemtype); | |
| 1422 | - | |
| 1423 | 1507 | pic = mv88w8618_pic_init(MP_PIC_BASE, pic[ARM_PIC_CPU_IRQ]); |
| 1424 | 1508 | mv88w8618_pit_init(MP_PIT_BASE, pic, MP_TIMER1_IRQ); |
| 1425 | 1509 | |
| ... | ... | @@ -1454,13 +1538,18 @@ static void musicpal_init(ram_addr_t ram_size, int vga_ram_size, |
| 1454 | 1538 | } |
| 1455 | 1539 | mv88w8618_flashcfg_init(MP_FLASHCFG_BASE); |
| 1456 | 1540 | |
| 1457 | - musicpal_lcd_init(MP_LCD_BASE); | |
| 1541 | + musicpal_lcd_init(); | |
| 1458 | 1542 | |
| 1459 | 1543 | qemu_add_kbd_event_handler(musicpal_key_event, pic[MP_GPIO_IRQ]); |
| 1460 | 1544 | |
| 1461 | 1545 | mv88w8618_eth_init(&nd_table[0], MP_ETH_BASE, pic[MP_ETH_IRQ]); |
| 1462 | 1546 | |
| 1463 | - mixer_i2c = musicpal_audio_init(MP_AUDIO_BASE, pic[MP_AUDIO_IRQ]); | |
| 1547 | + mixer_i2c = musicpal_audio_init(pic[MP_AUDIO_IRQ]); | |
| 1548 | + | |
| 1549 | + mv88w8618_wlan_init(MP_WLAN_BASE); | |
| 1550 | + | |
| 1551 | + musicpal_misc_init(); | |
| 1552 | + musicpal_gpio_init(); | |
| 1464 | 1553 | |
| 1465 | 1554 | musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE; |
| 1466 | 1555 | musicpal_binfo.kernel_filename = kernel_filename; | ... | ... |