diff options
Diffstat (limited to 'src/superio/ite/it8716f/early_serial.c')
-rw-r--r-- | src/superio/ite/it8716f/early_serial.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/superio/ite/it8716f/early_serial.c b/src/superio/ite/it8716f/early_serial.c index 02f030449c..2085a8fee2 100644 --- a/src/superio/ite/it8716f/early_serial.c +++ b/src/superio/ite/it8716f/early_serial.c @@ -2,9 +2,8 @@ * This file is part of the coreboot project. * * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de> - * - * Copyright (C) 2007 AMD - * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD. + * Copyright (C) 2007 AMD Written by Yinghai Lu <yinghai.lu@amd.com> for AMD. + * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,13 +21,9 @@ */ #include <arch/io.h> +#include <device/pnp.h> #include "it8716f.h" -/* The base address is 0x2e or 0x4e, depending on config bytes. */ -#define SIO_BASE 0x2e -#define SIO_INDEX SIO_BASE -#define SIO_DATA (SIO_BASE + 1) - /* Global configuration registers. */ #define IT8716F_CONFIG_REG_CC 0x02 /* Configure Control (write-only). */ #define IT8716F_CONFIG_REG_LDN 0x07 /* Logical Device Number. */ @@ -36,7 +31,7 @@ #define IT8716F_CONFIG_REG_CLOCKSEL 0x23 /* Clock Selection. */ #define IT8716F_CONFIG_REG_SWSUSP 0x24 /* Software Suspend, Flash I/F. */ -static void pnp_enter_ext_func_mode(device_t dev) +static void it8716f_enter_conf(device_t dev) { u16 port = dev >> 8; @@ -46,17 +41,39 @@ static void pnp_enter_ext_func_mode(device_t dev) outb((port == 0x4e) ? 0xaa : 0x55, port); } -static void pnp_exit_ext_func_mode(device_t dev) +static void it8716f_exit_conf(device_t dev) { pnp_write_config(dev, IT8716F_CONFIG_REG_CC, 0x02); } +static void it8716f_reg_write(device_t dev, u8 index, u8 value) +{ + it8716f_enter_conf(dev); + pnp_write_config(dev, index, value); + it8716f_exit_conf(dev); +} + + +/* + * in romstage.c + * #define CLKIN_DEV PNP_DEV(0x2e, IT8716F_GPIO) + * and pass: CLKIN_DEV + * IT8716F_UART_CLK_PREDIVIDE_24 + * IT8716F_UART_CLK_PREDIVIDE_48 (default) + */ +void it8716f_conf_clkin(device_t dev, u8 predivide) +{ + it8716f_reg_write(dev, IT8716F_CONFIG_REG_CLOCKSEL, (0x1 & predivide)); +} + + +/* Enable the serial port(s). */ void it8716f_enable_serial(device_t dev, u16 iobase) { - pnp_enter_ext_func_mode(dev); + it8716f_enter_conf(dev); pnp_set_logical_device(dev); pnp_set_enable(dev, 0); pnp_set_iobase(dev, PNP_IDX_IO0, iobase); pnp_set_enable(dev, 1); - pnp_exit_ext_func_mode(dev); + it8716f_exit_conf(dev); } |