[parisc-linux-cvs] linux-2.6 deller
Helge Deller
deller at gmx.de
Sun Jul 11 16:12:33 MDT 2004
Hi Kars,
I committed your patch (with small modifications) to the PARISC Linux CVS repository.
The new patch is attached, but since it was copy&pasted in here, it's easier if you just update from the PARISC CVS repository....
Helge
On Monday 12 July 2004 00:03, Helge Deller wrote:
> CVSROOT: /var/cvs
> Module name: linux-2.6
> Changes by: deller 04/07/11 16:03:48
>
> Modified files:
> include/linux : hp_sdc.h
> drivers/input/serio: hp_sdc.c
> drivers/input/keyboard: hil_kbd.c
>
> Log message:
> apply HIL patch (with small modifications) provided by Kars de Jong <jongk at linux-m68k.org> for his M68000 HP9000/425t machine
-------------- next part --------------
Index: include/linux/hp_sdc.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/linux/hp_sdc.h,v
retrieving revision 1.7
diff -u -p -r1.7 hp_sdc.h
--- include/linux/hp_sdc.h 8 Sep 2003 22:00:28 -0000 1.7
+++ include/linux/hp_sdc.h 11 Jul 2004 21:56:23 -0000
@@ -42,7 +42,9 @@
#include <linux/types.h>
#include <linux/time.h>
#include <linux/timer.h>
+#if defined(__hppa__)
#include <asm/hardware.h>
+#endif
/* No 4X status reads take longer than this (in usec).
@@ -281,9 +283,11 @@ typedef struct {
struct timeval rtv; /* Time when current read started */
int wcurr; /* Current write transact in process */
-#ifdef __hppa__
- struct parisc_device *dev;
int dev_err; /* carries status from registration */
+#if defined(__hppa__)
+ struct parisc_device *dev;
+#elif defined(__mc68000__)
+ void *dev;
#else
#error No support for device registration on this arch yet.
#endif
Index: drivers/input/serio/hp_sdc.c
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/input/serio/hp_sdc.c,v
retrieving revision 1.8
diff -u -p -r1.8 hp_sdc.c
--- drivers/input/serio/hp_sdc.c 6 Jan 2004 22:31:59 -0000 1.8
+++ drivers/input/serio/hp_sdc.c 11 Jul 2004 21:56:24 -0000
@@ -72,7 +72,20 @@
#include <linux/hil.h>
#include <asm/io.h>
#include <asm/system.h>
-#include <asm/parisc-device.h>
+
+/* Machine-specific abstraction */
+
+#if defined(__hppa__)
+# include <asm/parisc-device.h>
+# define sdc_readb(p) gsc_readb(p)
+# define sdc_writeb(v,p) gsc_writeb((v),(p))
+#elif defined(__mc68000__)
+# include <asm/uaccess.h>
+# define sdc_readb(p) in_8(p)
+# define sdc_writeb(v,p) out_8((p),(v))
+#else
+# error "HIL is not supported on this platform"
+#endif
#define PREFIX "HP SDC: "
@@ -99,7 +112,7 @@ static inline uint8_t hp_sdc_status_in8
unsigned long flags;
write_lock_irqsave(&hp_sdc.ibf_lock, flags);
- status = gsc_readb(hp_sdc.status_io);
+ status = sdc_readb(hp_sdc.status_io);
if (!(status & HP_SDC_STATUS_IBF)) hp_sdc.ibf = 0;
write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
@@ -107,7 +120,7 @@ static inline uint8_t hp_sdc_status_in8
}
static inline uint8_t hp_sdc_data_in8 (void) {
- return gsc_readb(hp_sdc.data_io);
+ return sdc_readb(hp_sdc.data_io);
}
static inline void hp_sdc_status_out8 (uint8_t val) {
@@ -116,7 +129,7 @@ static inline void hp_sdc_status_out8 (u
write_lock_irqsave(&hp_sdc.ibf_lock, flags);
hp_sdc.ibf = 1;
if ((val & 0xf0) == 0xe0) hp_sdc.wi = 0xff;
- gsc_writeb(val, hp_sdc.status_io);
+ sdc_writeb(val, hp_sdc.status_io);
write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
}
@@ -125,7 +138,7 @@ static inline void hp_sdc_data_out8 (uin
write_lock_irqsave(&hp_sdc.ibf_lock, flags);
hp_sdc.ibf = 1;
- gsc_writeb(val, hp_sdc.data_io);
+ sdc_writeb(val, hp_sdc.data_io);
write_unlock_irqrestore(&hp_sdc.ibf_lock, flags);
}
@@ -146,7 +159,7 @@ static inline void hp_sdc_spin_ibf(void)
}
read_unlock(lock);
write_lock(lock);
- while (gsc_readb(hp_sdc.status_io) & HP_SDC_STATUS_IBF) {};
+ while (sdc_readb(hp_sdc.status_io) & HP_SDC_STATUS_IBF) {};
hp_sdc.ibf = 0;
write_unlock_irqrestore(lock, flags);
}
@@ -635,7 +648,7 @@ int hp_sdc_request_hil_irq(hp_sdc_irqhoo
}
hp_sdc.hil = callback;
- hp_sdc.im &= ~HP_SDC_IM_HIL;
+ hp_sdc.im &= ~(HP_SDC_IM_HIL | HP_SDC_IM_RESET);
hp_sdc.set_im = 1;
write_unlock_irq(&hp_sdc.hook_lock);
@@ -660,7 +673,7 @@ int hp_sdc_request_cooked_irq(hp_sdc_irq
/* Enable interrupts from the HIL MLC */
hp_sdc.cooked = callback;
- hp_sdc.im &= ~HP_SDC_IM_HIL;
+ hp_sdc.im &= ~(HP_SDC_IM_HIL | HP_SDC_IM_RESET);
hp_sdc.set_im = 1;
write_unlock_irq(&hp_sdc.hook_lock);
@@ -704,7 +717,7 @@ int hp_sdc_release_hil_irq(hp_sdc_irqhoo
hp_sdc.hil = NULL;
/* Disable interrupts from HIL only if there is no cooked driver. */
if(hp_sdc.cooked == NULL) {
- hp_sdc.im |= HP_SDC_IM_HIL;
+ hp_sdc.im |= (HP_SDC_IM_HIL | HP_SDC_IM_RESET);
hp_sdc.set_im = 1;
}
write_unlock_irq(&hp_sdc.hook_lock);
@@ -726,7 +739,7 @@ int hp_sdc_release_cooked_irq(hp_sdc_irq
hp_sdc.cooked = NULL;
/* Disable interrupts from HIL only if there is no raw HIL driver. */
if(hp_sdc.hil == NULL) {
- hp_sdc.im |= HP_SDC_IM_HIL;
+ hp_sdc.im |= (HP_SDC_IM_HIL | HP_SDC_IM_RESET);
hp_sdc.set_im = 1;
}
write_unlock_irq(&hp_sdc.hook_lock);
@@ -746,6 +759,8 @@ void hp_sdc_kicker (unsigned long data)
/************************** Module Initialization ***************************/
+#if defined(__hppa__)
+
static struct parisc_device_id hp_sdc_tbl[] = {
{
.hw_type = HPHW_FIO,
@@ -758,36 +773,24 @@ static struct parisc_device_id hp_sdc_tb
MODULE_DEVICE_TABLE(parisc, hp_sdc_tbl);
-static int __init hp_sdc_init(struct parisc_device *d);
+static int __init hp_sdc_init_hppa(struct parisc_device *d);
static struct parisc_driver hp_sdc_driver = {
.name = "HP SDC",
.id_table = hp_sdc_tbl,
- .probe = hp_sdc_init,
+ .probe = hp_sdc_init_hppa,
};
-static int __init hp_sdc_init(struct parisc_device *d)
+#endif /* __hppa__ */
+
+static int __init hp_sdc_init(void)
{
int i;
- char *errstr = NULL;
+ char *errstr;
hp_sdc_transaction t_sync;
uint8_t ts_sync[6];
struct semaphore s_sync;
-
- errstr = "foo\n";
-
- if (!d) return 1;
- if (hp_sdc.dev != NULL) return 1; /* We only expect one SDC */
-
- hp_sdc.dev = d;
- hp_sdc.irq = d->irq;
- /* TODO: Is NMI == IRQ - 1 all cases, or is there a way to query? */
- hp_sdc.nmi = d->irq - 1;
- hp_sdc.base_io = (unsigned long) d->hpa;
- hp_sdc.data_io = (unsigned long) d->hpa + 0x800;
- hp_sdc.status_io = (unsigned long) d->hpa + 0x801;
-
hp_sdc.lock = RW_LOCK_UNLOCKED;
hp_sdc.ibf_lock = RW_LOCK_UNLOCKED;
hp_sdc.rtq_lock = RW_LOCK_UNLOCKED;
@@ -821,16 +824,18 @@ static int __init hp_sdc_init(struct par
hp_sdc.dev_err = -EBUSY;
+#if defined(__hppa__)
errstr = "IO not available for";
if (request_region(hp_sdc.data_io, 2, hp_sdc_driver.name)) goto err0;
+#endif
errstr = "IRQ not available for";
- if(request_irq(hp_sdc.irq, &hp_sdc_isr, 0, hp_sdc_driver.name,
+ if(request_irq(hp_sdc.irq, &hp_sdc_isr, 0, "HP SDC",
(void *) hp_sdc.base_io)) goto err1;
errstr = "NMI not available for";
- if (request_irq(hp_sdc.nmi, &hp_sdc_nmisr, 0, "HP SDC NMI",
- (void*)d->hpa)) goto err2;
+ if (request_irq(hp_sdc.nmi, &hp_sdc_nmisr, 0, "HP SDC NMI",
+ (void *) hp_sdc.base_io)) goto err2;
printk(KERN_INFO PREFIX "HP SDC at 0x%p, IRQ %d (NMI IRQ %d)\n",
(void *)hp_sdc.base_io, hp_sdc.irq, hp_sdc.nmi);
@@ -872,13 +877,37 @@ static int __init hp_sdc_init(struct par
return hp_sdc.dev_err;
}
+#if defined(__hppa__)
+
+static int __init hp_sdc_init_hppa(struct parisc_device *d)
+{
+ if (!d) return 1;
+ if (hp_sdc.dev != NULL) return 1; /* We only expect one SDC */
+
+ hp_sdc.dev = d;
+ hp_sdc.irq = d->irq;
+ /* TODO: Is NMI == IRQ - 1 all cases, or is there a way to query? */
+ hp_sdc.nmi = d->irq - 1;
+ hp_sdc.base_io = (unsigned long) d->hpa;
+ hp_sdc.data_io = (unsigned long) d->hpa + 0x800;
+ hp_sdc.status_io = (unsigned long) d->hpa + 0x801;
+
+ return hp_sdc_init();
+}
+
+#endif /* __hppa__ */
+
+#if !defined(__mc68000__) /* Link error on m68k! */
static void __exit hp_sdc_exit(void)
+#else
+static void hp_sdc_exit(void)
+#endif
{
write_lock_irq(&hp_sdc.lock);
/* Turn off all maskable "sub-function" irq's. */
hp_sdc_spin_ibf();
- gsc_writeb(HP_SDC_CMD_SET_IM | HP_SDC_IM_MASK, hp_sdc.status_io);
+ sdc_writeb(HP_SDC_CMD_SET_IM | HP_SDC_IM_MASK, hp_sdc.status_io);
/* Wait until we know this has been processed by the i8042 */
hp_sdc_spin_ibf();
@@ -893,22 +922,45 @@ static void __exit hp_sdc_exit(void)
/* release_region(hp_sdc.data_io, 2); */
+#if defined(__hppa__)
if (unregister_parisc_driver(&hp_sdc_driver))
printk(KERN_WARNING PREFIX "Error unregistering HP SDC");
+#endif
}
static int __init hp_sdc_register(void)
{
- hp_sdc.dev = NULL;
- hp_sdc.dev_err = 0;
hp_sdc_transaction tq_init;
uint8_t tq_init_seq[5];
struct semaphore tq_init_sem;
-
+#if defined(__mc68000__)
+ mm_segment_t fs;
+ unsigned char i;
+#endif
+
+ hp_sdc.dev = NULL;
+ hp_sdc.dev_err = 0;
+#if defined(__hppa__)
if (register_parisc_driver(&hp_sdc_driver)) {
printk(KERN_WARNING PREFIX "Error registering SDC with system bus tree.\n");
return -ENODEV;
}
+#elif defined(__mc68000__)
+ if (!MACH_IS_HP300)
+ return -ENODEV;
+
+ hp_sdc.irq = 1;
+ hp_sdc.nmi = 7;
+ hp_sdc.base_io = (unsigned long) 0xf0428000;
+ hp_sdc.data_io = (unsigned long) hp_sdc.base_io + 1;
+ hp_sdc.status_io = (unsigned long) hp_sdc.base_io + 3;
+ fs = get_fs();
+ set_fs(KERNEL_DS);
+ if (!get_user(i, (unsigned char *)hp_sdc.data_io))
+ hp_sdc.dev = (void *)1;
+ set_fs(fs);
+ hp_sdc.dev_err = hp_sdc_init();
+#endif
if (hp_sdc.dev == NULL) {
printk(KERN_WARNING PREFIX "No SDC found.\n");
return hp_sdc.dev_err;
Index: drivers/input/keyboard/hil_kbd.c
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/input/keyboard/hil_kbd.c,v
retrieving revision 1.8
diff -u -p -r1.8 hil_kbd.c
--- drivers/input/keyboard/hil_kbd.c 8 Sep 2003 22:00:23 -0000 1.8
+++ drivers/input/keyboard/hil_kbd.c 11 Jul 2004 21:56:24 -0000
@@ -156,9 +156,9 @@ static void hil_kbd_process_record(struc
key = kbd->data[cnt++];
up = key & HIL_KBD_SET1_UPBIT;
key &= (~HIL_KBD_SET1_UPBIT & 0xff);
- key = key >> HIL_KBD_SET1_SHIFT;
+ key = hil_kbd_set1[key >> HIL_KBD_SET1_SHIFT];
if (key != KEY_RESERVED)
- input_report_key(dev, hil_kbd_set1[key], !up);
+ input_report_key(dev, key, !up);
}
break;
case HIL_POL_CHARTYPE_SET2:
@@ -180,9 +180,9 @@ static void hil_kbd_process_record(struc
key = kbd->data[cnt++];
up = key & HIL_KBD_SET3_UPBIT;
key &= (~HIL_KBD_SET1_UPBIT & 0xff);
- key = key >> HIL_KBD_SET3_SHIFT;
+ key = hil_kbd_set3[key >> HIL_KBD_SET3_SHIFT];
if (key != KEY_RESERVED)
- input_report_key(dev, hil_kbd_set3[key], !up);
+ input_report_key(dev, key, !up);
}
break;
}
More information about the parisc-linux-cvs
mailing list