ftpmu010.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2009 Faraday Technology
  4. * Po-Yu Chuang <ratbert@faraday-tech.com>
  5. *
  6. * Copyright (C) 2010 Andes Technology Corporation
  7. * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
  8. * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
  9. */
  10. #include <common.h>
  11. #include <asm/io.h>
  12. #include <faraday/ftpmu010.h>
  13. /* OSCC: OSC Control Register */
  14. void ftpmu010_32768osc_enable(void)
  15. {
  16. static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
  17. unsigned int oscc;
  18. /* enable the 32768Hz oscillator */
  19. oscc = readl(&pmu->OSCC);
  20. oscc &= ~(FTPMU010_OSCC_OSCL_OFF | FTPMU010_OSCC_OSCL_TRI);
  21. writel(oscc, &pmu->OSCC);
  22. /* wait until ready */
  23. while (!(readl(&pmu->OSCC) & FTPMU010_OSCC_OSCL_STABLE))
  24. ;
  25. /* select 32768Hz oscillator */
  26. oscc = readl(&pmu->OSCC);
  27. oscc |= FTPMU010_OSCC_OSCL_RTCLSEL;
  28. writel(oscc, &pmu->OSCC);
  29. }
  30. /* MFPSR: Multi-Function Port Setting Register */
  31. void ftpmu010_mfpsr_select_dev(unsigned int dev)
  32. {
  33. static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
  34. unsigned int mfpsr;
  35. mfpsr = readl(&pmu->MFPSR);
  36. mfpsr |= dev;
  37. writel(mfpsr, &pmu->MFPSR);
  38. }
  39. void ftpmu010_mfpsr_diselect_dev(unsigned int dev)
  40. {
  41. static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
  42. unsigned int mfpsr;
  43. mfpsr = readl(&pmu->MFPSR);
  44. mfpsr &= ~dev;
  45. writel(mfpsr, &pmu->MFPSR);
  46. }
  47. /* PDLLCR0: PLL/DLL Control Register 0 */
  48. void ftpmu010_dlldis_disable(void)
  49. {
  50. static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
  51. unsigned int pdllcr0;
  52. pdllcr0 = readl(&pmu->PDLLCR0);
  53. pdllcr0 |= FTPMU010_PDLLCR0_DLLDIS;
  54. writel(pdllcr0, &pmu->PDLLCR0);
  55. }
  56. void ftpmu010_sdram_clk_disable(unsigned int cr0)
  57. {
  58. static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
  59. unsigned int pdllcr0;
  60. pdllcr0 = readl(&pmu->PDLLCR0);
  61. pdllcr0 |= FTPMU010_PDLLCR0_HCLKOUTDIS(cr0);
  62. writel(pdllcr0, &pmu->PDLLCR0);
  63. }
  64. /* SDRAMHTC: SDRAM Signal Hold Time Control */
  65. void ftpmu010_sdramhtc_set(unsigned int val)
  66. {
  67. static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
  68. unsigned int sdramhtc;
  69. sdramhtc = readl(&pmu->SDRAMHTC);
  70. sdramhtc |= val;
  71. writel(sdramhtc, &pmu->SDRAMHTC);
  72. }