coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/mmu.h>
4 #include <device/device.h>
5 #include <soc/addressmap.h>
6 #include <soc/clk_rst.h>
7 #include <soc/clock.h>
8 #include <soc/funitcfg.h>
9 #include <soc/nvidia/tegra/i2c.h>
10 #include <soc/padconfig.h>
11 #include <soc/spi.h>
12 #include <soc/nvidia/tegra/dc.h>
13 #include <soc/display.h>
14 
15 
16 static const struct pad_config sdmmc1_pad[] = {
17  /* MMC1(SDCARD) */
18  PAD_CFG_SFIO(SDMMC1_CLK, PINMUX_INPUT_ENABLE, SDMMC1),
19  PAD_CFG_SFIO(SDMMC1_CMD, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, SDMMC1),
20  PAD_CFG_SFIO(SDMMC1_DAT0, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, SDMMC1),
21  PAD_CFG_SFIO(SDMMC1_DAT1, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, SDMMC1),
22  PAD_CFG_SFIO(SDMMC1_DAT2, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, SDMMC1),
23  PAD_CFG_SFIO(SDMMC1_DAT3, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, SDMMC1),
24  /* MMC1 Card Detect pin */
26  /* Disable SD card reader power so it can be reset even on warm boot.
27  Payloads must enable power before accessing SD card slots. */
29 };
30 
31 static const struct pad_config audio_codec_pads[] = {
32  /* GPIO_X1_AUD(BB3) is AUDIO_LDO_EN (->CODEC RESET_N pin) */
33  PAD_CFG_GPIO_OUT1(GPIO_X1_AUD, PINMUX_PULL_DOWN),
34 };
35 
36 static const struct pad_config padcfgs[] = {
37  /* We pull the USB VBUS signals up but keep them as inputs since the
38  * voltage source likes to drive them low on overcurrent conditions */
41 
42  /* Add backlight vdd/enable/pwm/dp hpd pad cfgs here */
43 };
44 
45 static const struct pad_config i2c1_pad[] = {
46  /* GEN1 I2C */
47  PAD_CFG_SFIO(GEN1_I2C_SCL, PINMUX_INPUT_ENABLE, I2C1),
48  PAD_CFG_SFIO(GEN1_I2C_SDA, PINMUX_INPUT_ENABLE, I2C1),
49 };
50 
51 static const struct pad_config i2s1_pad[] = {
52  /* I2S1 */
53  PAD_CFG_SFIO(DAP1_SCLK, PINMUX_INPUT_ENABLE, I2S1),
54  PAD_CFG_SFIO(DAP1_FS, PINMUX_INPUT_ENABLE, I2S1),
55  PAD_CFG_SFIO(DAP1_DOUT, PINMUX_INPUT_ENABLE, I2S1),
57  /* codec MCLK via AUD SFIO */
58  PAD_CFG_SFIO(AUD_MCLK, PINMUX_PULL_NONE, AUD),
59 };
60 
61 static const struct funit_cfg audio_funit[] = {
62  /* We need 1.5MHz for I2S1. So we use CLK_M */
63  FUNIT_CFG(I2S1, CLK_M, 1500, i2s1_pad, ARRAY_SIZE(i2s1_pad)),
64 };
65 
66 static const struct funit_cfg funitcfgs[] = {
67  FUNIT_CFG(SDMMC1, PLLP, 48000, sdmmc1_pad, ARRAY_SIZE(sdmmc1_pad)),
68  FUNIT_CFG(SDMMC4, PLLP, 48000, NULL, 0),
71  FUNIT_CFG_USB(USBD),
72 };
73 
74 /* Audio init: clocks and enables/resets */
75 static void setup_audio(void)
76 {
77  /* Audio codec (ES755) uses OSC freq (via AUD_MCLK), s/b 38.4MHz */
79 
80  /*
81  * As per NVIDIA hardware team, we need to take ALL audio devices
82  * connected to AHUB (AUDIO, APB2APE, I2S, SPDIF, etc.) out of reset
83  * and clock-enabled, otherwise reading AHUB devices (in our case,
84  * I2S/APBIF/AUDIO<XBAR>) will hang.
85  */
88 }
89 
90 static void mainboard_init(struct device *dev)
91 {
94 
96  setup_audio();
97 }
98 
99 static void mainboard_enable(struct device *dev)
100 {
101  dev->ops->init = &mainboard_init;
102 }
103 
106 };
struct chip_operations mainboard_ops
Definition: mainboard.c:19
void soc_configure_ape(void)
Definition: ape.c:31
#define ARRAY_SIZE(a)
Definition: helpers.h:12
void soc_configure_funits(const struct funit_cfg *const entries, size_t num)
Definition: funitcfg.c:132
#define FUNIT_CFG(_funit, _clk_src, _clk_freq, _cfg, _cfg_size)
Definition: funitcfg.h:55
#define FUNIT_CFG_USB(_funit)
Definition: funitcfg.h:65
@ I2C1_BUS
Definition: funitcfg.h:34
static void mainboard_init(struct device *dev)
Definition: mainboard.c:90
static void setup_audio(void)
Definition: mainboard.c:75
static const struct pad_config i2s1_pad[]
Definition: mainboard.c:51
static const struct funit_cfg audio_funit[]
Definition: mainboard.c:61
static const struct pad_config audio_codec_pads[]
Definition: mainboard.c:31
static const struct funit_cfg funitcfgs[]
Definition: mainboard.c:66
static const struct pad_config i2c1_pad[]
Definition: mainboard.c:45
static const struct pad_config sdmmc1_pad[]
Definition: mainboard.c:16
static const struct pad_config padcfgs[]
Definition: mainboard.c:36
static void mainboard_enable(struct device *dev)
Definition: mainboard.c:99
@ PINMUX_INPUT_ENABLE
Definition: pinmux.h:17
@ PINMUX_PULL_NONE
Definition: pinmux.h:12
@ PINMUX_PULL_DOWN
Definition: pinmux.h:13
@ PINMUX_PULL_UP
Definition: pinmux.h:14
@ PINMUX_TRISTATE
Definition: pinmux.h:16
@ PINMUX_IO_HV
Definition: pinmux.h:23
@ PINMUX_PARKED
Definition: pinmux.h:18
@ PINMUX_LPDR
Definition: pinmux.h:21
#define PAD_CFG_GPIO_OUT1(ball_, pinmux_flgs_)
Definition: padconfig.h:40
#define PAD_CFG_GPIO_INPUT(ball_, pinmux_flgs_)
Definition: padconfig.h:21
#define PAD_CFG_SFIO(ball_, pinmux_flgs_, sfio_)
Definition: padconfig.h:50
void soc_configure_pads(const struct pad_config *const entries, size_t num)
Definition: padconfig.c:105
#define PAD_CFG_GPIO_OUT0(ball_, pinmux_flgs_)
Definition: padconfig.h:30
@ I2C1
Definition: i2c.h:51
@ I2C6
Definition: i2c.h:56
@ PLLP
Definition: clock.h:245
@ CLK_M
Definition: clock.h:253
void clock_enable_audio(void)
Definition: clock.c:772
void i2c_init(unsigned int bus)
Definition: i2c.c:198
#define NULL
Definition: stddef.h:19
void(* enable_dev)(struct device *dev)
Definition: device.h:24
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
struct device_operations * ops
Definition: device.h:143