summaryrefslogtreecommitdiffstats
path: root/drivers/misc/tifm_7xx1.c
diff options
context:
space:
mode:
authorAlex Dubov <oakad@yahoo.com>2007-04-12 16:59:16 +1000
committerPierre Ossman <drzeus@drzeus.cx>2007-05-01 13:04:13 +0200
commit342c0ec4859446140c0dc5d7d903bb3b3f0577cd (patch)
tree0b2e7fc07d23cd845c74da0ddf257f183427db10 /drivers/misc/tifm_7xx1.c
parent3540af8ffddcdbc7573451ac0b5cd57a2eaf8af5 (diff)
tifm_7xx1: improve card detection routine
Remove unneeded conditions and change a sleeping regime a little in the card type detection routine. Signed-off-by: Alex Dubov <oakad@yahoo.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/misc/tifm_7xx1.c')
-rw-r--r--drivers/misc/tifm_7xx1.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c
index e5655fef42d..34746798ba8 100644
--- a/drivers/misc/tifm_7xx1.c
+++ b/drivers/misc/tifm_7xx1.c
@@ -75,48 +75,46 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}
-static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr,
- int is_x2)
+static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr)
{
unsigned int s_state;
int cnt;
writel(0x0e00, sock_addr + SOCK_CONTROL);
- for (cnt = 0; cnt < 100; cnt++) {
+ for (cnt = 16; cnt <= 256; cnt <<= 1) {
if (!(TIFM_SOCK_STATE_POWERED
& readl(sock_addr + SOCK_PRESENT_STATE)))
break;
- msleep(10);
+
+ msleep(cnt);
}
s_state = readl(sock_addr + SOCK_PRESENT_STATE);
if (!(TIFM_SOCK_STATE_OCCUPIED & s_state))
return 0;
- if (is_x2) {
- writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL);
- } else {
- // SmartMedia cards need extra 40 msec
- if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7) == 1)
- msleep(40);
- writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
- sock_addr + SOCK_CONTROL);
- msleep(10);
- writel((s_state & 0x7) | 0x0c00 | TIFM_CTRL_LED,
- sock_addr + SOCK_CONTROL);
- }
+ writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
+ sock_addr + SOCK_CONTROL);
- for (cnt = 0; cnt < 100; cnt++) {
+ /* xd needs some extra time before power on */
+ if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7)
+ == TIFM_TYPE_XD)
+ msleep(40);
+
+ writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL);
+ /* wait for power to stabilize */
+ msleep(20);
+ for (cnt = 16; cnt <= 256; cnt <<= 1) {
if ((TIFM_SOCK_STATE_POWERED
& readl(sock_addr + SOCK_PRESENT_STATE)))
break;
- msleep(10);
+
+ msleep(cnt);
}
- if (!is_x2)
- writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED),
- sock_addr + SOCK_CONTROL);
+ writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED),
+ sock_addr + SOCK_CONTROL);
return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7;
}
@@ -169,8 +167,7 @@ static void tifm_7xx1_switch_media(struct work_struct *work)
spin_unlock_irqrestore(&fm->lock, flags);
media_id = tifm_7xx1_toggle_sock_power(
- tifm_7xx1_sock_addr(fm->addr, cnt),
- fm->num_sockets == 2);
+ tifm_7xx1_sock_addr(fm->addr, cnt));
if (media_id) {
sock = tifm_alloc_device(fm);
if (sock) {
@@ -258,8 +255,7 @@ static int tifm_7xx1_resume(struct pci_dev *dev)
for (cnt = 0; cnt < fm->num_sockets; cnt++)
new_ids[cnt] = tifm_7xx1_toggle_sock_power(
- tifm_7xx1_sock_addr(fm->addr, cnt),
- fm->num_sockets == 2);
+ tifm_7xx1_sock_addr(fm->addr, cnt));
spin_lock_irqsave(&fm->lock, flags);
fm->socket_change_set = 0;
for (cnt = 0; cnt < fm->num_sockets; cnt++) {