setup-sdhci-gpio.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/sdhci.h>
  21. void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
  22. {
  23. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  24. unsigned int num;
  25. num = width;
  26. /* In case of 8 width, we should decrease the 2 */
  27. if (width == 8)
  28. num = width - 2;
  29. /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
  30. s3c_gpio_cfgrange_nopull(S5PC100_GPG0(0), 2 + num, S3C_GPIO_SFN(2));
  31. if (width == 8)
  32. s3c_gpio_cfgrange_nopull(S5PC100_GPG1(0), 2, S3C_GPIO_SFN(2));
  33. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  34. s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
  35. s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2));
  36. }
  37. }
  38. void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
  39. {
  40. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  41. /* Set all the necessary GPG2 pins to special-function 2 */
  42. s3c_gpio_cfgrange_nopull(S5PC100_GPG2(0), 2 + width, S3C_GPIO_SFN(2));
  43. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  44. s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
  45. s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2));
  46. }
  47. }
  48. void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  49. {
  50. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  51. /* Set all the necessary GPG3 pins to special-function 2 */
  52. s3c_gpio_cfgrange_nopull(S5PC100_GPG3(0), 2 + width, S3C_GPIO_SFN(2));
  53. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  54. s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
  55. s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2));
  56. }
  57. }