Skip to content

Commit dbe0580

Browse files
author
Linus Torvalds
committed
Merge master.kernel.org:/home/rmk/linux-2.6-mmc
2 parents 2073194 + 19c1f3c commit dbe0580

File tree

1 file changed

+91
-28
lines changed

1 file changed

+91
-28
lines changed

drivers/mmc/wbsd.c

Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,16 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
10331033
}
10341034
else
10351035
{
1036-
setup &= ~WBSD_DAT3_H;
1036+
if (setup & WBSD_DAT3_H)
1037+
{
1038+
setup &= ~WBSD_DAT3_H;
10371039

1038-
/*
1039-
* We cannot resume card detection immediatly
1040-
* because of capacitance and delays in the chip.
1041-
*/
1042-
mod_timer(&host->ignore_timer, jiffies + HZ/100);
1040+
/*
1041+
* We cannot resume card detection immediatly
1042+
* because of capacitance and delays in the chip.
1043+
*/
1044+
mod_timer(&host->ignore_timer, jiffies + HZ/100);
1045+
}
10431046
}
10441047
wbsd_write_index(host, WBSD_IDX_SETUP, setup);
10451048

@@ -1461,22 +1464,24 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
14611464
{
14621465
id = 0xFFFF;
14631466

1464-
outb(unlock_codes[j], config_ports[i]);
1465-
outb(unlock_codes[j], config_ports[i]);
1467+
host->config = config_ports[i];
1468+
host->unlock_code = unlock_codes[j];
1469+
1470+
wbsd_unlock_config(host);
14661471

14671472
outb(WBSD_CONF_ID_HI, config_ports[i]);
14681473
id = inb(config_ports[i] + 1) << 8;
14691474

14701475
outb(WBSD_CONF_ID_LO, config_ports[i]);
14711476
id |= inb(config_ports[i] + 1);
14721477

1478+
wbsd_lock_config(host);
1479+
14731480
for (k = 0;k < sizeof(valid_ids)/sizeof(int);k++)
14741481
{
14751482
if (id == valid_ids[k])
14761483
{
14771484
host->chip_id = id;
1478-
host->config = config_ports[i];
1479-
host->unlock_code = unlock_codes[i];
14801485

14811486
return 0;
14821487
}
@@ -1487,13 +1492,14 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
14871492
DBG("Unknown hardware (id %x) found at %x\n",
14881493
id, config_ports[i]);
14891494
}
1490-
1491-
outb(LOCK_CODE, config_ports[i]);
14921495
}
14931496

14941497
release_region(config_ports[i], 2);
14951498
}
14961499

1500+
host->config = 0;
1501+
host->unlock_code = 0;
1502+
14971503
return -ENODEV;
14981504
}
14991505

@@ -1699,8 +1705,10 @@ static void __devexit wbsd_release_resources(struct wbsd_host* host)
16991705
* Configure the resources the chip should use.
17001706
*/
17011707

1702-
static void __devinit wbsd_chip_config(struct wbsd_host* host)
1708+
static void wbsd_chip_config(struct wbsd_host* host)
17031709
{
1710+
wbsd_unlock_config(host);
1711+
17041712
/*
17051713
* Reset the chip.
17061714
*/
@@ -1733,16 +1741,20 @@ static void __devinit wbsd_chip_config(struct wbsd_host* host)
17331741
*/
17341742
wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
17351743
wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
1744+
1745+
wbsd_lock_config(host);
17361746
}
17371747

17381748
/*
17391749
* Check that configured resources are correct.
17401750
*/
17411751

