aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Dubov <oakad@yahoo.com>2007-04-12 02:59:16 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-05-01 07:04:13 -0400
commit342c0ec4859446140c0dc5d7d903bb3b3f0577cd (patch)
tree0b2e7fc07d23cd845c74da0ddf257f183427db10 /drivers
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')
-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 e5655fef42d7..34746798ba8e 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)
75 return IRQ_HANDLED; 75 return IRQ_HANDLED;
76} 76}
77 77
78static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr, 78static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr)
79 int is_x2)
80{ 79{
81 unsigned int s_state; 80 unsigned int s_state;
82 int cnt; 81 int cnt;
83 82
84 writel(0x0e00, sock_addr + SOCK_CONTROL); 83 writel(0x0e00, sock_addr + SOCK_CONTROL);
85 84
86 for (cnt = 0; cnt < 100; cnt++) { 85 for (cnt = 16; cnt <= 256; cnt <<= 1) {
87 if (!(TIFM_SOCK_STATE_POWERED 86 if (!(TIFM_SOCK_STATE_POWERED
88 & readl(sock_addr + SOCK_PRESENT_STATE))) 87 & readl(sock_addr + SOCK_PRESENT_STATE)))
89 break; 88 break;
90 msleep(10); 89
90 msleep(cnt);
91 } 91 }
92 92
93 s_state = readl(sock_addr + SOCK_PRESENT_STATE); 93 s_state = readl(sock_addr + SOCK_PRESENT_STATE);
94 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state)) 94 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state))
95 return 0; 95 return 0;
96 96
97 if (is_x2) { 97 writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
98 writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL); 98 sock_addr + SOCK_CONTROL);
99 } else {
100 // SmartMedia cards need extra 40 msec
101 if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7) == 1)
102 msleep(40);
103 writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
104 sock_addr + SOCK_CONTROL);
105 msleep(10);
106 writel((s_state & 0x7) | 0x0c00 | TIFM_CTRL_LED,
107 sock_addr + SOCK_CONTROL);
108 }
109 99
110 for (cnt = 0; cnt < 100; cnt++) { 100 /* xd needs some extra time before power on */
101 if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7)
102 == TIFM_TYPE_XD)
103 msleep(40);
104
105 writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL);
106 /* wait for power to stabilize */
107 msleep(20);
108 for (cnt = 16; cnt <= 256; cnt <<= 1) {
111 if ((TIFM_SOCK_STATE_POWERED 109 if ((TIFM_SOCK_STATE_POWERED
112 & readl(sock_addr + SOCK_PRESENT_STATE))) 110 & readl(sock_addr + SOCK_PRESENT_STATE)))
113 break; 111 break;
114 msleep(10); 112
113 msleep(cnt);
115 } 114 }
116 115
117 if (!is_x2) 116 writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED),
118 writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED), 117 sock_addr + SOCK_CONTROL);
119 sock_addr + SOCK_CONTROL);
120 118
121 return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7; 119 return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7;
122} 120}
@@ -169,8 +167,7 @@ static void tifm_7xx1_switch_media(struct work_struct *work)
169 167
170 spin_unlock_irqrestore(&fm->lock, flags); 168 spin_unlock_irqrestore(&fm->lock, flags);
171 media_id = tifm_7xx1_toggle_sock_power( 169 media_id = tifm_7xx1_toggle_sock_power(
172 tifm_7xx1_sock_addr(fm->addr, cnt), 170 tifm_7xx1_sock_addr(fm->addr, cnt));
173 fm->num_sockets == 2);
174 if (media_id) { 171 if (media_id) {
175 sock = tifm_alloc_device(fm); 172 sock = tifm_alloc_device(fm);
176 if (sock) { 173 if (sock) {
@@ -258,8 +255,7 @@ static int tifm_7xx1_resume(struct pci_dev *dev)
258 255
259 for (cnt = 0; cnt < fm->num_sockets; cnt++) 256 for (cnt = 0; cnt < fm->num_sockets; cnt++)
260 new_ids[cnt] = tifm_7xx1_toggle_sock_power( 257 new_ids[cnt] = tifm_7xx1_toggle_sock_power(
261 tifm_7xx1_sock_addr(fm->addr, cnt), 258 tifm_7xx1_sock_addr(fm->addr, cnt));
262 fm->num_sockets == 2);
263 spin_lock_irqsave(&fm->lock, flags); 259 spin_lock_irqsave(&fm->lock, flags);
264 fm->socket_change_set = 0; 260 fm->socket_change_set = 0;
265 for (cnt = 0; cnt < fm->num_sockets; cnt++) { 261 for (cnt = 0; cnt < fm->num_sockets; cnt++) {