Implement 16 bit card autoprobing by calling the generic PCMCIA cftable entry parser through the pcmcia_parse_tuple interface. Signed-off-by: Michael Schmitz <schmitzmic@xxxxxxxxx> --- arch/m68k/amiga/pcmcia.c | 37 +++++++++++++++++++++++++++++++++++++ arch/m68k/include/asm/amipcmcia.h | 4 ++++ 2 files changed, 41 insertions(+) diff --git a/arch/m68k/amiga/pcmcia.c b/arch/m68k/amiga/pcmcia.c index 7106f0c..e7651e6 100644 --- a/arch/m68k/amiga/pcmcia.c +++ b/arch/m68k/amiga/pcmcia.c @@ -16,6 +16,7 @@ #include <linux/jiffies.h> #include <linux/timer.h> #include <linux/module.h> +#include <pcmcia/cistpl.h> #include <asm/amigayle.h> #include <asm/amipcmcia.h> @@ -120,3 +121,39 @@ void pcmcia_write_disable(void) } EXPORT_SYMBOL(pcmcia_write_disable); +int pcmcia_is_16bit(void) +{ + u_char cftuple[258]; + int cftuple_len; + tuple_t cftable_tuple; + cistpl_cftable_entry_t cftable_entry; + + cftuple_len = pcmcia_copy_tuple(CISTPL_CFTABLE_ENTRY, cftuple, 256); + if (cftuple_len < 3) + return 0; +#ifdef DEBUG + else + print_hex_dump(KERN_WARNING, "cftable: ", DUMP_PREFIX_NONE, 8, + sizeof(char), cftuple, cftuple_len, false); +#endif + + /* build tuple_t struct and call pcmcia_parse_tuple */ + cftable_tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; + cftable_tuple.TupleCode = CISTPL_CFTABLE_ENTRY; + cftable_tuple.TupleData = &cftuple[2]; + cftable_tuple.TupleDataLen = cftuple_len-2; + cftable_tuple.TupleDataMax = cftuple_len-2; + + if (pcmcia_parse_tuple(&cftable_tuple, &cftable_entry)) + return 0; + +#ifdef DEBUG + pr_info("IO flags: %x\n", cftable_entry.io.flags); +#endif + + if (cftable_entry.io.flags & CISTPL_IO_16BIT) + return 1; + + return 0; +} +EXPORT_SYMBOL(pcmcia_is_16bit); diff --git a/arch/m68k/include/asm/amipcmcia.h b/arch/m68k/include/asm/amipcmcia.h index 6f1ec18..fac9534 100644 --- a/arch/m68k/include/asm/amipcmcia.h +++ b/arch/m68k/include/asm/amipcmcia.h @@ -19,10 +19,12 @@ void pcmcia_reset(void); int pcmcia_copy_tuple(unsigned char tuple_id, void *tuple, int max_len); +int pcmcia_parse_tuple(void *tuple, void *parse); void pcmcia_program_voltage(int voltage); void pcmcia_access_speed(int speed); void pcmcia_write_enable(void); void pcmcia_write_disable(void); +int pcmcia_is_16bit(void); static inline u_char pcmcia_read_status(void) { @@ -64,6 +66,7 @@ static inline void pcmcia_disable_irq(void) #define PCMCIA_SPEED_250NS 250 #define PCMCIA_SPEED_720NS 720 +#ifndef _LINUX_CISTPL_H /* PCMCIA Tuple codes */ #define CISTPL_NULL 0x00 @@ -106,5 +109,6 @@ static inline void pcmcia_disable_irq(void) #define CISTPL_FUNCID_NETWORK 0x06 #define CISTPL_FUNCID_AIMS 0x07 #define CISTPL_FUNCID_SCSI 0x08 +#endif #endif -- 2.7.4