setup-sdhci-gpio.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* linux/arch/arm/mach-s5p64x0/setup-sdhci-gpio.c
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  5. *
  6. * S5P64X0 - 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/platform_device.h>
  13. #include <linux/io.h>
  14. #include <linux/gpio.h>
  15. #include <mach/regs-gpio.h>
  16. #include <mach/regs-clock.h>
  17. #include <plat/gpio-cfg.h>
  18. #include <plat/sdhci.h>
  19. #include <plat/cpu.h>
  20. void s5p64x0_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
  21. {
  22. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  23. /* Set all the necessary GPG pins to special-function 2 */
  24. if (soc_is_s5p6450())
  25. s3c_gpio_cfgrange_nopull(S5P6450_GPG(0), 2 + width,
  26. S3C_GPIO_SFN(2));
  27. else
  28. s3c_gpio_cfgrange_nopull(S5P6440_GPG(0), 2 + width,
  29. S3C_GPIO_SFN(2));
  30. /* Set GPG[6] pin to special-function 2 - MMC0 CDn */
  31. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  32. if (soc_is_s5p6450()) {
  33. s3c_gpio_setpull(S5P6450_GPG(6), S3C_GPIO_PULL_UP);
  34. s3c_gpio_cfgpin(S5P6450_GPG(6), S3C_GPIO_SFN(2));
  35. } else {
  36. s3c_gpio_setpull(S5P6440_GPG(6), S3C_GPIO_PULL_UP);
  37. s3c_gpio_cfgpin(S5P6440_GPG(6), S3C_GPIO_SFN(2));
  38. }
  39. }
  40. }
  41. void s5p64x0_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
  42. {
  43. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  44. /* Set GPH[0:1] pins to special-function 2 - CLK and CMD */
  45. if (soc_is_s5p6450())
  46. s3c_gpio_cfgrange_nopull(S5P6450_GPH(0), 2, S3C_GPIO_SFN(2));
  47. else
  48. s3c_gpio_cfgrange_nopull(S5P6440_GPH(0), 2 , S3C_GPIO_SFN(2));
  49. switch (width) {
  50. case 8:
  51. /* Set data pins GPH[6:9] special-function 2 */
  52. if (soc_is_s5p6450())
  53. s3c_gpio_cfgrange_nopull(S5P6450_GPH(6), 4,
  54. S3C_GPIO_SFN(2));
  55. else
  56. s3c_gpio_cfgrange_nopull(S5P6440_GPH(6), 4,
  57. S3C_GPIO_SFN(2));
  58. case 4:
  59. /* set data pins GPH[2:5] special-function 2 */
  60. if (soc_is_s5p6450())
  61. s3c_gpio_cfgrange_nopull(S5P6450_GPH(2), 4,
  62. S3C_GPIO_SFN(2));
  63. else
  64. s3c_gpio_cfgrange_nopull(S5P6440_GPH(2), 4,
  65. S3C_GPIO_SFN(2));
  66. default:
  67. break;
  68. }
  69. /* Set GPG[6] pin to special-funtion 3 : MMC1 CDn */
  70. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  71. if (soc_is_s5p6450()) {
  72. s3c_gpio_setpull(S5P6450_GPG(6), S3C_GPIO_PULL_UP);
  73. s3c_gpio_cfgpin(S5P6450_GPG(6), S3C_GPIO_SFN(3));
  74. } else {
  75. s3c_gpio_setpull(S5P6440_GPG(6), S3C_GPIO_PULL_UP);
  76. s3c_gpio_cfgpin(S5P6440_GPG(6), S3C_GPIO_SFN(3));
  77. }
  78. }
  79. }
  80. void s5p6440_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  81. {
  82. /* Set GPC[4:5] pins to special-function 3 - CLK and CMD */
  83. s3c_gpio_cfgrange_nopull(S5P6440_GPC(4), 2, S3C_GPIO_SFN(3));
  84. /* Set data pins GPH[6:9] pins to special-function 3 */
  85. s3c_gpio_cfgrange_nopull(S5P6440_GPH(6), 4, S3C_GPIO_SFN(3));
  86. }
  87. void s5p6450_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  88. {
  89. /* Set all the necessary GPG pins to special-function 3 */
  90. s3c_gpio_cfgrange_nopull(S5P6450_GPG(7), 2 + width, S3C_GPIO_SFN(3));
  91. }