drivers/mipi: Add support for KD_KD110N11_51IE panel
[coreboot2.git] / src / soc / mediatek / mt8173 / spi.c
blobb7d6d94f71c0e127807381ba6f8694eb54b2d9d1
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/mmio.h>
4 #include <assert.h>
5 #include <gpio.h>
6 #include <spi_flash.h>
7 #include <soc/addressmap.h>
8 #include <soc/flash_controller_common.h>
9 #include <soc/spi.h>
11 struct mtk_spi_bus spi_bus[SPI_BUS_NUMBER] = {
13 .regs = (void *)SPI_BASE,
14 .cs_gpio = GPIO(MSDC2_CMD),
18 void mtk_spi_set_gpio_pinmux(unsigned int bus,
19 enum spi_pad_mask pad_select)
21 /* TODO: implement support for other pads when needed */
22 assert(pad_select == SPI_PAD1_MASK);
23 gpio_set_mode(GPIO(MSDC2_DAT2), PAD_MSDC2_DAT2_FUNC_SPI_CK_1);
24 gpio_set_mode(GPIO(MSDC2_DAT3), PAD_MSDC2_DAT3_FUNC_SPI_MI_1);
25 gpio_set_mode(GPIO(MSDC2_CLK), PAD_MSDC2_CLK_FUNC_SPI_MO_1);
26 gpio_set_mode(GPIO(MSDC2_CMD), 0);
29 static const struct spi_ctrlr spi_flash_ctrlr = {
30 .max_xfer_size = 65535,
31 .flash_probe = mtk_spi_flash_probe,
34 const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = {
36 .ctrlr = &spi_ctrlr,
37 .bus_start = 0,
38 .bus_end = SPI_BUS_NUMBER - 1,
41 .ctrlr = &spi_flash_ctrlr,
42 .bus_start = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS,
43 .bus_end = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS,
47 const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map);