Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jan 2004 15:48:23 +0900
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        sos@FreeBSD.org
Cc:        current@FreeBSD.org
Subject:   Panasonic KXLC005 support
Message-ID:  <yged695sx8o.wl%ume@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
Hi,

I have Panasonic KXLC005 CDROM drive which is connected via PC-CARD.
Unfortunately, it requires extra initialization, and is not recognized
by current ATA driver.  So, I made a patch.  Please review it.

Index: sys/dev/ata/ata-card.c
diff -u -p sys/dev/ata/ata-card.c.orig sys/dev/ata/ata-card.c
--- sys/dev/ata/ata-card.c.orig	Thu Jan 15 15:47:27 2004
+++ sys/dev/ata/ata-card.c	Wed Jan 21 23:14:44 2004
@@ -49,15 +49,22 @@ __FBSDID("$FreeBSD: src/sys/dev/ata/ata-
 #include <dev/pccard/pccardreg.h>
 #include <dev/pccard/pccardvar.h>
 
-static const struct pccard_product ata_pccard_products[] = {
-	PCMCIA_CARD(FREECOM, PCCARDIDE, 0),
-	PCMCIA_CARD(EXP, EXPMULTIMEDIA, 0),
-	PCMCIA_CARD(IODATA, CBIDE2, 0),
-	PCMCIA_CARD(OEM2, CDROM1, 0),
-	PCMCIA_CARD(OEM2, IDE, 0),
-	PCMCIA_CARD(PANASONIC, KXLC005, 0),
-	PCMCIA_CARD(TEAC, IDECARDII, 0),
-	{NULL}
+#define KME_IO		0x1
+#define KME_TIMEOUT	(hz / 5)
+
+static const struct ata_pccard_product {
+	struct pccard_product prod;
+	int flags;
+} ata_pccard_products[] = {
+	{ PCMCIA_CARD(FREECOM, PCCARDIDE, 0), 0 },
+	{ PCMCIA_CARD(EXP, EXPMULTIMEDIA, 0), 0 },
+	{ PCMCIA_CARD(IODATA, CBIDE2, 0), 0 },
+	{ PCMCIA_CARD(OEM2, CDROM1, 0), 0 },
+	{ PCMCIA_CARD(OEM2, IDE, 0), 0 },
+	{ PCMCIA_CARD(PANASONIC, KXLC005, 0), KME_IO },
+	{ PCMCIA_CARD(PANASONIC, KXLC005_1, 0), KME_IO },
+	{ PCMCIA_CARD(TEAC, IDECARDII, 0), 0 },
+	{ {NULL}, 0 }
 };
 
 MALLOC_DECLARE(M_ATA);
@@ -65,7 +72,7 @@ MALLOC_DECLARE(M_ATA);
 static int
 ata_pccard_match(device_t dev)
 {
-    const struct pccard_product *pp;
+    const struct ata_pccard_product *pp;
     u_int32_t fcn = PCCARD_FUNCTION_UNSPEC;
     int error = 0;
 
@@ -78,10 +85,13 @@ ata_pccard_match(device_t dev)
 	return (0);
 
     /* match other devices here, primarily cdrom/dvd rom */
-    if ((pp = pccard_product_lookup(dev, ata_pccard_products,
-				    sizeof(ata_pccard_products[0]), NULL))) {
-	if (pp->pp_name)
-	    device_set_desc(dev, pp->pp_name);
+    if ((pp = (const struct ata_pccard_product *)pccard_product_lookup(dev,
+	(const struct pccard_product *)ata_pccard_products,
+	sizeof(ata_pccard_products[0]), NULL))) {
+	if (pp->prod.pp_name)
+	    device_set_desc(dev, pp->prod.pp_name);
+	if (pp->flags == KME_IO)
+	    device_set_flags(dev, KME_IO);
 	return (0);
     }
     return(ENXIO);
@@ -103,7 +113,7 @@ ata_pccard_probe(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(dev);
     struct resource *io, *altio;
-    int i, rid, len;
+    int i, rid, len, ts;
 
     /* allocate the io range to get start and length */
     rid = ATA_IOADDR_RID;
@@ -129,8 +139,11 @@ ata_pccard_probe(device_t dev)
     }
     else {
 	rid = ATA_ALTADDR_RID;
-	altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
-				   ATA_ALTIOSIZE, RF_ACTIVE);
+	len = ATA_ALTIOSIZE;
+	if (device_get_flags(dev) == KME_IO)
+	    ++len;
+	altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, len,
+				   RF_ACTIVE);
 	if (!altio) {
 	    bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io);
 	    for (i = ATA_DATA; i < ATA_MAX_RES; i++)
@@ -139,6 +152,12 @@ ata_pccard_probe(device_t dev)
 	}
 	ch->r_io[ATA_ALTSTAT].res = altio;
 	ch->r_io[ATA_ALTSTAT].offset = 0;
+	if (device_get_flags(dev) == KME_IO) {
+	    bus_space_write_1(rman_get_bustag(altio),
+			      rman_get_bushandle(altio), 1, 0x81);
+	    if (!cold)
+		tsleep(&ts, PRIBIO, "atacard", KME_TIMEOUT);
+	}
     }
 
     /* initialize softc for this channel */


Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?yged695sx8o.wl%ume>