padmux.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. *
  3. * arch/arm/mach-u300/padmux.c
  4. *
  5. *
  6. * Copyright (C) 2009 ST-Ericsson AB
  7. * License terms: GNU General Public License (GPL) version 2
  8. * U300 PADMUX functions
  9. * Author: Linus Walleij <linus.walleij@stericsson.com>
  10. *
  11. */
  12. #include <linux/io.h>
  13. #include <linux/err.h>
  14. #include <mach/u300-regs.h>
  15. #include <mach/syscon.h>
  16. #include "padmux.h"
  17. /* Set the PAD MUX to route the MMC reader correctly to GPIO0. */
  18. void pmx_set_mission_mode_mmc(void)
  19. {
  20. u16 val;
  21. val = readw(U300_SYSCON_VBASE + U300_SYSCON_PMC1LR);
  22. val &= ~U300_SYSCON_PMC1LR_MMCSD_MASK;
  23. writew(val, U300_SYSCON_VBASE + U300_SYSCON_PMC1LR);
  24. val = readw(U300_SYSCON_VBASE + U300_SYSCON_PMC1HR);
  25. val &= ~U300_SYSCON_PMC1HR_APP_GPIO_1_MASK;
  26. val |= U300_SYSCON_PMC1HR_APP_GPIO_1_MMC;
  27. writew(val, U300_SYSCON_VBASE + U300_SYSCON_PMC1HR);
  28. }
  29. void pmx_set_mission_mode_spi(void)
  30. {
  31. u16 val;
  32. /* Set up padmuxing so the SPI port and its chipselects are active */
  33. val = readw(U300_SYSCON_VBASE + U300_SYSCON_PMC1HR);
  34. /*
  35. * Activate the SPI port (disable the use of these pins for generic
  36. * GPIO, DSP, AAIF
  37. */
  38. val &= ~U300_SYSCON_PMC1HR_APP_SPI_2_MASK;
  39. val |= U300_SYSCON_PMC1HR_APP_SPI_2_SPI;
  40. /*
  41. * Use GPIO pin SPI CS1 for CS1 actually (it can be used for other
  42. * things also)
  43. */
  44. val &= ~U300_SYSCON_PMC1HR_APP_SPI_CS_1_MASK;
  45. val |= U300_SYSCON_PMC1HR_APP_SPI_CS_1_SPI;
  46. /*
  47. * Use GPIO pin SPI CS2 for CS2 actually (it can be used for other
  48. * things also)
  49. */
  50. val &= ~U300_SYSCON_PMC1HR_APP_SPI_CS_2_MASK;
  51. val |= U300_SYSCON_PMC1HR_APP_SPI_CS_2_SPI;
  52. writew(val, U300_SYSCON_VBASE + U300_SYSCON_PMC1HR);
  53. }