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 #include <linux/platform_data/irda-pxaficp.h>
22
pxa2xx_clear_reset_status(unsigned int mask)23 void pxa2xx_clear_reset_status(unsigned int mask)
24 {
25 /* RESET_STATUS_* has a 1:1 mapping with RCSR */
26 RCSR = mask;
27 }
28
29 static unsigned long pxa2xx_mfp_fir[] = {
30 GPIO46_FICP_RXD,
31 GPIO47_FICP_TXD,
32 };
33
34 static unsigned long pxa2xx_mfp_sir[] = {
35 GPIO46_STUART_RXD,
36 GPIO47_STUART_TXD,
37 };
38
39 static unsigned long pxa2xx_mfp_off[] = {
40 GPIO46_GPIO | MFP_LPM_DRIVE_LOW,
41 GPIO47_GPIO | MFP_LPM_DRIVE_LOW,
42 };
43
pxa2xx_transceiver_mode(struct device * dev,int mode)44 void pxa2xx_transceiver_mode(struct device *dev, int mode)
45 {
46 if (mode & IR_OFF) {
47 pxa2xx_mfp_config(pxa2xx_mfp_off, ARRAY_SIZE(pxa2xx_mfp_off));
48 } else if (mode & IR_SIRMODE) {
49 pxa2xx_mfp_config(pxa2xx_mfp_sir, ARRAY_SIZE(pxa2xx_mfp_sir));
50 } else if (mode & IR_FIRMODE) {
51 pxa2xx_mfp_config(pxa2xx_mfp_fir, ARRAY_SIZE(pxa2xx_mfp_fir));
52 } else
53 BUG();
54 }
55 EXPORT_SYMBOL_GPL(pxa2xx_transceiver_mode);
56
57 #define MDCNFG_DRAC2(mdcnfg) (((mdcnfg) >> 21) & 0x3)
58 #define MDCNFG_DRAC0(mdcnfg) (((mdcnfg) >> 5) & 0x3)
59
pxa2xx_smemc_get_sdram_rows(void)60 int pxa2xx_smemc_get_sdram_rows(void)
61 {
62 static int sdram_rows;
63 unsigned int drac2 = 0, drac0 = 0;
64 u32 mdcnfg;
65
66 if (sdram_rows)
67 return sdram_rows;
68
69 mdcnfg = readl_relaxed(MDCNFG);
70
71 if (mdcnfg & (MDCNFG_DE2 | MDCNFG_DE3))
72 drac2 = MDCNFG_DRAC2(mdcnfg);
73
74 if (mdcnfg & (MDCNFG_DE0 | MDCNFG_DE1))
75 drac0 = MDCNFG_DRAC0(mdcnfg);
76
77 sdram_rows = 1 << (11 + max(drac0, drac2));
78 return sdram_rows;
79 }
80