[PATCH 8/9] define global BIT macro

2007-08-18 Thread Jiri Slaby
define global BIT macro

move all local BIT defines to the new globally define macro.

Signed-off-by: Jiri Slaby [EMAIL PROTECTED]

---
commit 19b14b967521eda7011bd70891bbe5044882d739
tree cd49de4f9f8d991ee7af22037a86978ea227abb8
parent fef5bcc8e5a7bfd66920df6d02c3448314dfe4b2
author Jiri Slaby [EMAIL PROTECTED] Sat, 18 Aug 2007 11:16:36 +0200
committer Jiri Slaby [EMAIL PROTECTED] Sat, 18 Aug 2007 11:16:36 +0200

 arch/ppc/platforms/chestnut.c   |1 -
 drivers/edac/edac_core.h|2 --
 drivers/firmware/dcdbas.h   |2 --
 drivers/input/serio/maceps2.c   |2 --
 drivers/net/eth16i.c|1 -
 drivers/net/meth.h  |3 ---
 drivers/net/wireless/hostap/hostap_common.h |2 --
 drivers/scsi/FlashPoint.c   |1 -
 drivers/scsi/nsp32.h|5 -
 drivers/scsi/pcmcia/nsp_cs.h|1 -
 drivers/video/pnx4008/sdum.h|3 ---
 include/asm-arm/arch-ixp4xx/io.h|3 ---
 include/asm-mips/ip32/crime.h   |3 ---
 include/asm-mips/ip32/mace.h|3 ---
 include/linux/bitops.h  |1 +
 include/video/sstfb.h   |1 -
 include/video/tdfx.h|2 --
 net/mac80211/ieee80211_i.h  |2 --
 18 files changed, 1 insertions(+), 37 deletions(-)

diff --git a/arch/ppc/platforms/chestnut.c b/arch/ppc/platforms/chestnut.c
index 4696849..ccd2faa 100644
--- a/arch/ppc/platforms/chestnut.c
+++ b/arch/ppc/platforms/chestnut.c
@@ -49,7 +49,6 @@ extern void gen550_progress(char *, unsigned short);
 extern void gen550_init(int, struct uart_port *);
 extern void mv64360_pcibios_fixup(mv64x60_handle_t *bh);
 
-#define BIT(x) (1x)
 #define CHESTNUT_PRESERVE_MASK (BIT(MV64x60_CPU2DEV_0_WIN) | \
BIT(MV64x60_CPU2DEV_1_WIN) | \
BIT(MV64x60_CPU2DEV_2_WIN) | \
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 4e6bad1..309a1a5 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -94,8 +94,6 @@ extern int edac_debug_level;
 
 #endif /* !CONFIG_EDAC_DEBUG */
 
-#define BIT(x) (1  (x))
-
 #define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
PCI_DEVICE_ID_ ## vend ## _ ## dev
 
diff --git a/drivers/firmware/dcdbas.h b/drivers/firmware/dcdbas.h
index 8960cad..87bc341 100644
--- a/drivers/firmware/dcdbas.h
+++ b/drivers/firmware/dcdbas.h
@@ -20,8 +20,6 @@
 #include linux/sysfs.h
 #include linux/types.h
 
-#define BIT(x) (1UL  x)
-
 #define MAX_SMI_DATA_BUF_SIZE  (256 * 1024)
 
 #define HC_ACTION_NONE (0)
diff --git a/drivers/input/serio/maceps2.c b/drivers/input/serio/maceps2.c
index 5a41b8f..558200e 100644
--- a/drivers/input/serio/maceps2.c
+++ b/drivers/input/serio/maceps2.c
@@ -31,8 +31,6 @@ MODULE_LICENSE(GPL);
 
 #define MACE_PS2_TIMEOUT 1 /* in 50us unit */
 
-#define BIT(x) (1UL  (x))
-
 #define PS2_STATUS_CLOCK_SIGNAL  BIT(0) /* external clock signal */
 #define PS2_STATUS_CLOCK_INHIBIT BIT(1) /* clken output signal */
 #define PS2_STATUS_TX_INPROGRESS BIT(2) /* transmission in progress */
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index 04abf59..f613dae 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -170,7 +170,6 @@ static char *version =
 
 
 /* Few macros */
-#define BIT(a)( (1  (a)) )
 #define BITSET(ioaddr, bnum)   ((outb(((inb(ioaddr)) | (bnum)), ioaddr)))
 #define BITCLR(ioaddr, bnum)   ((outb(((inb(ioaddr))  (~(bnum))), ioaddr)))
 
