17bea0dd4SPhilippe Mathieu-Daudé /*
27bea0dd4SPhilippe Mathieu-Daudé * SMC FDC37C669 Super I/O controller
37bea0dd4SPhilippe Mathieu-Daudé *
47bea0dd4SPhilippe Mathieu-Daudé * Copyright (c) 2018 Philippe Mathieu-Daudé
57bea0dd4SPhilippe Mathieu-Daudé *
6*b822dfaeSPhilippe Mathieu-Daudé * This work is licensed under the terms of the GNU GPL, version 2 or later.
77bea0dd4SPhilippe Mathieu-Daudé * See the COPYING file in the top-level directory.
87bea0dd4SPhilippe Mathieu-Daudé * SPDX-License-Identifier: GPL-2.0-or-later
97bea0dd4SPhilippe Mathieu-Daudé */
107bea0dd4SPhilippe Mathieu-Daudé
117bea0dd4SPhilippe Mathieu-Daudé #include "qemu/osdep.h"
127bea0dd4SPhilippe Mathieu-Daudé #include "hw/isa/superio.h"
130b8fa32fSMarkus Armbruster #include "qemu/module.h"
147bea0dd4SPhilippe Mathieu-Daudé
157bea0dd4SPhilippe Mathieu-Daudé /* UARTs (compatible with NS16450 or PC16550) */
167bea0dd4SPhilippe Mathieu-Daudé
get_serial_iobase(ISASuperIODevice * sio,uint8_t index)177bea0dd4SPhilippe Mathieu-Daudé static uint16_t get_serial_iobase(ISASuperIODevice *sio, uint8_t index)
187bea0dd4SPhilippe Mathieu-Daudé {
197bea0dd4SPhilippe Mathieu-Daudé return index ? 0x2f8 : 0x3f8;
207bea0dd4SPhilippe Mathieu-Daudé }
217bea0dd4SPhilippe Mathieu-Daudé
get_serial_irq(ISASuperIODevice * sio,uint8_t index)227bea0dd4SPhilippe Mathieu-Daudé static unsigned int get_serial_irq(ISASuperIODevice *sio, uint8_t index)
237bea0dd4SPhilippe Mathieu-Daudé {
247bea0dd4SPhilippe Mathieu-Daudé return index ? 3 : 4;
257bea0dd4SPhilippe Mathieu-Daudé }
267bea0dd4SPhilippe Mathieu-Daudé
277bea0dd4SPhilippe Mathieu-Daudé /* Parallel port */
287bea0dd4SPhilippe Mathieu-Daudé
get_parallel_iobase(ISASuperIODevice * sio,uint8_t index)297bea0dd4SPhilippe Mathieu-Daudé static uint16_t get_parallel_iobase(ISASuperIODevice *sio, uint8_t index)
307bea0dd4SPhilippe Mathieu-Daudé {
3175cacb12SPhilippe Mathieu-Daudé return 0x378;
327bea0dd4SPhilippe Mathieu-Daudé }
337bea0dd4SPhilippe Mathieu-Daudé
get_parallel_irq(ISASuperIODevice * sio,uint8_t index)347bea0dd4SPhilippe Mathieu-Daudé static unsigned int get_parallel_irq(ISASuperIODevice *sio, uint8_t index)
357bea0dd4SPhilippe Mathieu-Daudé {
367bea0dd4SPhilippe Mathieu-Daudé return 7;
377bea0dd4SPhilippe Mathieu-Daudé }
387bea0dd4SPhilippe Mathieu-Daudé
get_parallel_dma(ISASuperIODevice * sio,uint8_t index)397bea0dd4SPhilippe Mathieu-Daudé static unsigned int get_parallel_dma(ISASuperIODevice *sio, uint8_t index)
407bea0dd4SPhilippe Mathieu-Daudé {
417bea0dd4SPhilippe Mathieu-Daudé return 3;
427bea0dd4SPhilippe Mathieu-Daudé }
437bea0dd4SPhilippe Mathieu-Daudé
447bea0dd4SPhilippe Mathieu-Daudé /* Diskette controller (Software compatible with the Intel PC8477) */
457bea0dd4SPhilippe Mathieu-Daudé
get_fdc_iobase(ISASuperIODevice * sio,uint8_t index)467bea0dd4SPhilippe Mathieu-Daudé static uint16_t get_fdc_iobase(ISASuperIODevice *sio, uint8_t index)
477bea0dd4SPhilippe Mathieu-Daudé {
487bea0dd4SPhilippe Mathieu-Daudé return 0x3f0;
497bea0dd4SPhilippe Mathieu-Daudé }
507bea0dd4SPhilippe Mathieu-Daudé
get_fdc_irq(ISASuperIODevice * sio,uint8_t index)517bea0dd4SPhilippe Mathieu-Daudé static unsigned int get_fdc_irq(ISASuperIODevice *sio, uint8_t index)
527bea0dd4SPhilippe Mathieu-Daudé {
537bea0dd4SPhilippe Mathieu-Daudé return 6;
547bea0dd4SPhilippe Mathieu-Daudé }
557bea0dd4SPhilippe Mathieu-Daudé
get_fdc_dma(ISASuperIODevice * sio,uint8_t index)567bea0dd4SPhilippe Mathieu-Daudé static unsigned int get_fdc_dma(ISASuperIODevice *sio, uint8_t index)
577bea0dd4SPhilippe Mathieu-Daudé {
587bea0dd4SPhilippe Mathieu-Daudé return 2;
597bea0dd4SPhilippe Mathieu-Daudé }
607bea0dd4SPhilippe Mathieu-Daudé
smc37c669_class_init(ObjectClass * klass,void * data)617bea0dd4SPhilippe Mathieu-Daudé static void smc37c669_class_init(ObjectClass *klass, void *data)
627bea0dd4SPhilippe Mathieu-Daudé {
637bea0dd4SPhilippe Mathieu-Daudé ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
647bea0dd4SPhilippe Mathieu-Daudé
657bea0dd4SPhilippe Mathieu-Daudé sc->parallel = (ISASuperIOFuncs){
667bea0dd4SPhilippe Mathieu-Daudé .count = 1,
677bea0dd4SPhilippe Mathieu-Daudé .get_iobase = get_parallel_iobase,
687bea0dd4SPhilippe Mathieu-Daudé .get_irq = get_parallel_irq,
697bea0dd4SPhilippe Mathieu-Daudé .get_dma = get_parallel_dma,
707bea0dd4SPhilippe Mathieu-Daudé };
717bea0dd4SPhilippe Mathieu-Daudé sc->serial = (ISASuperIOFuncs){
727bea0dd4SPhilippe Mathieu-Daudé .count = 2,
737bea0dd4SPhilippe Mathieu-Daudé .get_iobase = get_serial_iobase,
747bea0dd4SPhilippe Mathieu-Daudé .get_irq = get_serial_irq,
757bea0dd4SPhilippe Mathieu-Daudé };
767bea0dd4SPhilippe Mathieu-Daudé sc->floppy = (ISASuperIOFuncs){
777bea0dd4SPhilippe Mathieu-Daudé .count = 1,
787bea0dd4SPhilippe Mathieu-Daudé .get_iobase = get_fdc_iobase,
797bea0dd4SPhilippe Mathieu-Daudé .get_irq = get_fdc_irq,
807bea0dd4SPhilippe Mathieu-Daudé .get_dma = get_fdc_dma,
817bea0dd4SPhilippe Mathieu-Daudé };
827bea0dd4SPhilippe Mathieu-Daudé sc->ide.count = 0;
837bea0dd4SPhilippe Mathieu-Daudé }
847bea0dd4SPhilippe Mathieu-Daudé
857bea0dd4SPhilippe Mathieu-Daudé static const TypeInfo smc37c669_type_info = {
867bea0dd4SPhilippe Mathieu-Daudé .name = TYPE_SMC37C669_SUPERIO,
877bea0dd4SPhilippe Mathieu-Daudé .parent = TYPE_ISA_SUPERIO,
887bea0dd4SPhilippe Mathieu-Daudé .class_size = sizeof(ISASuperIOClass),
897bea0dd4SPhilippe Mathieu-Daudé .class_init = smc37c669_class_init,
907bea0dd4SPhilippe Mathieu-Daudé };
917bea0dd4SPhilippe Mathieu-Daudé
smc37c669_register_types(void)927bea0dd4SPhilippe Mathieu-Daudé static void smc37c669_register_types(void)
937bea0dd4SPhilippe Mathieu-Daudé {
947bea0dd4SPhilippe Mathieu-Daudé type_register_static(&smc37c669_type_info);
957bea0dd4SPhilippe Mathieu-Daudé }
967bea0dd4SPhilippe Mathieu-Daudé
977bea0dd4SPhilippe Mathieu-Daudé type_init(smc37c669_register_types)
98