1 /*
2  * SPL/U-Boot common functions for CompuLab CL-SOM-iMX7 module
3  *
4  * (C) Copyright 2017 CompuLab, Ltd. http://www.compulab.com
5  *
6  * Author: Uri Mashiach <uri.mashiach@compulab.co.il>
7  *
8  * SPDX-License-Identifier:	GPL-2.0+
9  */
10 
11 #include <common.h>
12 #include <fsl_esdhc.h>
13 #include <asm-generic/gpio.h>
14 #include "common.h"
15 
16 #ifdef CONFIG_SPI
17 
18 #define CL_SOM_IMX7_GPIO_SPI_CS	IMX_GPIO_NR(4, 19)
19 
20 int board_spi_cs_gpio(unsigned int bus, unsigned int cs)
21 {
22 	return CL_SOM_IMX7_GPIO_SPI_CS;
23 }
24 
25 #endif /* CONFIG_SPI */
26 
27 #ifdef CONFIG_FSL_ESDHC
28 
29 int board_mmc_getcd(struct mmc *mmc)
30 {
31 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
32 	int ret = 0;
33 
34 	switch (cfg->esdhc_base) {
35 	case USDHC1_BASE_ADDR:
36 		ret = !gpio_get_value(CL_SOM_IMX7_GPIO_USDHC1_CD);
37 		break;
38 	case USDHC3_BASE_ADDR:
39 		ret = 1; /* Assume uSDHC3 emmc is always present */
40 		break;
41 	}
42 
43 	return ret;
44 }
45 
46 #endif /* CONFIG_FSL_ESDHC */
47