1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/device.h>
5 #include <soc/addressmap.h>
6 #include <soc/clk_rst.h>
8 #include <soc/funitcfg.h>
9 #include <soc/nvidia/tegra/i2c.h>
10 #include <soc/padconfig.h>
12 #include <soc/nvidia/tegra/dc.h>
13 #include <soc/display.h>
16 static const struct pad_config sdmmc1_pad
[] = {
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 */
25 PAD_CFG_GPIO_INPUT(GPIO_PZ1
, PINMUX_PULL_UP
),
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. */
28 PAD_CFG_GPIO_OUT0(GPIO_PZ4
, PINMUX_PULL_NONE
),
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
),
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 */
39 PAD_CFG_GPIO_INPUT(USB_VBUS_EN1
, PINMUX_PULL_NONE
| PINMUX_PARKED
|
40 PINMUX_INPUT_ENABLE
| PINMUX_LPDR
| PINMUX_IO_HV
),
42 /* Add backlight vdd/enable/pwm/dp hpd pad cfgs here */
45 static const struct pad_config i2c1_pad
[] = {
47 PAD_CFG_SFIO(GEN1_I2C_SCL
, PINMUX_INPUT_ENABLE
, I2C1
),
48 PAD_CFG_SFIO(GEN1_I2C_SDA
, PINMUX_INPUT_ENABLE
, I2C1
),
51 static const struct pad_config i2s1_pad
[] = {
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
),
56 PAD_CFG_SFIO(DAP1_DIN
, PINMUX_INPUT_ENABLE
| PINMUX_TRISTATE
, I2S1
),
57 /* codec MCLK via AUD SFIO */
58 PAD_CFG_SFIO(AUD_MCLK
, PINMUX_PULL_NONE
, AUD
),
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
)),
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),
69 FUNIT_CFG(I2C1
, PLLP
, 100, i2c1_pad
, ARRAY_SIZE(i2c1_pad
)),
70 FUNIT_CFG(I2C6
, PLLP
, 400, audio_codec_pads
, ARRAY_SIZE(audio_codec_pads
)),
74 /* Audio init: clocks and enables/resets */
75 static void setup_audio(void)
77 /* Audio codec (ES755) uses OSC freq (via AUD_MCLK), s/b 38.4MHz */
78 soc_configure_funits(audio_funit
, ARRAY_SIZE(audio_funit
));
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.
90 static void mainboard_init(struct device
*dev
)
92 soc_configure_pads(padcfgs
, ARRAY_SIZE(padcfgs
));
93 soc_configure_funits(funitcfgs
, ARRAY_SIZE(funitcfgs
));
99 static void mainboard_enable(struct device
*dev
)
101 dev
->ops
->init
= &mainboard_init
;
104 struct chip_operations mainboard_ops
= {
105 .enable_dev
= mainboard_enable
,