From owner-freebsd-current@FreeBSD.ORG Tue Jan 27 00:08:55 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2A03616A4CE; Tue, 27 Jan 2004 00:08:55 -0800 (PST) Received: from spider.deepcore.dk (cpe.atm2-0-53484.0x50a6c9a6.abnxx9.customer.tele.dk [80.166.201.166]) by mx1.FreeBSD.org (Postfix) with ESMTP id 12BE543D1F; Tue, 27 Jan 2004 00:08:36 -0800 (PST) (envelope-from sos@spider.deepcore.dk) Received: from spider.deepcore.dk (localhost [127.0.0.1]) by spider.deepcore.dk (8.12.10/8.12.10) with ESMTP id i0R87LCm025833; Tue, 27 Jan 2004 09:07:21 +0100 (CET) (envelope-from sos@spider.deepcore.dk) Received: (from sos@localhost) by spider.deepcore.dk (8.12.10/8.12.10/Submit) id i0R87L9s025832; Tue, 27 Jan 2004 09:07:21 +0100 (CET) (envelope-from sos) Message-Id: <200401270807.i0R87L9s025832@spider.deepcore.dk> In-Reply-To: To: Hajimu UMEMOTO Date: Tue, 27 Jan 2004 09:07:21 +0100 (CET) Sender: sos@spider.deepcore.dk From: sos@deepcore.dk X-Mailer: ELM [version 2.4ME+ PL99f (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=ISO-8859-1 X-mail-scanned: by DeepCore Virus & Spam killer v1.3 X-Mailman-Approved-At: Tue, 27 Jan 2004 05:23:04 -0800 cc: current@FreeBSD.ORG cc: sos@FreeBSD.ORG Subject: Re: Panasonic KXLC005 support X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2004 08:08:55 -0000 It seems Hajimu UMEMOTO wrote: > 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. There must be a cleaner way of doing this. if I read it right the only thing you want to have done is to write 0x81 to ALTIO+1 and wait a bit is that correct ? -Søren > 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 > #include > > -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 */