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