setup-sdhci-gpio.c 4.1 KB

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