mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
mmc: merge from mainline
PD#SWPL-15312 Change-Id: Ib35b38a4ec7a660e5fafddfbe6522952479753c4 Signed-off-by: Lei Qian <lei.qian@amlogic.com>
This commit is contained in:
@@ -3270,6 +3270,7 @@ static int meson_mmc_probe(struct platform_device *pdev)
|
||||
mmc->f_max = pdata->f_max;
|
||||
mmc->max_current_180 = 300; /* 300 mA in 1.8V */
|
||||
mmc->max_current_330 = 300; /* 300 mA in 3.3V */
|
||||
pdata->signal_voltage = 0xff;
|
||||
|
||||
if (aml_card_type_sdio(pdata)) { /* if sdio_wifi */
|
||||
/* mmc->host_rescan_disable = true;*/
|
||||
|
||||
@@ -162,6 +162,21 @@ int meson_mmc_clk_init_v3(struct amlsd_host *host)
|
||||
|
||||
return ret;
|
||||
}
|
||||
/**************************
|
||||
* select clock source
|
||||
* ************************
|
||||
* HS200 200M -> HS400 200M
|
||||
*
|
||||
* G12B: 800M -> 800M
|
||||
*
|
||||
* TL1 : 792M -> 792M
|
||||
*
|
||||
* SM1 : 1G -> 800M
|
||||
*
|
||||
* TM2 : 1G -> 800M
|
||||
*
|
||||
* TXLX: 1G -> 400M
|
||||
**************************/
|
||||
|
||||
static int meson_mmc_clk_set_rate_v3(struct mmc_host *mmc,
|
||||
unsigned long clk_ios)
|
||||
@@ -469,6 +484,10 @@ static void aml_sd_emmc_set_power_v3(struct amlsd_platform *pdata,
|
||||
pdata->pwr_on(pdata);
|
||||
break;
|
||||
case MMC_POWER_UP:
|
||||
if (aml_card_type_non_sdio(pdata)) {
|
||||
of_amlsd_pwr_off(pdata);
|
||||
of_amlsd_pwr_on(pdata);
|
||||
}
|
||||
break;
|
||||
case MMC_POWER_OFF:
|
||||
writel(0, host->base + SD_EMMC_DELAY1_V3);
|
||||
@@ -1130,7 +1149,13 @@ static u32 scan_emmc_cmd_win(struct mmc_host *mmc, int send_status)
|
||||
writel(delay2, host->base + SD_EMMC_DELAY2_V3);
|
||||
offset = (u32)(get_random_long() % capacity);
|
||||
for (j = 0; j < repeat_times; j++) {
|
||||
err = single_read_cmd_for_scan(mmc,
|
||||
if (send_status)
|
||||
err = emmc_send_cmd(mmc,
|
||||
MMC_SEND_STATUS,
|
||||
1 << 16,
|
||||
MMC_RSP_R1 | MMC_CMD_AC);
|
||||
else
|
||||
err = single_read_cmd_for_scan(mmc,
|
||||
MMC_READ_SINGLE_BLOCK,
|
||||
host->blk_test, 512, 1,
|
||||
offset);
|
||||
@@ -2307,8 +2332,7 @@ int aml_mmc_execute_tuning_v3(struct mmc_host *mmc, u32 opcode)
|
||||
intf3 |= (1<<22);
|
||||
writel(intf3, (host->base + SD_EMMC_INTF3));
|
||||
pdata->intf3 = intf3;
|
||||
if ((host->data->chip_type >= MMC_CHIP_TL1)
|
||||
|| (host->data->chip_type == MMC_CHIP_G12B))
|
||||
if (host->data->chip_type == MMC_CHIP_G12B)
|
||||
aml_emmc_hs200_tl1(mmc);
|
||||
err = 0;
|
||||
}
|
||||
|
||||
@@ -335,18 +335,6 @@ void of_amlsd_pwr_prepare(struct amlsd_platform *pdata)
|
||||
{
|
||||
}
|
||||
|
||||
void of_amlsd_pwr_on(struct amlsd_platform *pdata)
|
||||
{
|
||||
if (pdata->gpio_power)
|
||||
gpio_set_value(pdata->gpio_power, pdata->power_level);
|
||||
}
|
||||
|
||||
void of_amlsd_pwr_off(struct amlsd_platform *pdata)
|
||||
{
|
||||
if (pdata->gpio_power)
|
||||
gpio_set_value(pdata->gpio_power, !pdata->power_level);
|
||||
}
|
||||
|
||||
#ifdef CARD_DETECT_IRQ
|
||||
void of_amlsd_irq_init(struct amlsd_platform *pdata)
|
||||
{
|
||||
@@ -384,7 +372,8 @@ int of_amlsd_init(struct amlsd_platform *pdata)
|
||||
#endif
|
||||
#if !defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
|
||||
if (pdata->gpio_power) {
|
||||
if (pdata->power_level) {
|
||||
if (pdata->power_level &&
|
||||
!aml_card_type_non_sdio(pdata)) {
|
||||
ret = gpio_request_one(pdata->gpio_power,
|
||||
GPIOF_OUT_INIT_LOW, MODULE_NAME);
|
||||
CHECK_RET(ret);
|
||||
@@ -433,14 +422,14 @@ static struct pinctrl * __must_check aml_devm_pinctrl_get_select(
|
||||
s = pinctrl_lookup_state(p, name);
|
||||
if (IS_ERR(s)) {
|
||||
pr_err("lookup %s fail\n", name);
|
||||
devm_pinctrl_put(p);
|
||||
aml_devm_pinctrl_put(host);
|
||||
return ERR_CAST(s);
|
||||
}
|
||||
|
||||
ret = pinctrl_select_state(p, s);
|
||||
if (ret < 0) {
|
||||
pr_err("select %s fail\n", name);
|
||||
devm_pinctrl_put(p);
|
||||
aml_devm_pinctrl_put(host);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
if ((host->mem->start == host->data->port_b_base)
|
||||
@@ -477,6 +466,47 @@ static struct pinctrl * __must_check aml_devm_pinctrl_get_select(
|
||||
}
|
||||
#endif /* SD_EMMC_PIN_CTRL */
|
||||
|
||||
#define sd3_pwr_dbg 1
|
||||
void of_amlsd_pwr_on(struct amlsd_platform *pdata)
|
||||
{
|
||||
#if sd3_pwr_dbg
|
||||
struct pinctrl *p = NULL;
|
||||
struct amlsd_host *host = pdata->host;
|
||||
#endif
|
||||
|
||||
if (pdata->gpio_power) {
|
||||
gpio_set_value(pdata->gpio_power, pdata->power_level);
|
||||
#if sd3_pwr_dbg
|
||||
if (aml_card_type_non_sdio(pdata)) {
|
||||
mutex_lock(&host->pinmux_lock);
|
||||
p = aml_devm_pinctrl_get_select(host, "sd_all_pins");
|
||||
mutex_unlock(&host->pinmux_lock);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void of_amlsd_pwr_off(struct amlsd_platform *pdata)
|
||||
{
|
||||
#if sd3_pwr_dbg
|
||||
struct pinctrl *p = NULL;
|
||||
struct amlsd_host *host = pdata->host;
|
||||
#endif
|
||||
|
||||
if (pdata->gpio_power) {
|
||||
gpio_set_value(pdata->gpio_power, !pdata->power_level);
|
||||
|
||||
#if sd3_pwr_dbg
|
||||
if (aml_card_type_non_sdio(pdata)) {
|
||||
mutex_lock(&host->pinmux_lock);
|
||||
p = aml_devm_pinctrl_get_select(host, "sd_all_pd_pins");
|
||||
mutex_unlock(&host->pinmux_lock);
|
||||
mdelay(200); //pull down need 200ms.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void of_amlsd_xfer_pre(struct amlsd_platform *pdata)
|
||||
{
|
||||
struct amlsd_host *host = pdata->host;
|
||||
|
||||
Reference in New Issue
Block a user