diff options
Diffstat (limited to 'drivers/mmc')
| -rw-r--r-- | drivers/mmc/host/mvsdio.c | 92 | ||||
| -rw-r--r-- | drivers/mmc/host/rtsx_pci_sdmmc.c | 30 | 
2 files changed, 35 insertions, 87 deletions
diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c index de4c20b3936..f8dd3610294 100644 --- a/drivers/mmc/host/mvsdio.c +++ b/drivers/mmc/host/mvsdio.c @@ -50,8 +50,6 @@ struct mvsd_host {  	struct timer_list timer;  	struct mmc_host *mmc;  	struct device *dev; -	struct resource *res; -	int irq;  	struct clk *clk;  	int gpio_card_detect;  	int gpio_write_protect; @@ -718,10 +716,6 @@ static int __init mvsd_probe(struct platform_device *pdev)  	if (!r || irq < 0 || !mvsd_data)  		return -ENXIO; -	r = request_mem_region(r->start, SZ_1K, DRIVER_NAME); -	if (!r) -		return -EBUSY; -  	mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev);  	if (!mmc) {  		ret = -ENOMEM; @@ -731,8 +725,8 @@ static int __init mvsd_probe(struct platform_device *pdev)  	host = mmc_priv(mmc);  	host->mmc = mmc;  	host->dev = &pdev->dev; -	host->res = r;  	host->base_clock = mvsd_data->clock / 2; +	host->clk = ERR_PTR(-EINVAL);  	mmc->ops = &mvsd_ops; @@ -752,7 +746,7 @@ static int __init mvsd_probe(struct platform_device *pdev)  	spin_lock_init(&host->lock); -	host->base = ioremap(r->start, SZ_4K); +	host->base = devm_request_and_ioremap(&pdev->dev, r);  	if (!host->base) {  		ret = -ENOMEM;  		goto out; @@ -765,44 +759,45 @@ static int __init mvsd_probe(struct platform_device *pdev)  	mvsd_power_down(host); -	ret = request_irq(irq, mvsd_irq, 0, DRIVER_NAME, host); +	ret = devm_request_irq(&pdev->dev, irq, mvsd_irq, 0, DRIVER_NAME, host);  	if (ret) {  		pr_err("%s: cannot assign irq %d\n", DRIVER_NAME, irq);  		goto out; -	} else -		host->irq = irq; +	}  	/* Not all platforms can gate the clock, so it is not  	   an error if the clock does not exists. */ -	host->clk = clk_get(&pdev->dev, NULL); -	if (!IS_ERR(host->clk)) { +	host->clk = devm_clk_get(&pdev->dev, NULL); +	if (!IS_ERR(host->clk))  		clk_prepare_enable(host->clk); -	}  	if (mvsd_data->gpio_card_detect) { -		ret = gpio_request(mvsd_data->gpio_card_detect, -				   DRIVER_NAME " cd"); +		ret = devm_gpio_request_one(&pdev->dev, +					    mvsd_data->gpio_card_detect, +					    GPIOF_IN, DRIVER_NAME " cd");  		if (ret == 0) { -			gpio_direction_input(mvsd_data->gpio_card_detect);  			irq = gpio_to_irq(mvsd_data->gpio_card_detect); -			ret = request_irq(irq, mvsd_card_detect_irq, -					  IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING, -					  DRIVER_NAME " cd", host); +			ret = devm_request_irq(&pdev->dev, irq, +					       mvsd_card_detect_irq, +					       IRQ_TYPE_EDGE_RISING | +					       IRQ_TYPE_EDGE_FALLING, +					       DRIVER_NAME " cd", host);  			if (ret == 0)  				host->gpio_card_detect =  					mvsd_data->gpio_card_detect;  			else -				gpio_free(mvsd_data->gpio_card_detect); +				devm_gpio_free(&pdev->dev, +					       mvsd_data->gpio_card_detect);  		}  	}  	if (!host->gpio_card_detect)  		mmc->caps |= MMC_CAP_NEEDS_POLL;  	if (mvsd_data->gpio_write_protect) { -		ret = gpio_request(mvsd_data->gpio_write_protect, -				   DRIVER_NAME " wp"); +		ret = devm_gpio_request_one(&pdev->dev, +					    mvsd_data->gpio_write_protect, +					    GPIOF_IN, DRIVER_NAME " wp");  		if (ret == 0) { -			gpio_direction_input(mvsd_data->gpio_write_protect);  			host->gpio_write_protect =  				mvsd_data->gpio_write_protect;  		} @@ -824,26 +819,11 @@ static int __init mvsd_probe(struct platform_device *pdev)  	return 0;  out: -	if (host) { -		if (host->irq) -			free_irq(host->irq, host); -		if (host->gpio_card_detect) { -			free_irq(gpio_to_irq(host->gpio_card_detect), host); -			gpio_free(host->gpio_card_detect); -		} -		if (host->gpio_write_protect) -			gpio_free(host->gpio_write_protect); -		if (host->base) -			iounmap(host->base); -	} -	if (r) -		release_resource(r); -	if (mmc) -		if (!IS_ERR_OR_NULL(host->clk)) { +	if (mmc) { +		if (!IS_ERR(host->clk))  			clk_disable_unprepare(host->clk); -			clk_put(host->clk); -		}  		mmc_free_host(mmc); +	}  	return ret;  } @@ -852,28 +832,16 @@ static int __exit mvsd_remove(struct platform_device *pdev)  {  	struct mmc_host *mmc = platform_get_drvdata(pdev); -	if (mmc) { -		struct mvsd_host *host = mmc_priv(mmc); +	struct mvsd_host *host = mmc_priv(mmc); -		if (host->gpio_card_detect) { -			free_irq(gpio_to_irq(host->gpio_card_detect), host); -			gpio_free(host->gpio_card_detect); -		} -		mmc_remove_host(mmc); -		free_irq(host->irq, host); -		if (host->gpio_write_protect) -			gpio_free(host->gpio_write_protect); -		del_timer_sync(&host->timer); -		mvsd_power_down(host); -		iounmap(host->base); -		release_resource(host->res); +	mmc_remove_host(mmc); +	del_timer_sync(&host->timer); +	mvsd_power_down(host); + +	if (!IS_ERR(host->clk)) +		clk_disable_unprepare(host->clk); +	mmc_free_host(mmc); -		if (!IS_ERR(host->clk)) { -			clk_disable_unprepare(host->clk); -			clk_put(host->clk); -		} -		mmc_free_host(mmc); -	}  	platform_set_drvdata(pdev, NULL);  	return 0;  } diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c index 571915dfb21..f74b5adca64 100644 --- a/drivers/mmc/host/rtsx_pci_sdmmc.c +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c @@ -1060,26 +1060,6 @@ static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc *host)  	return 0;  } -static int sd_change_bank_voltage(struct realtek_pci_sdmmc *host, u8 voltage) -{ -	struct rtsx_pcr *pcr = host->pcr; -	int err; - -	if (voltage == SD_IO_3V3) { -		err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); -		if (err < 0) -			return err; -	} else if (voltage == SD_IO_1V8) { -		err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); -		if (err < 0) -			return err; -	} else { -		return -EINVAL; -	} - -	return 0; -} -  static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)  {  	struct realtek_pci_sdmmc *host = mmc_priv(mmc); @@ -1098,11 +1078,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)  	rtsx_pci_start_run(pcr);  	if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) -		voltage = SD_IO_3V3; +		voltage = OUTPUT_3V3;  	else -		voltage = SD_IO_1V8; +		voltage = OUTPUT_1V8; -	if (voltage == SD_IO_1V8) { +	if (voltage == OUTPUT_1V8) {  		err = rtsx_pci_write_register(pcr,  				SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B);  		if (err < 0) @@ -1113,11 +1093,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)  			goto out;  	} -	err = sd_change_bank_voltage(host, voltage); +	err = rtsx_pci_switch_output_voltage(pcr, voltage);  	if (err < 0)  		goto out; -	if (voltage == SD_IO_1V8) { +	if (voltage == OUTPUT_1V8) {  		err = sd_wait_voltage_stable_2(host);  		if (err < 0)  			goto out;  |