xref: /openbmc/linux/arch/arm/mach-pxa/pxa2xx.c (revision fceec5d6)
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 
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/device.h>
13 #include <linux/io.h>
14 
15 #include "pxa2xx-regs.h"
16 #include "mfp-pxa25x.h"
17 #include "generic.h"
18 #include "reset.h"
19 #include "smemc.h"
20 #include <linux/soc/pxa/smemc.h>
21 
22 void pxa2xx_clear_reset_status(unsigned int mask)
23 {
24 	/* RESET_STATUS_* has a 1:1 mapping with RCSR */
25 	RCSR = mask;
26 }
27 
28 #define MDCNFG_DRAC2(mdcnfg)	(((mdcnfg) >> 21) & 0x3)
29 #define MDCNFG_DRAC0(mdcnfg)	(((mdcnfg) >> 5) & 0x3)
30 
31 int pxa2xx_smemc_get_sdram_rows(void)
32 {
33 	static int sdram_rows;
34 	unsigned int drac2 = 0, drac0 = 0;
35 	u32 mdcnfg;
36 
37 	if (sdram_rows)
38 		return sdram_rows;
39 
40 	mdcnfg = readl_relaxed(MDCNFG);
41 
42 	if (mdcnfg & (MDCNFG_DE2 | MDCNFG_DE3))
43 		drac2 = MDCNFG_DRAC2(mdcnfg);
44 
45 	if (mdcnfg & (MDCNFG_DE0 | MDCNFG_DE1))
46 		drac0 = MDCNFG_DRAC0(mdcnfg);
47 
48 	sdram_rows = 1 << (11 + max(drac0, drac2));
49 	return sdram_rows;
50 }
51