setup-sdhci-gpio.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* linux/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
  2. *
  3. * Copyright 2009 Samsung Eletronics
  4. *
  5. * S5PC1XX - 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. void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
  22. {
  23. unsigned int gpio;
  24. unsigned int end;
  25. unsigned int num;
  26. num = width;
  27. /* In case of 8 width, we should decrease the 2 */
  28. if (width == 8)
  29. num = width - 2;
  30. end = S5PC100_GPG0(2 + num);
  31. /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
  32. for (gpio = S5PC100_GPG0(0); gpio < end; gpio++) {
  33. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  34. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  35. }
  36. if (width == 8) {
  37. for (gpio = S5PC100_GPG1(0); gpio <= S5PC100_GPG1(1); gpio++) {
  38. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  39. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  40. }
  41. }
  42. s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
  43. s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2));
  44. }
  45. void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
  46. {
  47. unsigned int gpio;
  48. unsigned int end;
  49. end = S5PC100_GPG2(2 + width);
  50. /* Set all the necessary GPG2 pins to special-function 2 */
  51. for (gpio = S5PC100_GPG2(0); gpio < end; gpio++) {
  52. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  53. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  54. }
  55. s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
  56. s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2));
  57. }
  58. void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  59. {
  60. unsigned int gpio;
  61. unsigned int end;
  62. end = S5PC100_GPG3(2 + width);
  63. /* Set all the necessary GPG3 pins to special-function 2 */
  64. for (gpio = S5PC100_GPG3(0); gpio < end; gpio++) {
  65. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  66. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  67. }
  68. s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
  69. s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2));
  70. }