Skip to content

Commit 42b380b

Browse files
tmlindstorulf
authored andcommitted
mmc: sdhci-omap: Add omap_offset to support omap3 and earlier
The omap specific registers are at offset 0x100 from base for omap4 and later, and for omap3 and earlier they are at offset 0. Let's handle also the earlier SoCs by adding omap_offset. Note that eventually we should just move to using standard sdhci register access for the sdhci range with new offsets starting at 0x100. Signed-off-by: Tony Lindgren <tony@atomide.com> Link: https://lore.kernel.org/r/20211015104720.52240-4-tony@atomide.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent de5ccd2 commit 42b380b

File tree

1 file changed

+45
-16
lines changed

1 file changed

+45
-16
lines changed

drivers/mmc/host/sdhci-omap.c

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121

2222
#include "sdhci-pltfm.h"
2323

24-
#define SDHCI_OMAP_SYSCONFIG 0x110
24+
/*
25+
* Note that the register offsets used here are from omap_regs
26+
* base which is 0x100 for omap4 and later, and 0 for omap3 and
27+
* earlier.
28+
*/
29+
#define SDHCI_OMAP_SYSCONFIG 0x10
2530

26-
#define SDHCI_OMAP_CON 0x12c
31+
#define SDHCI_OMAP_CON 0x2c
2732
#define CON_DW8 BIT(5)
2833
#define CON_DMA_MASTER BIT(20)
2934
#define CON_DDR BIT(19)
@@ -33,49 +38,49 @@
3338
#define CON_INIT BIT(1)
3439
#define CON_OD BIT(0)
3540

36-
#define SDHCI_OMAP_DLL 0x0134
41+
#define SDHCI_OMAP_DLL 0x34
3742
#define DLL_SWT BIT(20)
3843
#define DLL_FORCE_SR_C_SHIFT 13
3944
#define DLL_FORCE_SR_C_MASK (0x7f << DLL_FORCE_SR_C_SHIFT)
4045
#define DLL_FORCE_VALUE BIT(12)
4146
#define DLL_CALIB BIT(1)
4247

43-
#define SDHCI_OMAP_CMD 0x20c
48+
#define SDHCI_OMAP_CMD 0x10c
4449

45-
#define SDHCI_OMAP_PSTATE 0x0224
50+
#define SDHCI_OMAP_PSTATE 0x124
4651
#define PSTATE_DLEV_DAT0 BIT(20)
4752
#define PSTATE_DATI BIT(1)
4853

49-
#define SDHCI_OMAP_HCTL 0x228
54+
#define SDHCI_OMAP_HCTL 0x128
5055
#define HCTL_SDBP BIT(8)
5156
#define HCTL_SDVS_SHIFT 9
5257
#define HCTL_SDVS_MASK (0x7 << HCTL_SDVS_SHIFT)
5358
#define HCTL_SDVS_33 (0x7 << HCTL_SDVS_SHIFT)
5459
#define HCTL_SDVS_30 (0x6 << HCTL_SDVS_SHIFT)
5560
#define HCTL_SDVS_18 (0x5 << HCTL_SDVS_SHIFT)
5661

57-
#define SDHCI_OMAP_SYSCTL 0x22c
62+
#define SDHCI_OMAP_SYSCTL 0x12c
5863
#define SYSCTL_CEN BIT(2)
5964
#define SYSCTL_CLKD_SHIFT 6
6065
#define SYSCTL_CLKD_MASK 0x3ff
6166

62-
#define SDHCI_OMAP_STAT 0x230
67+
#define SDHCI_OMAP_STAT 0x130
6368

64-
#define SDHCI_OMAP_IE 0x234
69+
#define SDHCI_OMAP_IE 0x134
6570
#define INT_CC_EN BIT(0)
6671

67-
#define SDHCI_OMAP_ISE 0x238
72+
#define SDHCI_OMAP_ISE 0x138
6873

69-
#define SDHCI_OMAP_AC12 0x23c
74+
#define SDHCI_OMAP_AC12 0x13c
7075
#define AC12_V1V8_SIGEN BIT(19)
7176
#define AC12_SCLK_SEL BIT(23)
7277

73-
#define SDHCI_OMAP_CAPA 0x240
78+
#define SDHCI_OMAP_CAPA 0x140
7479
#define CAPA_VS33 BIT(24)
7580
#define CAPA_VS30 BIT(25)
7681
#define CAPA_VS18 BIT(26)
7782

78-
#define SDHCI_OMAP_CAPA2 0x0244
83+
#define SDHCI_OMAP_CAPA2 0x144
7984
#define CAPA2_TSDR50 BIT(13)
8085

