Commit 25fbb358 authored by David Hinds's avatar David Hinds Committed by Linus Torvalds

[PATCH] PATCH: PCMCIA updates for 2.5, #4

drivers/ide/legacy/ide-cs.c:
 o Added MODULE_{AUTHOR,DESCRIPTION}, fixed MODULE_LICENSE
 o Added support for (Panasonic) KME KXLC005 cards
 o Better errno for failed module initialization

drivers/parport/parport_cs.c
 o Fixed it so it actually works
 o Removed cruft for old kernels
 o Better errno for failed module initialization
parent 87ebb81d
......@@ -2,7 +2,7 @@
A driver for PCMCIA IDE/ATA disk cards
ide_cs.c 1.26 1999/11/16 02:10:49
ide-cs.c 1.3 2002/10/26 05:45:31
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
......@@ -19,8 +19,8 @@
are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
Alternatively, the contents of this file may be used under the
terms of the GNU General Public License version 2 (the "GPL"), in which
case the provisions of the GPL are applicable instead of the
terms of the GNU General Public License version 2 (the "GPL"), in
which case the provisions of the GPL are applicable instead of the
above. If you wish to allow the use of your version of this file
only under the terms of the GPL and not to allow others to use
your version of this file under the MPL, indicate your decision
......@@ -40,10 +40,9 @@
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/ioport.h>
#include <linux/ide.h>
#include <linux/hdreg.h>
#include <linux/major.h>
#include <linux/ide.h>
#include <asm/io.h>
#include <asm/system.h>
......@@ -53,38 +52,37 @@
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#include <pcmcia/cisreg.h>
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
MODULE_PARM(pc_debug, "i");
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
"ide_cs.c 1.26 1999/11/16 02:10:49 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
#include <pcmcia/ciscode.h>
/*====================================================================*/
/* Parameters that can be set with 'insmod' */
/* Module parameters */
MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
MODULE_DESCRIPTION("PCMCIA ATA/IDE card driver");
MODULE_LICENSE("Dual MPL/GPL");
#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
/* Bit map of interrupts to choose from */
static u_int irq_mask = 0xdeb8;
INT_MODULE_PARM(irq_mask, 0xdeb8);
static int irq_list[4] = { -1 };
MODULE_PARM(irq_mask, "i");
MODULE_PARM(irq_list, "1-4i");
MODULE_LICENSE("GPL");
#ifdef PCMCIA_DEBUG
INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
"ide-cs.c 1.3 2002/10/26 05:45:31 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
/*====================================================================*/
static const char ide_major[] = {
IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR,
#ifdef IDE4_MAJOR
IDE4_MAJOR, IDE5_MAJOR
#endif
};
typedef struct ide_info_t {
......@@ -94,7 +92,6 @@ typedef struct ide_info_t {
int hd;
} ide_info_t;
static void ide_config(dev_link_t *link);
static void ide_release(u_long arg);
static int ide_event(event_t event, int priority,
event_callback_args_t *args);
......@@ -227,13 +224,13 @@ while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
#define CFG_CHECK(fn, args...) \
if (CardServices(fn, args) != 0) goto next_entry
int idecs_register (int arg1, int arg2, int irq)
static int idecs_register(int io, int ctl, int irq)
{
hw_regs_t hw;
ide_init_hwif_ports(&hw, (ide_ioreg_t) arg1, (ide_ioreg_t) arg2, NULL);
hw.irq = irq;
hw.chipset = ide_pci; /* this enables IRQ sharing w/ PCI irqs */
return ide_register_hw(&hw, NULL);
hw_regs_t hw;
ide_init_hwif_ports(&hw, (ide_ioreg_t)io, (ide_ioreg_t)ctl, NULL);
hw.irq = irq;
hw.chipset = ide_pci;
return ide_register_hw(&hw, NULL);
}
void ide_config(dev_link_t *link)
......@@ -246,7 +243,7 @@ void ide_config(dev_link_t *link)
config_info_t conf;
cistpl_cftable_entry_t *cfg = &parse.cftable_entry;
cistpl_cftable_entry_t dflt = { 0 };
int i, pass, last_ret, last_fn, hd=-1, io_base, ctl_base;
int i, pass, last_ret, last_fn, hd, io_base, ctl_base, is_kme = 0;
DEBUG(0, "ide_config(0x%p)\n", link);
......@@ -259,7 +256,15 @@ void ide_config(dev_link_t *link)
CS_CHECK(ParseTuple, handle, &tuple, &parse);
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
tuple.DesiredTuple = CISTPL_MANFID;
if (!CardServices(GetFirstTuple, handle, &tuple) &&
!CardServices(GetTupleData, handle, &tuple) &&
!CardServices(ParseTuple, handle, &tuple, &parse))
is_kme = ((parse.manfid.manf == MANFID_KME) &&
((parse.manfid.card == PRODID_KME_KXLC005_A) ||
(parse.manfid.card == PRODID_KME_KXLC005_B)));
/* Configure card */
link->state |= DEV_CONFIG;
......@@ -303,7 +308,7 @@ void ide_config(dev_link_t *link)
if (io->nwin == 2) {
link->io.NumPorts1 = 8;
link->io.BasePort2 = io->win[1].base;
link->io.NumPorts2 = 1;
link->io.NumPorts2 = (is_kme) ? 2 : 1;
CFG_CHECK(RequestIO, link->handle, &link->io);
io_base = link->io.BasePort1;
ctl_base = link->io.BasePort2;
......@@ -337,17 +342,20 @@ void ide_config(dev_link_t *link)
if (link->io.NumPorts2)
release_region(link->io.BasePort2, link->io.NumPorts2);
/* disable drive interrupts during IDE probe */
outb(0x02, ctl_base);
/* special setup for KXLC005 card */
if (is_kme) outb(0x81, ctl_base+1);
/* retry registration in case device is still spinning up */
for (i = 0; i < 10; i++) {
if (ctl_base)
outb(0x02, ctl_base); /* Set nIEN = disable device interrupts */
for (hd = -1, i = 0; i < 10; i++) {
hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ);
if (hd >= 0) break;
if (link->io.NumPorts1 == 0x20) {
if (ctl_base)
outb(0x02, ctl_base+0x10);
outb(0x02, ctl_base+0x10);
hd = idecs_register(io_base+0x10, ctl_base+0x10,
link->irq.AssignedIRQ);
link->irq.AssignedIRQ);
if (hd >= 0) {
io_base += 0x10; ctl_base += 0x10;
break;
......@@ -358,7 +366,7 @@ void ide_config(dev_link_t *link)
}
if (hd < 0) {
printk(KERN_NOTICE "ide_cs: ide_register() at 0x%03x & 0x%03x"
printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3x & 0x%3x"
", irq %u failed\n", io_base, ctl_base,
link->irq.AssignedIRQ);
goto failed;
......@@ -371,7 +379,7 @@ void ide_config(dev_link_t *link)
info->node.minor = 0;
info->hd = hd;
link->dev = &info->node;
printk(KERN_INFO "ide_cs: %s: Vcc = %d.%d, Vpp = %d.%d\n",
printk(KERN_INFO "ide-cs: %s: Vcc = %d.%d, Vpp = %d.%d\n",
info->node.dev_name, link->conf.Vcc/10, link->conf.Vcc%10,
link->conf.Vpp1/10, link->conf.Vpp1%10);
......@@ -382,6 +390,7 @@ void ide_config(dev_link_t *link)
cs_error(link->handle, last_fn, last_ret);
failed:
ide_release((u_long)link);
link->state &= ~DEV_CONFIG_PENDING;
} /* ide_config */
......@@ -402,13 +411,14 @@ void ide_release(u_long arg)
if (info->ndev) {
ide_unregister(info->hd);
/* deal with brain dead IDE resource management */
request_region(link->io.BasePort1, link->io.NumPorts1,
info->node.dev_name);
if (link->io.NumPorts2)
request_region(link->io.BasePort2, link->io.NumPorts2,
info->node.dev_name);
MOD_DEC_USE_COUNT;
}
request_region(link->io.BasePort1, link->io.NumPorts1,"ide-cs");
if (link->io.NumPorts2)
request_region(link->io.BasePort2, link->io.NumPorts2,"ide-cs");
info->ndev = 0;
link->dev = NULL;
......@@ -472,9 +482,9 @@ static int __init init_ide_cs(void)
DEBUG(0, "%s\n", version);
CardServices(GetCardServicesInfo, &serv);
if (serv.Revision != CS_RELEASE_CODE) {
printk(KERN_NOTICE "ide_cs: Card Services release "
printk(KERN_NOTICE "ide-cs: Card Services release "
"does not match!\n");
return -1;
return -EINVAL;
}
register_pccard_driver(&dev_info, &ide_attach, &ide_detach);
return 0;
......@@ -482,7 +492,7 @@ static int __init init_ide_cs(void)
static void __exit exit_ide_cs(void)
{
DEBUG(0, "ide_cs: unloading\n");
DEBUG(0, "ide-cs: unloading\n");
unregister_pccard_driver(&dev_info);
while (dev_list != NULL)
ide_detach(dev_list);
......
......@@ -5,7 +5,7 @@
(specifically, for the Quatech SPP-100 EPP card: other cards will
probably require driver tweaks)
parport_cs.c 1.20 2000/11/02 23:15:05
parport_cs.c 1.29 2002/10/11 06:57:41
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
......@@ -34,9 +34,7 @@
======================================================================*/
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
......@@ -45,7 +43,6 @@
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/ioport.h>
#include <linux/major.h>
#include <linux/parport.h>
#include <linux/parport_pc.h>
......@@ -58,32 +55,31 @@
#include <pcmcia/cisreg.h>
#include <pcmcia/ciscode.h>
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
MODULE_PARM(pc_debug, "i");
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
"parport_cs.c 1.20 2000/11/02 23:15:05 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
/*====================================================================*/
#ifndef VERSION
#define VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
/* Module parameters */
/*====================================================================*/
MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
MODULE_DESCRIPTION("PCMCIA parallel port card driver");
MODULE_LICENSE("Dual MPL/GPL");
/* Parameters that can be set with 'insmod' */
#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
/* Bit map of interrupts to choose from */
static u_int irq_mask = 0xdeb8;
INT_MODULE_PARM(irq_mask, 0xdeb8);
static int irq_list[4] = { -1 };
static int epp_mode = 1;
MODULE_PARM(irq_mask, "i");
MODULE_PARM(irq_list, "1-4i");
MODULE_PARM(epp_mode, "i");
INT_MODULE_PARM(epp_mode, 1);
#ifdef PCMCIA_DEBUG
INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
"parport_cs.c 1.29 2002/10/11 06:57:41 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
/*====================================================================*/
......@@ -106,8 +102,6 @@ static int parport_event(event_t event, int priority,
static dev_info_t dev_info = "parport_cs";
static dev_link_t *dev_list = NULL;
extern struct parport_operations parport_pc_ops;
/*====================================================================*/
static void cs_error(client_handle_t handle, int func, int ret)
......@@ -228,12 +222,6 @@ while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
#define CFG_CHECK(fn, args...) \
if (CardServices(fn, args) != 0) goto next_entry
static struct { u_int flag; char *name; } mode[] = {
{ PARPORT_MODE_TRISTATE, "PS2" },
{ PARPORT_MODE_EPP, "EPP" },
{ PARPORT_MODE_ECP, "ECP" },
};
void parport_config(dev_link_t *link)
{
client_handle_t handle = link->handle;
......@@ -245,7 +233,7 @@ void parport_config(dev_link_t *link)
cistpl_cftable_entry_t *cfg = &parse.cftable_entry;
cistpl_cftable_entry_t dflt = { 0 };
struct parport *p;
int i, last_ret, last_fn;
int last_ret, last_fn;
DEBUG(0, "parport_config(0x%p)\n", link);
......@@ -297,6 +285,9 @@ void parport_config(dev_link_t *link)
CS_CHECK(RequestIRQ, handle, &link->irq);
CS_CHECK(RequestConfiguration, handle, &link->conf);
release_region(link->io.BasePort1, link->io.NumPorts1);
if (link->io.NumPorts2)
release_region(link->io.BasePort2, link->io.NumPorts2);
p = parport_pc_probe_port(link->io.BasePort1, link->io.BasePort2,
link->irq.AssignedIRQ, PARPORT_DMA_NONE,
NULL);
......@@ -307,19 +298,6 @@ void parport_config(dev_link_t *link)
goto failed;
}
#if (LINUX_VERSION_CODE < VERSION(2,3,6))
#if (LINUX_VERSION_CODE >= VERSION(2,2,8))
p->private_data = kmalloc(sizeof(struct parport_pc_private),
GFP_KERNEL);
((struct parport_pc_private *)(p->private_data))->ctr = 0x0c;
#endif
parport_proc_register(p);
p->flags |= PARPORT_FLAG_COMA;
parport_pc_write_econtrol(p, 0x00);
parport_pc_write_control(p, 0x0c);
parport_pc_write_data(p, 0x00);
#endif
p->modes |= PARPORT_MODE_PCSPP;
if (epp_mode)
p->modes |= PARPORT_MODE_TRISTATE | PARPORT_MODE_EPP;
......@@ -329,15 +307,7 @@ void parport_config(dev_link_t *link)
info->port = p;
strcpy(info->node.dev_name, p->name);
link->dev = &info->node;
printk(KERN_INFO "%s: PC-style PCMCIA at %#x", p->name,
link->io.BasePort1);
if (link->io.NumPorts2)
printk(" & %#x", link->io.BasePort2);
printk(", irq %u [SPP", link->irq.AssignedIRQ);
for (i = 0; i < 5; i++)
if (p->modes & mode[i].flag) printk(",%s", mode[i].name);
printk("]\n");
link->state &= ~DEV_CONFIG_PENDING;
return;
......@@ -345,6 +315,7 @@ void parport_config(dev_link_t *link)
cs_error(link->handle, last_fn, last_ret);
failed:
parport_cs_release((u_long)link);
link->state &= ~DEV_CONFIG_PENDING;
} /* parport_config */
......@@ -365,15 +336,12 @@ void parport_cs_release(u_long arg)
if (info->ndev) {
struct parport *p = info->port;
#if (LINUX_VERSION_CODE < VERSION(2,3,6))
if (!(p->flags & PARPORT_FLAG_COMA))
parport_quiesce(p);
#endif
parport_proc_unregister(p);
#if (LINUX_VERSION_CODE >= VERSION(2,2,8))
kfree(p->private_data);
#endif
parport_unregister_port(p);
parport_pc_unregister_port(p);
request_region(link->io.BasePort1, link->io.NumPorts1,
info->node.dev_name);
if (link->io.NumPorts2)
request_region(link->io.BasePort2, link->io.NumPorts2,
info->node.dev_name);
}
info->ndev = 0;
link->dev = NULL;
......@@ -430,24 +398,6 @@ int parport_event(event_t event, int priority,
/*====================================================================*/
#if (LINUX_VERSION_CODE < VERSION(2,3,6))
static void inc_use_count(void)
{
MOD_INC_USE_COUNT;
parport_pc_ops.inc_use_count();
}
static void dec_use_count(void)
{
MOD_DEC_USE_COUNT;
parport_pc_ops.dec_use_count();
}
#endif
/*====================================================================*/
static int __init init_parport_cs(void)
{
servinfo_t serv;
......@@ -456,9 +406,8 @@ static int __init init_parport_cs(void)
if (serv.Revision != CS_RELEASE_CODE) {
printk(KERN_NOTICE "parport_cs: Card Services release "
"does not match!\n");
return -1;
return -EINVAL;
}
register_pccard_driver(&dev_info, &parport_attach, &parport_detach);
return 0;
}
......@@ -473,4 +422,3 @@ static void __exit exit_parport_cs(void)
module_init(init_parport_cs);
module_exit(exit_parport_cs);
MODULE_LICENSE("Dual MPL/GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment