tmio_core.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #define CNF_CMD 0x04
  11. #define CNF_CTL_BASE 0x10
  12. #define CNF_INT_PIN 0x3d
  13. #define CNF_STOP_CLK_CTL 0x40
  14. #define CNF_GCLK_CTL 0x41
  15. #define CNF_SD_CLK_MODE 0x42
  16. #define CNF_PIN_STATUS 0x44
  17. #define CNF_PWR_CTL_1 0x48
  18. #define CNF_PWR_CTL_2 0x49
  19. #define CNF_PWR_CTL_3 0x4a
  20. #define CNF_CARD_DETECT_MODE 0x4c
  21. #define CNF_SD_SLOT 0x50
  22. #define CNF_EXT_GCLK_CTL_1 0xf0
  23. #define CNF_EXT_GCLK_CTL_2 0xf1
  24. #define CNF_EXT_GCLK_CTL_3 0xf9
  25. #define CNF_SD_LED_EN_1 0xfa
  26. #define CNF_SD_LED_EN_2 0xfe
  27. #define SDCREN 0x2 /* Enable access to MMC CTL regs. (flag in COMMAND_REG)*/
  28. int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base)
  29. {
  30. /* Enable the MMC/SD Control registers */
  31. sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
  32. sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
  33. /* Disable SD power during suspend */
  34. sd_config_write8(cnf, shift, CNF_PWR_CTL_3, 0x01);
  35. /* The below is required but why? FIXME */
  36. sd_config_write8(cnf, shift, CNF_STOP_CLK_CTL, 0x1f);
  37. /* Power down SD bus */
  38. sd_config_write8(cnf, shift, CNF_PWR_CTL_2, 0x00);
  39. return 0;
  40. }
  41. EXPORT_SYMBOL(tmio_core_mmc_enable);
  42. int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base)
  43. {
  44. /* Enable the MMC/SD Control registers */
  45. sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
  46. sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
  47. return 0;
  48. }
  49. EXPORT_SYMBOL(tmio_core_mmc_resume);
  50. void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state)
  51. {
  52. sd_config_write8(cnf, shift, CNF_PWR_CTL_2, state ? 0x02 : 0x00);
  53. }
  54. EXPORT_SYMBOL(tmio_core_mmc_pwr);
  55. void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state)
  56. {
  57. sd_config_write8(cnf, shift, CNF_SD_CLK_MODE, state ? 1 : 0);
  58. }
  59. EXPORT_SYMBOL(tmio_core_mmc_clk_div);