1742-
static int __devinit wbsd_chip_validate(struct wbsd_host* host)
1752+
static int wbsd_chip_validate(struct wbsd_host* host)
17431753
{
17441754
int base, irq, dma;
17451755

1756+
wbsd_unlock_config(host);
1757+
17461758
/*
17471759
* Select SD/MMC function.
17481760
*/
@@ -1758,6 +1770,8 @@ static int __devinit wbsd_chip_validate(struct wbsd_host* host)
17581770

17591771
dma = wbsd_read_config(host, WBSD_CONF_DRQ);
17601772

1773+
wbsd_lock_config(host);
1774+
17611775
/*
17621776
* Validate against given configuration.
17631777
*/
@@ -1771,6 +1785,20 @@ static int __devinit wbsd_chip_validate(struct wbsd_host* host)
17711785
return 1;
17721786
}
17731787

1788+
/*
1789+
* Powers down the SD function
1790+
*/
1791+
1792+
static void wbsd_chip_poweroff(struct wbsd_host* host)
1793+
{
1794+
wbsd_unlock_config(host);
1795+
1796+
wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1797+
wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1798+
1799+
wbsd_lock_config(host);
1800+
}
1801+
17741802
/*****************************************************************************\
17751803
* *
17761804
* Devices setup and shutdown *
@@ -1844,7 +1872,11 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
18441872
*/
18451873
#ifdef CONFIG_PM
18461874
if (host->config)
1875+
{
1876+
wbsd_unlock_config(host);
18471877
wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
1878+
wbsd_lock_config(host);
1879+
}
18481880
#endif
18491881
/*
18501882
* Allow device to initialise itself properly.
@@ -1885,16 +1917,11 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp)
18851917

18861918
mmc_remove_host(mmc);
18871919

1920+
/*
1921+
* Power down the SD/MMC function.
1922+
*/
18881923
if (!pnp)
1889-
{
1890-
/*
1891-
* Power down the SD/MMC function.
1892-
*/
1893-
wbsd_unlock_config(host);
1894-
wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1895-
wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1896-
wbsd_lock_config(host);
1897-
}
1924+
wbsd_chip_poweroff(host);
18981925

18991926
wbsd_release_resources(host);
19001927

@@ -1955,23 +1982,59 @@ static void __devexit wbsd_pnp_remove(struct pnp_dev * dev)
19551982
*/
19561983

19571984
#ifdef CONFIG_PM
1985+
19581986
static int wbsd_suspend(struct device *dev, pm_message_t state)
19591987
{
1960-
DBGF("Not yet supported\n");
1988+
struct mmc_host *mmc = dev_get_drvdata(dev);
1989+
struct wbsd_host *host;
1990+
int ret;
1991+
1992+
if (!mmc)
1993+
return 0;
1994+
1995+
DBG("Suspending...\n");
1996+
1997+
ret = mmc_suspend_host(mmc, state);
1998+
if (!ret)
1999+
return ret;
2000+
2001+
host = mmc_priv(mmc);
2002+
2003+
wbsd_chip_poweroff(host);
19612004

19622005
return 0;
19632006
}
19642007

19652008
static int wbsd_resume(struct device *dev)
19662009
{
1967-
DBGF("Not yet supported\n");
2010+
struct mmc_host *mmc = dev_get_drvdata(dev);
2011+
struct wbsd_host *host;
19682012

1969-
return 0;
2013+
if (!mmc)
2014+
return 0;
2015+
2016+
DBG("Resuming...\n");
2017+
2018+
host = mmc_priv(mmc);
2019+
2020+
wbsd_chip_config(host);
2021+
2022+
/*
2023+
* Allow device to initialise itself properly.
2024+
*/
2025+
mdelay(5);
2026+
2027+
wbsd_init_device(host);
2028+
2029+
return mmc_resume_host(mmc);
19702030
}
1971-
#else
2031+
2032+
#else /* CONFIG_PM */
2033+
19722034
#define wbsd_suspend NULL
19732035
#define wbsd_resume NULL
1974-
#endif
2036+
2037+
#endif /* CONFIG_PM */
19752038

19762039
static struct platform_device *wbsd_device;
19772040

0 commit comments

Comments
 (0)