hi6220_dw_mmc.c 1.3 KB

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