diff --git a/drivers/net/meth.h b/drivers/net/meth.h
index ea3b8fc..a78dc1c 100644
--- a/drivers/net/meth.h
+++ b/drivers/net/meth.h
@@ -28,9 +28,6 @@
 #define RX_BUFFER_OFFSET (sizeof(rx_status_vector)+2) /* staus vector + 2 
bytes of padding */
 #define RX_BUCKET_SIZE 256
 
-#undef BIT
-#define BIT(x) (1UL  (x))
-
 /* For more detailed explanations of what each field menas,
see Nick's great comments to #defines below (or docs, if
you are lucky enough toget hold of them :)*/
diff --git a/drivers/net/wireless/hostap/hostap_common.h 
b/drivers/net/wireless/hostap/hostap_common.h
index b31e6a0..f3930f9 100644
--- a/drivers/net/wireless/hostap/hostap_common.h
+++ b/drivers/net/wireless/hostap/hostap_common.h
@@ -4,8 +4,6 @@
 #include linux/types.h
 #include linux/if_ether.h
 
-#define BIT(x) (1  (x))
-
 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
 #define MACSTR %02x:%02x:%02x:%02x:%02x:%02x
 
diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c
index a7f916c..cf549ff 100644
--- a/drivers/scsi/FlashPoint.c
+++ b/drivers/scsi/FlashPoint.c
@@ -25,7 +25,6 @@
 
 #define FAILURE 0xL
 
-#define BIT(x)  ((unsigned char)(1(x)))  /* single-bit mask in 
bit position x

Re: [PATCH 8/9] define global BIT macro

2007-08-18 Thread Jiri Slaby
Randy Dunlap napsal(a):
 On Sat, 18 Aug 2007 11:44:12 +0200 (CEST) Jiri Slaby wrote:
 
 define global BIT macro

 move all local BIT defines to the new globally define macro.

 Signed-off-by: Jiri Slaby [EMAIL PROTECTED]

 ---

  include/linux/bitops.h  |1 +
  include/video/sstfb.h   |1 -
  include/video/tdfx.h|2 --
  net/mac80211/ieee80211_i.h  |2 --
  18 files changed, 1 insertions(+), 37 deletions(-)

 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
 index 3255b06..a57b81f 100644
 --- a/include/linux/bitops.h
 +++ b/include/linux/bitops.h
 @@ -3,6 +3,7 @@
  #include asm/types.h
  
  #ifdef  __KERNEL__
 +#define BIT(nr) (1UL  (nr))
  #define BIT_MASK(nr)(1UL  ((nr) % BITS_PER_LONG))
  #define BIT_WORD(nr)((nr) / BITS_PER_LONG)
  #define BITS_TO_TYPE(nr, t) (((nr)+(t)-1)/(t))
 
 
 So users of the BIT() macro in include/linux/input.h can be
 changed to use the global BIT_MASK() macro...
 and the former can be removed.

I'm afraid I don't understand you. Maybe, you are writing about changes done in
patch no. 7 [1], which didn't go through to the lkml?

[1]
http://www.fi.muni.cz/~xslaby/sklad/07-get-rid-of-input-bit-duplicate-defines.patch

thanks,
-- 
Jiri Slaby ([EMAIL PROTECTED])
Faculty of Informatics, Masaryk University


Re: [RFC 1/2] Input: ff, add FF_RAW effect

2007-04-26 Thread Jiri Slaby
Dmitry Torokhov napsal(a):
 On 4/22/07, Jiri Slaby [EMAIL PROTECTED] wrote:
 I think we won't be able to make the transition in independent way
 due to unspecified meaning of the torques.

 
 With phantom it still seems doable - if I understand correctly ther is
 one point of containct and one resulting vector of forces applied to
 user's hand. With the glove there are multiple points of contact and
 multiple feedback effects applied to different part of hand
 simultaneously and that is for sure requires special application.

Hi.

Good news are, that I've got openhaptics (OS independent layer for sensable
devices) under academic license (I don't know, what the open word in that name
means -- no sourcecodes; licensed), the bad ones are, that they use ioctl
approach for both reporting and FF.

Furthermore I tried phantom with input layer in X and realized, that it's needed
to compute real axies from that numbers and that's what I'm doing in userspace
with doubke precision.

