aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-11-20 03:30:55 -0500
committerChris Ball <chris@printf.net>2014-01-13 12:48:23 -0500
commit3b159a6e955c8d468f4ffa212c8b5d68d8323a8d (patch)
tree897ba847a2be1223b4dd142869528d7747f5e346
parent05fae4a7551543f10f1892f533af2d12378a4ba9 (diff)
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>
-rw-r--r--drivers/mmc/host/sh_mobile_sdhi.c8
-rw-r--r--drivers/mmc/host/tmio_mmc.c8
-rw-r--r--drivers/mmc/host/tmio_mmc.h17
-rw-r--r--drivers/mmc/host/tmio_mmc_dma.c2
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c3
-rw-r--r--include/linux/mfd/tmio.h1
6 files changed, 26 insertions, 13 deletions
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index ed1718a7f5eb..38553ae68e3a 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -133,10 +133,15 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
133 struct tmio_mmc_data *mmc_data; 133 struct tmio_mmc_data *mmc_data;
134 struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; 134 struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
135 struct tmio_mmc_host *host; 135 struct tmio_mmc_host *host;
136 struct resource *res;
136 int irq, ret, i = 0; 137 int irq, ret, i = 0;
137 bool multiplexed_isr = true; 138 bool multiplexed_isr = true;
138 struct tmio_mmc_dma *dma_priv; 139 struct tmio_mmc_dma *dma_priv;
139 140
141 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
142 if (!res)
143 return -EINVAL;
144
140 priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL); 145 priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL);
141 if (priv == NULL) { 146 if (priv == NULL) {
142 dev_err(&pdev->dev, "kzalloc failed\n"); 147 dev_err(&pdev->dev, "kzalloc failed\n");
@@ -206,6 +211,9 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
206 mmc_data->flags |= of_data->tmio_flags; 211 mmc_data->flags |= of_data->tmio_flags;
207 } 212 }
208 213
214 /* SD control register space size is 0x100, 0x200 for bus_shift=1 */
215 mmc_data->bus_shift = resource_size(res) >> 9;
216
209 ret = tmio_mmc_host_probe(&host, pdev, mmc_data); 217 ret = tmio_mmc_host_probe(&host, pdev, mmc_data);
210 if (ret < 0) 218 if (ret < 0)
211 goto eprobe; 219 goto eprobe;
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index 8860d4d2bc22..6cfb2d5317b0 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -62,6 +62,7 @@ static int tmio_mmc_probe(struct platform_device *pdev)
62 const struct mfd_cell *cell = mfd_get_cell(pdev); 62 const struct mfd_cell *cell = mfd_get_cell(pdev);
63 struct tmio_mmc_data *pdata; 63 struct tmio_mmc_data *pdata;
64 struct tmio_mmc_host *host; 64 struct tmio_mmc_host *host;
65 struct resource *res;
65 int ret = -EINVAL, irq; 66 int ret = -EINVAL, irq;
66 67
67 if (pdev->num_resources != 2) 68 if (pdev->num_resources != 2)
@@ -84,6 +85,13 @@ static int tmio_mmc_probe(struct platform_device *pdev)
84 goto out; 85 goto out;
85 } 86 }
86 87
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
87 ret = tmio_mmc_host_probe(&host, pdev, pdata); 95 ret = tmio_mmc_host_probe(&host, pdev, pdata);
88 if (ret) 96 if (ret)
89 goto cell_disable; 97 goto cell_disable;
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 86fd21e00099..aaa9c7e9e730 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -58,7 +58,6 @@ enum tmio_mmc_power {
58 58
59struct tmio_mmc_host { 59struct tmio_mmc_host {
60 void __iomem *ctl; 60 void __iomem *ctl;
61 unsigned long bus_shift;
62 struct mmc_command *cmd; 61 struct mmc_command *cmd;
63 struct mmc_request *mrq; 62 struct mmc_request *mrq;
64 struct mmc_data *data; 63 struct mmc_data *data;
@@ -176,19 +175,19 @@ int tmio_mmc_host_runtime_resume(struct device *dev);
176 175
177static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr) 176static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr)
178{ 177{
179 return readw(host->ctl + (addr << host->bus_shift)); 178 return readw(host->ctl + (addr << host->pdata->bus_shift));
180} 179}
181 180
182static inline void sd_ctrl_read16_rep(struct tmio_mmc_host *host, int addr, 181static inline void sd_ctrl_read16_rep(struct tmio_mmc_host *host, int addr,
183 u16 *buf, int count) 182 u16 *buf, int count)
184{ 183{
185 readsw(host->ctl + (addr << host->bus_shift), buf, count); 184 readsw(host->ctl + (addr << host->pdata->bus_shift), buf, count);
186} 185}
187 186
188static inline u32 sd_ctrl_read32(struct tmio_mmc_host *host, int addr) 187static inline u32 sd_ctrl_read32(struct tmio_mmc_host *host, int addr)
189{ 188{
190 return readw(host->ctl + (addr << host->bus_shift)) | 189 return readw(host->ctl + (addr << host->pdata->bus_shift)) |
191 readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16; 190 readw(host->ctl + ((addr + 2) << host->pdata->bus_shift)) << 16;
192} 191}
193 192
194static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, u16 val) 193static 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
198 */ 197 */
199 if (host->pdata->write16_hook && host->pdata->write16_hook(host, addr)) 198 if (host->pdata->write16_hook && host->pdata->write16_hook(host, addr))
200 return; 199 return;
201 writew(val, host->ctl + (addr << host->bus_shift)); 200 writew(val, host->ctl + (addr << host->pdata->bus_shift));
202} 201}
203 202
204static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr, 203static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr,
205 u16 *buf, int count) 204 u16 *buf, int count)
206{ 205{
207 writesw(host->ctl + (addr << host->bus_shift), buf, count); 206 writesw(host->ctl + (addr << host->pdata->bus_shift), buf, count);
208} 207}
209 208
210static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val) 209static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val)
211{ 210{
212 writew(val, host->ctl + (addr << host->bus_shift)); 211 writew(val, host->ctl + (addr << host->pdata->bus_shift));
213 writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift)); 212 writew(val >> 16, host->ctl + ((addr + 2) << host->pdata->bus_shift));
214} 213}
215 214
216 215
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index 65edb4a62452..03e7b280cb4c 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -293,7 +293,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
293 if (pdata->dma->chan_priv_tx) 293 if (pdata->dma->chan_priv_tx)
294 cfg.slave_id = pdata->dma->slave_id_tx; 294 cfg.slave_id = pdata->dma->slave_id_tx;
295 cfg.direction = DMA_MEM_TO_DEV; 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 cfg.src_addr = 0; 297 cfg.src_addr = 0;
298 ret = dmaengine_slave_config(host->chan_tx, &cfg); 298 ret = dmaengine_slave_config(host->chan_tx, &cfg);
299 if (ret < 0) 299 if (ret < 0)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index b94cb1666295..6836a8008c02 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1013,9 +1013,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
1013 _host->set_pwr = pdata->set_pwr; 1013 _host->set_pwr = pdata->set_pwr;
1014 _host->set_clk_div = pdata->set_clk_div; 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 ret = tmio_mmc_init_ocr(_host); 1016 ret = tmio_mmc_init_ocr(_host);
1020 if (ret < 0) 1017 if (ret < 0)
1021 goto host_free; 1018 goto host_free;
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index b22883d60500..92f72cf5311f 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -102,6 +102,7 @@ struct tmio_mmc_data {
102 unsigned long capabilities; 102 unsigned long capabilities;
103 unsigned long capabilities2; 103 unsigned long capabilities2;
104 unsigned long flags; 104 unsigned long flags;
105 unsigned long bus_shift;
105 u32 ocr_mask; /* available voltages */ 106 u32 ocr_mask; /* available voltages */
106 struct tmio_mmc_dma *dma; 107 struct tmio_mmc_dma *dma;
107 struct device *dev; 108 struct device *dev;