tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / mainboard / google / rush_ryu / romstage.c
blobe7b120b071e84b3b0b38aac67e533dcc52081cbe
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2014 Google Inc.
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.
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.
16 #include <delay.h>
17 #include <soc/addressmap.h>
18 #include <device/i2c.h>
19 #include <soc/clock.h>
20 #include <soc/funitcfg.h>
21 #include <soc/nvidia/tegra/i2c.h>
22 #include <soc/padconfig.h>
23 #include <soc/romstage.h>
25 #include "gpio.h"
26 #include "pmic.h"
28 static const struct pad_config padcfgs[] = {
29 /* AP_SYS_RESET_L */
30 PAD_CFG_GPIO_OUT1(GPIO_PI5, PINMUX_PULL_UP),
31 /* WP_L */
32 PAD_CFG_GPIO_INPUT(KB_ROW1, PINMUX_PULL_NONE),
33 /* MODEM_RESET */
34 PAD_CFG_GPIO_OUT0(KB_ROW11, PINMUX_PULL_DOWN),
35 /* MODEM_PWR_ON */
36 PAD_CFG_GPIO_OUT0(KB_ROW12, PINMUX_PULL_DOWN),
37 /* MDM_DET - expected to be pulled down by LTE modem */
38 PAD_CFG_GPIO_INPUT(GPIO_PV1, PINMUX_PULL_UP),
39 /* Power Button - active high / low depending on board id */
40 PAD_CFG_GPIO_INPUT(KB_COL0, PINMUX_PULL_UP),
41 /* BTN_AP_VOLD_L - active low */
42 PAD_CFG_GPIO_INPUT(KB_COL6, PINMUX_PULL_UP),
43 /* BTN_AP_VOLU_L - active low */
44 PAD_CFG_GPIO_INPUT(KB_COL7, PINMUX_PULL_UP),
47 static const struct pad_config tpm_pads[] = {
48 PAD_CFG_SFIO(CAM_I2C_SCL, PINMUX_INPUT_ENABLE, I2C3),
49 PAD_CFG_SFIO(CAM_I2C_SDA, PINMUX_INPUT_ENABLE, I2C3),
52 static const struct pad_config ec_i2c_pads[] = {
53 PAD_CFG_SFIO(GEN2_I2C_SCL, PINMUX_OPEN_DRAIN|PINMUX_INPUT_ENABLE, I2C2),
54 PAD_CFG_SFIO(GEN2_I2C_SDA, PINMUX_OPEN_DRAIN|PINMUX_INPUT_ENABLE, I2C2),
57 static const struct funit_cfg funits[] = {
58 /* TPM on I2C3 @ 400kHz */
59 FUNIT_CFG(I2C3, PLLP, 400, tpm_pads, ARRAY_SIZE(tpm_pads)),
60 /* EC on I2C2 - pulled to 3.3V @ 100kHz */
61 FUNIT_CFG(I2C2, PLLP, 100, ec_i2c_pads, ARRAY_SIZE(ec_i2c_pads)),
64 static void lte_modem_init(void)
66 int mdm_det;
67 uint8_t data;
69 /* A LTE modem is present if MDM_DET is pulled down by the modem */
70 mdm_det = gpio_get(MDM_DET);
71 if (mdm_det == 1)
72 return;
74 printk(BIOS_DEBUG, "Found LTE modem\n");
76 /* Enable PMIC CLK32KGAUDIO to drive CLK_MDM_32K */
77 pmic_read_reg(I2CPWR_BUS, TI65913_PAD2, &data);
78 pmic_write_reg(I2CPWR_BUS, TI65913_PAD2,
79 PAD2_GPIO_5_SEC_CLK32KGAUDIO(data), 0);
80 pmic_write_reg(I2CPWR_BUS, TI65913_CLK32KGAUDIO_CTRL,
81 TI65913_MODE_ACTIVE_ON, 0);
83 /* FULL_CARD_POWER_OFF# (A44: MODEM_PWR_ON) and RESET#
84 * (A44: MODEM_RESET) of the LTE modem are actively low and initially
85 * pulled down by the pad config. To properly enable the LTE modem,
86 * de-assert FULL_CARD_POWER_OFF#, wait for at least 10ms, and then
87 * de-assert RESET#.
89 gpio_output(MODEM_PWR_ON, 1);
90 udelay(15000);
91 gpio_output(MODEM_RESET, 1);
94 void romstage_mainboard_init(void)
96 /* Bring up controller interfaces for ramstage loading. */
97 soc_configure_funits(funits, ARRAY_SIZE(funits));
98 soc_configure_pads(padcfgs, ARRAY_SIZE(padcfgs));
100 /* TPM */
101 i2c_init(I2C3_BUS);
102 /* EC */
103 i2c_init(I2C2_BUS);
105 lte_modem_init();
108 void mainboard_configure_pmc(void)
112 void mainboard_enable_vdd_cpu(void)
114 /* VDD_CPU is already enabled in bootblock. */