Ok, so the question is if the old ioctl approach (something which I posted as a
first patch before we ever starrted to talk about FF and input layer without
mmaping anything to US) is acceptable alone (this is what is needed for
OHaptics) or at least some particular computing to convert the numbers and
reporting to input layer should be implemented (which will have no users anyway,
who will ever want to have 6$ pointer ;))?

thanks a lot,
-- 
http://www.fi.muni.cz/~xslaby/Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E


Re: [RFC 1/2] Input: ff, add FF_RAW effect

2007-04-23 Thread Jiri Slaby
Dmitry Torokhov napsal(a):
 For devices that require tailored application (for example that glove
 - I am not sure how a generic application could control it) old
 phantom way of controlling via ioctl will suffice. The device may
 still use input layer to report back coordinates.

And how about the individual FF ioctl? Did you mean registering another
chardev, which is totally ugly in my eyes or augment evdev.c to support
driver specific ioctl? i.e. either add another 'E' ioctl with pointer to
struct { code, value } as arg param or changing
if (_IOC_TYPE(cmd) != 'E'))
return -EINVAL;
to sth. like
if (_IOC_TYPE(cmd) != 'E'))
return dev-ioctl ? dev-ioctl(file, cmd, p) : -EINVAL;
in evdev_ioctl_handler, which is acceptable?

thanks,
-- 
http://www.fi.muni.cz/~xslaby/Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
 B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E


Re: [RFC 1/2] Input: ff, add FF_RAW effect

2007-04-22 Thread Jiri Slaby

On 4/19/07, Dmitry Torokhov [EMAIL PROTECTED] wrote:

On 4/19/07, Jiri Slaby [EMAIL PROTECTED] wrote:
 Dmitry Torokhov napsal(a):
  If we are interested in using FF API we need to come up with a way
  to express this effect without exposing implementation details of
  one particular device.

 Still, torques are better named raw/motor values, which goes to the device
 and I'm sceptic about inventing something class-better than this.


Well, I guess we need to make a decision whether moving this kind of
devices into a force feedback layer is possible or whether every
device needs to have an application specifically tailored to that
particular device.

If we say that it is feasible to plug a device into FF layer then we
must not expose hardware implementation details. That means that
device-sepcific translation between 3d vector of forces into motor
torques must be done by the driver itself.


Hmm, it's 3d at minimum (the glove has 14 torque points, phantom up to
6), I think we won't be able to make the transition in independent way
due to unspecified meaning of the torques.


For devices that require tailored application (for example that glove
- I am not sure how a generic application could control it) old
phantom way of controlling via ioctl will suffice. The device may
still use input layer to report back coordinates.


Ok, nobody seems to have an idea, I'm going to avoid FF layer in the
code and hope this is the final change ;).

thanks,
--
http://www.fi.muni.cz/~xslaby/Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E


Re: [RFC 2/2] Input: phantom, add a new driver

2007-04-20 Thread Jiri Slaby
Andrew Morton napsal(a):
 On Tue, 17 Apr 2007 22:02:10 +0200 (CEST) Jiri Slaby [EMAIL PROTECTED] 
 wrote:
 
 phantom, add a new driver
[...]
 +#define PHANTOM_VERSION n0.9.4
 
 That's an impressive version number ;)

fork of 0.8 or so 2.4 linux driver - the n in the meaning of new :)

 +#define PHM_MAX_TORQUES 3
 +
 +#define PHN_CONTROL 0x6
 +#define PHN_CTL_AMP 0x1
 +#define PHN_CTL_BUT 0x2
 +#define PHN_CTL_IRQ 0x10
 +
 +#define PHN_IRQCTL  0x4c
 +
 +#define PHN_ZERO_FORCE  2048
 
 wonders what all those do

I have no clue too, cutpaste from sensable 2.4 driver. But I'll document as
much as possible.

 +#define PCI_ENCODER(dev, axis) ((0 - (int)ioread32((dev)-iaddr + (axis))) 
  \
 +0x)
 
 Is there any reason why this cannot be a lower-cased inline C function? 
 Nicer to read, typesafe, etc.

