From: Michael Schmitz <schmitzmic@gmail.com>
To: linux-m68k@vger.kernel.org, geert@linux-m68k.org
Cc: alex@kazik.de, Michael Schmitz <schmitzmic@gmail.com>
Subject: [PATCH v7 2/4] m68k: amiga/pcmcia - implement 16 bit detection support for apne.c
Date: Sun, 29 Aug 2021 15:11:48 +1200 [thread overview]
Message-ID: <1630206710-5954-3-git-send-email-schmitzmic@gmail.com> (raw)
In-Reply-To: <1630206710-5954-1-git-send-email-schmitzmic@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2021-08-29 3:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-29 3:11 [PATCH v7 0/4] Add APNE PCMCIA 100 Mbit support Michael Schmitz
2021-08-29 3:11 ` [PATCH v7 1/4] m68k: Kconfig - select core PCMCIA support module for Amiga PCMCIA Michael Schmitz
2021-09-02 12:42 ` Geert Uytterhoeven
2021-09-03 2:51 ` Michael Schmitz
2021-09-03 14:14 ` Geert Uytterhoeven
2021-09-03 21:51 ` Michael Schmitz
2021-09-05 8:15 ` Michael Schmitz
2021-08-29 3:11 ` Michael Schmitz [this message]
2021-08-29 3:11 ` [PATCH v7 3/4] m68k: io_mm.h - add APNE 100 MBit support Michael Schmitz
2021-08-29 3:11 ` [PATCH net v7 4/4] net/8390: apne.c - add 100 Mbit support to apne.c driver Michael Schmitz
2021-11-02 6:24 ` [PATCH v7 0/4] Add APNE PCMCIA 100 Mbit support Michael Schmitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1630206710-5954-3-git-send-email-schmitzmic@gmail.com \
--to=schmitzmic@gmail.com \
--cc=alex@kazik.de \
--cc=geert@linux-m68k.org \
--cc=linux-m68k@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).