8186
#define SDHCI_OMAP_TIMEOUT 1 /* 1 msec */
@@ -93,7 +98,8 @@
9398
#define SDHCI_OMAP_SPECIAL_RESET BIT(1)
9499

95100
struct sdhci_omap_data {
96-
u32 offset;
101+
int omap_offset; /* Offset for omap regs from base */
102+
u32 offset; /* Offset for SDHCI regs from base */
97103
u8 flags;
98104
};
99105

@@ -112,6 +118,10 @@ struct sdhci_omap_host {
112118
struct pinctrl *pinctrl;
113119
struct pinctrl_state **pinctrl_state;
114120
bool is_tuning;
121+
122+
/* Offset for omap specific registers from base */
123+
int omap_offset;
124+
115125
/* Omap specific context save */
116126
u32 con;
117127
u32 hctl;
@@ -127,13 +137,13 @@ static void sdhci_omap_stop_clock(struct sdhci_omap_host *omap_host);
127137
static inline u32 sdhci_omap_readl(struct sdhci_omap_host *host,
128138
unsigned int offset)
129139
{
130-
return readl(host->base + offset);
140+
return readl(host->base + host->omap_offset + offset);
131141
}
132142

133143
static inline void sdhci_omap_writel(struct sdhci_omap_host *host,
134144
unsigned int offset, u32 data)
135145
{
136-
writel(data, host->base + offset);
146+
writel(data, host->base + host->omap_offset + offset);
137147
}
138148

139149
static int sdhci_omap_set_pbias(struct sdhci_omap_host *omap_host,
@@ -1009,36 +1019,54 @@ static const struct sdhci_pltfm_data sdhci_omap_pdata = {
10091019
.ops = &sdhci_omap_ops,
10101020
};
10111021

1022+
static const struct sdhci_omap_data omap2430_data = {
1023+
.omap_offset = 0,
1024+
.offset = 0x100,
1025+
};
1026+
1027+
static const struct sdhci_omap_data omap3_data = {
1028+
.omap_offset = 0,
1029+
.offset = 0x100,
1030+
};
1031+
10121032
static const struct sdhci_omap_data omap4_data = {
1033+
.omap_offset = 0x100,
10131034
.offset = 0x200,
10141035
.flags = SDHCI_OMAP_SPECIAL_RESET,
10151036
};
10161037

10171038
static const struct sdhci_omap_data omap5_data = {
1039+
.omap_offset = 0x100,
10181040
.offset = 0x200,
10191041
.flags = SDHCI_OMAP_SPECIAL_RESET,
10201042
};
10211043

10221044
static const struct sdhci_omap_data k2g_data = {
1045+
.omap_offset = 0x100,
10231046
.offset = 0x200,
10241047
};
10251048

10261049
static const struct sdhci_omap_data am335_data = {
1050+
.omap_offset = 0x100,
10271051
.offset = 0x200,
10281052
.flags = SDHCI_OMAP_SPECIAL_RESET,
10291053
};
10301054

10311055
static const struct sdhci_omap_data am437_data = {
1056+
.omap_offset = 0x100,
10321057
.offset = 0x200,
10331058
.flags = SDHCI_OMAP_SPECIAL_RESET,
10341059
};
10351060

10361061
static const struct sdhci_omap_data dra7_data = {
1062+
.omap_offset = 0x100,
10371063
.offset = 0x200,
10381064
.flags = SDHCI_OMAP_REQUIRE_IODELAY,
10391065
};
10401066

10411067
static const struct of_device_id omap_sdhci_match[] = {
1068+
{ .compatible = "ti,omap2430-sdhci", .data = &omap2430_data },
1069+
{ .compatible = "ti,omap3-sdhci", .data = &omap3_data },
10421070
{ .compatible = "ti,omap4-sdhci", .data = &omap4_data },
10431071
{ .compatible = "ti,omap5-sdhci", .data = &omap5_data },
10441072
{ .compatible = "ti,dra7-sdhci", .data = &dra7_data },
@@ -1223,6 +1251,7 @@ static int sdhci_omap_probe(struct platform_device *pdev)
12231251
omap_host->power_mode = MMC_POWER_UNDEFINED;
12241252
omap_host->timing = MMC_TIMING_LEGACY;
12251253
omap_host->flags = data->flags;
1254+
omap_host->omap_offset = data->omap_offset;
12261255
host->ioaddr += offset;
12271256
host->mapbase = regs->start + offset;
12281257

0 commit comments

Comments
 (0)