tmio_core.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright(c) 2009 Ian Molton <spyro@f2s.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/export.h>
  9. #include <linux/mfd/tmio.h>
  10. int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base)
  11. {
  12. /* Enable the MMC/SD Control registers */
  13. sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
  14. sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
  15. /* Disable SD power during suspend */
  16. sd_config_write8(cnf, shift, CNF_PWR_CTL_3, 0x01);
  17. /* The below is required but why? FIXME */
  18. sd_config_write8(cnf, shift, CNF_STOP_CLK_CTL, 0x1f);
  19. /* Power down SD bus */
  20. sd_config_write8(cnf, shift, CNF_PWR_CTL_2, 0x00);
  21. return 0;
  22. }
  23. EXPORT_SYMBOL(tmio_core_mmc_enable);
  24. int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base)
  25. {
  26. /* Enable the MMC/SD Control registers */
  27. sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
  28. sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
  29. return 0;
  30. }
  31. EXPORT_SYMBOL(tmio_core_mmc_resume);
  32. void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state)
  33. {
  34. sd_config_write8(cnf, shift, CNF_PWR_CTL_2, state ? 0x02 : 0x00);
  35. }
  36. EXPORT_SYMBOL(tmio_core_mmc_pwr);
  37. void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state)
  38. {
  39. sd_config_write8(cnf, shift, CNF_SD_CLK_MODE, state ? 1 : 0);
  40. }
  41. EXPORT_SYMBOL(tmio_core_mmc_clk_div);