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/mfd/tmio.h>
  9. int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base)
  10. {
  11. /* Enable the MMC/SD Control registers */
  12. sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
  13. sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
  14. /* Disable SD power during suspend */
  15. sd_config_write8(cnf, shift, CNF_PWR_CTL_3, 0x01);
  16. /* The below is required but why? FIXME */
  17. sd_config_write8(cnf, shift, CNF_STOP_CLK_CTL, 0x1f);
  18. /* Power down SD bus */
  19. sd_config_write8(cnf, shift, CNF_PWR_CTL_2, 0x00);
  20. return 0;
  21. }
  22. EXPORT_SYMBOL(tmio_core_mmc_enable);
  23. int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base)
  24. {
  25. /* Enable the MMC/SD Control registers */
  26. sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
  27. sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
  28. return 0;
  29. }
  30. EXPORT_SYMBOL(tmio_core_mmc_resume);
  31. void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state)
  32. {
  33. sd_config_write8(cnf, shift, CNF_PWR_CTL_2, state ? 0x02 : 0x00);
  34. }
  35. EXPORT_SYMBOL(tmio_core_mmc_pwr);
  36. void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state)
  37. {
  38. sd_config_write8(cnf, shift, CNF_SD_CLK_MODE, state ? 1 : 0);
  39. }
  40. EXPORT_SYMBOL(tmio_core_mmc_clk_div);