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