Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b159a6e authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Chris Ball
Browse files

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: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 05fae4a7
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -133,10 +133,15 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
	struct tmio_mmc_data *mmc_data;
	struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
	struct tmio_mmc_host *host;
	struct resource *res;
	int irq, ret, i = 0;
	bool multiplexed_isr = true;
	struct tmio_mmc_dma *dma_priv;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
		return -EINVAL;

	priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL);
	if (priv == NULL) {
		dev_err(&pdev->dev, "kzalloc failed\n");
@@ -206,6 +211,9 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
		mmc_data->flags |= of_data->tmio_flags;
	}

	/* SD control register space size is 0x100, 0x200 for bus_shift=1 */
	mmc_data->bus_shift = resource_size(res) >> 9;

	ret = tmio_mmc_host_probe(&host, pdev, mmc_data);
	if (ret < 0)
		goto eprobe;
+8 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ static int tmio_mmc_probe(struct platform_device *pdev)
	const struct mfd_cell *cell = mfd_get_cell(pdev);
	struct tmio_mmc_data *pdata;
	struct tmio_mmc_host *host;
	struct resource *res;
	int ret = -EINVAL, irq;

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

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
		return -EINVAL;

	/* SD control register space size is 0x200, 0x400 for bus_shift=1 */
	pdata->bus_shift = resource_size(res_ctl) >> 10;

	ret = tmio_mmc_host_probe(&host, pdev, pdata);
	if (ret)
		goto cell_disable;
+8 −9
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ enum tmio_mmc_power {

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

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

static inline void sd_ctrl_read16_rep(struct tmio_mmc_host *host, int addr,
		u16 *buf, int count)
{
	readsw(host->ctl + (addr << host->bus_shift), buf, count);
	readsw(host->ctl + (addr << host->pdata->bus_shift), buf, count);
}

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

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
	 */
	if (host->pdata->write16_hook && host->pdata->write16_hook(host, addr))
		return;
	writew(val, host->ctl + (addr << host->bus_shift));
	writew(val, host->ctl + (addr << host->pdata->bus_shift));
}

static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr,
		u16 *buf, int count)
{
	writesw(host->ctl + (addr << host->bus_shift), buf, count);
	writesw(host->ctl + (addr << host->pdata->bus_shift), buf, count);
}

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


+1 −1
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
		if (pdata->dma->chan_priv_tx)
			cfg.slave_id = pdata->dma->slave_id_tx;
		cfg.direction = DMA_MEM_TO_DEV;
		cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift);
		cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->pdata->bus_shift);
		cfg.src_addr = 0;
		ret = dmaengine_slave_config(host->chan_tx, &cfg);
		if (ret < 0)
+0 −3
Original line number Diff line number Diff line
@@ -1013,9 +1013,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
	_host->set_pwr = pdata->set_pwr;
	_host->set_clk_div = pdata->set_clk_div;

	/* SD control register space size is 0x200, 0x400 for bus_shift=1 */
	_host->bus_shift = resource_size(res_ctl) >> 10;

	ret = tmio_mmc_init_ocr(_host);
	if (ret < 0)
		goto host_free;
Loading