hi6220_dw_mmc.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2015 Linaro
  4. * peter.griffin <peter.griffin@linaro.org>
  5. */
  6. #include <common.h>
  7. #include <dwmmc.h>
  8. #include <malloc.h>
  9. #include <linux/errno.h>
  10. #define DWMMC_MAX_CH_NUM 4
  11. #define DWMMC_MAX_FREQ 50000000
  12. #define DWMMC_MIN_FREQ 400000
  13. /* Source clock is configured to 100MHz by ATF bl1*/
  14. #define MMC0_DEFAULT_FREQ 100000000
  15. static int hi6220_dwmci_core_init(struct dwmci_host *host, int index)
  16. {
  17. host->name = "Hisilicon DWMMC";
  18. host->dev_index = index;
  19. /* Add the mmc channel to be registered with mmc core */
  20. if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) {
  21. printf("DWMMC%d registration failed\n", index);
  22. return -1;
  23. }
  24. return 0;
  25. }
  26. /*
  27. * This function adds the mmc channel to be registered with mmc core.
  28. * index - mmc channel number.
  29. * regbase - register base address of mmc channel specified in 'index'.
  30. * bus_width - operating bus width of mmc channel specified in 'index'.
  31. */
  32. int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width)
  33. {
  34. struct dwmci_host *host = NULL;
  35. host = calloc(1, sizeof(struct dwmci_host));
  36. if (!host) {
  37. pr_err("dwmci_host calloc failed!\n");
  38. return -ENOMEM;
  39. }
  40. host->ioaddr = (void *)(ulong)regbase;
  41. host->buswidth = bus_width;
  42. host->bus_hz = MMC0_DEFAULT_FREQ;
  43. return hi6220_dwmci_core_init(host, index);
  44. }