1a257f626SPaul Burton /*
2a257f626SPaul Burton * Copyright (C) 2013 Imagination Technologies
3a257f626SPaul Burton * Author: Paul Burton <paul.burton@imgtec.com>
4a257f626SPaul Burton *
5a257f626SPaul Burton * Setup code for the FDC37M817 super I/O controller
6a257f626SPaul Burton *
7a257f626SPaul Burton * SPDX-License-Identifier: GPL-2.0+
8a257f626SPaul Burton */
9a257f626SPaul Burton
10a257f626SPaul Burton #include <common.h>
11a257f626SPaul Burton #include <asm/io.h>
12a257f626SPaul Burton
13a257f626SPaul Burton #define SIO_CONF_PORT 0x3f0
14a257f626SPaul Burton #define SIO_DATA_PORT 0x3f1
15a257f626SPaul Burton
16a257f626SPaul Burton enum sio_conf_key {
17a257f626SPaul Burton SIOCONF_DEVNUM = 0x07,
18a257f626SPaul Burton SIOCONF_ACTIVATE = 0x30,
19a257f626SPaul Burton SIOCONF_ENTER_SETUP = 0x55,
20a257f626SPaul Burton SIOCONF_BASE_HIGH = 0x60,
21a257f626SPaul Burton SIOCONF_BASE_LOW = 0x61,
22a257f626SPaul Burton SIOCONF_PRIMARY_INT = 0x70,
23a257f626SPaul Burton SIOCONF_EXIT_SETUP = 0xaa,
24a257f626SPaul Burton SIOCONF_MODE = 0xf0,
25a257f626SPaul Burton };
26a257f626SPaul Burton
27a257f626SPaul Burton static struct {
28a257f626SPaul Burton u8 key;
29a257f626SPaul Burton u8 data;
30a257f626SPaul Burton } sio_config[] = {
31a257f626SPaul Burton /* tty0 */
32a257f626SPaul Burton { SIOCONF_DEVNUM, 0x04 },
33a257f626SPaul Burton { SIOCONF_BASE_HIGH, 0x03 },
34a257f626SPaul Burton { SIOCONF_BASE_LOW, 0xf8 },
35a257f626SPaul Burton { SIOCONF_MODE, 0x02 },
36a257f626SPaul Burton { SIOCONF_PRIMARY_INT, 0x04 },
37a257f626SPaul Burton { SIOCONF_ACTIVATE, 0x01 },
38a257f626SPaul Burton
39a257f626SPaul Burton /* tty1 */
40a257f626SPaul Burton { SIOCONF_DEVNUM, 0x05 },
41a257f626SPaul Burton { SIOCONF_BASE_HIGH, 0x02 },
42a257f626SPaul Burton { SIOCONF_BASE_LOW, 0xf8 },
43a257f626SPaul Burton { SIOCONF_MODE, 0x02 },
44a257f626SPaul Burton { SIOCONF_PRIMARY_INT, 0x03 },
45a257f626SPaul Burton { SIOCONF_ACTIVATE, 0x01 },
46a257f626SPaul Burton };
47a257f626SPaul Burton
malta_superio_init(void)48*91ec615eSPaul Burton void malta_superio_init(void)
49a257f626SPaul Burton {
50a257f626SPaul Burton unsigned i;
51a257f626SPaul Burton
52a257f626SPaul Burton /* enter config state */
53*91ec615eSPaul Burton outb(SIOCONF_ENTER_SETUP, SIO_CONF_PORT);
54a257f626SPaul Burton
55a257f626SPaul Burton /* configure peripherals */
56a257f626SPaul Burton for (i = 0; i < ARRAY_SIZE(sio_config); i++) {
57*91ec615eSPaul Burton outb(sio_config[i].key, SIO_CONF_PORT);
58*91ec615eSPaul Burton outb(sio_config[i].data, SIO_DATA_PORT);
59a257f626SPaul Burton }
60a257f626SPaul Burton
61a257f626SPaul Burton /* exit config state */
62*91ec615eSPaul Burton outb(SIOCONF_EXIT_SETUP, SIO_CONF_PORT);
63a257f626SPaul Burton }
64