setup-sdhci-gpio.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* linux/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
  2. *
  3. * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  5. *
  6. * S5PV210 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <linux/gpio.h>
  18. #include <linux/mmc/host.h>
  19. #include <linux/mmc/card.h>
  20. #include <plat/gpio-cfg.h>
  21. #include <plat/regs-sdhci.h>
  22. #include <plat/sdhci.h>
  23. void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
  24. {
  25. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  26. /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
  27. s3c_gpio_cfgrange_nopull(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
  28. switch (width) {
  29. case 8:
  30. /* GPG1[3:6] special-function 3 */
  31. s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
  32. case 4:
  33. /* GPG0[3:6] special-function 2 */
  34. s3c_gpio_cfgrange_nopull(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
  35. default:
  36. break;
  37. }
  38. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  39. s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
  40. s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
  41. }
  42. }
  43. void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
  44. {
  45. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  46. /* Set all the necessary GPG1[0:1] pins to special-function 2 */
  47. s3c_gpio_cfgrange_nopull(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
  48. /* Data pin GPG1[3:6] to special-function 2 */
  49. s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
  50. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  51. s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
  52. s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
  53. }
  54. }
  55. void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  56. {
  57. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  58. /* Set all the necessary GPG2[0:1] pins to special-function 2 */
  59. s3c_gpio_cfgrange_nopull(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
  60. switch (width) {
  61. case 8:
  62. /* Data pin GPG3[3:6] to special-function 3 */
  63. s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
  64. case 4:
  65. /* Data pin GPG2[3:6] to special-function 2 */
  66. s3c_gpio_cfgrange_nopull(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
  67. default:
  68. break;
  69. }
  70. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  71. s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
  72. s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
  73. }
  74. }
  75. void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
  76. {
  77. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  78. /* Set all the necessary GPG3[0:1] pins to special-function 2 */
  79. s3c_gpio_cfgrange_nopull(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
  80. /* Data pin GPG3[3:6] to special-function 2 */
  81. s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
  82. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  83. s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
  84. s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));
  85. }
  86. }