setup-sdhci-gpio.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. unsigned int gpio;
  27. /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
  28. s3c_gpio_cfgpin_range(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
  29. for (gpio = S5PV210_GPG0(0); gpio < S5PV210_GPG0(2); gpio++)
  30. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  31. switch (width) {
  32. case 8:
  33. /* GPG1[3:6] special-funtion 3 */
  34. s3c_gpio_cfgpin_range(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
  35. for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++)
  36. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  37. case 4:
  38. /* GPG0[3:6] special-funtion 2 */
  39. s3c_gpio_cfgpin_range(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
  40. for (gpio = S5PV210_GPG0(3); gpio <= S5PV210_GPG0(6); gpio++)
  41. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  42. default:
  43. break;
  44. }
  45. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  46. s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
  47. s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
  48. }
  49. }
  50. void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
  51. {
  52. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  53. unsigned int gpio;
  54. /* Set all the necessary GPG1[0:1] pins to special-function 2 */
  55. s3c_gpio_cfgpin_range(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
  56. for (gpio = S5PV210_GPG1(0); gpio < S5PV210_GPG1(2); gpio++)
  57. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  58. /* Data pin GPG1[3:6] to special-function 2 */
  59. s3c_gpio_cfgpin_range(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
  60. for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++)
  61. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  62. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  63. s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
  64. s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
  65. }
  66. }
  67. void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  68. {
  69. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  70. unsigned int gpio;
  71. /* Set all the necessary GPG2[0:1] pins to special-function 2 */
  72. s3c_gpio_cfgpin_range(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
  73. for (gpio = S5PV210_GPG2(0); gpio < S5PV210_GPG2(2); gpio++)
  74. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  75. switch (width) {
  76. case 8:
  77. /* Data pin GPG3[3:6] to special-function 3 */
  78. s3c_gpio_cfgpin_range(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
  79. for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++)
  80. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  81. case 4:
  82. /* Data pin GPG2[3:6] to special-function 2 */
  83. s3c_gpio_cfgpin_range(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
  84. for (gpio = S5PV210_GPG2(3); gpio <= S5PV210_GPG2(6); gpio++)
  85. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  86. default:
  87. break;
  88. }
  89. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  90. s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
  91. s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
  92. }
  93. }
  94. void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
  95. {
  96. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  97. unsigned int gpio;
  98. /* Set all the necessary GPG3[0:1] pins to special-function 2 */
  99. s3c_gpio_cfgpin_range(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
  100. for (gpio = S5PV210_GPG3(0); gpio < S5PV210_GPG3(2); gpio++)
  101. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  102. /* Data pin GPG3[3:6] to special-function 2 */
  103. s3c_gpio_cfgpin_range(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
  104. for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++)
  105. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  106. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  107. s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
  108. s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));
  109. }
  110. }