1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2009 Faraday Technology
6 * Copyright (C) 2010 Andes Technology Corporation
13 #include <faraday/ftpmu010.h>
15 /* OSCC: OSC Control Register */
16 void ftpmu010_32768osc_enable(void)
18 static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
21 /* enable the 32768Hz oscillator */
22 oscc = readl(&pmu->OSCC);
23 oscc &= ~(FTPMU010_OSCC_OSCL_OFF | FTPMU010_OSCC_OSCL_TRI);
24 writel(oscc, &pmu->OSCC);
26 /* wait until ready */
27 while (!(readl(&pmu->OSCC) & FTPMU010_OSCC_OSCL_STABLE))
30 /* select 32768Hz oscillator */
31 oscc = readl(&pmu->OSCC);
32 oscc |= FTPMU010_OSCC_OSCL_RTCLSEL;
33 writel(oscc, &pmu->OSCC);
36 /* MFPSR: Multi-Function Port Setting Register */
37 void ftpmu010_mfpsr_select_dev(unsigned int dev)
39 static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
42 mfpsr = readl(&pmu->MFPSR);
44 writel(mfpsr, &pmu->MFPSR);
47 void ftpmu010_mfpsr_diselect_dev(unsigned int dev)
49 static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
52 mfpsr = readl(&pmu->MFPSR);
54 writel(mfpsr, &pmu->MFPSR);
57 /* PDLLCR0: PLL/DLL Control Register 0 */
58 void ftpmu010_dlldis_disable(void)
60 static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
63 pdllcr0 = readl(&pmu->PDLLCR0);
64 pdllcr0 |= FTPMU010_PDLLCR0_DLLDIS;
65 writel(pdllcr0, &pmu->PDLLCR0);
68 void ftpmu010_sdram_clk_disable(unsigned int cr0)
70 static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
73 pdllcr0 = readl(&pmu->PDLLCR0);
74 pdllcr0 |= FTPMU010_PDLLCR0_HCLKOUTDIS(cr0);
75 writel(pdllcr0, &pmu->PDLLCR0);
78 /* SDRAMHTC: SDRAM Signal Hold Time Control */
79 void ftpmu010_sdramhtc_set(unsigned int val)
81 static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
82 unsigned int sdramhtc;
84 sdramhtc = readl(&pmu->SDRAMHTC);
86 writel(sdramhtc, &pmu->SDRAMHTC);