yes, I'll switch it.

 +#define PHB_RUNNING 1
 +#define PHB_RESET   2
 +
 +static struct PH_CLASSTYPE *phantom_class;
 
 I guess that PH_CLASSTYPE is some protect-me-from-gregkh compatibility
 thing.  But there isn't such a macro in the tree.  I switched this to plain
 old `class'.

Yes, my bad.

 +
 +static irqreturn_t phantom_isr(int irq, void *data)
 +{
 +struct phantom_device *dev = data;
 +struct input_dev *idev = dev-idev;
 +unsigned int a, hw_status;
 +
 +hw_status = ioread32(dev-iaddr + PHN_CONTROL);
 +if (!(hw_status  PHN_CTL_IRQ))
 +return IRQ_NONE;
 +
 +iowrite32(0, dev-iaddr);
 +wmb();
 +iowrite32(0xc0, dev-iaddr);
 
 there too.

Seems reasonable, it can't be reordered. (I hope this holds on all archs.)

 +if (unlikely(idev == NULL))
 +return IRQ_HANDLED;
 
 Can this happen?  If so, a comment explaining why would be nice.

In the case of DEBUG_SHIRQ=y. Comment will be added or better -- devinit code
reordered.

thanks for notes,
-- 
http://www.fi.muni.cz/~xslaby/Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E


[RFC 1/2] Input: ff, add FF_RAW effect

2007-04-17 Thread Jiri Slaby
So fellows, what about these ones?

--

ff, add FF_RAW effect

Add new FF_RAW effect for devices such Phantom. The new model has up to 6DOF
torque force feedback independent on any 3d-or-so value.

Signed-off-by: Jiri Slaby [EMAIL PROTECTED]

---
commit 759e7f172031959f49e5d3a7282379e7d73621b3
tree 906d51925ff7f95ebae8148ef2f1b2f252ef3f4e
parent bd99756ce7fb8f3e9105b076a71046b0d8ad1f8f
author Jiri Slaby [EMAIL PROTECTED] Tue, 17 Apr 2007 21:50:21 +0200
committer Jiri Slaby [EMAIL PROTECTED] Tue, 17 Apr 2007 21:50:21 +0200

 drivers/input/ff-memless.c |4 
 include/linux/input.h  |4 +++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
index d226d93..3bbace9 100644
--- a/drivers/input/ff-memless.c
+++ b/drivers/input/ff-memless.c
@@ -275,6 +275,10 @@ static void ml_combine_effects(struct ff_effect *effect,
min(i + effect-u.rumble.weak_magnitude, 0xU);
break;
 
+   case FF_RAW:
+   memcpy(effect-u.ff_raw, new-u.ff_raw, sizeof(new-u.ff_raw));
+   break;
+
default:
printk(KERN_ERR ff-memless: invalid type in 
ml_combine_effects()\n);
break;
diff --git a/include/linux/input.h b/include/linux/input.h
index 2a23768..cc4ae1f 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -859,6 +859,7 @@ struct ff_effect {
struct ff_periodic_effect periodic;
struct ff_condition_effect condition[2]; /* One for each axis */
struct ff_rumble_effect rumble;
+   __u32 ff_raw[6];
} u;
 };
 
@@ -874,9 +875,10 @@ struct ff_effect {
 #define FF_DAMPER  0x55
 #define FF_INERTIA 0x56
 #define FF_RAMP0x57
+#define FF_RAW 0x58
 
 #define FF_EFFECT_MIN  FF_RUMBLE
-#define FF_EFFECT_MAX  FF_RAMP
+#define FF_EFFECT_MAX  FF_RAW
 
 /*
  * Force feedback periodic effect types


[RFC 2/2] Input: phantom, add a new driver

2007-04-17 Thread Jiri Slaby
phantom, add a new driver

Sensable Phantom is a up to 7DOF force feedback (up to 6DOF FF) device. It's
atypical, so it's based on the new added FF_RAW effect.

Signed-off-by: Jiri Slaby [EMAIL PROTECTED]

---
commit 73621a789a0482299242ea61c971af6b5f8b828a
tree 365ba8113af9aaf468415d67238378767efad092
parent 759e7f172031959f49e5d3a7282379e7d73621b3
author Jiri Slaby [EMAIL PROTECTED] Tue, 17 Apr 2007 21:58:27 +0200
committer Jiri Slaby [EMAIL PROTECTED] Tue, 17 Apr 2007 21:58:27 +0200

 MAINTAINERS  |5 +
 drivers/input/misc/Kconfig   |9 +
 drivers/input/misc/Makefile  |1 
 drivers/input/misc/phantom.c |  387 ++
 4 files changed, 402 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8a68712..86a8417 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3112,6 +3112,11 @@ L:   [EMAIL PROTECTED] (subscribers-only, general 
discussion)
 W: http://www.nsa.gov/selinux
 S: Supported
 
+SENSABLE PHANTOM
+P: Jiri Slaby
+M: [EMAIL PROTECTED]
+S: Maintained
+
 SERIAL ATA (SATA) SUBSYSTEM:
 P: Jeff Garzik
 M: [EMAIL PROTECTED]
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5694115..6e432b0 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -98,4 +98,13 @@ config HP_SDC_RTC
  Say Y here if you want to support the built-in real time clock
  of the HP SDC controller.
 
+config PHANTOM
+   tristate Sensable PHANToM
+   depends on PCI  INPUT_FF_MEMLESS
+   help
+ Say Y here if you want to build a driver for Sensable PHANToM device.
+
+ If you choose to build module, its name will be phantom. If unsure,
+ say N here.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9f08f27..3ab3cc2 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS)  += wistron_btns.o
 obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
 obj-$(CONFIG_HP_SDC_RTC)   += hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)  += ixp4xx-beeper.o
+obj-$(CONFIG_PHANTOM)  += phantom.o
diff --git a/drivers/input/misc/phantom.c b/drivers/input/misc/phantom.c
new file mode 100644
index 000..58f55cd
--- /dev/null
+++ b/drivers/input/misc/phantom.c
@@ -0,0 +1,387 @@
+/*
+ *  Copyright (C) 2005-2007 Jiri Slaby [EMAIL PROTECTED]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  You need an userspace library to cooperate with this driver. It (and other
+ *  info) may be obtained here:
+ *  http://www.fi.muni.cz/~xslaby/phantom.html
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/device.h
+#include linux/pci.h
+#include linux/fs.h
+#include linux/poll.h
+#include linux/interrupt.h
+#include linux/input.h
+
+#include asm/io.h
+
+#define PHANTOM_VERSIONn0.9.4
+
+#define PHM_MAX_TORQUES3
+
+#define PHN_CONTROL0x6
+#define PHN_CTL_AMP0x1
+#define PHN_CTL_BUT0x2
+#define PHN_CTL_IRQ0x10
+
+#define PHN_IRQCTL 0x4c
+
+#define PHN_ZERO_FORCE 2048
+
+#define PCI_ENCODER(dev, axis) ((0 - (int)ioread32((dev)-iaddr + (axis)))  \
+   0x)
+
+#define PHB_RUNNING1
+#define PHB_RESET  2
+
+static struct PH_CLASSTYPE *phantom_class;
+
+struct phantom_device {
+   void __iomem *caddr;
+   u32 __iomem *iaddr;
+   u32 __iomem *oaddr;
+   u32 amp_bit;
+   s16 torques[PHM_MAX_TORQUES];
+   unsigned long status;
+
+   struct input_dev *idev;
+};
+
+static int phantom_status(struct phantom_device *dev, unsigned long newstat)
+{
+   pr_debug(phantom_status %lx %lx\n, dev-status, newstat);
+
+   if (!(dev-status  PHB_RUNNING)  (newstat  PHB_RUNNING)) {
+   iowrite32(PHN_CTL_IRQ | PHN_CTL_AMP, dev-iaddr + PHN_CONTROL);
+   dev-amp_bit = PHN_CTL_IRQ;
+   iowrite32(0x43, dev-caddr + PHN_IRQCTL);
+   } else if ((dev-status  PHB_RUNNING)  !(newstat  PHB_RUNNING))
+   iowrite32(0, dev-caddr + PHN_IRQCTL);
+
+   dev-status = newstat;
+
+   return 0;
+}
+
+static void phantom_close(struct input_dev *idev)
+{
+   struct phantom_device *dev = idev-private;
+
+   phantom_status(dev, dev-status  ~PHB_RUNNING);
+}
+
+static void phantom_reset(struct phantom_device *dev)
+{
+   pr_debug(resetting\n);
+
+   iowrite32(~0x1f, dev-iaddr);
+   wmb();
+   iowrite32(0x1f, dev-iaddr);
+   dev-status |= PHB_RESET;
+}
+
+static void phantom_autocenter(struct input_dev *idev, u16 magnitude

[PATCH 1/1] Input: add sensable phantom driver

2007-03-07 Thread Jiri Slaby
add sensable phantom driver

Signed-off-by: Jiri Slaby [EMAIL PROTECTED]

---
commit bb9798e15d86ada19f4d15e31124dc240df78899
tree 06d0ac31976d92128b4e43b4d009810292bdf7a0
parent 551535195b52a4d02b476bbbdf5ca613b8e1afa2
author Jiri Slaby [EMAIL PROTECTED] Wed, 07 Mar 2007 12:29:27 +0100
committer Jiri Slaby [EMAIL PROTECTED] Wed, 07 Mar 2007 12:29:27 +0100

 Documentation/ioctl-number.txt |1 
 MAINTAINERS|5 
 drivers/input/misc/Kconfig |9 +
 drivers/input/misc/Makefile|1 
 drivers/input/misc/phantom.c   |  447 
 include/linux/phantom.h|   48 
 6 files changed, 511 insertions(+), 0 deletions(-)

diff --git a/Documentation/ioctl-number.txt b/Documentation/ioctl-number.txt
index 8f750c0..38da829 100644
--- a/Documentation/ioctl-number.txt
+++ b/Documentation/ioctl-number.txt
@@ -128,6 +128,7 @@ CodeSeq#Include FileComments
mailto:[EMAIL PROTECTED]
 'i'00-3F   linux/i2o.h
 'j'00-3F   linux/joystick.h
+'k'00-0F   linux/phantom.h Sensable PHANToM
 'l'00-3F   linux/tcfs_fs.h transparent cryptographic file system
http://mikonos.dia.unisa.it/tcfs
 'l'40-7F   linux/udf_fs_i.hin development:
diff --git a/MAINTAINERS b/MAINTAINERS
index 00fa7f1..d4ee114 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3076,6 +3076,11 @@ L:   [EMAIL PROTECTED] (subscribers-only, general 
discussion)
 W: http://www.nsa.gov/selinux
 S: Supported
 
+SENSABLE PHANTOM
+P: Jiri Slaby
+M: [EMAIL PROTECTED]
+S: Maintained
+
 SERIAL ATA (SATA) SUBSYSTEM:
 P: Jeff Garzik
 M: [EMAIL PROTECTED]
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5694115..68fed97 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -98,4 +98,13 @@ config HP_SDC_RTC
  Say Y here if you want to support the built-in real time clock
  of the HP SDC controller.
 
+config PHANTOM
+   tristate Sensable PHANToM
+   depends on PCI
+   help
+ Say Y here if you want to build a driver for Sensable PHANToM device.
+
+ If you choose to build module, its name will be phantom. If unsure,
+ say N here.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9f08f27..3ab3cc2 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS)  += wistron_btns.o
 obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
 obj-$(CONFIG_HP_SDC_RTC)   += hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)  += ixp4xx-beeper.o
+obj-$(CONFIG_PHANTOM)  += phantom.o
diff --git a/drivers/input/misc/phantom.c b/drivers/input/misc/phantom.c
new file mode 100644
index 000..1dcf775
--- /dev/null
+++ b/drivers/input/misc/phantom.c
@@ -0,0 +1,447 @@
+/*
+ *  Copyright (C) 2005-2007 Jiri Slaby [EMAIL PROTECTED]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  You need an userspace library to cooperate with this library. It may be
+ *  obtained here:
+ *  http://www.fi.muni.cz/~xslaby/phantom.html
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/device.h
+#include linux/pci.h
+#include linux/fs.h
+#include linux/poll.h
+#include linux/interrupt.h
+#include linux/cdev.h
+#include linux/rtc.h
+
+#include asm/io.h
+
+#include linux/phantom.h
+
+#define PHANTOM_VERSIONn0.9.1
+
+#define PHANTOM_MAX_MINORS 8
+
+#define phantom_write_cfgl(p, val, off) do {   \
+   writel(val, (p)-caddr + (off));\
+   readl((p)-caddr + PHN_IRQCTL); \
+} while (0)
+
+#define phantom_write_inl(p, val, off) do {\
+   outl(val, (p)-ibase + (off));  \
+   inl((p)-ibase);\
+} while (0)
+
+static struct class *phantom_class;
+static int phantom_major;
+
+struct phantom_device {
+   unsigned int opened;
+   void __iomem *caddr;
+   unsigned long ibase;
+   unsigned long obase;
+   struct phantom_status *stat;
+   unsigned long status;
+   unsigned int tCu[3];
+   unsigned int tFe[3];
+
+   wait_queue_head_t wait;
+   struct cdev cdev;
+
+   struct mutex open_lock;
+};
+
+static unsigned char phantom_devices[PHANTOM_MAX_MINORS];
+
+/*
+ * Update status of phantom; turn off and/or start task if necessary
+ *
+ * spinlock should be here for safety
+ */
+static int phantom_status(struct phantom_device *dev, unsigned long newstat)
+{
+   pr_debug(phantom_status %lx %lx\n, dev-status, newstat);
+
+   if (!(dev-status  PHB_RUNNING)  (newstat  PHB_RUNNING