common.c 908 B

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