setup-sdhci-gpio.c 3.1 KB

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