mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	mmc: tmio: add tmio_mmc_host_alloc/free()
Current tmio_mmc driver is using tmio_mmc_data for driver/platform specific data/callback, and it is needed for tmio_mmc_host_probe() function. Because of this style, include/linux/mfd/tmio.h header has tmio driver/framework specific data which is not needed from platform. This patch adds new tmio_mmc_host_alloc/free() as cleanup preparation. tmio driver specific data/callback will be implemented in tmio_mmc_host, and platform specific data/callback will be implemented in tmio_mmc_data in this cleanup. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
		
							parent
							
								
									ec6f34e5b5
								
							
						
					
					
						commit
						94b110aff8
					
				
					 5 changed files with 51 additions and 24 deletions
				
			
		| 
						 | 
					@ -113,7 +113,7 @@ static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host)
 | 
				
			||||||
		udelay(1);
 | 
							udelay(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!timeout) {
 | 
						if (!timeout) {
 | 
				
			||||||
		dev_warn(host->pdata->dev, "timeout waiting for SD bus idle\n");
 | 
							dev_warn(&host->pdev->dev, "timeout waiting for SD bus idle\n");
 | 
				
			||||||
		return -EBUSY;
 | 
							return -EBUSY;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -207,6 +207,12 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 | 
				
			||||||
		goto eclkget;
 | 
							goto eclkget;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						host = tmio_mmc_host_alloc(pdev);
 | 
				
			||||||
 | 
						if (!host) {
 | 
				
			||||||
 | 
							ret = -ENOMEM;
 | 
				
			||||||
 | 
							goto eprobe;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mmc_data->clk_enable = sh_mobile_sdhi_clk_enable;
 | 
						mmc_data->clk_enable = sh_mobile_sdhi_clk_enable;
 | 
				
			||||||
	mmc_data->clk_disable = sh_mobile_sdhi_clk_disable;
 | 
						mmc_data->clk_disable = sh_mobile_sdhi_clk_disable;
 | 
				
			||||||
	mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED;
 | 
						mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED;
 | 
				
			||||||
| 
						 | 
					@ -274,9 +280,9 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 | 
				
			||||||
	/* SD control register space size is 0x100, 0x200 for bus_shift=1 */
 | 
						/* SD control register space size is 0x100, 0x200 for bus_shift=1 */
 | 
				
			||||||
	mmc_data->bus_shift = resource_size(res) >> 9;
 | 
						mmc_data->bus_shift = resource_size(res) >> 9;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = tmio_mmc_host_probe(&host, pdev, mmc_data);
 | 
						ret = tmio_mmc_host_probe(host, mmc_data);
 | 
				
			||||||
	if (ret < 0)
 | 
						if (ret < 0)
 | 
				
			||||||
		goto eprobe;
 | 
							goto efree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * FIXME:
 | 
						 * FIXME:
 | 
				
			||||||
| 
						 | 
					@ -351,6 +357,8 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
eirq:
 | 
					eirq:
 | 
				
			||||||
	tmio_mmc_host_remove(host);
 | 
						tmio_mmc_host_remove(host);
 | 
				
			||||||
 | 
					efree:
 | 
				
			||||||
 | 
						tmio_mmc_host_free(host);
 | 
				
			||||||
eprobe:
 | 
					eprobe:
 | 
				
			||||||
eclkget:
 | 
					eclkget:
 | 
				
			||||||
	if (p && p->cleanup)
 | 
						if (p && p->cleanup)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,10 +92,14 @@ static int tmio_mmc_probe(struct platform_device *pdev)
 | 
				
			||||||
	pdata->bus_shift = resource_size(res) >> 10;
 | 
						pdata->bus_shift = resource_size(res) >> 10;
 | 
				
			||||||
	pdata->flags |= TMIO_MMC_HAVE_HIGH_REG;
 | 
						pdata->flags |= TMIO_MMC_HAVE_HIGH_REG;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = tmio_mmc_host_probe(&host, pdev, pdata);
 | 
						host = tmio_mmc_host_alloc(pdev);
 | 
				
			||||||
	if (ret)
 | 
						if (!host)
 | 
				
			||||||
		goto cell_disable;
 | 
							goto cell_disable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = tmio_mmc_host_probe(host, pdata);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							goto host_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = request_irq(irq, tmio_mmc_irq, IRQF_TRIGGER_FALLING,
 | 
						ret = request_irq(irq, tmio_mmc_irq, IRQF_TRIGGER_FALLING,
 | 
				
			||||||
				dev_name(&pdev->dev), host);
 | 
									dev_name(&pdev->dev), host);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
| 
						 | 
					@ -108,6 +112,8 @@ static int tmio_mmc_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
host_remove:
 | 
					host_remove:
 | 
				
			||||||
	tmio_mmc_host_remove(host);
 | 
						tmio_mmc_host_remove(host);
 | 
				
			||||||
 | 
					host_free:
 | 
				
			||||||
 | 
						tmio_mmc_host_free(host);
 | 
				
			||||||
cell_disable:
 | 
					cell_disable:
 | 
				
			||||||
	if (cell->disable)
 | 
						if (cell->disable)
 | 
				
			||||||
		cell->disable(pdev);
 | 
							cell->disable(pdev);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,8 +85,9 @@ struct tmio_mmc_host {
 | 
				
			||||||
	bool			sdio_irq_enabled;
 | 
						bool			sdio_irq_enabled;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 | 
					struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev);
 | 
				
			||||||
			struct platform_device *pdev,
 | 
					void tmio_mmc_host_free(struct tmio_mmc_host *host);
 | 
				
			||||||
 | 
					int tmio_mmc_host_probe(struct tmio_mmc_host *host,
 | 
				
			||||||
			struct tmio_mmc_data *pdata);
 | 
								struct tmio_mmc_data *pdata);
 | 
				
			||||||
void tmio_mmc_host_remove(struct tmio_mmc_host *host);
 | 
					void tmio_mmc_host_remove(struct tmio_mmc_host *host);
 | 
				
			||||||
void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
 | 
					void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1054,12 +1054,37 @@ static void tmio_mmc_of_parse(struct platform_device *pdev,
 | 
				
			||||||
		pdata->flags |= TMIO_MMC_WRPROTECT_DISABLE;
 | 
							pdata->flags |= TMIO_MMC_WRPROTECT_DISABLE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 | 
					struct tmio_mmc_host*
 | 
				
			||||||
				  struct platform_device *pdev,
 | 
					tmio_mmc_host_alloc(struct platform_device *pdev)
 | 
				
			||||||
				  struct tmio_mmc_data *pdata)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct tmio_mmc_host *_host;
 | 
						struct tmio_mmc_host *host;
 | 
				
			||||||
	struct mmc_host *mmc;
 | 
						struct mmc_host *mmc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev);
 | 
				
			||||||
 | 
						if (!mmc)
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						host = mmc_priv(mmc);
 | 
				
			||||||
 | 
						host->mmc = mmc;
 | 
				
			||||||
 | 
						host->pdev = pdev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return host;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL(tmio_mmc_host_alloc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void tmio_mmc_host_free(struct tmio_mmc_host *host)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						mmc_free_host(host->mmc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						host->mmc = NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL(tmio_mmc_host_free);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 | 
				
			||||||
 | 
								struct tmio_mmc_data *pdata)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct platform_device *pdev = _host->pdev;
 | 
				
			||||||
 | 
						struct mmc_host *mmc = _host->mmc;
 | 
				
			||||||
	struct resource *res_ctl;
 | 
						struct resource *res_ctl;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	u32 irq_mask = TMIO_MASK_CMD;
 | 
						u32 irq_mask = TMIO_MASK_CMD;
 | 
				
			||||||
| 
						 | 
					@ -1073,19 +1098,11 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 | 
				
			||||||
	if (!res_ctl)
 | 
						if (!res_ctl)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev);
 | 
					 | 
				
			||||||
	if (!mmc)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ret = mmc_of_parse(mmc);
 | 
						ret = mmc_of_parse(mmc);
 | 
				
			||||||
	if (ret < 0)
 | 
						if (ret < 0)
 | 
				
			||||||
		goto host_free;
 | 
							goto host_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pdata->dev = &pdev->dev;
 | 
					 | 
				
			||||||
	_host = mmc_priv(mmc);
 | 
					 | 
				
			||||||
	_host->pdata = pdata;
 | 
						_host->pdata = pdata;
 | 
				
			||||||
	_host->mmc = mmc;
 | 
					 | 
				
			||||||
	_host->pdev = pdev;
 | 
					 | 
				
			||||||
	platform_set_drvdata(pdev, mmc);
 | 
						platform_set_drvdata(pdev, mmc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_host->set_pwr = pdata->set_pwr;
 | 
						_host->set_pwr = pdata->set_pwr;
 | 
				
			||||||
| 
						 | 
					@ -1192,12 +1209,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 | 
				
			||||||
		mmc_gpiod_request_cd_irq(mmc);
 | 
							mmc_gpiod_request_cd_irq(mmc);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*host = _host;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
host_free:
 | 
					host_free:
 | 
				
			||||||
	mmc_free_host(mmc);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1222,7 +1236,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 | 
				
			||||||
	pm_runtime_disable(&pdev->dev);
 | 
						pm_runtime_disable(&pdev->dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	iounmap(host->ctl);
 | 
						iounmap(host->ctl);
 | 
				
			||||||
	mmc_free_host(mmc);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(tmio_mmc_host_remove);
 | 
					EXPORT_SYMBOL(tmio_mmc_host_remove);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,7 +135,6 @@ struct tmio_mmc_data {
 | 
				
			||||||
	unsigned long			bus_shift;
 | 
						unsigned long			bus_shift;
 | 
				
			||||||
	u32				ocr_mask;	/* available voltages */
 | 
						u32				ocr_mask;	/* available voltages */
 | 
				
			||||||
	struct tmio_mmc_dma		*dma;
 | 
						struct tmio_mmc_dma		*dma;
 | 
				
			||||||
	struct device			*dev;
 | 
					 | 
				
			||||||
	unsigned int			cd_gpio;
 | 
						unsigned int			cd_gpio;
 | 
				
			||||||
	void (*set_pwr)(struct platform_device *host, int state);
 | 
						void (*set_pwr)(struct platform_device *host, int state);
 | 
				
			||||||
	void (*set_clk_div)(struct platform_device *host, int state);
 | 
						void (*set_clk_div)(struct platform_device *host, int state);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue