ftpmu010.c 2.2 KB

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