setup-sdhci-gpio.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* linux/arch/arm/plat-s3c64xx/setup-sdhci-gpio.c
  2. *
  3. * Copyright 2008 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. * http://armlinux.simtec.co.uk/
  6. *
  7. * S3C64XX - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/io.h>
  18. #include <linux/gpio.h>
  19. #include <plat/gpio-cfg.h>
  20. #include <plat/sdhci.h>
  21. void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
  22. {
  23. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  24. unsigned int gpio;
  25. unsigned int end;
  26. end = S3C64XX_GPG(2 + width);
  27. /* Set all the necessary GPG pins to special-function 0 */
  28. for (gpio = S3C64XX_GPG(0); gpio < end; gpio++) {
  29. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  30. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  31. }
  32. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  33. s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP);
  34. s3c_gpio_cfgpin(S3C64XX_GPG(6), S3C_GPIO_SFN(2));
  35. }
  36. }
  37. void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
  38. {
  39. struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
  40. unsigned int gpio;
  41. unsigned int end;
  42. end = S3C64XX_GPH(2 + width);
  43. /* Set all the necessary GPG pins to special-function 0 */
  44. for (gpio = S3C64XX_GPH(0); gpio < end; gpio++) {
  45. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  46. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  47. }
  48. if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
  49. s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP);
  50. s3c_gpio_cfgpin(S3C64XX_GPG(6), S3C_GPIO_SFN(3));
  51. }
  52. }
  53. void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
  54. {
  55. unsigned int gpio;
  56. unsigned int end;
  57. end = S3C64XX_GPH(6 + width);
  58. /* Set all the necessary GPH pins to special-function 1 */
  59. for (gpio = S3C64XX_GPH(6); gpio < end; gpio++) {
  60. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
  61. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  62. }
  63. /* Set all the necessary GPC pins to special-function 1 */
  64. for (gpio = S3C64XX_GPC(4); gpio < S3C64XX_GPC(6); gpio++) {
  65. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
  66. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  67. }
  68. }