common.c 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #include <common.h>
  11. #include <fsl_esdhc.h>
  12. #include <asm-generic/gpio.h>
  13. #include "common.h"
  14. #ifdef CONFIG_SPI
  15. #define CL_SOM_IMX7_GPIO_SPI_CS IMX_GPIO_NR(4, 19)
  16. int board_spi_cs_gpio(unsigned int bus, unsigned int cs)
  17. {
  18. return CL_SOM_IMX7_GPIO_SPI_CS;
  19. }
  20. #endif /* CONFIG_SPI */
  21. #ifdef CONFIG_FSL_ESDHC
  22. int board_mmc_getcd(struct mmc *mmc)
  23. {
  24. struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
  25. int ret = 0;
  26. switch (cfg->esdhc_base) {
  27. case USDHC1_BASE_ADDR:
  28. ret = !gpio_get_value(CL_SOM_IMX7_GPIO_USDHC1_CD);
  29. break;
  30. case USDHC3_BASE_ADDR:
  31. ret = 1; /* Assume uSDHC3 emmc is always present */
  32. break;
  33. }
  34. return ret;
  35. }
  36. #endif /* CONFIG_FSL_ESDHC */