blob: 0b55bc6ae268af687b04380c7b7a4d58bbe0f11f [file] [log] [blame]
Lee Leahy274d20a2016-05-15 13:52:36 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <arch/io.h>
17#include <console/console.h>
Lee Leahybc518d52016-05-30 15:01:06 -070018#include <fsp/romstage.h>
Lee Leahy274d20a2016-05-15 13:52:36 -070019#include <soc/ramstage.h>
Lee Leahy15843bd2016-05-15 15:05:56 -070020#include "reg_access.h"
Lee Leahy274d20a2016-05-15 13:52:36 -070021#include "gen1.h"
22#include "gen2.h"
23
Lee Leahybc518d52016-05-30 15:01:06 -070024void car_mainboard_pre_console_init(void)
25{
26 const struct reg_script *script;
27
28 /* Initialize the GPIO controllers */
29 if (IS_ENABLED(CONFIG_GALILEO_GEN2))
30 script = gen2_gpio_init;
31 else
32 script = gen1_gpio_init;
33 reg_script_run(script);
34
35 /* Initialize the RXD and TXD paths for UART0 */
36 if (IS_ENABLED(CONFIG_ENABLE_BUILTIN_HSUART0)) {
37 if (IS_ENABLED(CONFIG_GALILEO_GEN2))
38 script = gen2_hsuart0;
39 else
40 script = (reg_legacy_gpio_read (R_QNC_GPIO_RGLVL_RESUME_WELL)
41 & GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO)
42 ? gen1_hsuart0_0x21 : gen1_hsuart0_0x20;
43 reg_script_run(script);
44 }
45}
46
Lee Leahy15843bd2016-05-15 15:05:56 -070047void mainboard_gpio_i2c_init(device_t dev)
48{
49 const struct reg_script *script;
50
51 printk(BIOS_INFO, "Galileo I2C chip initialization\n");
52
53 /* Determine the correct script for the board */
54 if (IS_ENABLED(CONFIG_GALILEO_GEN2))
55 script = gen2_i2c_init;
56 else
57 /* Determine which I2C address is in use */
58 script = (reg_legacy_gpio_read (R_QNC_GPIO_RGLVL_RESUME_WELL)
59 & GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO)
Lee Leahybc518d52016-05-30 15:01:06 -070060 ? gen1_i2c_0x21_init : gen1_i2c_0x20_init;
Lee Leahy15843bd2016-05-15 15:05:56 -070061
62 /* Initialize the I2C chips */
63 reg_script_run(script);
64}
65
Lee Leahy5ef051a2016-04-29 15:16:54 -070066void mainboard_gpio_pcie_reset(uint32_t pin_value)
67{
68 uint32_t pin_number;
69 uint32_t value;
70
71 /* Determine the correct PCIe reset pin */
72 if (IS_ENABLED(CONFIG_GALILEO_GEN2))
73 pin_number = GEN2_PCI_RESET_RESUMEWELL_GPIO;
74 else
75 pin_number = GEN1_PCI_RESET_RESUMEWELL_GPIO;
76
77 /* Update the PCIe reset value */
78 value = reg_legacy_gpio_read(R_QNC_GPIO_RGLVL_RESUME_WELL);
79 value = (value & ~(1 << pin_number)) | ((pin_value & 1) << pin_number);
80 reg_legacy_gpio_write(R_QNC_GPIO_RGLVL_RESUME_WELL, value);
81}