pxa2xx.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/pxa2xx.c
  4. *
  5. * code specific to pxa2xx
  6. *
  7. * Copyright (C) 2008 Dmitry Baryshkov
  8. */
  9. #include <linux/module.h>
  10. #include <linux/kernel.h>
  11. #include <linux/device.h>
  12. #include <linux/io.h>
  13. #include "pxa2xx-regs.h"
  14. #include "mfp-pxa25x.h"
  15. #include "generic.h"
  16. #include "reset.h"
  17. #include "smemc.h"
  18. #include <linux/soc/pxa/smemc.h>
  19. #include <linux/platform_data/irda-pxaficp.h>
  20. void pxa2xx_clear_reset_status(unsigned int mask)
  21. {
  22. /* RESET_STATUS_* has a 1:1 mapping with RCSR */
  23. RCSR = mask;
  24. }
  25. static unsigned long pxa2xx_mfp_fir[] = {
  26. GPIO46_FICP_RXD,
  27. GPIO47_FICP_TXD,
  28. };
  29. static unsigned long pxa2xx_mfp_sir[] = {
  30. GPIO46_STUART_RXD,
  31. GPIO47_STUART_TXD,
  32. };
  33. static unsigned long pxa2xx_mfp_off[] = {
  34. GPIO46_GPIO | MFP_LPM_DRIVE_LOW,
  35. GPIO47_GPIO | MFP_LPM_DRIVE_LOW,
  36. };
  37. void pxa2xx_transceiver_mode(struct device *dev, int mode)
  38. {
  39. if (mode & IR_OFF) {
  40. pxa2xx_mfp_config(pxa2xx_mfp_off, ARRAY_SIZE(pxa2xx_mfp_off));
  41. } else if (mode & IR_SIRMODE) {
  42. pxa2xx_mfp_config(pxa2xx_mfp_sir, ARRAY_SIZE(pxa2xx_mfp_sir));
  43. } else if (mode & IR_FIRMODE) {
  44. pxa2xx_mfp_config(pxa2xx_mfp_fir, ARRAY_SIZE(pxa2xx_mfp_fir));
  45. } else
  46. BUG();
  47. }
  48. EXPORT_SYMBOL_GPL(pxa2xx_transceiver_mode);
  49. #define MDCNFG_DRAC2(mdcnfg) (((mdcnfg) >> 21) & 0x3)
  50. #define MDCNFG_DRAC0(mdcnfg) (((mdcnfg) >> 5) & 0x3)
  51. int pxa2xx_smemc_get_sdram_rows(void)
  52. {
  53. static int sdram_rows;
  54. unsigned int drac2 = 0, drac0 = 0;
  55. u32 mdcnfg;
  56. if (sdram_rows)
  57. return sdram_rows;
  58. mdcnfg = readl_relaxed(MDCNFG);
  59. if (mdcnfg & (MDCNFG_DE2 | MDCNFG_DE3))
  60. drac2 = MDCNFG_DRAC2(mdcnfg);
  61. if (mdcnfg & (MDCNFG_DE0 | MDCNFG_DE1))
  62. drac0 = MDCNFG_DRAC0(mdcnfg);
  63. sdram_rows = 1 << (11 + max(drac0, drac2));
  64. return sdram_rows;
  65. }