diff options
Diffstat (limited to 'drivers/pcmcia/yenta_socket.c')
-rw-r--r-- | drivers/pcmcia/yenta_socket.c | 140 |
1 files changed, 44 insertions, 96 deletions
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index ec6ab65f0872..4145eb83b9b6 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c | |||
@@ -49,7 +49,13 @@ MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only | |||
49 | #define to_cycles(ns) ((ns)/120) | 49 | #define to_cycles(ns) ((ns)/120) |
50 | #define to_ns(cycles) ((cycles)*120) | 50 | #define to_ns(cycles) ((cycles)*120) |
51 | 51 | ||
52 | /** | ||
53 | * yenta PCI irq probing. | ||
54 | * currently only used in the TI/EnE initialization code | ||
55 | */ | ||
56 | #ifdef CONFIG_YENTA_TI | ||
52 | static int yenta_probe_cb_irq(struct yenta_socket *socket); | 57 | static int yenta_probe_cb_irq(struct yenta_socket *socket); |
58 | #endif | ||
53 | 59 | ||
54 | 60 | ||
55 | static unsigned int override_bios; | 61 | static unsigned int override_bios; |
@@ -224,95 +230,6 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value) | |||
224 | return 0; | 230 | return 0; |
225 | } | 231 | } |
226 | 232 | ||
227 | static void yenta_get_power(struct yenta_socket *socket, socket_state_t *state) | ||
228 | { | ||
229 | if (!(cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) && | ||
230 | (socket->flags & YENTA_16BIT_POWER_EXCA)) { | ||
231 | u8 reg, vcc, vpp; | ||
232 | |||
233 | reg = exca_readb(socket, I365_POWER); | ||
234 | vcc = reg & I365_VCC_MASK; | ||
235 | vpp = reg & I365_VPP1_MASK; | ||
236 | state->Vcc = state->Vpp = 0; | ||
237 | |||
238 | if (socket->flags & YENTA_16BIT_POWER_DF) { | ||
239 | if (vcc == I365_VCC_3V) | ||
240 | state->Vcc = 33; | ||
241 | if (vcc == I365_VCC_5V) | ||
242 | state->Vcc = 50; | ||
243 | if (vpp == I365_VPP1_5V) | ||
244 | state->Vpp = state->Vcc; | ||
245 | if (vpp == I365_VPP1_12V) | ||
246 | state->Vpp = 120; | ||
247 | } else { | ||
248 | if (reg & I365_VCC_5V) { | ||
249 | state->Vcc = 50; | ||
250 | if (vpp == I365_VPP1_5V) | ||
251 | state->Vpp = 50; | ||
252 | if (vpp == I365_VPP1_12V) | ||
253 | state->Vpp = 120; | ||
254 | } | ||
255 | } | ||
256 | } else { | ||
257 | u32 control; | ||
258 | |||
259 | control = cb_readl(socket, CB_SOCKET_CONTROL); | ||
260 | |||
261 | switch (control & CB_SC_VCC_MASK) { | ||
262 | case CB_SC_VCC_5V: state->Vcc = 50; break; | ||
263 | case CB_SC_VCC_3V: state->Vcc = 33; break; | ||
264 | default: state->Vcc = 0; | ||
265 | } | ||
266 | |||
267 | switch (control & CB_SC_VPP_MASK) { | ||
268 | case CB_SC_VPP_12V: state->Vpp = 120; break; | ||
269 | case CB_SC_VPP_5V: state->Vpp = 50; break; | ||
270 | case CB_SC_VPP_3V: state->Vpp = 33; break; | ||
271 | default: state->Vpp = 0; | ||
272 | } | ||
273 | } | ||
274 | } | ||
275 | |||
276 | static int yenta_get_socket(struct pcmcia_socket *sock, socket_state_t *state) | ||
277 | { | ||
278 | struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); | ||
279 | u8 reg; | ||
280 | u32 control; | ||
281 | |||
282 | control = cb_readl(socket, CB_SOCKET_CONTROL); | ||
283 | |||
284 | yenta_get_power(socket, state); | ||
285 | state->io_irq = socket->io_irq; | ||
286 | |||
287 | if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) { | ||
288 | u16 bridge = config_readw(socket, CB_BRIDGE_CONTROL); | ||
289 | if (bridge & CB_BRIDGE_CRST) | ||
290 | state->flags |= SS_RESET; | ||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | /* 16-bit card state.. */ | ||
295 | reg = exca_readb(socket, I365_POWER); | ||
296 | state->flags = (reg & I365_PWR_AUTO) ? SS_PWR_AUTO : 0; | ||
297 | state->flags |= (reg & I365_PWR_OUT) ? SS_OUTPUT_ENA : 0; | ||
298 | |||
299 | reg = exca_readb(socket, I365_INTCTL); | ||
300 | state->flags |= (reg & I365_PC_RESET) ? 0 : SS_RESET; | ||
301 | state->flags |= (reg & I365_PC_IOCARD) ? SS_IOCARD : 0; | ||
302 | |||
303 | reg = exca_readb(socket, I365_CSCINT); | ||
304 | state->csc_mask = (reg & I365_CSC_DETECT) ? SS_DETECT : 0; | ||
305 | if (state->flags & SS_IOCARD) { | ||
306 | state->csc_mask |= (reg & I365_CSC_STSCHG) ? SS_STSCHG : 0; | ||
307 | } else { | ||
308 | state->csc_mask |= (reg & I365_CSC_BVD1) ? SS_BATDEAD : 0; | ||
309 | state->csc_mask |= (reg & I365_CSC_BVD2) ? SS_BATWARN : 0; | ||
310 | state->csc_mask |= (reg & I365_CSC_READY) ? SS_READY : 0; | ||
311 | } | ||
312 | |||
313 | return 0; | ||
314 | } | ||
315 | |||
316 | static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state) | 233 | static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state) |
317 | { | 234 | { |
318 | /* some birdges require to use the ExCA registers to power 16bit cards */ | 235 | /* some birdges require to use the ExCA registers to power 16bit cards */ |
@@ -531,6 +448,9 @@ static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
531 | 448 | ||
532 | csc = exca_readb(socket, I365_CSC); | 449 | csc = exca_readb(socket, I365_CSC); |
533 | 450 | ||
451 | if (!(cb_event || csc)) | ||
452 | return IRQ_NONE; | ||
453 | |||
534 | events = (cb_event & (CB_CD1EVENT | CB_CD2EVENT)) ? SS_DETECT : 0 ; | 454 | events = (cb_event & (CB_CD1EVENT | CB_CD2EVENT)) ? SS_DETECT : 0 ; |
535 | events |= (csc & I365_CSC_DETECT) ? SS_DETECT : 0; | 455 | events |= (csc & I365_CSC_DETECT) ? SS_DETECT : 0; |
536 | if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { | 456 | if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { |
@@ -544,10 +464,7 @@ static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
544 | if (events) | 464 | if (events) |
545 | pcmcia_parse_events(&socket->socket, events); | 465 | pcmcia_parse_events(&socket->socket, events); |
546 | 466 | ||
547 | if (cb_event || csc) | 467 | return IRQ_HANDLED; |
548 | return IRQ_HANDLED; | ||
549 | |||
550 | return IRQ_NONE; | ||
551 | } | 468 | } |
552 | 469 | ||
553 | static void yenta_interrupt_wrapper(unsigned long data) | 470 | static void yenta_interrupt_wrapper(unsigned long data) |
@@ -828,17 +745,24 @@ static struct pccard_operations yenta_socket_operations = { | |||
828 | .init = yenta_sock_init, | 745 | .init = yenta_sock_init, |
829 | .suspend = yenta_sock_suspend, | 746 | .suspend = yenta_sock_suspend, |
830 | .get_status = yenta_get_status, | 747 | .get_status = yenta_get_status, |
831 | .get_socket = yenta_get_socket, | ||
832 | .set_socket = yenta_set_socket, | 748 | .set_socket = yenta_set_socket, |
833 | .set_io_map = yenta_set_io_map, | 749 | .set_io_map = yenta_set_io_map, |
834 | .set_mem_map = yenta_set_mem_map, | 750 | .set_mem_map = yenta_set_mem_map, |
835 | }; | 751 | }; |
836 | 752 | ||
837 | 753 | ||
754 | #ifdef CONFIG_YENTA_TI | ||
838 | #include "ti113x.h" | 755 | #include "ti113x.h" |
756 | #endif | ||
757 | #ifdef CONFIG_YENTA_RICOH | ||
839 | #include "ricoh.h" | 758 | #include "ricoh.h" |
759 | #endif | ||
760 | #ifdef CONFIG_YENTA_TOSHIBA | ||
840 | #include "topic.h" | 761 | #include "topic.h" |
762 | #endif | ||
763 | #ifdef CONFIG_YENTA_O2 | ||
841 | #include "o2micro.h" | 764 | #include "o2micro.h" |
765 | #endif | ||
842 | 766 | ||
843 | enum { | 767 | enum { |
844 | CARDBUS_TYPE_DEFAULT = -1, | 768 | CARDBUS_TYPE_DEFAULT = -1, |
@@ -858,6 +782,7 @@ enum { | |||
858 | * initialization sequences etc details. List them here.. | 782 | * initialization sequences etc details. List them here.. |
859 | */ | 783 | */ |
860 | static struct cardbus_type cardbus_type[] = { | 784 | static struct cardbus_type cardbus_type[] = { |
785 | #ifdef CONFIG_YENTA_TI | ||
861 | [CARDBUS_TYPE_TI] = { | 786 | [CARDBUS_TYPE_TI] = { |
862 | .override = ti_override, | 787 | .override = ti_override, |
863 | .save_state = ti_save_state, | 788 | .save_state = ti_save_state, |
@@ -882,27 +807,36 @@ static struct cardbus_type cardbus_type[] = { | |||
882 | .restore_state = ti_restore_state, | 807 | .restore_state = ti_restore_state, |
883 | .sock_init = ti_init, | 808 | .sock_init = ti_init, |
884 | }, | 809 | }, |
810 | #endif | ||
811 | #ifdef CONFIG_YENTA_RICOH | ||
885 | [CARDBUS_TYPE_RICOH] = { | 812 | [CARDBUS_TYPE_RICOH] = { |
886 | .override = ricoh_override, | 813 | .override = ricoh_override, |
887 | .save_state = ricoh_save_state, | 814 | .save_state = ricoh_save_state, |
888 | .restore_state = ricoh_restore_state, | 815 | .restore_state = ricoh_restore_state, |
889 | }, | 816 | }, |
817 | #endif | ||
818 | #ifdef CONFIG_YENTA_TOSHIBA | ||
890 | [CARDBUS_TYPE_TOPIC95] = { | 819 | [CARDBUS_TYPE_TOPIC95] = { |
891 | .override = topic95_override, | 820 | .override = topic95_override, |
892 | }, | 821 | }, |
893 | [CARDBUS_TYPE_TOPIC97] = { | 822 | [CARDBUS_TYPE_TOPIC97] = { |
894 | .override = topic97_override, | 823 | .override = topic97_override, |
895 | }, | 824 | }, |
825 | #endif | ||
826 | #ifdef CONFIG_YENTA_O2 | ||
896 | [CARDBUS_TYPE_O2MICRO] = { | 827 | [CARDBUS_TYPE_O2MICRO] = { |
897 | .override = o2micro_override, | 828 | .override = o2micro_override, |
898 | .restore_state = o2micro_restore_state, | 829 | .restore_state = o2micro_restore_state, |
899 | }, | 830 | }, |
831 | #endif | ||
832 | #ifdef CONFIG_YENTA_TI | ||
900 | [CARDBUS_TYPE_ENE] = { | 833 | [CARDBUS_TYPE_ENE] = { |
901 | .override = ene_override, | 834 | .override = ene_override, |
902 | .save_state = ti_save_state, | 835 | .save_state = ti_save_state, |
903 | .restore_state = ti_restore_state, | 836 | .restore_state = ti_restore_state, |
904 | .sock_init = ti_init, | 837 | .sock_init = ti_init, |
905 | }, | 838 | }, |
839 | #endif | ||
906 | }; | 840 | }; |
907 | 841 | ||
908 | 842 | ||
@@ -948,6 +882,12 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas | |||
948 | } | 882 | } |
949 | 883 | ||
950 | 884 | ||
885 | /** | ||
886 | * yenta PCI irq probing. | ||
887 | * currently only used in the TI/EnE initialization code | ||
888 | */ | ||
889 | #ifdef CONFIG_YENTA_TI | ||
890 | |||
951 | /* interrupt handler, only used during probing */ | 891 | /* interrupt handler, only used during probing */ |
952 | static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *regs) | 892 | static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *regs) |
953 | { | 893 | { |
@@ -1000,6 +940,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket) | |||
1000 | return (int) socket->probe_status; | 940 | return (int) socket->probe_status; |
1001 | } | 941 | } |
1002 | 942 | ||
943 | #endif /* CONFIG_YENTA_TI */ | ||
1003 | 944 | ||
1004 | 945 | ||
1005 | /* | 946 | /* |
@@ -1078,10 +1019,9 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i | |||
1078 | return -ENODEV; | 1019 | return -ENODEV; |
1079 | } | 1020 | } |
1080 | 1021 | ||
1081 | socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL); | 1022 | socket = kzalloc(sizeof(struct yenta_socket), GFP_KERNEL); |
1082 | if (!socket) | 1023 | if (!socket) |
1083 | return -ENOMEM; | 1024 | return -ENOMEM; |
1084 | memset(socket, 0, sizeof(*socket)); | ||
1085 | 1025 | ||
1086 | /* prepare pcmcia_socket */ | 1026 | /* prepare pcmcia_socket */ |
1087 | socket->socket.ops = ¥ta_socket_operations; | 1027 | socket->socket.ops = ¥ta_socket_operations; |
@@ -1263,6 +1203,7 @@ static struct pci_device_id yenta_table [] = { | |||
1263 | * advanced overrides instead. (I can't get the | 1203 | * advanced overrides instead. (I can't get the |
1264 | * data sheets for these devices. --rmk) | 1204 | * data sheets for these devices. --rmk) |
1265 | */ | 1205 | */ |
1206 | #ifdef CONFIG_YENTA_TI | ||
1266 | CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI), | 1207 | CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI), |
1267 | 1208 | ||
1268 | CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X), | 1209 | CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X), |
@@ -1305,18 +1246,25 @@ static struct pci_device_id yenta_table [] = { | |||
1305 | CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE), | 1246 | CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE), |
1306 | CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE), | 1247 | CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE), |
1307 | CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE), | 1248 | CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE), |
1249 | #endif /* CONFIG_YENTA_TI */ | ||
1308 | 1250 | ||
1251 | #ifdef CONFIG_YENTA_RICOH | ||
1309 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH), | 1252 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH), |
1310 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH), | 1253 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH), |
1311 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH), | 1254 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH), |
1312 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH), | 1255 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH), |
1313 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH), | 1256 | CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH), |
1257 | #endif | ||
1314 | 1258 | ||
1259 | #ifdef CONFIG_YENTA_TOSHIBA | ||
1315 | CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC95, TOPIC95), | 1260 | CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC95, TOPIC95), |
1316 | CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97), | 1261 | CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97), |
1317 | CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97), | 1262 | CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97), |
1263 | #endif | ||
1318 | 1264 | ||
1265 | #ifdef CONFIG_YENTA_O2 | ||
1319 | CB_ID(PCI_VENDOR_ID_O2, PCI_ANY_ID, O2MICRO), | 1266 | CB_ID(PCI_VENDOR_ID_O2, PCI_ANY_ID, O2MICRO), |
1267 | #endif | ||
1320 | 1268 | ||
1321 | /* match any cardbus bridge */ | 1269 | /* match any cardbus bridge */ |
1322 | CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT), | 1270 | CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT), |