Skip to content

Commit 3b159a6

Browse files
morimotocjb
authored andcommitted
mmc: tmio: bus_shift become tmio_mmc_data member
.bus_shift is used to 16/32bit register access offset calculation on tmio driver. tmio_mmc_xxx is used from Toshiba/Renesas now, but this bus_shift value depends on HW IP. This patch moves .bus_shift to tmio_mmc_data member and sets it on each driver. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent 05fae4a commit 3b159a6

6 files changed

Lines changed: 26 additions & 13 deletions

File tree

‎drivers/mmc/host/sh_mobile_sdhi.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,15 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
133133
struct tmio_mmc_data *mmc_data;
134134
struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
135135
struct tmio_mmc_host *host;
136+
struct resource *res;
136137
int irq, ret, i = 0;
137138
bool multiplexed_isr = true;
138139
struct tmio_mmc_dma *dma_priv;
139140

141+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
142+
if (!res)
143+
return -EINVAL;
144+
140145
priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL);
141146
if (priv == NULL) {
142147
dev_err(&pdev->dev, "kzalloc failed\n");
@@ -206,6 +211,9 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
206211
mmc_data->flags |= of_data->tmio_flags;
207212
}
208213

214+
/* SD control register space size is 0x100, 0x200 for bus_shift=1 */
215+
mmc_data->bus_shift = resource_size(res) >> 9;
216+
209217
ret = tmio_mmc_host_probe(&host, pdev, mmc_data);
210218
if (ret < 0)
211219
goto eprobe;

‎drivers/mmc/host/tmio_mmc.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static int tmio_mmc_probe(struct platform_device *pdev)
6262
const struct mfd_cell *cell = mfd_get_cell(pdev);
6363
struct tmio_mmc_data *pdata;
6464
struct tmio_mmc_host *host;
65+
struct resource *res;
6566
int ret = -EINVAL, irq;
6667

6768
if (pdev->num_resources != 2)
@@ -84,6 +85,13 @@ static int tmio_mmc_probe(struct platform_device *pdev)
8485
goto out;
8586
}
8687

88+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
89+
if (!res)
90+
return -EINVAL;
91+
92+
/* SD control register space size is 0x200, 0x400 for bus_shift=1 */
93+
pdata->bus_shift = resource_size(res_ctl) >> 10;
94+
8795
ret = tmio_mmc_host_probe(&host, pdev, pdata);
8896
if (ret)
8997
goto cell_disable;

‎drivers/mmc/host/tmio_mmc.h‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ enum tmio_mmc_power {
5858

5959
struct tmio_mmc_host {
6060
void __iomem *ctl;
61-
unsigned long bus_shift;
6261
struct mmc_command *cmd;
6362
struct mmc_request *mrq;
6463
struct mmc_data *data;
@@ -176,19 +175,19 @@ int tmio_mmc_host_runtime_resume(struct device *dev);
176175

177176
static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr)
178177
{
179-
return readw(host->ctl + (addr << host->bus_shift));
178+
return readw(host->ctl + (addr << host->pdata->bus_shift));
180179
}
181180

182181
static inline void sd_ctrl_read16_rep(struct tmio_mmc_host *host, int addr,
183182
u16 *buf, int count)
184183
{
185-
readsw(host->ctl + (addr << host->bus_shift), buf, count);
184+
readsw(host->ctl + (addr << host->pdata->bus_shift), buf, count);
186185
}
187186

188187
static inline u32 sd_ctrl_read32(struct tmio_mmc_host *host, int addr)
189188
{
190-
return readw(host->ctl + (addr << host->bus_shift)) |
191-
readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16;
189+
return readw(host->ctl + (addr << host->pdata->bus_shift)) |
190+
readw(host->ctl + ((addr + 2) << host->pdata->bus_shift)) << 16;
192191
}
193192

194193
static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, u16 val)
@@ -198,19 +197,19 @@ static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, u16 val
198197
*/
199198
if (host->pdata->write16_hook && host->pdata->write16_hook(host, addr))
200199
return;
201-
writew(val, host->ctl + (addr << host->bus_shift));
200+
writew(val, host->ctl + (addr << host->pdata->bus_shift));
202201
}
203202

204203
static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr,
205204
u16 *buf, int count)
206205
{
207-
writesw(host->ctl + (addr << host->bus_shift), buf, count);
206+
writesw(host->ctl + (addr << host->pdata->bus_shift), buf, count);
208207
}
209208

210209
static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val)
211210
{
212-
writew(val, host->ctl + (addr << host->bus_shift));
213-
writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
211+
writew(val, host->ctl + (addr << host->pdata->bus_shift));
212+
writew(val >> 16, host->ctl + ((addr + 2) << host->pdata->bus_shift));
214213
}
215214

216215

‎drivers/mmc/host/tmio_mmc_dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
293293
if (pdata->dma->chan_priv_tx)
294294
cfg.slave_id = pdata->dma->slave_id_tx;
295295
cfg.direction = DMA_MEM_TO_DEV;
296-
cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift);
296+
cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->pdata->bus_shift);
297297
cfg.src_addr = 0;
298298
ret = dmaengine_slave_config(host->chan_tx, &cfg);
299299
if (ret < 0)

‎drivers/mmc/host/tmio_mmc_pio.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
10131013
_host->set_pwr = pdata->set_pwr;
10141014
_host->set_clk_div = pdata->set_clk_div;
10151015

1016-
/* SD control register space size is 0x200, 0x400 for bus_shift=1 */
1017-
_host->bus_shift = resource_size(res_ctl) >> 10;
1018-
10191016
ret = tmio_mmc_init_ocr(_host);
10201017
if (ret < 0)
10211018
goto host_free;

‎include/linux/mfd/tmio.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct tmio_mmc_data {
102102
unsigned long capabilities;
103103
unsigned long capabilities2;
104104
unsigned long flags;
105+
unsigned long bus_shift;
105106
u32 ocr_mask; /* available voltages */
106107
struct tmio_mmc_dma *dma;
107108
struct device *dev;

0 commit comments

Comments
 (0)