setup-sdhci-gpio.c 3.4 KB

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