mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 12:14:06 +00:00
mmc: starfive: Unify the MMC code on evb/vf2/devkits
Unify the MMC code on evb/vf2/devkits to resolve conflicts when merging the code. Signed-off-by: William Qiu <william.qiu@starfivetech.com>
This commit is contained in:
parent
31bb215e65
commit
eaf4e7d161
1 changed files with 46 additions and 8 deletions
|
@ -15,6 +15,8 @@
|
|||
#include <linux/regmap.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include "dw_mmc.h"
|
||||
|
@ -119,12 +121,14 @@ static int dw_mci_starfive_switch_voltage(struct mmc_host *mmc, struct mmc_ios *
|
|||
struct dw_mci *host = slot->host;
|
||||
u32 ret;
|
||||
|
||||
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
|
||||
ret = gpio_direction_output(25, 0);
|
||||
else if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
|
||||
ret = gpio_direction_output(25, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (device_property_read_bool(host->dev, "board-is-evb")) {
|
||||
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
|
||||
ret = gpio_direction_output(25, 0);
|
||||
else if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
|
||||
ret = gpio_direction_output(25, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||
|
@ -134,8 +138,6 @@ static int dw_mci_starfive_switch_voltage(struct mmc_host *mmc, struct mmc_ios *
|
|||
}
|
||||
}
|
||||
|
||||
/* We should delay 20ms wait for timing setting finished. */
|
||||
mdelay(20);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -144,6 +146,7 @@ static const struct dw_mci_drv_data starfive_data = {
|
|||
.num_caps = ARRAY_SIZE(dw_mci_starfive_caps),
|
||||
.set_ios = dw_mci_starfive_set_ios,
|
||||
.execute_tuning = dw_mci_starfive_execute_tuning,
|
||||
.switch_voltage = dw_mci_starfive_switch_voltage,
|
||||
};
|
||||
|
||||
static const struct of_device_id dw_mci_starfive_match[] = {
|
||||
|
@ -157,11 +160,46 @@ static int dw_mci_starfive_probe(struct platform_device *pdev)
|
|||
{
|
||||
const struct dw_mci_drv_data *drv_data;
|
||||
const struct of_device_id *match;
|
||||
struct gpio_desc *power_gpio;
|
||||
int gpio_wl_reg_on = -1;
|
||||
int ret;
|
||||
|
||||
match = of_match_node(dw_mci_starfive_match, pdev->dev.of_node);
|
||||
drv_data = match->data;
|
||||
|
||||
if (device_property_read_bool(&pdev->dev, "board-is-devkits")) {
|
||||
power_gpio = devm_gpiod_get_optional(&pdev->dev, "power", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(power_gpio)) {
|
||||
dev_err(&pdev->dev, "Failed to get power-gpio\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
gpiod_set_value_cansleep(power_gpio, 1);
|
||||
}
|
||||
|
||||
gpio_wl_reg_on = of_get_named_gpio(pdev->dev.of_node, "gpio_wl_reg_on", 0);
|
||||
if (gpio_wl_reg_on >= 0) {
|
||||
ret = gpio_request(gpio_wl_reg_on, "WL_REG_ON");
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "gpio_request(%d) for WL_REG_ON failed %d\n",
|
||||
gpio_wl_reg_on, ret);
|
||||
gpio_wl_reg_on = -1;
|
||||
return -EINVAL;
|
||||
}
|
||||
ret = gpio_direction_output(gpio_wl_reg_on, 0);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "WL_REG_ON didn't output high\n");
|
||||
return -EIO;
|
||||
}
|
||||
mdelay(10);
|
||||
ret = gpio_direction_output(gpio_wl_reg_on, 1);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "WL_REG_ON didn't output high\n");
|
||||
return -EIO;
|
||||
}
|
||||
mdelay(10);
|
||||
}
|
||||
|
||||
pm_runtime_get_noresume(&pdev->dev);
|
||||
pm_runtime_set_active(&pdev->dev);
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
|
|
Loading…
Add table
Reference in a new issue