2015-05-13 03:23:27 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Google Inc.
|
2018-05-24 08:51:06 +02:00
|
|
|
* Copyright (C) 2015-2018 Intel Corporation
|
2015-05-13 03:23:27 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2018-05-24 08:51:06 +02:00
|
|
|
#include <console/console.h>
|
2017-12-04 11:54:21 +01:00
|
|
|
#include <device/pci_def.h>
|
|
|
|
#include <gpio.h>
|
|
|
|
#include <intelblocks/lpss.h>
|
|
|
|
#include <intelblocks/pcr.h>
|
2017-04-27 07:19:04 +02:00
|
|
|
#include <intelblocks/uart.h>
|
2017-12-04 11:54:21 +01:00
|
|
|
#include <soc/bootblock.h>
|
2015-05-13 03:23:27 +02:00
|
|
|
#include <soc/pci_devs.h>
|
2017-12-04 11:54:21 +01:00
|
|
|
#include <soc/pcr_ids.h>
|
|
|
|
|
2018-05-07 20:56:52 +02:00
|
|
|
/* UART pad configuration. Support RXD and TXD for now. */
|
2018-05-24 08:51:06 +02:00
|
|
|
const struct uart_gpio_pad_config uart_gpio_pads[] = {
|
2018-05-07 20:56:52 +02:00
|
|
|
{
|
2018-05-24 08:51:06 +02:00
|
|
|
.console_index = 0,
|
|
|
|
.gpios = {
|
|
|
|
PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1), /* UART0 RX */
|
|
|
|
PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1), /* UART0 TX */
|
|
|
|
},
|
2018-05-07 20:56:52 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-24 08:51:06 +02:00
|
|
|
.console_index = 1,
|
|
|
|
.gpios = {
|
|
|
|
PAD_CFG_NF(GPP_C12, NONE, DEEP, NF1), /* UART1 RX */
|
|
|
|
PAD_CFG_NF(GPP_C13, NONE, DEEP, NF1), /* UART1 TX */
|
|
|
|
},
|
2018-05-07 20:56:52 +02:00
|
|
|
},
|
|
|
|
{
|
2018-05-24 08:51:06 +02:00
|
|
|
.console_index = 2,
|
|
|
|
.gpios = {
|
|
|
|
PAD_CFG_NF(GPP_C20, NONE, DEEP, NF1), /* UART2 RX */
|
|
|
|
PAD_CFG_NF(GPP_C21, NONE, DEEP, NF1), /* UART2 TX */
|
|
|
|
},
|
2018-05-07 20:56:52 +02:00
|
|
|
}
|
2017-12-04 11:54:21 +01:00
|
|
|
};
|
|
|
|
|
2018-05-24 08:51:06 +02:00
|
|
|
const int uart_max_index = ARRAY_SIZE(uart_gpio_pads);
|
2017-12-04 11:54:21 +01:00
|
|
|
|
2018-05-24 08:51:06 +02:00
|
|
|
struct device *soc_uart_console_to_device(int uart_console)
|
2017-08-05 01:24:12 +02:00
|
|
|
{
|
2018-05-24 08:51:06 +02:00
|
|
|
/*
|
|
|
|
* if index is valid, this function will return corresponding structure
|
|
|
|
* for uart console else will return NULL.
|
|
|
|
*/
|
|
|
|
switch (uart_console) {
|
2018-05-07 20:56:52 +02:00
|
|
|
case 0:
|
2018-05-24 08:51:06 +02:00
|
|
|
return (struct device *)PCH_DEV_UART0;
|
2018-05-07 20:56:52 +02:00
|
|
|
case 1:
|
2018-05-24 08:51:06 +02:00
|
|
|
return (struct device *)PCH_DEV_UART1;
|
2018-05-07 20:56:52 +02:00
|
|
|
case 2:
|
2018-05-24 08:51:06 +02:00
|
|
|
return (struct device *)PCH_DEV_UART2;
|
2018-05-07 20:56:52 +02:00
|
|
|
default:
|
2018-05-24 08:51:06 +02:00
|
|
|
printk(BIOS_ERR, "Invalid UART console index\n");
|
|
|
|
return NULL;
|
2018-05-07 20:56:52 +02:00
|
|
|
}
|
2017-08-05 01:24:12 +02:00
|
|
|
}
|