xref: /openbmc/qemu/hw/isa/smc37c669-superio.c (revision 707ded20)
1 /*
2  * SMC FDC37C669 Super I/O controller
3  *
4  * Copyright (c) 2018 Philippe Mathieu-Daudé
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #include "qemu/osdep.h"
12 #include "hw/isa/superio.h"
13 #include "qemu/module.h"
14 
15 /* UARTs (compatible with NS16450 or PC16550) */
16 
17 static uint16_t get_serial_iobase(ISASuperIODevice *sio, uint8_t index)
18 {
19     return index ? 0x2f8 : 0x3f8;
20 }
21 
22 static unsigned int get_serial_irq(ISASuperIODevice *sio, uint8_t index)
23 {
24     return index ? 3 : 4;
25 }
26 
27 /* Parallel port */
28 
29 static uint16_t get_parallel_iobase(ISASuperIODevice *sio, uint8_t index)
30 {
31     return 0x378;
32 }
33 
34 static unsigned int get_parallel_irq(ISASuperIODevice *sio, uint8_t index)
35 {
36     return 7;
37 }
38 
39 static unsigned int get_parallel_dma(ISASuperIODevice *sio, uint8_t index)
40 {
41     return 3;
42 }
43 
44 /* Diskette controller (Software compatible with the Intel PC8477) */
45 
46 static uint16_t get_fdc_iobase(ISASuperIODevice *sio, uint8_t index)
47 {
48     return 0x3f0;
49 }
50 
51 static unsigned int get_fdc_irq(ISASuperIODevice *sio, uint8_t index)
52 {
53     return 6;
54 }
55 
56 static unsigned int get_fdc_dma(ISASuperIODevice *sio, uint8_t index)
57 {
58     return 2;
59 }
60 
61 static void smc37c669_class_init(ObjectClass *klass, void *data)
62 {
63     ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
64 
65     sc->parallel = (ISASuperIOFuncs){
66         .count = 1,
67         .get_iobase = get_parallel_iobase,
68         .get_irq    = get_parallel_irq,
69         .get_dma    = get_parallel_dma,
70     };
71     sc->serial = (ISASuperIOFuncs){
72         .count = 2,
73         .get_iobase = get_serial_iobase,
74         .get_irq    = get_serial_irq,
75     };
76     sc->floppy = (ISASuperIOFuncs){
77         .count = 1,
78         .get_iobase = get_fdc_iobase,
79         .get_irq    = get_fdc_irq,
80         .get_dma    = get_fdc_dma,
81     };
82     sc->ide.count = 0;
83 }
84 
85 static const TypeInfo smc37c669_type_info = {
86     .name          = TYPE_SMC37C669_SUPERIO,
87     .parent        = TYPE_ISA_SUPERIO,
88     .class_size    = sizeof(ISASuperIOClass),
89     .class_init    = smc37c669_class_init,
90 };
91 
92 static void smc37c669_register_types(void)
93 {
94     type_register_static(&smc37c669_type_info);
95 }
96 
97 type_init(smc37c669_register_types)
98