1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/mmio.h>
4 #include <boot/coreboot_tables.h>
6 #include <device/device.h>
7 #include <device/i2c_simple.h>
9 #include <soc/display.h>
13 #include <soc/clock.h>
14 #include <soc/rk808.h>
21 static void configure_usb(void)
23 gpio_output(GPIO(0, B
, 3), 1); /* HOST1_PWR_EN */
24 gpio_output(GPIO(0, B
, 4), 1); /* USBOTG_PWREN_H */
25 gpio_output(GPIO(7, C
, 5), 1); /* 5V_DRV */
28 static void configure_sdmmc(void)
30 write32(&rk3288_grf
->iomux_sdmmc0
, IOMUX_SDMMC0
);
32 /* use sdmmc0 io, disable JTAG function */
33 write32(&rk3288_grf
->soc_con0
, RK_CLRBITS(1 << 12));
35 /* Note: these power rail definitions are copied in romstage.c */
36 rk808_configure_ldo(4, 3300); /* VCCIO_SD */
37 rk808_configure_ldo(5, 3300); /* VCC33_SD */
39 gpio_input(GPIO(7, A
, 5)); /* SD_DET */
42 static void configure_emmc(void)
44 write32(&rk3288_grf
->iomux_emmcdata
, IOMUX_EMMCDATA
);
45 write32(&rk3288_grf
->iomux_emmcpwren
, IOMUX_EMMCPWREN
);
46 write32(&rk3288_grf
->iomux_emmccmd
, IOMUX_EMMCCMD
);
48 gpio_output(GPIO(2, B
, 1), 1); /* EMMC_RST_L */
51 static void configure_codec(void)
53 write32(&rk3288_grf
->iomux_i2c2
, IOMUX_I2C2
); /* CODEC I2C */
54 i2c_init(2, 400*KHz
); /* CODEC I2C */
56 write32(&rk3288_grf
->iomux_i2s
, IOMUX_I2S
);
57 write32(&rk3288_grf
->iomux_i2sclk
, IOMUX_I2SCLK
);
59 rk808_configure_ldo(6, 1800); /* VCC18_CODEC */
61 /* AUDIO IO domain 1.8V voltage selection */
62 write32(&rk3288_grf
->io_vsel
, RK_SETBITS(1 << 6));
63 rkclk_configure_i2s(12288000);
66 static void configure_vop(void)
68 write32(&rk3288_grf
->iomux_lcdc
, IOMUX_LCDC
);
70 /* lcdc(vop) iodomain select 1.8V */
71 write32(&rk3288_grf
->io_vsel
, RK_SETBITS(1 << 0));
73 gpio_output(GPIO(2, B
, 5), 1); /* AVDD_1V8_DISP_EN */
74 rk808_configure_ldo(7, 2500); /* VCC10_LCD_PWREN_H */
75 gpio_output(GPIO(7, B
, 6), 1); /* LCD_EN */
76 rk808_configure_switch(1, 1); /* VCC33_LCD */
79 gpio_input_pulldown(GPIO(7, B
, 3));
80 write32(&rk3288_grf
->iomux_edp_hotplug
, IOMUX_EDP_HOTPLUG
);
83 static void mainboard_init(struct device
*dev
)
85 gpio_output(GPIO_RESET
, 0);
94 static void mainboard_enable(struct device
*dev
)
96 dev
->ops
->init
= &mainboard_init
;
99 struct chip_operations mainboard_ops
= {
100 .enable_dev
= mainboard_enable
,
103 void lb_board(struct lb_header
*header
)
105 struct lb_range
*dma
;
107 dma
= (struct lb_range
*)lb_new_record(header
);
108 dma
->tag
= LB_TAG_DMA
;
109 dma
->size
= sizeof(*dma
);
110 dma
->range_start
= (uintptr_t)_dma_coherent
;
111 dma
->range_size
= REGION_SIZE(dma_coherent
);
114 void mainboard_power_on_backlight(void)
116 gpio_output(GPIO(2, B
, 4), 1); /* BL_PWR_EN */
118 gpio_output(GPIO(7, A
, 0), 1); /* LCD_BL */
120 gpio_output(GPIO_BACKLIGHT
, 1); /* BL_EN */