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