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