Lee Leahy | 01728bb | 2016-07-20 08:58:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Google Inc. |
| 5 | * Copyright (C) 2015-2016 Intel Corp. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | #define __SIMPLE_DEVICE__ |
| 17 | |
| 18 | #include <console/console.h> |
| 19 | #include <fsp/util.h> |
| 20 | #include <soc/iomap.h> |
| 21 | #include <soc/pci_devs.h> |
| 22 | #include <soc/romstage.h> |
| 23 | #include <soc/reg_access.h> |
| 24 | |
| 25 | static const struct reg_script legacy_gpio_init[] = { |
| 26 | /* Temporarily enable the legacy GPIO controller */ |
| 27 | REG_PCI_WRITE32(R_QNC_LPC_GBA_BASE, IO_ADDRESS_VALID |
| 28 | | LEGACY_GPIO_BASE_ADDRESS), |
| 29 | /* Temporarily enable the GPE controller */ |
| 30 | REG_PCI_WRITE32(R_QNC_LPC_GPE0BLK, IO_ADDRESS_VALID |
| 31 | | GPE0_BASE_ADDRESS), |
| 32 | REG_PCI_OR8(PCI_COMMAND, PCI_COMMAND_IO), |
| 33 | REG_SCRIPT_END |
| 34 | }; |
| 35 | |
| 36 | static const struct reg_script i2c_gpio_controller_init[] = { |
| 37 | /* Temporarily enable the GPIO controller */ |
| 38 | REG_PCI_WRITE32(PCI_BASE_ADDRESS_0, I2C_BASE_ADDRESS), |
| 39 | REG_PCI_WRITE32(PCI_BASE_ADDRESS_1, GPIO_BASE_ADDRESS), |
| 40 | REG_PCI_OR8(PCI_COMMAND, PCI_COMMAND_MEMORY), |
| 41 | REG_SCRIPT_END |
| 42 | }; |
| 43 | |
| 44 | static const struct reg_script hsuart_init[] = { |
| 45 | /* Enable the HSUART */ |
| 46 | REG_PCI_WRITE32(PCI_BASE_ADDRESS_0, UART_BASE_ADDRESS), |
| 47 | REG_PCI_OR8(PCI_COMMAND, PCI_COMMAND_MEMORY), |
| 48 | REG_SCRIPT_END |
| 49 | }; |
| 50 | |
| 51 | void car_soc_pre_console_init(void) |
| 52 | { |
| 53 | /* Initialize the controllers */ |
| 54 | reg_script_run_on_dev(I2CGPIO_BDF, i2c_gpio_controller_init); |
| 55 | reg_script_run_on_dev(LPC_BDF, legacy_gpio_init); |
| 56 | |
| 57 | /* Enable the HSUART */ |
| 58 | if (IS_ENABLED(CONFIG_ENABLE_BUILTIN_HSUART0)) |
| 59 | reg_script_run_on_dev(HSUART0_BDF, hsuart_init); |
| 60 | if (IS_ENABLED(CONFIG_ENABLE_BUILTIN_HSUART1)) |
| 61 | reg_script_run_on_dev(HSUART1_BDF, hsuart_init); |
| 62 | } |
| 63 | |
| 64 | void car_soc_post_console_init(void) |
| 65 | { |
| 66 | report_platform_info(); |
| 67 | }; |