setup-sdhci-gpio.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* linux/arch/arm/plat-s5pc100/setup-sdhci-gpio.c
  2. *
  3. * Copyright 2009 Samsung Eletronics
  4. *
  5. * S5PC100 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/io.h>
  16. #include <linux/gpio.h>
  17. #include <linux/mmc/host.h>
  18. #include <linux/mmc/card.h>
  19. #include <plat/gpio-cfg.h>
  20. #include <plat/regs-sdhci.h>
  21. #include <plat/sdhci.h>
  22. void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
  23. {
  24. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  25. unsigned int gpio;
  26. unsigned int end;
  27. unsigned int num;
  28. num = width;
  29. /* In case of 8 width, we should decrease the 2 */
  30. if (width == 8)
  31. num = width - 2;
  32. end = S5PC100_GPG0(2 + num);
  33. /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
  34. for (gpio = S5PC100_GPG0(0); gpio < end; gpio++) {
  35. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  36. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  37. }
  38. if (width == 8) {
  39. for (gpio = S5PC100_GPG1(0); gpio <= S5PC100_GPG1(1); gpio++) {
  40. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  41. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  42. }
  43. }
  44. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  45. s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
  46. s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2));
  47. }
  48. }
  49. void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
  50. {
  51. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  52. unsigned int gpio;
  53. unsigned int end;
  54. end = S5PC100_GPG2(2 + width);
  55. /* Set all the necessary GPG2 pins to special-function 2 */
  56. for (gpio = S5PC100_GPG2(0); gpio < end; gpio++) {
  57. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  58. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  59. }
  60. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  61. s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
  62. s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2));
  63. }
  64. }
  65. void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  66. {
  67. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  68. unsigned int gpio;
  69. unsigned int end;
  70. end = S5PC100_GPG3(2 + width);
  71. /* Set all the necessary GPG3 pins to special-function 2 */
  72. for (gpio = S5PC100_GPG3(0); gpio < end; gpio++) {
  73. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  74. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  75. }
  76. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  77. s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
  78. s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2));
  79. }
  80. }