Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kuninori Morimoto and committed by
Chris Ball
3b159a6e 05fae4a7

+26 -13
+8
drivers/mmc/host/sh_mobile_sdhi.c
··· 133 133 struct tmio_mmc_data *mmc_data; 134 134 struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; 135 135 struct tmio_mmc_host *host; 136 + struct resource *res; 136 137 int irq, ret, i = 0; 137 138 bool multiplexed_isr = true; 138 139 struct tmio_mmc_dma *dma_priv; 140 + 141 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 142 + if (!res) 143 + return -EINVAL; 139 144 140 145 priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL); 141 146 if (priv == NULL) { ··· 210 205 const struct sh_mobile_sdhi_of_data *of_data = of_id->data; 211 206 mmc_data->flags |= of_data->tmio_flags; 212 207 } 208 + 209 + /* SD control register space size is 0x100, 0x200 for bus_shift=1 */ 210 + mmc_data->bus_shift = resource_size(res) >> 9; 213 211 214 212 ret = tmio_mmc_host_probe(&host, pdev, mmc_data); 215 213 if (ret < 0)
+8
drivers/mmc/host/tmio_mmc.c
··· 62 62 const struct mfd_cell *cell = mfd_get_cell(pdev); 63 63 struct tmio_mmc_data *pdata; 64 64 struct tmio_mmc_host *host; 65 + struct resource *res; 65 66 int ret = -EINVAL, irq; 66 67 67 68 if (pdev->num_resources != 2) ··· 84 83 if (ret) 85 84 goto out; 86 85 } 86 + 87 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 88 + if (!res) 89 + return -EINVAL; 90 + 91 + /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ 92 + pdata->bus_shift = resource_size(res_ctl) >> 10; 87 93 88 94 ret = tmio_mmc_host_probe(&host, pdev, pdata); 89 95 if (ret)
+8 -9
drivers/mmc/host/tmio_mmc.h
··· 58 58 59 59 struct tmio_mmc_host { 60 60 void __iomem *ctl; 61 - unsigned long bus_shift; 62 61 struct mmc_command *cmd; 63 62 struct mmc_request *mrq; 64 63 struct mmc_data *data; ··· 175 176 176 177 static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr) 177 178 { 178 - return readw(host->ctl + (addr << host->bus_shift)); 179 + return readw(host->ctl + (addr << host->pdata->bus_shift)); 179 180 } 180 181 181 182 static inline void sd_ctrl_read16_rep(struct tmio_mmc_host *host, int addr, 182 183 u16 *buf, int count) 183 184 { 184 - readsw(host->ctl + (addr << host->bus_shift), buf, count); 185 + readsw(host->ctl + (addr << host->pdata->bus_shift), buf, count); 185 186 } 186 187 187 188 static inline u32 sd_ctrl_read32(struct tmio_mmc_host *host, int addr) 188 189 { 189 - return readw(host->ctl + (addr << host->bus_shift)) | 190 - readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16; 190 + return readw(host->ctl + (addr << host->pdata->bus_shift)) | 191 + readw(host->ctl + ((addr + 2) << host->pdata->bus_shift)) << 16; 191 192 } 192 193 193 194 static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, u16 val) ··· 197 198 */ 198 199 if (host->pdata->write16_hook && host->pdata->write16_hook(host, addr)) 199 200 return; 200 - writew(val, host->ctl + (addr << host->bus_shift)); 201 + writew(val, host->ctl + (addr << host->pdata->bus_shift)); 201 202 } 202 203 203 204 static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr, 204 205 u16 *buf, int count) 205 206 { 206 - writesw(host->ctl + (addr << host->bus_shift), buf, count); 207 + writesw(host->ctl + (addr << host->pdata->bus_shift), buf, count); 207 208 } 208 209 209 210 static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val) 210 211 { 211 - writew(val, host->ctl + (addr << host->bus_shift)); 212 - writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift)); 212 + writew(val, host->ctl + (addr << host->pdata->bus_shift)); 213 + writew(val >> 16, host->ctl + ((addr + 2) << host->pdata->bus_shift)); 213 214 } 214 215 215 216
+1 -1
drivers/mmc/host/tmio_mmc_dma.c
··· 293 293 if (pdata->dma->chan_priv_tx) 294 294 cfg.slave_id = pdata->dma->slave_id_tx; 295 295 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); 297 297 cfg.src_addr = 0; 298 298 ret = dmaengine_slave_config(host->chan_tx, &cfg); 299 299 if (ret < 0)
-3
drivers/mmc/host/tmio_mmc_pio.c
··· 1013 1013 _host->set_pwr = pdata->set_pwr; 1014 1014 _host->set_clk_div = pdata->set_clk_div; 1015 1015 1016 - /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ 1017 - _host->bus_shift = resource_size(res_ctl) >> 10; 1018 - 1019 1016 ret = tmio_mmc_init_ocr(_host); 1020 1017 if (ret < 0) 1021 1018 goto host_free;
+1
include/linux/mfd/tmio.h
··· 102 102 unsigned long capabilities; 103 103 unsigned long capabilities2; 104 104 unsigned long flags; 105 + unsigned long bus_shift; 105 106 u32 ocr_mask; /* available voltages */ 106 107 struct tmio_mmc_dma *dma; 107 108 struct device *dev;