arch/microblaze/kernel/head.S: redundant code?

2014-10-31 Thread Adrian McMenamin
Looking at this code at line 78 (in 3.17 kernel) it has:

mfs r1, rmsr
msrclr r8, 0
cmpu r8, r8, r1

But as far as I can see the result of that comparison is never used -
the comments state it is to test if the msrclr  instruction is
enabled.

Haven't posted a patch because I am using the code to understand how
to write my own boot code for a very specific Microblaze application -
but perhaps someone with real expertise could look and/or tell me I'm
wrong?

Cheers

Adrian

(apologies to Michal Simek for getting this twice)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


arch/microblaze/kernel/head.S: redundant code?

2014-10-31 Thread Adrian McMenamin
Looking at this code at line 78 (in 3.17 kernel) it has:

mfs r1, rmsr
msrclr r8, 0
cmpu r8, r8, r1

But as far as I can see the result of that comparison is never used -
the comments state it is to test if the msrclr  instruction is
enabled.

Haven't posted a patch because I am using the code to understand how
to write my own boot code for a very specific Microblaze application -
but perhaps someone with real expertise could look and/or tell me I'm
wrong?

Cheers

Adrian

(apologies to Michal Simek for getting this twice)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin

On Mon, 2008-02-25 at 14:33 +0900, Paul Mundt wrote:
> On Sun, Feb 24, 2008 at 10:32:53PM +0000, Adrian McMenamin wrote:
> > On Sun, 2008-02-24 at 21:50 +0000, Adrian McMenamin wrote:
> > > On Sun, 2008-02-24 at 14:30 +, Adrian McMenamin wrote:
> > > > The maple bus driver that went into the kernel mainline in
> > > > September 2007 contained some bugs which were revealed by the
> > > > update of the kobj code for the current release series.
> > > > Unfortunately those bugs also helped ensure maple devices were
> > > > properly detected. This patch (against the current git) now ensures
> > > > that devices are properly detected again.
> > > > 
> > > 
> > > Further testing has shown this has introduced another bug, this time
> > > limiting the effectiveness of subdevice detection. Please ignore this
> > > while I work on a fix.
> > > 
> > Sorry for the confusion, in fact there is nothing wrong with this code
> > (ie it should be applied), the error was in the driver for the Dreamcast
> > controller (the device, in general, into which the subdevices are
> > plugged in and out).
> > 
> > I will post a fix for that.
> > 
> > Sorry again.
> > 
> So what exactly is supposed to be applied here?

The patch at the start of this thread - ie
http://lkml.org/lkml/2008/2/24/125  - this should really go in now as it
fixes a problem with current code.

In addition there are two patch sets to add new device support:

http://lkml.org/lkml/2008/2/24/211- maple controller

http://lkml.org/lkml/2008/2/24/121  (thread) - maple mouse

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] input: support maple controller on SEGA Dreamcast

2008-02-24 Thread Adrian McMenamin
Add support for the Dreamcast maple controller (as a joystick).

Earlier patches caused subdevice detection headaches. Please use this one.

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
---

diff -ruN ./a/drivers/input/joystick/Kconfig ./b/drivers/input/joystick/Kconfig
--- ./a/drivers/input/joystick/Kconfig  2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Kconfig  2008-02-24 13:59:04.0 +
@@ -282,4 +282,17 @@
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
 
+config JOYSTICK_MAPLE
+   tristate "Dreamcast control pad"
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ Say Y here if you have a SEGA Dreamcast and want to use your
+ controller.
+
+ Most Dreamcast users will say Y.
+
+ To compile this as a module choose M here: the
+ module will be called maplecontrol.
+
 endif
diff -ruN ./a/drivers/input/joystick/Makefile 
./b/drivers/input/joystick/Makefile
--- ./a/drivers/input/joystick/Makefile 2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Makefile 2008-02-24 13:59:04.0 +
@@ -27,5 +27,6 @@
 obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
 obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
 obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o
+obj-$(CONFIG_JOYSTICK_MAPLE)   += maplecontrol.o
 
 obj-$(CONFIG_JOYSTICK_IFORCE)  += iforce/
diff -ruN ./a/drivers/input/joystick/maplecontrol.c 
./b/drivers/input/joystick/maplecontrol.c
--- ./a/drivers/input/joystick/maplecontrol.c   1970-01-01 01:00:00.0 
+0100
+++ ./b/drivers/input/joystick/maplecontrol.c   2008-02-24 22:56:31.0 
+
@@ -0,0 +1,222 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 by Adrian McMenamin, copyright 2008
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("YAEGASHI Takeshi <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("SEGA Dreamcast controller driver");
+MODULE_LICENSE("GPL");
+
+struct dc_pad {
+   struct input_dev *dev;
+   struct maple_device *mdev;
+   int open;
+};
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq->dev;
+   struct dc_pad *pad = mapledev->private_data;
+   struct input_dev *dev = pad->dev;
+   unsigned char *res = mq->recvbuf;
+
+   buttons = ~cpu_to_le16(*(unsigned short *)(res + 8));
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons & 0x0010 ? -1:0) + (buttons & 0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons & 0x0040 ? -1:0) + (buttons & 0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons & 0x1000 ? -1:0) + (buttons & 0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons & 0x4000 ? -1:0) + (buttons & 0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons & 0x0001);
+   input_report_key(dev, BTN_B,  buttons & 0x0002);
+   input_report_key(dev, BTN_A,  buttons & 0x0004);
+   input_report_key(dev, BTN_START,  buttons & 0x0008);
+   input_report_key(dev, BTN_Z,  buttons & 0x0100);
+   input_report_key(dev, BTN_Y,  buttons & 0x0200);
+   input_report_key(dev, BTN_X,  buttons & 0x0400);
+   input_report_key(dev, BTN_SELECT, buttons & 0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+
+   const short btn_bit[32] = {
+   BTN_C, BTN_B, BTN_A, BTN_START, -1, -1, -1, -1,
+   BTN_Z, BTN_Y, BTN_X, BTN_SELECT, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   const short abs_bit[32] = {
+   -1, -1, -1, -1, ABS_HAT0Y, ABS_HAT0Y, ABS_HAT0X, ABS_HAT0X,
+   -1, -1, -1, -1, ABS_HAT1Y, ABS_HAT1Y, ABS_HAT1X, ABS_HAT1X,
+   ABS_GAS, ABS_BRAKE, ABS_X, ABS_Y, ABS_RX, ABS_RY, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL);
+   if (!pad){
+   error = ENOMEM;
+   goto fail_nomem_1;
+

Re: [PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin

On Sun, 2008-02-24 at 21:50 +, Adrian McMenamin wrote:
> On Sun, 2008-02-24 at 14:30 +0000, Adrian McMenamin wrote:
> > The maple bus driver that went into the kernel mainline in September 2007 
> > contained some bugs which were revealed by the update of the kobj code for 
> > the current release series. Unfortunately those bugs also helped ensure 
> > maple devices were properly detected. This patch (against the current git) 
> > now ensures that devices are properly detected again.
> > 
> 
> Further testing has shown this has introduced another bug, this time
> limiting the effectiveness of subdevice detection. Please ignore this
> while I work on a fix.
> 
Sorry for the confusion, in fact there is nothing wrong with this code
(ie it should be applied), the error was in the driver for the Dreamcast
controller (the device, in general, into which the subdevices are
plugged in and out).

I will post a fix for that.

Sorry again.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin

On Sun, 2008-02-24 at 14:30 +, Adrian McMenamin wrote:
> The maple bus driver that went into the kernel mainline in September 2007 
> contained some bugs which were revealed by the update of the kobj code for 
> the current release series. Unfortunately those bugs also helped ensure maple 
> devices were properly detected. This patch (against the current git) now 
> ensures that devices are properly detected again.
> 

Further testing has shown this has introduced another bug, this time
limiting the effectiveness of subdevice detection. Please ignore this
while I work on a fix.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


lkml.org

2008-02-24 Thread Adrian McMenamin
At the risk of pointing out the obvious (though I cannot find anyone
else who has commented), this appears to be broken at the moment...(ie
not picking up new messages)

...which is a pity as it is a great site

Adrian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin
The maple bus driver that went into the kernel mainline in September 2007 
contained some bugs which were revealed by the update of the kobj code for the 
current release series. Unfortunately those bugs also helped ensure maple 
devices were properly detected. This patch (against the current git) now 
ensures that devices are properly detected again.

(A previous attempt to fix this by delaying initialisation only partially fixed 
this - as became apparent when the bus was fully loaded)

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
---



diff -ruN ./a/drivers/sh/maple/maple.c ./b/drivers/sh/maple/maple.c
--- ./a/drivers/sh/maple/maple.c2008-02-21 20:42:17.0 +
+++ ./b/drivers/sh/maple/maple.c2008-02-24 13:59:09.0 +
@@ -1,7 +1,7 @@
 /*
  * Core maple bus functionality
  *
- *  Copyright (C) 2007 Adrian McMenamin
+ *  Copyright (C) 2007, 2008 Adrian McMenamin
  *
  * Based on 2.4 code by:
  *
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -54,7 +53,7 @@
 static int subdevice_map[MAPLE_PORTS];
 static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
 static unsigned long maple_pnp_time;
-static int started, scanning, liststatus, realscan;
+static int started, scanning, liststatus, fullscan;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
@@ -62,6 +61,9 @@
int unit;
 };
 
+static bool checked[4];
+static struct maple_device *baseunits[4];
+
 /**
  *  maple_driver_register - register a device driver
  *  automatically makes the driver bus a maple bus
@@ -309,11 +311,9 @@
else
break;
 
-   if (realscan) {
-   printk(KERN_INFO "Maple device detected: %s\n",
-   mdev->product_name);
-   printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
-   }
+   printk(KERN_INFO "Maple device detected: %s\n",
+   mdev->product_name);
+   printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
 
function = be32_to_cpu(mdev->devinfo.function);
 
@@ -323,10 +323,9 @@
mdev->driver = _dummy_driver;
sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port);
} else {
-   if (realscan)
-   printk(KERN_INFO
-   "Maple bus at (%d, %d): Function 0x%lX\n",
-   mdev->port, mdev->unit, function);
+   printk(KERN_INFO
+   "Maple bus at (%d, %d): Function 0x%lX\n",
+   mdev->port, mdev->unit, function);
 
matched =
bus_for_each_drv(_bus_type, NULL, mdev,
@@ -334,9 +333,8 @@
 
if (matched == 0) {
/* Driver does not exist yet */
-   if (realscan)
-   printk(KERN_INFO
-   "No maple driver found.\n");
+   printk(KERN_INFO
+   "No maple driver found.\n");
mdev->driver = _dummy_driver;
}
sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port,
@@ -472,9 +470,12 @@
maple_detach_driver(mdev);
return;
}
-   if (!started) {
-   printk(KERN_INFO "No maple devices attached to port %d\n",
-  mdev->port);
+   if (!started || !fullscan) {
+   if (checked[mdev->port] == false) {
+   checked[mdev->port] = true;
+   printk(KERN_INFO "No maple devices attached"
+   " to port %d\n", mdev->port);
+   }
return;
}
maple_clean_submap(mdev);
@@ -485,8 +486,14 @@
   char *recvbuf)
 {
char submask;
-   if ((!started) || (scanning == 2)) {
-   maple_attach_driver(mdev);
+   if (!started || (scanning == 2) || !fullscan) {
+   if ((mdev->unit == 0) && (checked[mdev->port] == false)) {
+   checked[mdev->port] = true;
+   maple_attach_driver(mdev);
+   } else {
+   if (mdev->unit != 0)
+   maple_attach_driver(mdev);
+   }
return;
}
if (mdev->unit == 0) {
@@ -505,6 +512,7 @@
struct maple_device *dev;
char *recvbuf;
enum maple_code code;
+   int i;
 
if (!maple_dma_done())
return;
@@ -557,6 +565,19 @@
} else
scanning = 0;
 
+   if (!fulls

[PATCH] input: support maple controller on SEGA Dreamcast

2008-02-24 Thread Adrian McMenamin
This is a port of the old (never in mainline) 2.4 driver.

(It also fixes some issues with earlier patches which should be
discarded for this)


Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
---

diff -ruN ./a/drivers/input/joystick/Kconfig ./b/drivers/input/joystick/Kconfig
--- ./a/drivers/input/joystick/Kconfig  2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Kconfig  2008-02-24 13:59:04.0 +
@@ -282,4 +282,17 @@
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
 
+config JOYSTICK_MAPLE
+   tristate "Dreamcast control pad"
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ Say Y here if you have a SEGA Dreamcast and want to use your
+ controller.
+
+ Most Dreamcast users will say Y.
+
+ To compile this as a module choose M here: the
+ module will be called maplecontrol.
+
 endif
diff -ruN ./a/drivers/input/joystick/Makefile 
./b/drivers/input/joystick/Makefile
--- ./a/drivers/input/joystick/Makefile 2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Makefile 2008-02-24 13:59:04.0 +
@@ -27,5 +27,6 @@
 obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
 obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
 obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o
+obj-$(CONFIG_JOYSTICK_MAPLE)   += maplecontrol.o
 
 obj-$(CONFIG_JOYSTICK_IFORCE)  += iforce/
diff -ruN ./a/drivers/input/joystick/maplecontrol.c 
./b/drivers/input/joystick/maplecontrol.c
--- ./a/drivers/input/joystick/maplecontrol.c   1970-01-01 01:00:00.0 
+0100
+++ ./b/drivers/input/joystick/maplecontrol.c   2008-02-24 13:59:04.0 
+
@@ -0,0 +1,252 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 by Adrian McMenamin, copyright 2008
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("YAEGASHI Takeshi <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("SEGA Dreamcast controller driver");
+MODULE_LICENSE("GPL");
+
+struct dc_pad {
+   struct input_dev *dev;
+   struct maple_device *mdev;
+   int open;
+};
+
+static void dc_pad_callback_idle(struct mapleq *mq)
+{
+}
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq->dev;
+   struct dc_pad *pad = mapledev->private_data;
+   struct input_dev *dev = pad->dev;
+   unsigned char *res = mq->recvbuf;
+
+   buttons = ~cpu_to_le16(*(unsigned short *)(res + 8));
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons & 0x0010 ? -1:0) + (buttons & 0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons & 0x0040 ? -1:0) + (buttons & 0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons & 0x1000 ? -1:0) + (buttons & 0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons & 0x4000 ? -1:0) + (buttons & 0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons & 0x0001);
+   input_report_key(dev, BTN_B,  buttons & 0x0002);
+   input_report_key(dev, BTN_A,  buttons & 0x0004);
+   input_report_key(dev, BTN_START,  buttons & 0x0008);
+   input_report_key(dev, BTN_Z,  buttons & 0x0100);
+   input_report_key(dev, BTN_Y,  buttons & 0x0200);
+   input_report_key(dev, BTN_X,  buttons & 0x0400);
+   input_report_key(dev, BTN_SELECT, buttons & 0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_open(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev->private;
+   if (!pad->open)
+   maple_getcond_callback(pad->mdev, dc_pad_callback, HZ/50,
+   MAPLE_FUNC_CONTROLLER);
+   pad->open++;
+   return 0;
+
+}
+
+static void dc_pad_close(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev->private;
+
+   pad->open--;
+   if (pad->open)
+   return;
+
+   /* Almost never call something that does nothing */
+   maple_getcond_callback(pad->mdev, dc_pad_callback_idle, 0x,
+   MAPLE_FUNC_CONTROLLER);
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+
+   const short btn_bit[

[PATCH 3/3] input: support maple mouse on Dreamcast

2008-02-24 Thread Adrian McMenamin
input: add support for maple mouse on Dreamcast

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
---

diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
new file mode 100644
index 000..08cfb6f
--- /dev/null
+++ b/drivers/input/mouse/maplemouse.c
@@ -0,0 +1,148 @@
+/*
+ * SEGA Dreamcast mouse driver
+ * Based on drivers/usb/usbmouse.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 and other fixes
+ * copyright, Adrian McMenamin, 2008
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("YAEGASHI Takeshi <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("SEGA Dreamcast mouse driver");
+MODULE_LICENSE("GPL");
+
+static void dc_mouse_callback(struct mapleq *mq)
+{
+   int buttons, relx, rely, relz;
+   struct maple_device *mapledev = mq->dev;
+   struct input_dev *dev = mapledev->private_data;
+   unsigned char *res = mq->recvbuf;
+
+   buttons = ~res[8];
+   relx = *(unsigned short *)(res + 12) - 512;
+   rely = *(unsigned short *)(res + 14) - 512;
+   relz = *(unsigned short *)(res + 16) - 512;
+
+   input_report_key(dev, BTN_LEFT,   buttons & 4);
+   input_report_key(dev, BTN_MIDDLE, buttons & 9);
+   input_report_key(dev, BTN_RIGHT,  buttons & 2);
+   input_report_rel(dev, REL_X,  relx);
+   input_report_rel(dev, REL_Y,  rely);
+   input_report_rel(dev, REL_WHEEL,  relz);
+   input_sync(dev);
+}
+
+static int dc_mouse_connect(struct maple_device *mdev)
+{
+   struct input_dev *input_dev;
+   int error;
+
+   input_dev = input_allocate_device();
+   if (!input_dev) {
+   error = ENOMEM;
+   goto fail_nomem;
+   }
+   mdev->private_data = input_dev;
+
+   input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
+   input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 
BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
+
+   input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) | 
BIT_MASK(REL_WHEEL);
+
+   input_dev->name = mdev->product_name;
+   input_dev->id.bustype = BUS_HOST;
+
+   error = input_register_device(input_dev);
+   if (error)
+   goto fail_regdev;
+
+   maple_getcond_callback(mdev, dc_mouse_callback, HZ/50, 
MAPLE_FUNC_MOUSE);
+
+   return error;
+
+fail_regdev:
+   input_free_device(input_dev);
+fail_nomem:
+   return error;
+}
+
+static void dc_mouse_disconnect(struct maple_device *dev)
+{
+   struct input_dev *input_dev = dev->private_data;
+
+   input_unregister_device(input_dev);
+   kfree(input_dev);
+}
+
+/* allow the mouse to be used */
+static int probe_maple_mouse(struct device *dev)
+{
+   struct maple_device *mdev = to_maple_dev(dev);
+   struct maple_driver *mdrv = to_maple_driver(dev->driver);
+   int error;
+
+   error = dc_mouse_connect(mdev);
+   if (error)
+   return error;
+
+   mdev->driver = mdrv;
+
+   return 0;
+}
+
+
+static int remove_maple_mouse(struct device *dev)
+{
+   struct maple_device *mdev = to_maple_dev(dev);
+
+   dc_mouse_disconnect(mdev);
+   return 0;
+}
+
+static struct maple_driver dc_mouse_driver = {
+   .function = MAPLE_FUNC_MOUSE,
+   .connect =  dc_mouse_connect,
+   .disconnect =   dc_mouse_disconnect,
+   .drv = {
+   .name = "Dreamcast_mouse",
+   .probe = probe_maple_mouse,
+   .remove = remove_maple_mouse,
+   },
+};
+
+static int unplug_maple_mouse(struct device *dev, void *ignored)
+{
+   /* Please DO NOT really unplug your mouse */
+   struct maple_device *mdev;
+
+   mdev = to_maple_dev(dev);
+   if ((mdev->function & MAPLE_FUNC_MOUSE)
+   && (mdev->driver == _mouse_driver))
+   remove_maple_mouse(dev);
+
+   return 0;
+}
+
+static int __init dc_mouse_init(void)
+{
+   maple_driver_register(_mouse_driver.drv);
+   return 0;
+}
+
+static void __exit dc_mouse_exit(void)
+{
+   bus_for_each_dev(_bus_type, NULL, NULL, unplug_maple_mouse);
+   driver_unregister(_mouse_driver.drv);
+}
+
+module_init(dc_mouse_init);
+module_exit(dc_mouse_exit);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] input: support maple mouse on Dreamcast

2008-02-24 Thread Adrian McMenamin

input: update Makefile to support maple mouse on Dreamcast

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
---

diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 9e6e363..5d35939 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_MOUSE_SERIAL)+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)+= vsxxxaa.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
+obj-$(CONFIG_MOUSE_MAPLE)  += maplemouse.o
 
 psmouse-objs := psmouse-base.o synaptics.o

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] input: support maple mouse on Dreamcast

2008-02-24 Thread Adrian McMenamin
input: support maple mouse on Dreamcast

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
---

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 7bbea09..d171336 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -232,4 +232,16 @@ config MOUSE_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio_mouse.
 
+config MOUSE_MAPLE
+   tristate "Dreamcast mouse"
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ This driver supports the Maple bus mouse on a SEGA Dreamcast.
+
+ Most Dreamcast users (with a mouse) will want to say Y here.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maplemouse.
+
 endif

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] input: support maple mouse on Dreamcast

2008-02-24 Thread Adrian McMenamin
input: support maple mouse on Dreamcast

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
---

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 7bbea09..d171336 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -232,4 +232,16 @@ config MOUSE_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio_mouse.
 
+config MOUSE_MAPLE
+   tristate Dreamcast mouse
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ This driver supports the Maple bus mouse on a SEGA Dreamcast.
+
+ Most Dreamcast users (with a mouse) will want to say Y here.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maplemouse.
+
 endif

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] input: support maple mouse on Dreamcast

2008-02-24 Thread Adrian McMenamin

input: update Makefile to support maple mouse on Dreamcast

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
---

diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 9e6e363..5d35939 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_MOUSE_SERIAL)+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)+= vsxxxaa.o
 obj-$(CONFIG_MOUSE_GPIO)   += gpio_mouse.o
+obj-$(CONFIG_MOUSE_MAPLE)  += maplemouse.o
 
 psmouse-objs := psmouse-base.o synaptics.o

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] input: support maple mouse on Dreamcast

2008-02-24 Thread Adrian McMenamin
input: add support for maple mouse on Dreamcast

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
---

diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
new file mode 100644
index 000..08cfb6f
--- /dev/null
+++ b/drivers/input/mouse/maplemouse.c
@@ -0,0 +1,148 @@
+/*
+ * SEGA Dreamcast mouse driver
+ * Based on drivers/usb/usbmouse.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 and other fixes
+ * copyright, Adrian McMenamin, 2008
+ */
+
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/input.h
+#include linux/module.h
+#include linux/init.h
+#include linux/timer.h
+#include linux/maple.h
+#include asm/mach/maple.h
+
+MODULE_AUTHOR(YAEGASHI Takeshi [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(SEGA Dreamcast mouse driver);
+MODULE_LICENSE(GPL);
+
+static void dc_mouse_callback(struct mapleq *mq)
+{
+   int buttons, relx, rely, relz;
+   struct maple_device *mapledev = mq-dev;
+   struct input_dev *dev = mapledev-private_data;
+   unsigned char *res = mq-recvbuf;
+
+   buttons = ~res[8];
+   relx = *(unsigned short *)(res + 12) - 512;
+   rely = *(unsigned short *)(res + 14) - 512;
+   relz = *(unsigned short *)(res + 16) - 512;
+
+   input_report_key(dev, BTN_LEFT,   buttons  4);
+   input_report_key(dev, BTN_MIDDLE, buttons  9);
+   input_report_key(dev, BTN_RIGHT,  buttons  2);
+   input_report_rel(dev, REL_X,  relx);
+   input_report_rel(dev, REL_Y,  rely);
+   input_report_rel(dev, REL_WHEEL,  relz);
+   input_sync(dev);
+}
+
+static int dc_mouse_connect(struct maple_device *mdev)
+{
+   struct input_dev *input_dev;
+   int error;
+
+   input_dev = input_allocate_device();
+   if (!input_dev) {
+   error = ENOMEM;
+   goto fail_nomem;
+   }
+   mdev-private_data = input_dev;
+
+   input_dev-evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
+   input_dev-keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 
BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
+
+   input_dev-relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) | 
BIT_MASK(REL_WHEEL);
+
+   input_dev-name = mdev-product_name;
+   input_dev-id.bustype = BUS_HOST;
+
+   error = input_register_device(input_dev);
+   if (error)
+   goto fail_regdev;
+
+   maple_getcond_callback(mdev, dc_mouse_callback, HZ/50, 
MAPLE_FUNC_MOUSE);
+
+   return error;
+
+fail_regdev:
+   input_free_device(input_dev);
+fail_nomem:
+   return error;
+}
+
+static void dc_mouse_disconnect(struct maple_device *dev)
+{
+   struct input_dev *input_dev = dev-private_data;
+
+   input_unregister_device(input_dev);
+   kfree(input_dev);
+}
+
+/* allow the mouse to be used */
+static int probe_maple_mouse(struct device *dev)
+{
+   struct maple_device *mdev = to_maple_dev(dev);
+   struct maple_driver *mdrv = to_maple_driver(dev-driver);
+   int error;
+
+   error = dc_mouse_connect(mdev);
+   if (error)
+   return error;
+
+   mdev-driver = mdrv;
+
+   return 0;
+}
+
+
+static int remove_maple_mouse(struct device *dev)
+{
+   struct maple_device *mdev = to_maple_dev(dev);
+
+   dc_mouse_disconnect(mdev);
+   return 0;
+}
+
+static struct maple_driver dc_mouse_driver = {
+   .function = MAPLE_FUNC_MOUSE,
+   .connect =  dc_mouse_connect,
+   .disconnect =   dc_mouse_disconnect,
+   .drv = {
+   .name = Dreamcast_mouse,
+   .probe = probe_maple_mouse,
+   .remove = remove_maple_mouse,
+   },
+};
+
+static int unplug_maple_mouse(struct device *dev, void *ignored)
+{
+   /* Please DO NOT really unplug your mouse */
+   struct maple_device *mdev;
+
+   mdev = to_maple_dev(dev);
+   if ((mdev-function  MAPLE_FUNC_MOUSE)
+(mdev-driver == dc_mouse_driver))
+   remove_maple_mouse(dev);
+
+   return 0;
+}
+
+static int __init dc_mouse_init(void)
+{
+   maple_driver_register(dc_mouse_driver.drv);
+   return 0;
+}
+
+static void __exit dc_mouse_exit(void)
+{
+   bus_for_each_dev(maple_bus_type, NULL, NULL, unplug_maple_mouse);
+   driver_unregister(dc_mouse_driver.drv);
+}
+
+module_init(dc_mouse_init);
+module_exit(dc_mouse_exit);

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] input: support maple controller on SEGA Dreamcast

2008-02-24 Thread Adrian McMenamin
This is a port of the old (never in mainline) 2.4 driver.

(It also fixes some issues with earlier patches which should be
discarded for this)


Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
---

diff -ruN ./a/drivers/input/joystick/Kconfig ./b/drivers/input/joystick/Kconfig
--- ./a/drivers/input/joystick/Kconfig  2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Kconfig  2008-02-24 13:59:04.0 +
@@ -282,4 +282,17 @@
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
 
+config JOYSTICK_MAPLE
+   tristate Dreamcast control pad
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ Say Y here if you have a SEGA Dreamcast and want to use your
+ controller.
+
+ Most Dreamcast users will say Y.
+
+ To compile this as a module choose M here: the
+ module will be called maplecontrol.
+
 endif
diff -ruN ./a/drivers/input/joystick/Makefile 
./b/drivers/input/joystick/Makefile
--- ./a/drivers/input/joystick/Makefile 2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Makefile 2008-02-24 13:59:04.0 +
@@ -27,5 +27,6 @@
 obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
 obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
 obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o
+obj-$(CONFIG_JOYSTICK_MAPLE)   += maplecontrol.o
 
 obj-$(CONFIG_JOYSTICK_IFORCE)  += iforce/
diff -ruN ./a/drivers/input/joystick/maplecontrol.c 
./b/drivers/input/joystick/maplecontrol.c
--- ./a/drivers/input/joystick/maplecontrol.c   1970-01-01 01:00:00.0 
+0100
+++ ./b/drivers/input/joystick/maplecontrol.c   2008-02-24 13:59:04.0 
+
@@ -0,0 +1,252 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 by Adrian McMenamin, copyright 2008
+ */
+
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/input.h
+#include linux/module.h
+#include linux/init.h
+#include linux/timer.h
+#include linux/maple.h
+#include asm/mach/maple.h
+
+MODULE_AUTHOR(YAEGASHI Takeshi [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(SEGA Dreamcast controller driver);
+MODULE_LICENSE(GPL);
+
+struct dc_pad {
+   struct input_dev *dev;
+   struct maple_device *mdev;
+   int open;
+};
+
+static void dc_pad_callback_idle(struct mapleq *mq)
+{
+}
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq-dev;
+   struct dc_pad *pad = mapledev-private_data;
+   struct input_dev *dev = pad-dev;
+   unsigned char *res = mq-recvbuf;
+
+   buttons = ~cpu_to_le16(*(unsigned short *)(res + 8));
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons  0x0010 ? -1:0) + (buttons  0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons  0x0040 ? -1:0) + (buttons  0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons  0x1000 ? -1:0) + (buttons  0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons  0x4000 ? -1:0) + (buttons  0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons  0x0001);
+   input_report_key(dev, BTN_B,  buttons  0x0002);
+   input_report_key(dev, BTN_A,  buttons  0x0004);
+   input_report_key(dev, BTN_START,  buttons  0x0008);
+   input_report_key(dev, BTN_Z,  buttons  0x0100);
+   input_report_key(dev, BTN_Y,  buttons  0x0200);
+   input_report_key(dev, BTN_X,  buttons  0x0400);
+   input_report_key(dev, BTN_SELECT, buttons  0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_open(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev-private;
+   if (!pad-open)
+   maple_getcond_callback(pad-mdev, dc_pad_callback, HZ/50,
+   MAPLE_FUNC_CONTROLLER);
+   pad-open++;
+   return 0;
+
+}
+
+static void dc_pad_close(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev-private;
+
+   pad-open--;
+   if (pad-open)
+   return;
+
+   /* Almost never call something that does nothing */
+   maple_getcond_callback(pad-mdev, dc_pad_callback_idle, 0x,
+   MAPLE_FUNC_CONTROLLER);
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev-devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+
+   const short btn_bit[32] = {
+   BTN_C, BTN_B, BTN_A, BTN_START, -1, -1, -1, -1

[PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin
The maple bus driver that went into the kernel mainline in September 2007 
contained some bugs which were revealed by the update of the kobj code for the 
current release series. Unfortunately those bugs also helped ensure maple 
devices were properly detected. This patch (against the current git) now 
ensures that devices are properly detected again.

(A previous attempt to fix this by delaying initialisation only partially fixed 
this - as became apparent when the bus was fully loaded)

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
---



diff -ruN ./a/drivers/sh/maple/maple.c ./b/drivers/sh/maple/maple.c
--- ./a/drivers/sh/maple/maple.c2008-02-21 20:42:17.0 +
+++ ./b/drivers/sh/maple/maple.c2008-02-24 13:59:09.0 +
@@ -1,7 +1,7 @@
 /*
  * Core maple bus functionality
  *
- *  Copyright (C) 2007 Adrian McMenamin
+ *  Copyright (C) 2007, 2008 Adrian McMenamin
  *
  * Based on 2.4 code by:
  *
@@ -18,7 +18,6 @@
 #include linux/init.h
 #include linux/kernel.h
 #include linux/device.h
-#include linux/module.h
 #include linux/interrupt.h
 #include linux/list.h
 #include linux/io.h
@@ -54,7 +53,7 @@
 static int subdevice_map[MAPLE_PORTS];
 static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
 static unsigned long maple_pnp_time;
-static int started, scanning, liststatus, realscan;
+static int started, scanning, liststatus, fullscan;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
@@ -62,6 +61,9 @@
int unit;
 };
 
+static bool checked[4];
+static struct maple_device *baseunits[4];
+
 /**
  *  maple_driver_register - register a device driver
  *  automatically makes the driver bus a maple bus
@@ -309,11 +311,9 @@
else
break;
 
-   if (realscan) {
-   printk(KERN_INFO Maple device detected: %s\n,
-   mdev-product_name);
-   printk(KERN_INFO Maple device: %s\n, mdev-product_licence);
-   }
+   printk(KERN_INFO Maple device detected: %s\n,
+   mdev-product_name);
+   printk(KERN_INFO Maple device: %s\n, mdev-product_licence);
 
function = be32_to_cpu(mdev-devinfo.function);
 
@@ -323,10 +323,9 @@
mdev-driver = maple_dummy_driver;
sprintf(mdev-dev.bus_id, %d:0.port, mdev-port);
} else {
-   if (realscan)
-   printk(KERN_INFO
-   Maple bus at (%d, %d): Function 0x%lX\n,
-   mdev-port, mdev-unit, function);
+   printk(KERN_INFO
+   Maple bus at (%d, %d): Function 0x%lX\n,
+   mdev-port, mdev-unit, function);
 
matched =
bus_for_each_drv(maple_bus_type, NULL, mdev,
@@ -334,9 +333,8 @@
 
if (matched == 0) {
/* Driver does not exist yet */
-   if (realscan)
-   printk(KERN_INFO
-   No maple driver found.\n);
+   printk(KERN_INFO
+   No maple driver found.\n);
mdev-driver = maple_dummy_driver;
}
sprintf(mdev-dev.bus_id, %d:0%d.%lX, mdev-port,
@@ -472,9 +470,12 @@
maple_detach_driver(mdev);
return;
}
-   if (!started) {
-   printk(KERN_INFO No maple devices attached to port %d\n,
-  mdev-port);
+   if (!started || !fullscan) {
+   if (checked[mdev-port] == false) {
+   checked[mdev-port] = true;
+   printk(KERN_INFO No maple devices attached
+to port %d\n, mdev-port);
+   }
return;
}
maple_clean_submap(mdev);
@@ -485,8 +486,14 @@
   char *recvbuf)
 {
char submask;
-   if ((!started) || (scanning == 2)) {
-   maple_attach_driver(mdev);
+   if (!started || (scanning == 2) || !fullscan) {
+   if ((mdev-unit == 0)  (checked[mdev-port] == false)) {
+   checked[mdev-port] = true;
+   maple_attach_driver(mdev);
+   } else {
+   if (mdev-unit != 0)
+   maple_attach_driver(mdev);
+   }
return;
}
if (mdev-unit == 0) {
@@ -505,6 +512,7 @@
struct maple_device *dev;
char *recvbuf;
enum maple_code code;
+   int i;
 
if (!maple_dma_done())
return;
@@ -557,6 +565,19 @@
} else
scanning = 0;
 
+   if (!fullscan) {
+   fullscan = 1;
+   for (i = 0; i  MAPLE_PORTS; i++) {
+   if (checked[i] == false

lkml.org

2008-02-24 Thread Adrian McMenamin
At the risk of pointing out the obvious (though I cannot find anyone
else who has commented), this appears to be broken at the moment...(ie
not picking up new messages)

...which is a pity as it is a great site

Adrian
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin

On Sun, 2008-02-24 at 14:30 +, Adrian McMenamin wrote:
 The maple bus driver that went into the kernel mainline in September 2007 
 contained some bugs which were revealed by the update of the kobj code for 
 the current release series. Unfortunately those bugs also helped ensure maple 
 devices were properly detected. This patch (against the current git) now 
 ensures that devices are properly detected again.
 

Further testing has shown this has introduced another bug, this time
limiting the effectiveness of subdevice detection. Please ignore this
while I work on a fix.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin

On Sun, 2008-02-24 at 21:50 +, Adrian McMenamin wrote:
 On Sun, 2008-02-24 at 14:30 +, Adrian McMenamin wrote:
  The maple bus driver that went into the kernel mainline in September 2007 
  contained some bugs which were revealed by the update of the kobj code for 
  the current release series. Unfortunately those bugs also helped ensure 
  maple devices were properly detected. This patch (against the current git) 
  now ensures that devices are properly detected again.
  
 
 Further testing has shown this has introduced another bug, this time
 limiting the effectiveness of subdevice detection. Please ignore this
 while I work on a fix.
 
Sorry for the confusion, in fact there is nothing wrong with this code
(ie it should be applied), the error was in the driver for the Dreamcast
controller (the device, in general, into which the subdevices are
plugged in and out).

I will post a fix for that.

Sorry again.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] input: support maple controller on SEGA Dreamcast

2008-02-24 Thread Adrian McMenamin
Add support for the Dreamcast maple controller (as a joystick).

Earlier patches caused subdevice detection headaches. Please use this one.

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
---

diff -ruN ./a/drivers/input/joystick/Kconfig ./b/drivers/input/joystick/Kconfig
--- ./a/drivers/input/joystick/Kconfig  2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Kconfig  2008-02-24 13:59:04.0 +
@@ -282,4 +282,17 @@
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
 
+config JOYSTICK_MAPLE
+   tristate Dreamcast control pad
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ Say Y here if you have a SEGA Dreamcast and want to use your
+ controller.
+
+ Most Dreamcast users will say Y.
+
+ To compile this as a module choose M here: the
+ module will be called maplecontrol.
+
 endif
diff -ruN ./a/drivers/input/joystick/Makefile 
./b/drivers/input/joystick/Makefile
--- ./a/drivers/input/joystick/Makefile 2008-02-21 20:42:07.0 +
+++ ./b/drivers/input/joystick/Makefile 2008-02-24 13:59:04.0 +
@@ -27,5 +27,6 @@
 obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
 obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
 obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o
+obj-$(CONFIG_JOYSTICK_MAPLE)   += maplecontrol.o
 
 obj-$(CONFIG_JOYSTICK_IFORCE)  += iforce/
diff -ruN ./a/drivers/input/joystick/maplecontrol.c 
./b/drivers/input/joystick/maplecontrol.c
--- ./a/drivers/input/joystick/maplecontrol.c   1970-01-01 01:00:00.0 
+0100
+++ ./b/drivers/input/joystick/maplecontrol.c   2008-02-24 22:56:31.0 
+
@@ -0,0 +1,222 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 by Adrian McMenamin, copyright 2008
+ */
+
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/input.h
+#include linux/module.h
+#include linux/init.h
+#include linux/timer.h
+#include linux/maple.h
+#include asm/mach/maple.h
+
+MODULE_AUTHOR(YAEGASHI Takeshi [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(SEGA Dreamcast controller driver);
+MODULE_LICENSE(GPL);
+
+struct dc_pad {
+   struct input_dev *dev;
+   struct maple_device *mdev;
+   int open;
+};
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq-dev;
+   struct dc_pad *pad = mapledev-private_data;
+   struct input_dev *dev = pad-dev;
+   unsigned char *res = mq-recvbuf;
+
+   buttons = ~cpu_to_le16(*(unsigned short *)(res + 8));
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons  0x0010 ? -1:0) + (buttons  0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons  0x0040 ? -1:0) + (buttons  0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons  0x1000 ? -1:0) + (buttons  0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons  0x4000 ? -1:0) + (buttons  0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons  0x0001);
+   input_report_key(dev, BTN_B,  buttons  0x0002);
+   input_report_key(dev, BTN_A,  buttons  0x0004);
+   input_report_key(dev, BTN_START,  buttons  0x0008);
+   input_report_key(dev, BTN_Z,  buttons  0x0100);
+   input_report_key(dev, BTN_Y,  buttons  0x0200);
+   input_report_key(dev, BTN_X,  buttons  0x0400);
+   input_report_key(dev, BTN_SELECT, buttons  0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev-devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+
+   const short btn_bit[32] = {
+   BTN_C, BTN_B, BTN_A, BTN_START, -1, -1, -1, -1,
+   BTN_Z, BTN_Y, BTN_X, BTN_SELECT, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   const short abs_bit[32] = {
+   -1, -1, -1, -1, ABS_HAT0Y, ABS_HAT0Y, ABS_HAT0X, ABS_HAT0X,
+   -1, -1, -1, -1, ABS_HAT1Y, ABS_HAT1Y, ABS_HAT1X, ABS_HAT1X,
+   ABS_GAS, ABS_BRAKE, ABS_X, ABS_Y, ABS_RX, ABS_RY, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL);
+   if (!pad){
+   error = ENOMEM;
+   goto fail_nomem_1;
+   }
+
+   dev = input_allocate_device();
+   if (!dev

Re: [PATCH] maple: fix device detection

2008-02-24 Thread Adrian McMenamin

On Mon, 2008-02-25 at 14:33 +0900, Paul Mundt wrote:
 On Sun, Feb 24, 2008 at 10:32:53PM +, Adrian McMenamin wrote:
  On Sun, 2008-02-24 at 21:50 +, Adrian McMenamin wrote:
   On Sun, 2008-02-24 at 14:30 +, Adrian McMenamin wrote:
The maple bus driver that went into the kernel mainline in
September 2007 contained some bugs which were revealed by the
update of the kobj code for the current release series.
Unfortunately those bugs also helped ensure maple devices were
properly detected. This patch (against the current git) now ensures
that devices are properly detected again.

   
   Further testing has shown this has introduced another bug, this time
   limiting the effectiveness of subdevice detection. Please ignore this
   while I work on a fix.
   
  Sorry for the confusion, in fact there is nothing wrong with this code
  (ie it should be applied), the error was in the driver for the Dreamcast
  controller (the device, in general, into which the subdevices are
  plugged in and out).
  
  I will post a fix for that.
  
  Sorry again.
  
 So what exactly is supposed to be applied here?

The patch at the start of this thread - ie
http://lkml.org/lkml/2008/2/24/125  - this should really go in now as it
fixes a problem with current code.

In addition there are two patch sets to add new device support:

http://lkml.org/lkml/2008/2/24/211- maple controller

http://lkml.org/lkml/2008/2/24/121  (thread) - maple mouse

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Current git very broken on the Dreamcast

2008-02-18 Thread Adrian McMenamin

On Mon, 2008-02-18 at 17:57 +0900, Magnus Damm wrote:
> Hi Adrian,
> 
> [fixed up Matsubara-sans address]
> 
> On Feb 17, 2008 4:48 AM, Adrian McMenamin
> <[EMAIL PROTECTED]> wrote:
> > On Sat, 2008-02-16 at 18:38 +, Adrian McMenamin wrote:
> > > Will seek to bisect this, but I have just updated my sources to the
> > > latest git and it is not booting at all on the Dreamcast.
> > >
> > > With early printk on, I get nothing more than this before an instant
> > > reboot:
> > >
> > > [0.00] Linux version 2.6.25-rc2-10953-g52065cd
> > > ([EMAIL PROTECTED]) (gcc version 3.4.6) #511 PREEMPT Sat Feb 16 18:31:43
> > > GMT 2008
> > > [0.00] console [sercon0] enabled
> > > [0.00] Booting machvec: Sega Dreamcast
> >
> >
> > [EMAIL PROTECTED]:~/gdrom-dev$ git bisect good
> > e036eaa681a17f71b64f6d9040fe60623919 is first bad commit
> > commit e036eaa681a17f71b64f6d9040fe60623919
> > Author: Magnus Damm <[EMAIL PROTECTED]>
> > Date:   Thu Feb 14 13:52:43 2008 +0900
> >
> > sh: use ctrl_in/out for on chip pci access
> >
> > This patch makes sure ctrl_inN/outN are used instead of inN/outN for
> > on chip
> > pci registers. Without this patch addresses may be adjusted using
> > the value
> > in generic_io_base. This patch makes it possible to set
> > generic_io_base and
> > have pci without reading and writing all over the place.
> >
> > Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
> > Acked-by: Katsuya MATSUBARA <[EMAIL PROTECTED]>
> > Signed-off-by: Paul Mundt <[EMAIL PROTECTED]>
> >
> > :04 04 17a9f8181301e3a082d8a1a2fdef9b13ff1185e4
> > 87e4a2e912be56b0d12e8a92db9489d6615c31f7 M  arch
> 
> Thanks for tracking this down and sorry for breaking the dreamcast pci driver.
> 
> Most code for the dreamcast currently do direct register access using
> ctrl_inN/outN or readN/writeN. Only a few places use inN/outN and
> depend on the value of generic_io_base. Doing inN/outN is ok (but
> outdated, use ioreadN/iowriteN instead) in a portable pci/isa driver,
> but it doesn't make sense for any dreamcast specific code to rely on
> generic_io_base. For the dreamcast we already know the address at
> compile time so doing adjustment during runtime is just unnecessary
> overhead.
> 
> It is of course possible to revert the dreamcast-specific bits of the
> commit you pointed out, but I think the change for the dreamcast makes
> sense since it makes the code both faster and more uniform.
> 
> However, at this point it is broken. Sorry about that. I just looked
> through all upstream dreamcast-specific code I could find and irq.c is
> now the only file that does inN/outN. I've attached a patch that makes
> the irq code independent of generic_io_base. There is also another
> patch attached that adjusts the addresses of the pci register.
> Together they should solve the problem you are seeing. Please try them
> on top of 2.6.25-rc2.
> 
> With these patches io ports count from 0 -> 8k-1 instead of being a
> pointer. We currently rely on generic_io_base logic but that will be
> changed in the future.
> 
Magnus,

This fixed the original problem but re-introduced the problem I had
before with not having a a working nic - so it's stole broken atm:

[2.220263] NET: Registered protocol family 17
[2.224976] RPC: Registered udp transport module.
[2.228064] RPC: Registered tcp transport module.
[2.740995] IP-Config: Failed to open eth0
[2.744076] IP-Config: No network devices available.
[2.748232] Looking up port of RPC 13/2 on 192.168.61.50


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Current git very broken on the Dreamcast

2008-02-18 Thread Adrian McMenamin

On Mon, 2008-02-18 at 17:57 +0900, Magnus Damm wrote:
 Hi Adrian,
 
 [fixed up Matsubara-sans address]
 
 On Feb 17, 2008 4:48 AM, Adrian McMenamin
 [EMAIL PROTECTED] wrote:
  On Sat, 2008-02-16 at 18:38 +, Adrian McMenamin wrote:
   Will seek to bisect this, but I have just updated my sources to the
   latest git and it is not booting at all on the Dreamcast.
  
   With early printk on, I get nothing more than this before an instant
   reboot:
  
   [0.00] Linux version 2.6.25-rc2-10953-g52065cd
   ([EMAIL PROTECTED]) (gcc version 3.4.6) #511 PREEMPT Sat Feb 16 18:31:43
   GMT 2008
   [0.00] console [sercon0] enabled
   [0.00] Booting machvec: Sega Dreamcast
 
 
  [EMAIL PROTECTED]:~/gdrom-dev$ git bisect good
  e036eaa681a17f71b64f6d9040fe60623919 is first bad commit
  commit e036eaa681a17f71b64f6d9040fe60623919
  Author: Magnus Damm [EMAIL PROTECTED]
  Date:   Thu Feb 14 13:52:43 2008 +0900
 
  sh: use ctrl_in/out for on chip pci access
 
  This patch makes sure ctrl_inN/outN are used instead of inN/outN for
  on chip
  pci registers. Without this patch addresses may be adjusted using
  the value
  in generic_io_base. This patch makes it possible to set
  generic_io_base and
  have pci without reading and writing all over the place.
 
  Signed-off-by: Magnus Damm [EMAIL PROTECTED]
  Acked-by: Katsuya MATSUBARA [EMAIL PROTECTED]
  Signed-off-by: Paul Mundt [EMAIL PROTECTED]
 
  :04 04 17a9f8181301e3a082d8a1a2fdef9b13ff1185e4
  87e4a2e912be56b0d12e8a92db9489d6615c31f7 M  arch
 
 Thanks for tracking this down and sorry for breaking the dreamcast pci driver.
 
 Most code for the dreamcast currently do direct register access using
 ctrl_inN/outN or readN/writeN. Only a few places use inN/outN and
 depend on the value of generic_io_base. Doing inN/outN is ok (but
 outdated, use ioreadN/iowriteN instead) in a portable pci/isa driver,
 but it doesn't make sense for any dreamcast specific code to rely on
 generic_io_base. For the dreamcast we already know the address at
 compile time so doing adjustment during runtime is just unnecessary
 overhead.
 
 It is of course possible to revert the dreamcast-specific bits of the
 commit you pointed out, but I think the change for the dreamcast makes
 sense since it makes the code both faster and more uniform.
 
 However, at this point it is broken. Sorry about that. I just looked
 through all upstream dreamcast-specific code I could find and irq.c is
 now the only file that does inN/outN. I've attached a patch that makes
 the irq code independent of generic_io_base. There is also another
 patch attached that adjusts the addresses of the pci register.
 Together they should solve the problem you are seeing. Please try them
 on top of 2.6.25-rc2.
 
 With these patches io ports count from 0 - 8k-1 instead of being a
 pointer. We currently rely on generic_io_base logic but that will be
 changed in the future.
 
Magnus,

This fixed the original problem but re-introduced the problem I had
before with not having a a working nic - so it's stole broken atm:

[2.220263] NET: Registered protocol family 17
[2.224976] RPC: Registered udp transport module.
[2.228064] RPC: Registered tcp transport module.
[2.740995] IP-Config: Failed to open eth0
[2.744076] IP-Config: No network devices available.
[2.748232] Looking up port of RPC 13/2 on 192.168.61.50


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] maple: add driver for Sega Dreamcast controller

2008-02-16 Thread Adrian McMenamin
Add support for the SEGA Dreamcast controller as a joystick device. Based on 
Yaegashi Takeshi's old 2.4 driver (never in mainline) with the addition of 
functioning removal (and reinsertion) code.

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>

--- 


diff -ruN a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
--- a/drivers/input/joystick/Kconfig2008-02-16 20:51:49.0 +
+++ b/drivers/input/joystick/Kconfig2008-02-16 21:41:52.0 +
@@ -282,4 +282,17 @@
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
 
+config JOYSTICK_MAPLE
+   tristate "Dreamcast control pad"
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ Say Y here if you have a SEGA Dreamcast and want to use your
+ controller.
+
+ Most Dreamcast users will say Y.
+
+ To compile this as a module choose M here: the
+ module will be called maplecontrol.
+
 endif
diff -ruN a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
--- a/drivers/input/joystick/Makefile   2008-02-16 20:51:49.0 +
+++ b/drivers/input/joystick/Makefile   2008-02-16 21:41:52.0 +
@@ -27,5 +27,6 @@
 obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
 obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
 obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o
+obj-$(CONFIG_JOYSTICK_MAPLE)   += maplecontrol.o
 
 obj-$(CONFIG_JOYSTICK_IFORCE)  += iforce/
diff -ruN a/drivers/input/joystick/maplecontrol.c 
b/drivers/input/joystick/maplecontrol.c
--- a/drivers/input/joystick/maplecontrol.c 1970-01-01 01:00:00.0 
+0100
+++ b/drivers/input/joystick/maplecontrol.c 2008-02-16 21:41:52.0 
+
@@ -0,0 +1,246 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 by Adrian McMenamin, copyright 2008
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("YAEGASHI Takeshi <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("SEGA Dreamcast controller driver");
+MODULE_LICENSE("GPL");
+
+struct dc_pad {
+   struct input_dev *dev;
+   struct maple_device *mdev;
+   int open;
+};
+
+static void dc_pad_callback_idle(struct mapleq *mq)
+{
+}
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq->dev;
+   struct dc_pad *pad = mapledev->private_data;
+   struct input_dev *dev = pad->dev;
+   unsigned char *res = mq->recvbuf;
+
+   buttons = ~*(unsigned short *)(res+8);
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons & 0x0010 ? -1:0) + (buttons & 0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons & 0x0040 ? -1:0) + (buttons & 0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons & 0x1000 ? -1:0) + (buttons & 0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons & 0x4000 ? -1:0) + (buttons & 0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons & 0x0001);
+   input_report_key(dev, BTN_B,  buttons & 0x0002);
+   input_report_key(dev, BTN_A,  buttons & 0x0004);
+   input_report_key(dev, BTN_START,  buttons & 0x0008);
+   input_report_key(dev, BTN_Z,  buttons & 0x0100);
+   input_report_key(dev, BTN_Y,  buttons & 0x0200);
+   input_report_key(dev, BTN_X,  buttons & 0x0400);
+   input_report_key(dev, BTN_SELECT, buttons & 0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_open(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev->private;
+   if (!pad->open)
+   maple_getcond_callback(pad->mdev, dc_pad_callback, HZ/50,
+   MAPLE_FUNC_CONTROLLER);
+   pad->open++;
+   return 0;
+
+}
+
+static void dc_pad_close(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev->private;
+
+   pad->open--;
+   if (pad->open)
+   return;
+
+   /* Almost never call something that does nothing */
+   maple_getcond_callback(pad->mdev, dc_pad_callback_idle, 0x,
+   MAPLE_FUNC_CONTROLLER);
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+

[PATCH] maple: allow removal and reinsertion of keyboard driver module

2008-02-16 Thread Adrian McMenamin
Allow the removal (and subsequent reinsertion) of the maple_keyb (maple 
keyboard) driver by adding a working removal function.

Also tidy long lines.

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>

---



diff -ruN a/drivers/input/keyboard/maple_keyb.c 
b/drivers/input/keyboard/maple_keyb.c
--- a/drivers/input/keyboard/maple_keyb.c   2008-02-16 20:51:49.0 
+
+++ b/drivers/input/keyboard/maple_keyb.c   2008-02-16 21:41:52.0 
+
@@ -2,7 +2,7 @@
  * SEGA Dreamcast keyboard driver
  * Based on drivers/usb/usbkbd.c
  * Copyright YAEGASHI Takeshi, 2001
- * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007, 2008
  *
  * 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
@@ -46,39 +46,51 @@
 };
 
 static const unsigned short dc_kbd_keycode[NR_SCANCODES] = {
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B, 
KEY_C, KEY_D,
-   KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L,
-   KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
-   KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2,
-   KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0,
-   KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, 
KEY_EQUAL, KEY_LEFTBRACE,
-   KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON, 
KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA,
-   KEY_DOT, KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, 
KEY_F5, KEY_F6,
+   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B,
+   KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L,
+   KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V,
+   KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
+   KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE,
+   KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE,
+   KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON,
+   KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, KEY_DOT, KEY_SLASH,
+   KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_SYSRQ,
-   KEY_SCROLLLOCK, KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE,
-   KEY_END, KEY_PAGEDOWN, KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP,
-   KEY_NUMLOCK, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS, 
KEY_KPENTER, KEY_KP1, KEY_KP2,
-   KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KP0, 
KEY_KPDOT,
-   KEY_102ND, KEY_COMPOSE, KEY_POWER, KEY_KPEQUAL, KEY_F13, KEY_F14, 
KEY_F15,
-   KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20,
-   KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_OPEN, KEY_HELP, KEY_PROPS, 
KEY_FRONT,
-   KEY_STOP, KEY_AGAIN, KEY_UNDO, KEY_CUT, KEY_COPY, KEY_PASTE, KEY_FIND, 
KEY_MUTE,
-   KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_KPCOMMA, KEY_RESERVED, KEY_RO, KEY_KATAKANAHIRAGANA , KEY_YEN,
-   KEY_HENKAN, KEY_MUHENKAN, KEY_KPJPCOMMA, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED,
-   KEY_HANGEUL, KEY_HANJA, KEY_KATAKANA, KEY_HIRAGANA, KEY_ZENKAKUHANKAKU, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_LEFTCTRL, KEY_LEFTSHIFT, KEY_LEFTALT, KEY_LEFTMETA, KEY_RIGHTCTRL, 
KEY_RIGHTSHIFT, KEY_RIGHTALT, KEY_RIGHTMETA,
-   KEY_PLAYPAUSE, KEY_STOPCD, KEY_PREVIOUSSONG, KEY_NEXTSONG, KEY_EJECTCD, 
KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_MUTE,
-   KEY_WWW, KEY_BACK, KEY_FORWARD, KEY_STOP, KEY_FIND, KEY_SCROLLUP, 
KEY_SCROLLDOWN, KEY_EDIT, KEY_SLEEP,
-   KEY_SCREENLOCK, KEY_REFRESH, KEY_CALC, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED
+   KEY_SCROLLLOCK, KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP,
+   KEY_DELETE, KEY_END, KEY_PA

[PATCH] maple: remove unused variable

2008-02-16 Thread Adrian McMenamin
Remove an unused variable from the definition of struct maple_device

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
---

diff -ruN a/include/linux/maple.h b/include/linux/maple.h
--- a/include/linux/maple.h 2008-02-16 20:52:09.0 +
+++ b/include/linux/maple.h 2008-02-16 21:42:06.0 +
@@ -64,7 +64,6 @@
int (*connect) (struct maple_device * dev);
void (*disconnect) (struct maple_device * dev);
struct device_driver drv;
-   int registered;
 };
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Current git very broken on the Dreamcast

2008-02-16 Thread Adrian McMenamin

On Sat, 2008-02-16 at 19:48 +, Adrian McMenamin wrote:
> On Sat, 2008-02-16 at 18:38 +0000, Adrian McMenamin wrote:
> > Will seek to bisect this, but I have just updated my sources to the
> > latest git and it is not booting at all on the Dreamcast.
> > 

> [EMAIL PROTECTED]:~/gdrom-dev$ git bisect good
> e036eaa681a17f71b64f6d9040fe60623919 is first bad commit
> commit e036eaa681a17f71b64f6d9040fe60623919
> Author: Magnus Damm <[EMAIL PROTECTED]>
> Date:   Thu Feb 14 13:52:43 2008 +0900
> 

Reverting this commit *will* let my Dreamcast boot - can it be rolled
back pending further testing for a patch please?

Adrian

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Current git very broken on the Dreamcast

2008-02-16 Thread Adrian McMenamin

On Sat, 2008-02-16 at 18:38 +, Adrian McMenamin wrote:
> Will seek to bisect this, but I have just updated my sources to the
> latest git and it is not booting at all on the Dreamcast.
> 
> With early printk on, I get nothing more than this before an instant
> reboot:
> 
> [0.00] Linux version 2.6.25-rc2-10953-g52065cd
> ([EMAIL PROTECTED]) (gcc version 3.4.6) #511 PREEMPT Sat Feb 16 18:31:43
> GMT 2008
> [0.00] console [sercon0] enabled
> [0.00] Booting machvec: Sega Dreamcast


[EMAIL PROTECTED]:~/gdrom-dev$ git bisect good
e036eaa681a17f71b64f6d9040fe60623919 is first bad commit
commit e036eaa681a17f71b64f6d9040fe60623919
Author: Magnus Damm <[EMAIL PROTECTED]>
Date:   Thu Feb 14 13:52:43 2008 +0900

sh: use ctrl_in/out for on chip pci access

This patch makes sure ctrl_inN/outN are used instead of inN/outN for
on chip
pci registers. Without this patch addresses may be adjusted using
the value
in generic_io_base. This patch makes it possible to set
generic_io_base and
have pci without reading and writing all over the place.

Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
Acked-by: Katsuya MATSUBARA <[EMAIL PROTECTED]>
Signed-off-by: Paul Mundt <[EMAIL PROTECTED]>

:04 04 17a9f8181301e3a082d8a1a2fdef9b13ff1185e4
87e4a2e912be56b0d12e8a92db9489d6615c31f7 M  arch


I'll now try reverting this and seeing what happens


Adrian

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Current git very broken on the Dreamcast

2008-02-16 Thread Adrian McMenamin
Will seek to bisect this, but I have just updated my sources to the
latest git and it is not booting at all on the Dreamcast.

With early printk on, I get nothing more than this before an instant
reboot:

[0.00] Linux version 2.6.25-rc2-10953-g52065cd
([EMAIL PROTECTED]) (gcc version 3.4.6) #511 PREEMPT Sat Feb 16 18:31:43
GMT 2008
[0.00] console [sercon0] enabled
[0.00] Booting machvec: Sega Dreamcast


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Current git very broken on the Dreamcast

2008-02-16 Thread Adrian McMenamin
Will seek to bisect this, but I have just updated my sources to the
latest git and it is not booting at all on the Dreamcast.

With early printk on, I get nothing more than this before an instant
reboot:

[0.00] Linux version 2.6.25-rc2-10953-g52065cd
([EMAIL PROTECTED]) (gcc version 3.4.6) #511 PREEMPT Sat Feb 16 18:31:43
GMT 2008
[0.00] console [sercon0] enabled
[0.00] Booting machvec: Sega Dreamcast


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Current git very broken on the Dreamcast

2008-02-16 Thread Adrian McMenamin

On Sat, 2008-02-16 at 18:38 +, Adrian McMenamin wrote:
 Will seek to bisect this, but I have just updated my sources to the
 latest git and it is not booting at all on the Dreamcast.
 
 With early printk on, I get nothing more than this before an instant
 reboot:
 
 [0.00] Linux version 2.6.25-rc2-10953-g52065cd
 ([EMAIL PROTECTED]) (gcc version 3.4.6) #511 PREEMPT Sat Feb 16 18:31:43
 GMT 2008
 [0.00] console [sercon0] enabled
 [0.00] Booting machvec: Sega Dreamcast


[EMAIL PROTECTED]:~/gdrom-dev$ git bisect good
e036eaa681a17f71b64f6d9040fe60623919 is first bad commit
commit e036eaa681a17f71b64f6d9040fe60623919
Author: Magnus Damm [EMAIL PROTECTED]
Date:   Thu Feb 14 13:52:43 2008 +0900

sh: use ctrl_in/out for on chip pci access

This patch makes sure ctrl_inN/outN are used instead of inN/outN for
on chip
pci registers. Without this patch addresses may be adjusted using
the value
in generic_io_base. This patch makes it possible to set
generic_io_base and
have pci without reading and writing all over the place.

Signed-off-by: Magnus Damm [EMAIL PROTECTED]
Acked-by: Katsuya MATSUBARA [EMAIL PROTECTED]
Signed-off-by: Paul Mundt [EMAIL PROTECTED]

:04 04 17a9f8181301e3a082d8a1a2fdef9b13ff1185e4
87e4a2e912be56b0d12e8a92db9489d6615c31f7 M  arch


I'll now try reverting this and seeing what happens


Adrian

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Current git very broken on the Dreamcast

2008-02-16 Thread Adrian McMenamin

On Sat, 2008-02-16 at 19:48 +, Adrian McMenamin wrote:
 On Sat, 2008-02-16 at 18:38 +, Adrian McMenamin wrote:
  Will seek to bisect this, but I have just updated my sources to the
  latest git and it is not booting at all on the Dreamcast.
  

 [EMAIL PROTECTED]:~/gdrom-dev$ git bisect good
 e036eaa681a17f71b64f6d9040fe60623919 is first bad commit
 commit e036eaa681a17f71b64f6d9040fe60623919
 Author: Magnus Damm [EMAIL PROTECTED]
 Date:   Thu Feb 14 13:52:43 2008 +0900
 

Reverting this commit *will* let my Dreamcast boot - can it be rolled
back pending further testing for a patch please?

Adrian

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] maple: remove unused variable

2008-02-16 Thread Adrian McMenamin
Remove an unused variable from the definition of struct maple_device

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
---

diff -ruN a/include/linux/maple.h b/include/linux/maple.h
--- a/include/linux/maple.h 2008-02-16 20:52:09.0 +
+++ b/include/linux/maple.h 2008-02-16 21:42:06.0 +
@@ -64,7 +64,6 @@
int (*connect) (struct maple_device * dev);
void (*disconnect) (struct maple_device * dev);
struct device_driver drv;
-   int registered;
 };
 


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] maple: allow removal and reinsertion of keyboard driver module

2008-02-16 Thread Adrian McMenamin
Allow the removal (and subsequent reinsertion) of the maple_keyb (maple 
keyboard) driver by adding a working removal function.

Also tidy long lines.

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]

---



diff -ruN a/drivers/input/keyboard/maple_keyb.c 
b/drivers/input/keyboard/maple_keyb.c
--- a/drivers/input/keyboard/maple_keyb.c   2008-02-16 20:51:49.0 
+
+++ b/drivers/input/keyboard/maple_keyb.c   2008-02-16 21:41:52.0 
+
@@ -2,7 +2,7 @@
  * SEGA Dreamcast keyboard driver
  * Based on drivers/usb/usbkbd.c
  * Copyright YAEGASHI Takeshi, 2001
- * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007, 2008
  *
  * 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
@@ -46,39 +46,51 @@
 };
 
 static const unsigned short dc_kbd_keycode[NR_SCANCODES] = {
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B, 
KEY_C, KEY_D,
-   KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L,
-   KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
-   KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2,
-   KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0,
-   KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, 
KEY_EQUAL, KEY_LEFTBRACE,
-   KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON, 
KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA,
-   KEY_DOT, KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, 
KEY_F5, KEY_F6,
+   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B,
+   KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L,
+   KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V,
+   KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
+   KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE,
+   KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE,
+   KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON,
+   KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, KEY_DOT, KEY_SLASH,
+   KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_SYSRQ,
-   KEY_SCROLLLOCK, KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE,
-   KEY_END, KEY_PAGEDOWN, KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP,
-   KEY_NUMLOCK, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS, 
KEY_KPENTER, KEY_KP1, KEY_KP2,
-   KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KP0, 
KEY_KPDOT,
-   KEY_102ND, KEY_COMPOSE, KEY_POWER, KEY_KPEQUAL, KEY_F13, KEY_F14, 
KEY_F15,
-   KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20,
-   KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_OPEN, KEY_HELP, KEY_PROPS, 
KEY_FRONT,
-   KEY_STOP, KEY_AGAIN, KEY_UNDO, KEY_CUT, KEY_COPY, KEY_PASTE, KEY_FIND, 
KEY_MUTE,
-   KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_KPCOMMA, KEY_RESERVED, KEY_RO, KEY_KATAKANAHIRAGANA , KEY_YEN,
-   KEY_HENKAN, KEY_MUHENKAN, KEY_KPJPCOMMA, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED,
-   KEY_HANGEUL, KEY_HANJA, KEY_KATAKANA, KEY_HIRAGANA, KEY_ZENKAKUHANKAKU, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
-   KEY_LEFTCTRL, KEY_LEFTSHIFT, KEY_LEFTALT, KEY_LEFTMETA, KEY_RIGHTCTRL, 
KEY_RIGHTSHIFT, KEY_RIGHTALT, KEY_RIGHTMETA,
-   KEY_PLAYPAUSE, KEY_STOPCD, KEY_PREVIOUSSONG, KEY_NEXTSONG, KEY_EJECTCD, 
KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_MUTE,
-   KEY_WWW, KEY_BACK, KEY_FORWARD, KEY_STOP, KEY_FIND, KEY_SCROLLUP, 
KEY_SCROLLDOWN, KEY_EDIT, KEY_SLEEP,
-   KEY_SCREENLOCK, KEY_REFRESH, KEY_CALC, KEY_RESERVED, KEY_RESERVED, 
KEY_RESERVED, KEY_RESERVED
+   KEY_SCROLLLOCK, KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP,
+   KEY_DELETE, KEY_END, KEY_PAGEDOWN

[PATCH] maple: add driver for Sega Dreamcast controller

2008-02-16 Thread Adrian McMenamin
Add support for the SEGA Dreamcast controller as a joystick device. Based on 
Yaegashi Takeshi's old 2.4 driver (never in mainline) with the addition of 
functioning removal (and reinsertion) code.

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]

--- 


diff -ruN a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
--- a/drivers/input/joystick/Kconfig2008-02-16 20:51:49.0 +
+++ b/drivers/input/joystick/Kconfig2008-02-16 21:41:52.0 +
@@ -282,4 +282,17 @@
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
 
+config JOYSTICK_MAPLE
+   tristate Dreamcast control pad
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+ Say Y here if you have a SEGA Dreamcast and want to use your
+ controller.
+
+ Most Dreamcast users will say Y.
+
+ To compile this as a module choose M here: the
+ module will be called maplecontrol.
+
 endif
diff -ruN a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
--- a/drivers/input/joystick/Makefile   2008-02-16 20:51:49.0 +
+++ b/drivers/input/joystick/Makefile   2008-02-16 21:41:52.0 +
@@ -27,5 +27,6 @@
 obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
 obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
 obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o
+obj-$(CONFIG_JOYSTICK_MAPLE)   += maplecontrol.o
 
 obj-$(CONFIG_JOYSTICK_IFORCE)  += iforce/
diff -ruN a/drivers/input/joystick/maplecontrol.c 
b/drivers/input/joystick/maplecontrol.c
--- a/drivers/input/joystick/maplecontrol.c 1970-01-01 01:00:00.0 
+0100
+++ b/drivers/input/joystick/maplecontrol.c 2008-02-16 21:41:52.0 
+
@@ -0,0 +1,246 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Porting to 2.6 by Adrian McMenamin, copyright 2008
+ */
+
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/input.h
+#include linux/module.h
+#include linux/init.h
+#include linux/timer.h
+#include linux/maple.h
+#include asm/mach/maple.h
+
+MODULE_AUTHOR(YAEGASHI Takeshi [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(SEGA Dreamcast controller driver);
+MODULE_LICENSE(GPL);
+
+struct dc_pad {
+   struct input_dev *dev;
+   struct maple_device *mdev;
+   int open;
+};
+
+static void dc_pad_callback_idle(struct mapleq *mq)
+{
+}
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq-dev;
+   struct dc_pad *pad = mapledev-private_data;
+   struct input_dev *dev = pad-dev;
+   unsigned char *res = mq-recvbuf;
+
+   buttons = ~*(unsigned short *)(res+8);
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons  0x0010 ? -1:0) + (buttons  0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons  0x0040 ? -1:0) + (buttons  0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons  0x1000 ? -1:0) + (buttons  0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons  0x4000 ? -1:0) + (buttons  0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons  0x0001);
+   input_report_key(dev, BTN_B,  buttons  0x0002);
+   input_report_key(dev, BTN_A,  buttons  0x0004);
+   input_report_key(dev, BTN_START,  buttons  0x0008);
+   input_report_key(dev, BTN_Z,  buttons  0x0100);
+   input_report_key(dev, BTN_Y,  buttons  0x0200);
+   input_report_key(dev, BTN_X,  buttons  0x0400);
+   input_report_key(dev, BTN_SELECT, buttons  0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_open(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev-private;
+   if (!pad-open)
+   maple_getcond_callback(pad-mdev, dc_pad_callback, HZ/50,
+   MAPLE_FUNC_CONTROLLER);
+   pad-open++;
+   return 0;
+
+}
+
+static void dc_pad_close(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev-private;
+
+   pad-open--;
+   if (pad-open)
+   return;
+
+   /* Almost never call something that does nothing */
+   maple_getcond_callback(pad-mdev, dc_pad_callback_idle, 0x,
+   MAPLE_FUNC_CONTROLLER);
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev-devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+
+   const short btn_bit[32] = {
+   BTN_C, BTN_B, BTN_A, BTN_START, -1, -1

Re: [PATCH 1/2] SH/Dreamcast - joystick (Control pad)

2008-02-11 Thread Adrian McMenamin
On Mon, February 11, 2008 4:25 pm, Dmitry Torokhov wrote:
> On Mon, Feb 11, 2008 at 11:19:22AM -0500, Mike Frysinger wrote:
>> On Monday 11 February 2008, Adrian McMenamin wrote:
>> > On Mon, February 11, 2008 12:22 am, Mike Frysinger wrote:
>> > > no remove function ?  looks like the probe() forces a connect, but
>> > > there's no remove() to force a disconnect ...
>> >
>> > Removing these devices (or any other plugged directly into the maple
>> > ports) is a quick way to destroy your Dreamcast: hence they were never
>> > implemented I guess. But there is no convincing reason for the
>> software
>> > not doing so, I suppose. I can just put in comments about it.
>>
>> and not allow the driver to be built as a module until the comments
>> become
>> code ...
>> -mike
>
> Normally drivers can be unbound from devices via sysfs even if they are
> built-in, not modules.
>
>
I meant comments about not being so silly as to start plugging maple
devices in and out of the ports on the DC. I understand the point about
the code and will rework appropriately.

All I wanted to do is take somebody's old code and get it to work on 2.6.
But nothing is that simple :-/

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] SH/Dreamcast - joystick (Control pad)

2008-02-11 Thread Adrian McMenamin
On Mon, February 11, 2008 12:22 am, Mike Frysinger wrote:
>
> no remove function ?  looks like the probe() forces a connect, but there's
> no
> remove() to force a disconnect ...


Removing these devices (or any other plugged directly into the maple
ports) is a quick way to destroy your Dreamcast: hence they were never
implemented I guess. But there is no convincing reason for the software
not doing so, I suppose. I can just put in comments about it.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] SH/Dreamcast - joystick (Control pad)

2008-02-11 Thread Adrian McMenamin
On Mon, February 11, 2008 4:25 pm, Dmitry Torokhov wrote:
 On Mon, Feb 11, 2008 at 11:19:22AM -0500, Mike Frysinger wrote:
 On Monday 11 February 2008, Adrian McMenamin wrote:
  On Mon, February 11, 2008 12:22 am, Mike Frysinger wrote:
   no remove function ?  looks like the probe() forces a connect, but
   there's no remove() to force a disconnect ...
 
  Removing these devices (or any other plugged directly into the maple
  ports) is a quick way to destroy your Dreamcast: hence they were never
  implemented I guess. But there is no convincing reason for the
 software
  not doing so, I suppose. I can just put in comments about it.

 and not allow the driver to be built as a module until the comments
 become
 code ...
 -mike

 Normally drivers can be unbound from devices via sysfs even if they are
 built-in, not modules.


I meant comments about not being so silly as to start plugging maple
devices in and out of the ports on the DC. I understand the point about
the code and will rework appropriately.

All I wanted to do is take somebody's old code and get it to work on 2.6.
But nothing is that simple :-/

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] SH/Dreamcast - joystick (Control pad)

2008-02-11 Thread Adrian McMenamin
On Mon, February 11, 2008 12:22 am, Mike Frysinger wrote:

 no remove function ?  looks like the probe() forces a connect, but there's
 no
 remove() to force a disconnect ...


Removing these devices (or any other plugged directly into the maple
ports) is a quick way to destroy your Dreamcast: hence they were never
implemented I guess. But there is no convincing reason for the software
not doing so, I suppose. I can just put in comments about it.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] SH/Dreamcast - joystick (controlpad)

2008-02-10 Thread Adrian McMenamin
Changes to the Kconfig and Makefile needed to build the Maple controlpad
code.

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>
==

diff --combined drivers/input/joystick/Kconfig
index 7c662ee,7c662ee..3566fa2
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@@ -282,4 -282,4 +282,17 @@@ config JOYSTICK_XPAD_LED
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
  
+config JOYSTICK_MAPLE
+   tristate "Dreamcast control pad"
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+Say Y here if you have a SEGA Dreamcast and want to use your
+controller.
+
+Most Dreamcast users will say Y.
+
+To compile this as a module choose M here: the
+module will be called maplecontrol.
+
  endif
diff --combined drivers/input/joystick/Makefile
index e855abb,e855abb..62929ef
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
@@@ -27,5 -27,5 +27,6 @@@ obj-$(CONFIG_JOYSTICK_TURBOGRAFX) += tu
  obj-$(CONFIG_JOYSTICK_TWIDJOY)+= twidjoy.o
  obj-$(CONFIG_JOYSTICK_WARRIOR)+= warrior.o
  obj-$(CONFIG_JOYSTICK_XPAD)   += xpad.o
+ obj-$(CONFIG_JOYSTICK_MAPLE)  += maplecontrol.o
  
  obj-$(CONFIG_JOYSTICK_IFORCE) += iforce/





--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] SH/Dreamcast - joystick (Control pad)

2008-02-10 Thread Adrian McMenamin
Adds support for the Dreamcast control pad.

This is a port of the 2.4 driver (never in mainline) by Yaegashi
Takeshi.

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>

==

--- /dev/null   2007-10-16 19:02:41.0 +0100
+++ drivers/input/joystick/maplecontrol.c   2008-02-10 22:50:17.0 
+
@@ -0,0 +1,215 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Ported to 2.6 by Adrian McMenamin, 2008
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("YAEGASHI Takeshi <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("SEGA Dreamcast controller driver");
+MODULE_LICENSE("GPL");
+
+struct dc_pad {
+   struct input_dev *dev;
+   int open;
+};
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq->dev;
+   struct dc_pad *pad = mapledev->private_data;
+   struct input_dev *dev = pad->dev;
+   unsigned char *res = mq->recvbuf;
+
+   buttons = ~*(unsigned short *)(res+8);
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons & 0x0010 ? -1:0) + (buttons & 0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons & 0x0040 ? -1:0) + (buttons & 0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons & 0x1000 ? -1:0) + (buttons & 0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons & 0x4000 ? -1:0) + (buttons & 0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons & 0x0001);
+   input_report_key(dev, BTN_B,  buttons & 0x0002);
+   input_report_key(dev, BTN_A,  buttons & 0x0004);
+   input_report_key(dev, BTN_START,  buttons & 0x0008);
+   input_report_key(dev, BTN_Z,  buttons & 0x0100);
+   input_report_key(dev, BTN_Y,  buttons & 0x0200);
+   input_report_key(dev, BTN_X,  buttons & 0x0400);
+   input_report_key(dev, BTN_SELECT, buttons & 0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_open(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev->private;
+   pad->open++;
+   return 0;
+}
+
+static void dc_pad_close(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev->private;
+   pad->open--;
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+
+   const short btn_bit[32] = {
+   BTN_C, BTN_B, BTN_A, BTN_START, -1, -1, -1, -1,
+   BTN_Z, BTN_Y, BTN_X, BTN_SELECT, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   const short abs_bit[32] = {
+   -1, -1, -1, -1, ABS_HAT0Y, ABS_HAT0Y, ABS_HAT0X, ABS_HAT0X,
+   -1, -1, -1, -1, ABS_HAT1Y, ABS_HAT1Y, ABS_HAT1X, ABS_HAT1X,
+   ABS_GAS, ABS_BRAKE, ABS_X, ABS_Y, ABS_RX, ABS_RY, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL);
+   if (!pad)
+   return -ENOMEM;
+
+   dev = input_allocate_device();
+   if (!dev) {
+   kfree(pad);
+   return -ENOMEM;
+   }
+
+   pad->dev = dev;
+
+   mdev->private_data = pad;
+
+   for (i = 0; i < 32; i++)
+   if (data & (1<= 0)
+   pad->dev->keybit[BTN_JOYSTICK/32] |= BIT(btn_bit[i]);
+
+   if (pad->dev->keybit[BTN_JOYSTICK/32])
+   pad->dev->evbit[0] |= BIT(EV_KEY);
+
+   for (i = 0; i < 32; i++)
+   if (data&(1<= 0)
+   pad->dev->absbit[0] |= BIT(abs_bit[i]);
+
+   if (pad->dev->absbit[0])
+   pad->dev->evbit[0] |= BIT(EV_ABS);
+
+   for (i = ABS_X; i <= ABS_BRAKE; i++) {
+   pad->dev->absmax[i] = 255;
+   pad->dev->absmin[i] = 0;
+   pad->dev->absfuzz[i] = 0;
+   pad->dev->absflat[i] = 0;
+   }
+
+   for (i = ABS_HAT0X; i <= ABS_HAT3Y; i++) {
+   pad->dev->absmax[i] = 1;
+   pad->dev->absmin[i] = -1;
+   pad->dev->absfuzz[i] = 0;
+   pad->dev->absflat[i] = 0;
+   }
+
+   pad->

[PATCH 1/2] SH/Dreamcast - joystick (Control pad)

2008-02-10 Thread Adrian McMenamin
Adds support for the Dreamcast control pad.

This is a port of the 2.4 driver (never in mainline) by Yaegashi
Takeshi.

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]

==

--- /dev/null   2007-10-16 19:02:41.0 +0100
+++ drivers/input/joystick/maplecontrol.c   2008-02-10 22:50:17.0 
+
@@ -0,0 +1,215 @@
+/*
+ * SEGA Dreamcast controller driver
+ * Based on drivers/usb/iforce.c
+ *
+ * Copyright Yaegashi Takeshi, 2001
+ * Ported to 2.6 by Adrian McMenamin, 2008
+ */
+
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/input.h
+#include linux/module.h
+#include linux/init.h
+#include linux/timer.h
+#include linux/maple.h
+#include asm/mach/maple.h
+
+MODULE_AUTHOR(YAEGASHI Takeshi [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(SEGA Dreamcast controller driver);
+MODULE_LICENSE(GPL);
+
+struct dc_pad {
+   struct input_dev *dev;
+   int open;
+};
+
+static void dc_pad_callback(struct mapleq *mq)
+{
+   unsigned short buttons;
+   struct maple_device *mapledev = mq-dev;
+   struct dc_pad *pad = mapledev-private_data;
+   struct input_dev *dev = pad-dev;
+   unsigned char *res = mq-recvbuf;
+
+   buttons = ~*(unsigned short *)(res+8);
+
+   input_report_abs(dev, ABS_HAT0Y,
+(buttons  0x0010 ? -1:0) + (buttons  0x0020 ? 1:0));
+   input_report_abs(dev, ABS_HAT0X,
+(buttons  0x0040 ? -1:0) + (buttons  0x0080 ? 1:0));
+   input_report_abs(dev, ABS_HAT1Y,
+(buttons  0x1000 ? -1:0) + (buttons  0x2000 ? 1:0));
+   input_report_abs(dev, ABS_HAT1X,
+(buttons  0x4000 ? -1:0) + (buttons  0x8000 ? 1:0));
+
+   input_report_key(dev, BTN_C,  buttons  0x0001);
+   input_report_key(dev, BTN_B,  buttons  0x0002);
+   input_report_key(dev, BTN_A,  buttons  0x0004);
+   input_report_key(dev, BTN_START,  buttons  0x0008);
+   input_report_key(dev, BTN_Z,  buttons  0x0100);
+   input_report_key(dev, BTN_Y,  buttons  0x0200);
+   input_report_key(dev, BTN_X,  buttons  0x0400);
+   input_report_key(dev, BTN_SELECT, buttons  0x0800);
+
+   input_report_abs(dev, ABS_GAS,   res[10]);
+   input_report_abs(dev, ABS_BRAKE, res[11]);
+   input_report_abs(dev, ABS_X, res[12]);
+   input_report_abs(dev, ABS_Y, res[13]);
+   input_report_abs(dev, ABS_RX,res[14]);
+   input_report_abs(dev, ABS_RY,res[15]);
+}
+
+static int dc_pad_open(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev-private;
+   pad-open++;
+   return 0;
+}
+
+static void dc_pad_close(struct input_dev *dev)
+{
+   struct dc_pad *pad = dev-private;
+   pad-open--;
+}
+
+static int dc_pad_connect(struct maple_device *mdev)
+{
+   int i, error;
+   unsigned long data = be32_to_cpu(mdev-devinfo.function_data[0]);
+   struct dc_pad *pad;
+   struct input_dev *dev;
+
+   const short btn_bit[32] = {
+   BTN_C, BTN_B, BTN_A, BTN_START, -1, -1, -1, -1,
+   BTN_Z, BTN_Y, BTN_X, BTN_SELECT, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   const short abs_bit[32] = {
+   -1, -1, -1, -1, ABS_HAT0Y, ABS_HAT0Y, ABS_HAT0X, ABS_HAT0X,
+   -1, -1, -1, -1, ABS_HAT1Y, ABS_HAT1Y, ABS_HAT1X, ABS_HAT1X,
+   ABS_GAS, ABS_BRAKE, ABS_X, ABS_Y, ABS_RX, ABS_RY, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   };
+
+   pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL);
+   if (!pad)
+   return -ENOMEM;
+
+   dev = input_allocate_device();
+   if (!dev) {
+   kfree(pad);
+   return -ENOMEM;
+   }
+
+   pad-dev = dev;
+
+   mdev-private_data = pad;
+
+   for (i = 0; i  32; i++)
+   if (data  (1i)  btn_bit[i] = 0)
+   pad-dev-keybit[BTN_JOYSTICK/32] |= BIT(btn_bit[i]);
+
+   if (pad-dev-keybit[BTN_JOYSTICK/32])
+   pad-dev-evbit[0] |= BIT(EV_KEY);
+
+   for (i = 0; i  32; i++)
+   if (data(1i)  abs_bit[i] = 0)
+   pad-dev-absbit[0] |= BIT(abs_bit[i]);
+
+   if (pad-dev-absbit[0])
+   pad-dev-evbit[0] |= BIT(EV_ABS);
+
+   for (i = ABS_X; i = ABS_BRAKE; i++) {
+   pad-dev-absmax[i] = 255;
+   pad-dev-absmin[i] = 0;
+   pad-dev-absfuzz[i] = 0;
+   pad-dev-absflat[i] = 0;
+   }
+
+   for (i = ABS_HAT0X; i = ABS_HAT3Y; i++) {
+   pad-dev-absmax[i] = 1;
+   pad-dev-absmin[i] = -1;
+   pad-dev-absfuzz[i] = 0;
+   pad-dev-absflat[i] = 0;
+   }
+
+   pad-dev-private = pad;
+   pad-dev-open = dc_pad_open;
+   pad-dev-close = dc_pad_close;
+   pad-dev-event = NULL;
+   pad-dev-dev.parent = mdev-dev;
+   pad-dev-name = mdev

[PATCH 2/2] SH/Dreamcast - joystick (controlpad)

2008-02-10 Thread Adrian McMenamin
Changes to the Kconfig and Makefile needed to build the Maple controlpad
code.

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]
==

diff --combined drivers/input/joystick/Kconfig
index 7c662ee,7c662ee..3566fa2
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@@ -282,4 -282,4 +282,17 @@@ config JOYSTICK_XPAD_LED
  This option enables support for the LED which surrounds the Big X on
  XBox 360 controller.
  
+config JOYSTICK_MAPLE
+   tristate Dreamcast control pad
+   depends on SH_DREAMCAST
+   select MAPLE
+   help
+Say Y here if you have a SEGA Dreamcast and want to use your
+controller.
+
+Most Dreamcast users will say Y.
+
+To compile this as a module choose M here: the
+module will be called maplecontrol.
+
  endif
diff --combined drivers/input/joystick/Makefile
index e855abb,e855abb..62929ef
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
@@@ -27,5 -27,5 +27,6 @@@ obj-$(CONFIG_JOYSTICK_TURBOGRAFX) += tu
  obj-$(CONFIG_JOYSTICK_TWIDJOY)+= twidjoy.o
  obj-$(CONFIG_JOYSTICK_WARRIOR)+= warrior.o
  obj-$(CONFIG_JOYSTICK_XPAD)   += xpad.o
+ obj-$(CONFIG_JOYSTICK_MAPLE)  += maplecontrol.o
  
  obj-$(CONFIG_JOYSTICK_IFORCE) += iforce/





--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] 8139too fix for Dreamcast

2008-02-08 Thread Adrian McMenamin
Updates the 8139too driver to work with recently added
(a724605cb7a66d423a494a395f9a8ba871b8a1eb) declared coherent memory
patch for the Dreamcast.

Jeff - I am assuming you are still the maintainer and I guess Paul
should also ack this as it is SH related.

Signed-off-by: Adrian McMenamin <[EMAIL PROTECTED]>

-


diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index d373545..80f1cce 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -168,7 +168,7 @@ static int debug = -1;
  * Warning: 64K ring has hardware issues and may lock up.
  */
 #if defined(CONFIG_SH_DREAMCAST)
-#define RX_BUF_IDX 1   /* 16K ring */
+#define RX_BUF_IDX 0   /* 8K ring */
 #else
 #define RX_BUF_IDX 2   /* 32K ring */
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] 8139too fix for Dreamcast

2008-02-08 Thread Adrian McMenamin
Updates the 8139too driver to work with recently added
(a724605cb7a66d423a494a395f9a8ba871b8a1eb) declared coherent memory
patch for the Dreamcast.

Jeff - I am assuming you are still the maintainer and I guess Paul
should also ack this as it is SH related.

Signed-off-by: Adrian McMenamin [EMAIL PROTECTED]

-


diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index d373545..80f1cce 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -168,7 +168,7 @@ static int debug = -1;
  * Warning: 64K ring has hardware issues and may lock up.
  */
 #if defined(CONFIG_SH_DREAMCAST)
-#define RX_BUF_IDX 1   /* 16K ring */
+#define RX_BUF_IDX 0   /* 8K ring */
 #else
 #define RX_BUF_IDX 2   /* 32K ring */
 #endif
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] - SH/Dreamcast - additional patch to maple.h

2008-02-06 Thread Adrian McMenamin
This patch removes the now unneeded registration check variable from
struct maple_device. (This patch assumes the include/linux/maple.h file
has already been patched for whitespace errors by
http://lkml.org/lkml/2008/2/6/327)

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>


diff --git a/include/linux/maple.h b/include/linux/maple.h
index 1334062..3f01e2b 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -56,7 +56,6 @@ struct maple_device {
unsigned char port, unit;
char product_name[32];
char product_licence[64];
-   int registered;
struct device dev;
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] - SH/Dreamcast - fix maple bus bugs

2008-02-06 Thread Adrian McMenamin
Replacement second-in-series patch:

This patch fixes up memory leaks and, by delaying initialisation, makes
device detection more robust.

It also makes clearer the difference between struct maple_device and
struct device, as well as cleaning up the interrupt request code
(without changing its function in any way).

Also now removes redundant registration checking.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>



diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 3f341dc..fbca7f8 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin");
 MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
@@ -52,7 +53,7 @@ static struct device maple_bus;
 static int subdevice_map[MAPLE_PORTS];
 static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
 static unsigned long maple_pnp_time;
-static int started, scanning, liststatus;
+static int started, scanning, liststatus, realscan;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
@@ -72,7 +73,6 @@ int maple_driver_register(struct device_driver *drv)
drv->bus = _bus_type;
return driver_register(drv);
 }
-
 EXPORT_SYMBOL_GPL(maple_driver_register);
 
 /* set hardware registers to enable next round of dma */
@@ -94,15 +94,14 @@ static void maplebus_dma_reset(void)
  * @function: the function code for the device
  */
 void maple_getcond_callback(struct maple_device *dev,
-   void (*callback) (struct mapleq * mq),
-   unsigned long interval, unsigned long function)
+   void (*callback) (struct mapleq *mq),
+   unsigned long interval, unsigned long function)
 {
dev->callback = callback;
dev->interval = interval;
dev->function = cpu_to_be32(function);
dev->when = jiffies;
 }
-
 EXPORT_SYMBOL_GPL(maple_getcond_callback);
 
 static int maple_dma_done(void)
@@ -112,10 +111,19 @@ static int maple_dma_done(void)
 
 static void maple_release_device(struct device *dev)
 {
-   if (dev->type) {
-   kfree(dev->type->name);
-   kfree(dev->type);
+   struct maple_device *mdev;
+   struct mapleq *mq;
+   if (!dev)
+   return;
+   mdev = to_maple_dev(dev);
+   mq = mdev->mq;
+   if (mq) {
+   if (mq->recvbufdcsp)
+   kmem_cache_free(maple_queue_cache, mq->recvbufdcsp);
+   kfree(mq);
+   mq = NULL;
}
+   kfree(mdev);
 }
 
 /**
@@ -128,10 +136,9 @@ void maple_add_packet(struct mapleq *mq)
list_add(>list, _waitq);
mutex_unlock(_list_lock);
 }
-
 EXPORT_SYMBOL_GPL(maple_add_packet);
 
-static struct mapleq *maple_allocq(struct maple_device *dev)
+static struct mapleq *maple_allocq(struct maple_device *mdev)
 {
struct mapleq *mq;
 
@@ -139,7 +146,7 @@ static struct mapleq *maple_allocq(struct maple_device *dev)
if (!mq)
return NULL;
 
-   mq->dev = dev;
+   mq->dev = mdev;
mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
if (!mq->recvbuf) {
@@ -152,22 +159,24 @@ static struct mapleq *maple_allocq(struct maple_device 
*dev)
 
 static struct maple_device *maple_alloc_dev(int port, int unit)
 {
-   struct maple_device *dev;
+   struct maple_device *mdev;
 
-   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-   if (!dev)
+   mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+   if (!mdev)
return NULL;
 
-   dev->port = port;
-   dev->unit = unit;
-   dev->mq = maple_allocq(dev);
+   mdev->port = port;
+   mdev->unit = unit;
+   mdev->mq = maple_allocq(mdev);
 
-   if (!dev->mq) {
-   kfree(dev);
+   if (!mdev->mq) {
+   kfree(mdev);
return NULL;
}
-
-   return dev;
+   mdev->dev.bus = _bus_type;
+   mdev->dev.parent = _bus;
+   mdev->function = 0;
+   return mdev;
 }
 
 static void maple_free_dev(struct maple_device *mdev)
@@ -175,7 +184,9 @@ static void maple_free_dev(struct maple_device *mdev)
if (!mdev)
return;
if (mdev->mq) {
-   kmem_cache_free(maple_queue_cache, mdev->mq->recvbufdcsp);
+   if (mdev->mq->recvbufdcsp)
+   kmem_cache_free(maple_queue_cache,
+   mdev->mq->recvbufdcsp);
kfree(mdev->mq);
}
kfree(mdev);
@@ -259,80 +270,89 @@ static void maple_detach_driver(struct maple_device *mdev)
mdev->driver->disconnect(mdev);
   

Re: [PATCH 2/2] - SH/Dreamcast - fix maple bus bugs

2008-02-06 Thread Adrian McMenamin

On Wed, 2008-02-06 at 15:01 -0800, Greg KH wrote:
> On Wed, Feb 06, 2008 at 10:53:51PM +0000, Adrian McMenamin wrote:
> > -   dev->function = function;
> > -   dev->dev.bus = _bus_type;
> > -   dev->dev.parent = _bus;
> > -   dev->dev.release = _release_device;
> > -   retval = device_register(>dev);
> > -   if (retval) {
> > -   printk(KERN_INFO
> > -  "Maple bus: Attempt to register device (%x, %x) 
> > failed.\n",
> > -  dev->port, dev->unit);
> > -   maple_free_dev(dev);
> > +   mdev->function = function;
> > +   mdev->dev.release = _release_device;
> > +   if (mdev->registered == 0) {
> > +   retval = device_register(>dev);
> > +   if (retval) {
> > +   printk(KERN_INFO
> > +   "Maple bus: Attempt to register device"
> > +   " (%x, %x) failed.\n",
> > +   mdev->port, mdev->unit);
> > +   maple_free_dev(mdev);
> > +   mdev = NULL;
> > +   return;
> > +   }
> > +   mdev->registered = 1;
> > }
> > -   dev->registered = 1;
> 
> I think you are still papering over the real problem here of trying to
> register a device twice.  That's something you should never be doing,
> and your bus walking logic must be incorrect...
> 
I just left that in as a sanity check. It should never be acted on. I
can remove it if you prefer.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] - SH/Dreamcast - fix maple bus bugs

2008-02-06 Thread Adrian McMenamin
This patch fixes up memory leaks and, by delaying initialisation, makes
device detection more robust.

It also makes clearer the difference between struct maple_device and
struct device, as well as cleaning up the interrupt request code
(without changing its function in any way).

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>


diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 3f341dc..60eeb92 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin");
 MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
@@ -52,7 +53,7 @@ static struct device maple_bus;
 static int subdevice_map[MAPLE_PORTS];
 static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
 static unsigned long maple_pnp_time;
-static int started, scanning, liststatus;
+static int started, scanning, liststatus, realscan;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
@@ -72,7 +73,6 @@ int maple_driver_register(struct device_driver *drv)
drv->bus = _bus_type;
return driver_register(drv);
 }
-
 EXPORT_SYMBOL_GPL(maple_driver_register);
 
 /* set hardware registers to enable next round of dma */
@@ -94,15 +94,14 @@ static void maplebus_dma_reset(void)
  * @function: the function code for the device
  */
 void maple_getcond_callback(struct maple_device *dev,
-   void (*callback) (struct mapleq * mq),
-   unsigned long interval, unsigned long function)
+   void (*callback) (struct mapleq *mq),
+   unsigned long interval, unsigned long function)
 {
dev->callback = callback;
dev->interval = interval;
dev->function = cpu_to_be32(function);
dev->when = jiffies;
 }
-
 EXPORT_SYMBOL_GPL(maple_getcond_callback);
 
 static int maple_dma_done(void)
@@ -112,10 +111,19 @@ static int maple_dma_done(void)
 
 static void maple_release_device(struct device *dev)
 {
-   if (dev->type) {
-   kfree(dev->type->name);
-   kfree(dev->type);
+   struct maple_device *mdev;
+   struct mapleq *mq;
+   if (!dev)
+   return;
+   mdev = to_maple_dev(dev);
+   mq = mdev->mq;
+   if (mq) {
+   if (mq->recvbufdcsp)
+   kmem_cache_free(maple_queue_cache, mq->recvbufdcsp);
+   kfree(mq);
+   mq = NULL;
}
+   kfree(mdev);
 }
 
 /**
@@ -128,10 +136,9 @@ void maple_add_packet(struct mapleq *mq)
list_add(>list, _waitq);
mutex_unlock(_list_lock);
 }
-
 EXPORT_SYMBOL_GPL(maple_add_packet);
 
-static struct mapleq *maple_allocq(struct maple_device *dev)
+static struct mapleq *maple_allocq(struct maple_device *mdev)
 {
struct mapleq *mq;
 
@@ -139,7 +146,7 @@ static struct mapleq *maple_allocq(struct maple_device *dev)
if (!mq)
return NULL;
 
-   mq->dev = dev;
+   mq->dev = mdev;
mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
if (!mq->recvbuf) {
@@ -152,22 +159,24 @@ static struct mapleq *maple_allocq(struct maple_device 
*dev)
 
 static struct maple_device *maple_alloc_dev(int port, int unit)
 {
-   struct maple_device *dev;
+   struct maple_device *mdev;
 
-   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-   if (!dev)
+   mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+   if (!mdev)
return NULL;
 
-   dev->port = port;
-   dev->unit = unit;
-   dev->mq = maple_allocq(dev);
+   mdev->port = port;
+   mdev->unit = unit;
+   mdev->mq = maple_allocq(mdev);
 
-   if (!dev->mq) {
-   kfree(dev);
+   if (!mdev->mq) {
+   kfree(mdev);
return NULL;
}
-
-   return dev;
+   mdev->dev.bus = _bus_type;
+   mdev->dev.parent = _bus;
+   mdev->function = 0;
+   return mdev;
 }
 
 static void maple_free_dev(struct maple_device *mdev)
@@ -175,7 +184,9 @@ static void maple_free_dev(struct maple_device *mdev)
if (!mdev)
return;
if (mdev->mq) {
-   kmem_cache_free(maple_queue_cache, mdev->mq->recvbufdcsp);
+   if (mdev->mq->recvbufdcsp)
+   kmem_cache_free(maple_queue_cache,
+   mdev->mq->recvbufdcsp);
kfree(mdev->mq);
}
kfree(mdev);
@@ -259,80 +270,93 @@ static void maple_detach_driver(struct maple_device *mdev)
mdev->driver->disconnect(mdev);
}
mdev->driver = NULL;
-   if (mdev->registered) {
-

[PATCH 1/2] - SH/Dreamcast - fix maple bus bugs

2008-02-06 Thread Adrian McMenamin
This patch is fundamentally about fixing up the whitespace problems introduced 
by my previous patch (that brought the code into mainline). A second patch will 
follow that will fix memory leaks. The two need to be applied sequentially.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>

---

diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 37c0bf7..3f341dc 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -56,8 +56,8 @@ static int started, scanning, liststatus;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
-   int port;
-   int unit;
+   int port;
+   int unit;
 };
 
 /**
@@ -67,22 +67,23 @@ struct maple_device_specify {
  */
 int maple_driver_register(struct device_driver *drv)
 {
-   if (!drv)
-   return -EINVAL;
-   drv->bus = _bus_type;
-   return driver_register(drv);
+   if (!drv)
+   return -EINVAL;
+   drv->bus = _bus_type;
+   return driver_register(drv);
 }
+
 EXPORT_SYMBOL_GPL(maple_driver_register);
 
 /* set hardware registers to enable next round of dma */
 static void maplebus_dma_reset(void)
 {
-   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
-   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
-   ctrl_outl(1, MAPLE_TRIGTYPE);
-   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
-   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
-   ctrl_outl(1, MAPLE_ENABLE);
+   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
+   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
+   ctrl_outl(1, MAPLE_TRIGTYPE);
+   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
+   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
+   ctrl_outl(1, MAPLE_ENABLE);
 }
 
 /**
@@ -93,27 +94,28 @@ static void maplebus_dma_reset(void)
  * @function: the function code for the device
  */
 void maple_getcond_callback(struct maple_device *dev,
-   void (*callback) (struct mapleq * mq),
-   unsigned long interval, unsigned long function)
+   void (*callback) (struct mapleq * mq),
+   unsigned long interval, unsigned long function)
 {
-   dev->callback = callback;
-   dev->interval = interval;
-   dev->function = cpu_to_be32(function);
-   dev->when = jiffies;
+   dev->callback = callback;
+   dev->interval = interval;
+   dev->function = cpu_to_be32(function);
+   dev->when = jiffies;
 }
+
 EXPORT_SYMBOL_GPL(maple_getcond_callback);
 
 static int maple_dma_done(void)
 {
-   return (ctrl_inl(MAPLE_STATE) & 1) == 0;
+   return (ctrl_inl(MAPLE_STATE) & 1) == 0;
 }
 
 static void maple_release_device(struct device *dev)
 {
-   if (dev->type) {
-   kfree(dev->type->name);
-   kfree(dev->type);
-   }
+   if (dev->type) {
+   kfree(dev->type->name);
+   kfree(dev->type);
+   }
 }
 
 /**
@@ -122,60 +124,61 @@ static void maple_release_device(struct device *dev)
  */
 void maple_add_packet(struct mapleq *mq)
 {
-   mutex_lock(_list_lock);
-   list_add(>list, _waitq);
-   mutex_unlock(_list_lock);
+   mutex_lock(_list_lock);
+   list_add(>list, _waitq);
+   mutex_unlock(_list_lock);
 }
+
 EXPORT_SYMBOL_GPL(maple_add_packet);
 
 static struct mapleq *maple_allocq(struct maple_device *dev)
 {
-   struct mapleq *mq;
+   struct mapleq *mq;
 
-   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
-   if (!mq)
-   return NULL;
+   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
+   if (!mq)
+   return NULL;
 
-   mq->dev = dev;
-   mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
-   mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
-   if (!mq->recvbuf) {
-   kfree(mq);
-   return NULL;
-   }
+   mq->dev = dev;
+   mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
+   mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
+   if (!mq->recvbuf) {
+   kfree(mq);
+   return NULL;
+   }
 
-   return mq;
+   return mq;
 }
 
 static struct maple_device *maple_alloc_dev(int port, int unit)
 {
-   struct maple_device *dev;
+   struct maple_device *dev;
 
-   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-   if (!dev)
-   return NULL;
+   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+   if (!dev)
+   return NULL;
 
-   dev->port = port;
-   dev->unit = unit;
-   dev->mq = maple_allocq(dev);
+   dev->port = port;
+   dev->unit = unit;
+   dev->mq = maple_allocq(dev);
 
-   if (!dev->mq) {
-   kfree(dev);
-   return NU

[PATCH 1/2] - SH/Dreamcast - fix maple bus bugs

2008-02-06 Thread Adrian McMenamin
This patch is fundamentally about fixing up the whitespace problems introduced 
by my previous patch (that brought the code into mainline). A second patch will 
follow that will fix memory leaks. The two need to be applied sequentially.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

---

diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 37c0bf7..3f341dc 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -56,8 +56,8 @@ static int started, scanning, liststatus;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
-   int port;
-   int unit;
+   int port;
+   int unit;
 };
 
 /**
@@ -67,22 +67,23 @@ struct maple_device_specify {
  */
 int maple_driver_register(struct device_driver *drv)
 {
-   if (!drv)
-   return -EINVAL;
-   drv-bus = maple_bus_type;
-   return driver_register(drv);
+   if (!drv)
+   return -EINVAL;
+   drv-bus = maple_bus_type;
+   return driver_register(drv);
 }
+
 EXPORT_SYMBOL_GPL(maple_driver_register);
 
 /* set hardware registers to enable next round of dma */
 static void maplebus_dma_reset(void)
 {
-   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
-   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
-   ctrl_outl(1, MAPLE_TRIGTYPE);
-   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
-   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
-   ctrl_outl(1, MAPLE_ENABLE);
+   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
+   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
+   ctrl_outl(1, MAPLE_TRIGTYPE);
+   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
+   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
+   ctrl_outl(1, MAPLE_ENABLE);
 }
 
 /**
@@ -93,27 +94,28 @@ static void maplebus_dma_reset(void)
  * @function: the function code for the device
  */
 void maple_getcond_callback(struct maple_device *dev,
-   void (*callback) (struct mapleq * mq),
-   unsigned long interval, unsigned long function)
+   void (*callback) (struct mapleq * mq),
+   unsigned long interval, unsigned long function)
 {
-   dev-callback = callback;
-   dev-interval = interval;
-   dev-function = cpu_to_be32(function);
-   dev-when = jiffies;
+   dev-callback = callback;
+   dev-interval = interval;
+   dev-function = cpu_to_be32(function);
+   dev-when = jiffies;
 }
+
 EXPORT_SYMBOL_GPL(maple_getcond_callback);
 
 static int maple_dma_done(void)
 {
-   return (ctrl_inl(MAPLE_STATE)  1) == 0;
+   return (ctrl_inl(MAPLE_STATE)  1) == 0;
 }
 
 static void maple_release_device(struct device *dev)
 {
-   if (dev-type) {
-   kfree(dev-type-name);
-   kfree(dev-type);
-   }
+   if (dev-type) {
+   kfree(dev-type-name);
+   kfree(dev-type);
+   }
 }
 
 /**
@@ -122,60 +124,61 @@ static void maple_release_device(struct device *dev)
  */
 void maple_add_packet(struct mapleq *mq)
 {
-   mutex_lock(maple_list_lock);
-   list_add(mq-list, maple_waitq);
-   mutex_unlock(maple_list_lock);
+   mutex_lock(maple_list_lock);
+   list_add(mq-list, maple_waitq);
+   mutex_unlock(maple_list_lock);
 }
+
 EXPORT_SYMBOL_GPL(maple_add_packet);
 
 static struct mapleq *maple_allocq(struct maple_device *dev)
 {
-   struct mapleq *mq;
+   struct mapleq *mq;
 
-   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
-   if (!mq)
-   return NULL;
+   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
+   if (!mq)
+   return NULL;
 
-   mq-dev = dev;
-   mq-recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
-   mq-recvbuf = (void *) P2SEGADDR(mq-recvbufdcsp);
-   if (!mq-recvbuf) {
-   kfree(mq);
-   return NULL;
-   }
+   mq-dev = dev;
+   mq-recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
+   mq-recvbuf = (void *) P2SEGADDR(mq-recvbufdcsp);
+   if (!mq-recvbuf) {
+   kfree(mq);
+   return NULL;
+   }
 
-   return mq;
+   return mq;
 }
 
 static struct maple_device *maple_alloc_dev(int port, int unit)
 {
-   struct maple_device *dev;
+   struct maple_device *dev;
 
-   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-   if (!dev)
-   return NULL;
+   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+   if (!dev)
+   return NULL;
 
-   dev-port = port;
-   dev-unit = unit;
-   dev-mq = maple_allocq(dev);
+   dev-port = port;
+   dev-unit = unit;
+   dev-mq = maple_allocq(dev);
 
-   if (!dev-mq) {
-   kfree(dev);
-   return NULL;
-   }
+   if (!dev-mq) {
+   kfree(dev);
+   return NULL;
+   }
 
-   return dev

[PATCH 2/2] - SH/Dreamcast - fix maple bus bugs

2008-02-06 Thread Adrian McMenamin
This patch fixes up memory leaks and, by delaying initialisation, makes
device detection more robust.

It also makes clearer the difference between struct maple_device and
struct device, as well as cleaning up the interrupt request code
(without changing its function in any way).

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]


diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 3f341dc..60eeb92 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -30,6 +30,7 @@
 #include asm/mach/dma.h
 #include asm/mach/sysasic.h
 #include asm/mach/maple.h
+#include linux/delay.h
 
 MODULE_AUTHOR(Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin);
 MODULE_DESCRIPTION(Maple bus driver for Dreamcast);
@@ -52,7 +53,7 @@ static struct device maple_bus;
 static int subdevice_map[MAPLE_PORTS];
 static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
 static unsigned long maple_pnp_time;
-static int started, scanning, liststatus;
+static int started, scanning, liststatus, realscan;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
@@ -72,7 +73,6 @@ int maple_driver_register(struct device_driver *drv)
drv-bus = maple_bus_type;
return driver_register(drv);
 }
-
 EXPORT_SYMBOL_GPL(maple_driver_register);
 
 /* set hardware registers to enable next round of dma */
@@ -94,15 +94,14 @@ static void maplebus_dma_reset(void)
  * @function: the function code for the device
  */
 void maple_getcond_callback(struct maple_device *dev,
-   void (*callback) (struct mapleq * mq),
-   unsigned long interval, unsigned long function)
+   void (*callback) (struct mapleq *mq),
+   unsigned long interval, unsigned long function)
 {
dev-callback = callback;
dev-interval = interval;
dev-function = cpu_to_be32(function);
dev-when = jiffies;
 }
-
 EXPORT_SYMBOL_GPL(maple_getcond_callback);
 
 static int maple_dma_done(void)
@@ -112,10 +111,19 @@ static int maple_dma_done(void)
 
 static void maple_release_device(struct device *dev)
 {
-   if (dev-type) {
-   kfree(dev-type-name);
-   kfree(dev-type);
+   struct maple_device *mdev;
+   struct mapleq *mq;
+   if (!dev)
+   return;
+   mdev = to_maple_dev(dev);
+   mq = mdev-mq;
+   if (mq) {
+   if (mq-recvbufdcsp)
+   kmem_cache_free(maple_queue_cache, mq-recvbufdcsp);
+   kfree(mq);
+   mq = NULL;
}
+   kfree(mdev);
 }
 
 /**
@@ -128,10 +136,9 @@ void maple_add_packet(struct mapleq *mq)
list_add(mq-list, maple_waitq);
mutex_unlock(maple_list_lock);
 }
-
 EXPORT_SYMBOL_GPL(maple_add_packet);
 
-static struct mapleq *maple_allocq(struct maple_device *dev)
+static struct mapleq *maple_allocq(struct maple_device *mdev)
 {
struct mapleq *mq;
 
@@ -139,7 +146,7 @@ static struct mapleq *maple_allocq(struct maple_device *dev)
if (!mq)
return NULL;
 
-   mq-dev = dev;
+   mq-dev = mdev;
mq-recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
mq-recvbuf = (void *) P2SEGADDR(mq-recvbufdcsp);
if (!mq-recvbuf) {
@@ -152,22 +159,24 @@ static struct mapleq *maple_allocq(struct maple_device 
*dev)
 
 static struct maple_device *maple_alloc_dev(int port, int unit)
 {
-   struct maple_device *dev;
+   struct maple_device *mdev;
 
-   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-   if (!dev)
+   mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+   if (!mdev)
return NULL;
 
-   dev-port = port;
-   dev-unit = unit;
-   dev-mq = maple_allocq(dev);
+   mdev-port = port;
+   mdev-unit = unit;
+   mdev-mq = maple_allocq(mdev);
 
-   if (!dev-mq) {
-   kfree(dev);
+   if (!mdev-mq) {
+   kfree(mdev);
return NULL;
}
-
-   return dev;
+   mdev-dev.bus = maple_bus_type;
+   mdev-dev.parent = maple_bus;
+   mdev-function = 0;
+   return mdev;
 }
 
 static void maple_free_dev(struct maple_device *mdev)
@@ -175,7 +184,9 @@ static void maple_free_dev(struct maple_device *mdev)
if (!mdev)
return;
if (mdev-mq) {
-   kmem_cache_free(maple_queue_cache, mdev-mq-recvbufdcsp);
+   if (mdev-mq-recvbufdcsp)
+   kmem_cache_free(maple_queue_cache,
+   mdev-mq-recvbufdcsp);
kfree(mdev-mq);
}
kfree(mdev);
@@ -259,80 +270,93 @@ static void maple_detach_driver(struct maple_device *mdev)
mdev-driver-disconnect(mdev);
}
mdev-driver = NULL;
-   if (mdev-registered) {
-   maple_release_device(mdev-dev);
+   if (mdev-registered)
device_unregister(mdev-dev

Re: [PATCH 2/2] - SH/Dreamcast - fix maple bus bugs

2008-02-06 Thread Adrian McMenamin

On Wed, 2008-02-06 at 15:01 -0800, Greg KH wrote:
 On Wed, Feb 06, 2008 at 10:53:51PM +, Adrian McMenamin wrote:
  -   dev-function = function;
  -   dev-dev.bus = maple_bus_type;
  -   dev-dev.parent = maple_bus;
  -   dev-dev.release = maple_release_device;
  -   retval = device_register(dev-dev);
  -   if (retval) {
  -   printk(KERN_INFO
  -  Maple bus: Attempt to register device (%x, %x) 
  failed.\n,
  -  dev-port, dev-unit);
  -   maple_free_dev(dev);
  +   mdev-function = function;
  +   mdev-dev.release = maple_release_device;
  +   if (mdev-registered == 0) {
  +   retval = device_register(mdev-dev);
  +   if (retval) {
  +   printk(KERN_INFO
  +   Maple bus: Attempt to register device
  +(%x, %x) failed.\n,
  +   mdev-port, mdev-unit);
  +   maple_free_dev(mdev);
  +   mdev = NULL;
  +   return;
  +   }
  +   mdev-registered = 1;
  }
  -   dev-registered = 1;
 
 I think you are still papering over the real problem here of trying to
 register a device twice.  That's something you should never be doing,
 and your bus walking logic must be incorrect...
 
I just left that in as a sanity check. It should never be acted on. I
can remove it if you prefer.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] - SH/Dreamcast - additional patch to maple.h

2008-02-06 Thread Adrian McMenamin
This patch removes the now unneeded registration check variable from
struct maple_device. (This patch assumes the include/linux/maple.h file
has already been patched for whitespace errors by
http://lkml.org/lkml/2008/2/6/327)

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]


diff --git a/include/linux/maple.h b/include/linux/maple.h
index 1334062..3f01e2b 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -56,7 +56,6 @@ struct maple_device {
unsigned char port, unit;
char product_name[32];
char product_licence[64];
-   int registered;
struct device dev;
 };

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Mon, 2008-02-04 at 22:37 +, Adrian McMenamin wrote:

> 
> The hardware is very flaky. If I add in delays to the bus start, it will
> detect the devices, but it's not brilliant. Registering an empty device
> got round that problem, at the price of testing for the earlier
> registration.
> 


I have found if I push it (and drivers) further down the initcall
hierarchy that problem is less significant and the hardware seems to be
properly detected.

I'll look to post a clean up series of patches in the next few days.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Mon, 2008-02-04 at 08:14 -0800, Greg KH wrote:
> On Mon, Feb 04, 2008 at 08:27:55AM +0000, Adrian McMenamin wrote:
> > 
> > On Sun, 2008-02-03 at 21:29 -0800, Greg KH wrote:
> > > On Sun, Feb 03, 2008 at 08:00:47PM +, Adrian McMenamin wrote:
> > > > From: Adrian McMenamin
> > > > 
> > > > This patch fixes the regression noted here:
> > > > http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
> > > > previous commit of this driver and the memory leaks noted here:
> > > > http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
> > > > cleanups).
> > > 
> > > Which portion of the patch fixes the kobject WARN_ON()?
> > 
> > 
> > 
> > +   if (mdev->registered == 0) {
> > +   retval = device_register(>dev);
> > +   if (retval) {
> > +   printk(KERN_INFO
> > +   "Maple bus: Attempt to register device"
> > +   " (%x, %x) failed.\n",
> > +   mdev->port, mdev->unit);
> > +   maple_free_dev(mdev);
> > +   mdev = NULL;
> > +   return;
> > +   }
> > +   mdev->registered = 1;
> > +   }
> >  }
> > 
> > 
> > Specifically the check on mdev->registered
> 
> So the code path could cause devices to be registered more than once?
> That seems broken, as no other bus that I know of needs such a check :(
> 
> Is there a way to fix the root problem here, instead of this type of
> change?
> 

The hardware is very flaky. If I add in delays to the bus start, it will
detect the devices, but it's not brilliant. Registering an empty device
got round that problem, at the price of testing for the earlier
registration.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin
On Mon, February 4, 2008 9:59 am, Paul Mundt wrote:
> On Mon, Feb 04, 2008 at 09:35:11AM -0000, Adrian McMenamin wrote:
>> On Mon, February 4, 2008 9:02 am, Paul Mundt wrote:
>> > My previous commit was directly from _your_ patch, given that your
>> > patches have a history of whitespace damage, this doesn't seem like
>> much
>> > of a stretch. It's true I neglected to run it through checkpatch, I'll
>> be
>> > more careful with that in the future when applying patches from
>> certain
>> > parties.
>> >
>>
>> I'm sorry. But that's garbage.
>>
>
> Thanks for playing, try again.
>

It's a fair cop. My apologies.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin
On Mon, February 4, 2008 9:02 am, Paul Mundt wrote:

> My previous commit was directly from _your_ patch, given that your
> patches have a history of whitespace damage, this doesn't seem like much
> of a stretch. It's true I neglected to run it through checkpatch, I'll be
> more careful with that in the future when applying patches from certain
> parties.
>

I'm sorry. But that's garbage.

I'm prepared to admit I made a mistake. Clearly you aren't.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Sun, 2008-02-03 at 21:29 -0800, Greg KH wrote:
> On Sun, Feb 03, 2008 at 08:00:47PM +0000, Adrian McMenamin wrote:
> > From: Adrian McMenamin
> > 
> > This patch fixes the regression noted here:
> > http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
> > previous commit of this driver and the memory leaks noted here:
> > http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
> > cleanups).
> 
> Which portion of the patch fixes the kobject WARN_ON()?



+   if (mdev->registered == 0) {
+   retval = device_register(>dev);
+   if (retval) {
+   printk(KERN_INFO
+   "Maple bus: Attempt to register device"
+   " (%x, %x) failed.\n",
+   mdev->port, mdev->unit);
+   maple_free_dev(mdev);
+   mdev = NULL;
+   return;
+   }
+   mdev->registered = 1;
+   }
 }


Specifically the check on mdev->registered

Unfortunately the previous commit was completely corrupted by whitespace
everywhere so the patch essentially covers the whole dirver (I had a
choice of submitting broken code with whitespace removed or working code
with whitespace removed)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Mon, 2008-02-04 at 10:10 +0900, Paul Mundt wrote:
> On Sun, Feb 03, 2008 at 08:00:47PM +0000, Adrian McMenamin wrote:
> > From: Adrian McMenamin
> > 
> This is useless if you are submitting the patch, especially if you're
> missing a mail address.
> 

>From Documentation/SubmittingPatches

The canonical patch message body contains the following:
  * 
  *   - A "from" line specifying the patch author.
  * 


> > This patch fixes the regression noted here:
> > http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
> > previous commit of this driver and the memory leaks noted here:
> > http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
> > cleanups).
> > 
> The subject notes 3 specific things that are being addressed, but you've
> rolled this all in to one patch which makes it utterly impossible to
> figure out what you're actually fixing. At the very least, split this in
> to 3 different patches, each dealing with one of the things noted in the
> subject. The fact that regressions is plural also suggests you may want
> to split this down in to smaller patches that deal with specific
> regressions if they are not directly related.
> 

What would be the point of submitting patches of broken code just to
remove the whitespace your previous commit added to all the lines?


> > Signed off by: Adrian McMenamin <[EMAIL PROTECTED]>
> > 
> Do not invent new sign-off tags, see Documentation/SubmittingPatches.
> Scripts do end up having to parse this stuff.


Yes, sorry for that.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Sun, 2008-02-03 at 21:29 -0800, Greg KH wrote:
 On Sun, Feb 03, 2008 at 08:00:47PM +, Adrian McMenamin wrote:
  From: Adrian McMenamin
  
  This patch fixes the regression noted here:
  http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
  previous commit of this driver and the memory leaks noted here:
  http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
  cleanups).
 
 Which portion of the patch fixes the kobject WARN_ON()?



+   if (mdev-registered == 0) {
+   retval = device_register(mdev-dev);
+   if (retval) {
+   printk(KERN_INFO
+   Maple bus: Attempt to register device
+(%x, %x) failed.\n,
+   mdev-port, mdev-unit);
+   maple_free_dev(mdev);
+   mdev = NULL;
+   return;
+   }
+   mdev-registered = 1;
+   }
 }


Specifically the check on mdev-registered

Unfortunately the previous commit was completely corrupted by whitespace
everywhere so the patch essentially covers the whole dirver (I had a
choice of submitting broken code with whitespace removed or working code
with whitespace removed)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Mon, 2008-02-04 at 10:10 +0900, Paul Mundt wrote:
 On Sun, Feb 03, 2008 at 08:00:47PM +, Adrian McMenamin wrote:
  From: Adrian McMenamin
  
 This is useless if you are submitting the patch, especially if you're
 missing a mail address.
 

From Documentation/SubmittingPatches

The canonical patch message body contains the following:
  * 
  *   - A from line specifying the patch author.
  * 


  This patch fixes the regression noted here:
  http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
  previous commit of this driver and the memory leaks noted here:
  http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
  cleanups).
  
 The subject notes 3 specific things that are being addressed, but you've
 rolled this all in to one patch which makes it utterly impossible to
 figure out what you're actually fixing. At the very least, split this in
 to 3 different patches, each dealing with one of the things noted in the
 subject. The fact that regressions is plural also suggests you may want
 to split this down in to smaller patches that deal with specific
 regressions if they are not directly related.
 

What would be the point of submitting patches of broken code just to
remove the whitespace your previous commit added to all the lines?


  Signed off by: Adrian McMenamin [EMAIL PROTECTED]
  
 Do not invent new sign-off tags, see Documentation/SubmittingPatches.
 Scripts do end up having to parse this stuff.


Yes, sorry for that.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin
On Mon, February 4, 2008 9:02 am, Paul Mundt wrote:

 My previous commit was directly from _your_ patch, given that your
 patches have a history of whitespace damage, this doesn't seem like much
 of a stretch. It's true I neglected to run it through checkpatch, I'll be
 more careful with that in the future when applying patches from certain
 parties.


I'm sorry. But that's garbage.

I'm prepared to admit I made a mistake. Clearly you aren't.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin
On Mon, February 4, 2008 9:59 am, Paul Mundt wrote:
 On Mon, Feb 04, 2008 at 09:35:11AM -, Adrian McMenamin wrote:
 On Mon, February 4, 2008 9:02 am, Paul Mundt wrote:
  My previous commit was directly from _your_ patch, given that your
  patches have a history of whitespace damage, this doesn't seem like
 much
  of a stretch. It's true I neglected to run it through checkpatch, I'll
 be
  more careful with that in the future when applying patches from
 certain
  parties.
 

 I'm sorry. But that's garbage.


 Thanks for playing, try again.


It's a fair cop. My apologies.


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Mon, 2008-02-04 at 22:37 +, Adrian McMenamin wrote:

 
 The hardware is very flaky. If I add in delays to the bus start, it will
 detect the devices, but it's not brilliant. Registering an empty device
 got round that problem, at the price of testing for the earlier
 registration.
 


I have found if I push it (and drivers) further down the initcall
hierarchy that problem is less significant and the hardware seems to be
properly detected.

I'll look to post a clean up series of patches in the next few days.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-04 Thread Adrian McMenamin

On Mon, 2008-02-04 at 08:14 -0800, Greg KH wrote:
 On Mon, Feb 04, 2008 at 08:27:55AM +, Adrian McMenamin wrote:
  
  On Sun, 2008-02-03 at 21:29 -0800, Greg KH wrote:
   On Sun, Feb 03, 2008 at 08:00:47PM +, Adrian McMenamin wrote:
From: Adrian McMenamin

This patch fixes the regression noted here:
http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
previous commit of this driver and the memory leaks noted here:
http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
cleanups).
   
   Which portion of the patch fixes the kobject WARN_ON()?
  
  
  
  +   if (mdev-registered == 0) {
  +   retval = device_register(mdev-dev);
  +   if (retval) {
  +   printk(KERN_INFO
  +   Maple bus: Attempt to register device
  +(%x, %x) failed.\n,
  +   mdev-port, mdev-unit);
  +   maple_free_dev(mdev);
  +   mdev = NULL;
  +   return;
  +   }
  +   mdev-registered = 1;
  +   }
   }
  
  
  Specifically the check on mdev-registered
 
 So the code path could cause devices to be registered more than once?
 That seems broken, as no other bus that I know of needs such a check :(
 
 Is there a way to fix the root problem here, instead of this type of
 change?
 

The hardware is very flaky. If I add in delays to the bus start, it will
detect the devices, but it's not brilliant. Registering an empty device
got round that problem, at the price of testing for the earlier
registration.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-03 Thread Adrian McMenamin
From: Adrian McMenamin

This patch fixes the regression noted here:
http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
previous commit of this driver and the memory leaks noted here:
http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
cleanups).

Signed off by: Adrian McMenamin <[EMAIL PROTECTED]>

==



diff -ruN a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
--- a/drivers/sh/maple/maple.c  2008-02-03 19:32:23.0 +
+++ b/drivers/sh/maple/maple.c  2008-02-03 19:45:41.0 +
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -53,12 +52,12 @@
 static int subdevice_map[MAPLE_PORTS];
 static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
 static unsigned long maple_pnp_time;
-static int started, scanning, liststatus;
+static int started, scanning, liststatus, realscan;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
-   int port;
-   int unit;
+   int port;
+   int unit;
 };
 
 /**
@@ -68,22 +67,22 @@
  */
 int maple_driver_register(struct device_driver *drv)
 {
-   if (!drv)
-   return -EINVAL;
-   drv->bus = _bus_type;
-   return driver_register(drv);
+   if (!drv)
+   return -EINVAL;
+   drv->bus = _bus_type;
+   return driver_register(drv);
 }
 EXPORT_SYMBOL_GPL(maple_driver_register);
 
 /* set hardware registers to enable next round of dma */
 static void maplebus_dma_reset(void)
 {
-   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
-   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
-   ctrl_outl(1, MAPLE_TRIGTYPE);
-   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
-   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
-   ctrl_outl(1, MAPLE_ENABLE);
+   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
+   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
+   ctrl_outl(1, MAPLE_TRIGTYPE);
+   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
+   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
+   ctrl_outl(1, MAPLE_ENABLE);
 }
 
 /**
@@ -94,27 +93,36 @@
  * @function: the function code for the device
  */
 void maple_getcond_callback(struct maple_device *dev,
-   void (*callback) (struct mapleq * mq),
-   unsigned long interval, unsigned long function)
+   void (*callback) (struct mapleq *mq),
+   unsigned long interval, unsigned long function)
 {
-   dev->callback = callback;
-   dev->interval = interval;
-   dev->function = cpu_to_be32(function);
-   dev->when = jiffies;
+   dev->callback = callback;
+   dev->interval = interval;
+   dev->function = cpu_to_be32(function);
+   dev->when = jiffies;
 }
 EXPORT_SYMBOL_GPL(maple_getcond_callback);
 
 static int maple_dma_done(void)
 {
-   return (ctrl_inl(MAPLE_STATE) & 1) == 0;
+   return (ctrl_inl(MAPLE_STATE) & 1) == 0;
 }
 
 static void maple_release_device(struct device *dev)
 {
-   if (dev->type) {
-   kfree(dev->type->name);
-   kfree(dev->type);
-   }
+   struct maple_device *mdev;
+   struct mapleq *mq;
+   if (!dev)
+   return;
+   mdev = to_maple_dev(dev);
+   mq = mdev->mq;
+   if (mq) {
+   if (mq->recvbufdcsp)
+   kmem_cache_free(maple_queue_cache, mq->recvbufdcsp);
+   kfree(mq);
+   mq = NULL;
+   }
+   kfree(mdev);
 }
 
 /**
@@ -123,60 +131,62 @@
  */
 void maple_add_packet(struct mapleq *mq)
 {
-   mutex_lock(_list_lock);
-   list_add(>list, _waitq);
-   mutex_unlock(_list_lock);
+   mutex_lock(_list_lock);
+   list_add(>list, _waitq);
+   mutex_unlock(_list_lock);
 }
 EXPORT_SYMBOL_GPL(maple_add_packet);
 
-static struct mapleq *maple_allocq(struct maple_device *dev)
+static struct mapleq *maple_allocq(struct maple_device *mdev)
 {
-   struct mapleq *mq;
+   struct mapleq *mq;
 
-   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
-   if (!mq)
-   return NULL;
-
-   mq->dev = dev;
-   mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
-   mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
-   if (!mq->recvbuf) {
-   kfree(mq);
-   return NULL;
-   }
+   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
+   if (!mq)
+   return NULL;
+
+   mq->dev = mdev;
+   mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
+   mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
+   if (!mq->recvbuf) {
+   kfree(mq);
+   return NULL;
+   }
 
-   return mq;
+   return mq;
 }
 
 static struct 

[PATCH] SH/Dreamcast - fix regressions, whitespace and memory leaks in Maple Bus driver

2008-02-03 Thread Adrian McMenamin
From: Adrian McMenamin

This patch fixes the regression noted here:
http://lkml.org/lkml/2008/1/26/189 as well as whitespace issues in the
previous commit of this driver and the memory leaks noted here:
http://lkml.org/lkml/2008/2/2/143 (as well as one or two other minor
cleanups).

Signed off by: Adrian McMenamin [EMAIL PROTECTED]

==



diff -ruN a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
--- a/drivers/sh/maple/maple.c  2008-02-03 19:32:23.0 +
+++ b/drivers/sh/maple/maple.c  2008-02-03 19:45:41.0 +
@@ -18,7 +18,6 @@
 #include linux/init.h
 #include linux/kernel.h
 #include linux/device.h
-#include linux/module.h
 #include linux/interrupt.h
 #include linux/list.h
 #include linux/io.h
@@ -53,12 +52,12 @@
 static int subdevice_map[MAPLE_PORTS];
 static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
 static unsigned long maple_pnp_time;
-static int started, scanning, liststatus;
+static int started, scanning, liststatus, realscan;
 static struct kmem_cache *maple_queue_cache;
 
 struct maple_device_specify {
-   int port;
-   int unit;
+   int port;
+   int unit;
 };
 
 /**
@@ -68,22 +67,22 @@
  */
 int maple_driver_register(struct device_driver *drv)
 {
-   if (!drv)
-   return -EINVAL;
-   drv-bus = maple_bus_type;
-   return driver_register(drv);
+   if (!drv)
+   return -EINVAL;
+   drv-bus = maple_bus_type;
+   return driver_register(drv);
 }
 EXPORT_SYMBOL_GPL(maple_driver_register);
 
 /* set hardware registers to enable next round of dma */
 static void maplebus_dma_reset(void)
 {
-   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
-   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
-   ctrl_outl(1, MAPLE_TRIGTYPE);
-   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
-   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
-   ctrl_outl(1, MAPLE_ENABLE);
+   ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
+   /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
+   ctrl_outl(1, MAPLE_TRIGTYPE);
+   ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(5), MAPLE_SPEED);
+   ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
+   ctrl_outl(1, MAPLE_ENABLE);
 }
 
 /**
@@ -94,27 +93,36 @@
  * @function: the function code for the device
  */
 void maple_getcond_callback(struct maple_device *dev,
-   void (*callback) (struct mapleq * mq),
-   unsigned long interval, unsigned long function)
+   void (*callback) (struct mapleq *mq),
+   unsigned long interval, unsigned long function)
 {
-   dev-callback = callback;
-   dev-interval = interval;
-   dev-function = cpu_to_be32(function);
-   dev-when = jiffies;
+   dev-callback = callback;
+   dev-interval = interval;
+   dev-function = cpu_to_be32(function);
+   dev-when = jiffies;
 }
 EXPORT_SYMBOL_GPL(maple_getcond_callback);
 
 static int maple_dma_done(void)
 {
-   return (ctrl_inl(MAPLE_STATE)  1) == 0;
+   return (ctrl_inl(MAPLE_STATE)  1) == 0;
 }
 
 static void maple_release_device(struct device *dev)
 {
-   if (dev-type) {
-   kfree(dev-type-name);
-   kfree(dev-type);
-   }
+   struct maple_device *mdev;
+   struct mapleq *mq;
+   if (!dev)
+   return;
+   mdev = to_maple_dev(dev);
+   mq = mdev-mq;
+   if (mq) {
+   if (mq-recvbufdcsp)
+   kmem_cache_free(maple_queue_cache, mq-recvbufdcsp);
+   kfree(mq);
+   mq = NULL;
+   }
+   kfree(mdev);
 }
 
 /**
@@ -123,60 +131,62 @@
  */
 void maple_add_packet(struct mapleq *mq)
 {
-   mutex_lock(maple_list_lock);
-   list_add(mq-list, maple_waitq);
-   mutex_unlock(maple_list_lock);
+   mutex_lock(maple_list_lock);
+   list_add(mq-list, maple_waitq);
+   mutex_unlock(maple_list_lock);
 }
 EXPORT_SYMBOL_GPL(maple_add_packet);
 
-static struct mapleq *maple_allocq(struct maple_device *dev)
+static struct mapleq *maple_allocq(struct maple_device *mdev)
 {
-   struct mapleq *mq;
+   struct mapleq *mq;
 
-   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
-   if (!mq)
-   return NULL;
-
-   mq-dev = dev;
-   mq-recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
-   mq-recvbuf = (void *) P2SEGADDR(mq-recvbufdcsp);
-   if (!mq-recvbuf) {
-   kfree(mq);
-   return NULL;
-   }
+   mq = kmalloc(sizeof(*mq), GFP_KERNEL);
+   if (!mq)
+   return NULL;
+
+   mq-dev = mdev;
+   mq-recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
+   mq-recvbuf = (void *) P2SEGADDR(mq-recvbufdcsp);
+   if (!mq-recvbuf) {
+   kfree(mq);
+   return NULL;
+   }
 
-   return mq;
+   return mq;
 }
 
 static struct

slab cache question

2008-02-02 Thread Adrian McMenamin
I have been having problems with the slab cache (using slub) in my maple
bus driver (eg see http://lkml.org/lkml/2008/1/28/74).



I have now switched to using SLAB_POISON in kmem_cache_create and
instead of fatal oops, I get what follows - could someone tell me the
likely causes I should be looking for?

[  433.428976] 
=
[  433.430826] BUG maple_queue_cache: Poison overwritten
[  433.430826] 
-
[  433.430826] 
[  433.430826] INFO: 0x8cacc000-0x8cacc01f. First byte 0xff instead of 0x6b
[  433.430826] INFO: Slab 0x8c29f980 used=0 fp=0x8cacc000 flags=0x40c2
[  433.430826] INFO: Object 0x8cacc000 @offset=0 fp=0x8cacc420
[  433.430826] 
[  433.430826]   Object 0x8cacc000:  ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff 
[  433.430826]   Object 0x8cacc010:  ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff 
[  433.430826]   Object 0x8cacc020:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc030:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc040:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc050:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc060:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc070:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]  Padding 0x8cacc404:  5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 
5a 5a 
[  433.430826]  Padding 0x8cacc414:  5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 
[  433.430826] Stack: (0x8cc19e50 to 0x8cc1a000)
[  433.430826] 9e40: 8c063e0c 8cacc01f 
8cacc020 8cacc000 
[  433.430826] 9e60: 8c06403a 80d0 8cc5f9a0 8c063d80  8c29f980 
8cacc000 8cc79f00 
[  433.430826] 9e80: 8cacc000 006b 03ff 8c064d6a 0001 8cc79f00 
8cacc000 8cc79f70 
[  433.430826] 9ea0: 8c29f980  8c154cc4 8c0117ea 8c064e90 8cc2e290 
8cc5f9a0 0001 
[  433.430826] 9ec0: 8cc79f70 8c064e60 80d0  8cc79f70 8c154cc4 
0002 8c064e60 
[  433.430826] 9ee0: 8cb03720 8cb44e00 8c155480  8c2540ac 0002 
8cc2e200  
[  433.430826] 9f00: 0002 0002 8c029656  8c018700 fffe 
8c155300 ff0f 
[  433.430826] 9f20: 8cc01300 8c25409c 8c0297a4 8c02d800 8c0295a0 8c02d9c0 
8c02d260 8cc01308 
[  433.430826] 9f40: 8cc01300  8cc0e9c0 8c02da60 8cc19f50 8cc19f50 
 8cc0e9c0 
[  433.430826] 9f60: 8c02da60 8cc19f50 8cc19f50 8c02d2b6  fffc 
8c0135c0 8c029720 
[  433.430826] 9f80: 8cc01300 8c02d260 8c003844    
  
[  433.430826] 9fa0:     8cc11ed4 8c02d280 
  
[  433.430826] 9fc0:       
 8cc19fa0 
[  433.430826] 9fe0: 8c003840  4000    
  
[  433.430826] 
[  433.430826] Call trace: 
[  433.430826] [<8c06403a>] check_object+0xba/0x200
[  433.430826] [<8c063d80>] check_bytes_and_report+0x0/0xe0
[  433.430826] [<8c064d6a>] __slab_alloc+0x40a/0x500
[  433.430826] [<8c154cc4>] maple_alloc_dev+0x44/0xa0
[  433.430826] [<8c0117ea>] update_curr+0x4a/0xe0
[  433.430826] [<8c064e90>] kmem_cache_alloc+0x30/0xc0
[  433.430826] [<8c064e60>] kmem_cache_alloc+0x0/0xc0
[  433.430826] [<8c154cc4>] maple_alloc_dev+0x44/0xa0
[  433.430826] [<8c064e60>] kmem_cache_alloc+0x0/0xc0
[  433.430826] [<8c155480>] maple_dma_handler+0x180/0x2e0
[  433.430826] [<8c029656>] run_workqueue+0xb6/0x180
[  433.430826] [<8c018700>] printk+0x0/0x20
[  433.430826] [<8c155300>] maple_dma_handler+0x0/0x2e0
[  433.430826] [<8c0297a4>] worker_thread+0x84/0xe0
[  433.430826] [<8c02d800>] prepare_to_wait+0x0/0xe0
[  433.430826] [<8c0295a0>] run_workqueue+0x0/0x180
[  433.430826] [<8c02d9c0>] finish_wait+0x0/0xa0
[  433.430826] [<8c02d260>] kthread_should_stop+0x0/0x20
[  433.430826] [<8c02da60>] autoremove_wake_function+0x0/0x40
[  433.430826] [<8c02da60>] autoremove_wake_function+0x0/0x40
[  433.430826] [<8c02d2b6>] kthread+0x36/0x80
[  433.430826] [<8c0135c0>] complete+0x0/0xc0
[  433.430826] [<8c029720>] worker_thread+0x0/0xe0
[  433.430826] [<8c02d260>] kthread_should_stop+0x0/0x20
[  433.430826] [<8c003844>] kernel_thread_helper+0x4/0x20
[  433.430826] [<8c02d280>] kthread+0x0/0x80
[  433.430826] [<8c003840>] kernel_thread_helper+0x0/0x20
[  433.430826] 
[  433.430826] FIX maple_queue_cache: Restoring 0x8cacc000-0x8cacc01f=0x6b
[  433.430826] 
[  433.430826] FIX maple_queue_cache: Marking all objects used
[  433.474526] Maple bus at (0, 2): Connected function 0x10
[  433.474865] No maple driver found for this device

--
To unsubscribe from 

slab cache question

2008-02-02 Thread Adrian McMenamin
I have been having problems with the slab cache (using slub) in my maple
bus driver (eg see http://lkml.org/lkml/2008/1/28/74).



I have now switched to using SLAB_POISON in kmem_cache_create and
instead of fatal oops, I get what follows - could someone tell me the
likely causes I should be looking for?

[  433.428976] 
=
[  433.430826] BUG maple_queue_cache: Poison overwritten
[  433.430826] 
-
[  433.430826] 
[  433.430826] INFO: 0x8cacc000-0x8cacc01f. First byte 0xff instead of 0x6b
[  433.430826] INFO: Slab 0x8c29f980 used=0 fp=0x8cacc000 flags=0x40c2
[  433.430826] INFO: Object 0x8cacc000 @offset=0 fp=0x8cacc420
[  433.430826] 
[  433.430826]   Object 0x8cacc000:  ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff 
[  433.430826]   Object 0x8cacc010:  ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff 
[  433.430826]   Object 0x8cacc020:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc030:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc040:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc050:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc060:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]   Object 0x8cacc070:  6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 
6b 6b 
[  433.430826]  Padding 0x8cacc404:  5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 
5a 5a 
[  433.430826]  Padding 0x8cacc414:  5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
 
[  433.430826] Stack: (0x8cc19e50 to 0x8cc1a000)
[  433.430826] 9e40: 8c063e0c 8cacc01f 
8cacc020 8cacc000 
[  433.430826] 9e60: 8c06403a 80d0 8cc5f9a0 8c063d80  8c29f980 
8cacc000 8cc79f00 
[  433.430826] 9e80: 8cacc000 006b 03ff 8c064d6a 0001 8cc79f00 
8cacc000 8cc79f70 
[  433.430826] 9ea0: 8c29f980  8c154cc4 8c0117ea 8c064e90 8cc2e290 
8cc5f9a0 0001 
[  433.430826] 9ec0: 8cc79f70 8c064e60 80d0  8cc79f70 8c154cc4 
0002 8c064e60 
[  433.430826] 9ee0: 8cb03720 8cb44e00 8c155480  8c2540ac 0002 
8cc2e200  
[  433.430826] 9f00: 0002 0002 8c029656  8c018700 fffe 
8c155300 ff0f 
[  433.430826] 9f20: 8cc01300 8c25409c 8c0297a4 8c02d800 8c0295a0 8c02d9c0 
8c02d260 8cc01308 
[  433.430826] 9f40: 8cc01300  8cc0e9c0 8c02da60 8cc19f50 8cc19f50 
 8cc0e9c0 
[  433.430826] 9f60: 8c02da60 8cc19f50 8cc19f50 8c02d2b6  fffc 
8c0135c0 8c029720 
[  433.430826] 9f80: 8cc01300 8c02d260 8c003844    
  
[  433.430826] 9fa0:     8cc11ed4 8c02d280 
  
[  433.430826] 9fc0:       
 8cc19fa0 
[  433.430826] 9fe0: 8c003840  4000    
  
[  433.430826] 
[  433.430826] Call trace: 
[  433.430826] [8c06403a] check_object+0xba/0x200
[  433.430826] [8c063d80] check_bytes_and_report+0x0/0xe0
[  433.430826] [8c064d6a] __slab_alloc+0x40a/0x500
[  433.430826] [8c154cc4] maple_alloc_dev+0x44/0xa0
[  433.430826] [8c0117ea] update_curr+0x4a/0xe0
[  433.430826] [8c064e90] kmem_cache_alloc+0x30/0xc0
[  433.430826] [8c064e60] kmem_cache_alloc+0x0/0xc0
[  433.430826] [8c154cc4] maple_alloc_dev+0x44/0xa0
[  433.430826] [8c064e60] kmem_cache_alloc+0x0/0xc0
[  433.430826] [8c155480] maple_dma_handler+0x180/0x2e0
[  433.430826] [8c029656] run_workqueue+0xb6/0x180
[  433.430826] [8c018700] printk+0x0/0x20
[  433.430826] [8c155300] maple_dma_handler+0x0/0x2e0
[  433.430826] [8c0297a4] worker_thread+0x84/0xe0
[  433.430826] [8c02d800] prepare_to_wait+0x0/0xe0
[  433.430826] [8c0295a0] run_workqueue+0x0/0x180
[  433.430826] [8c02d9c0] finish_wait+0x0/0xa0
[  433.430826] [8c02d260] kthread_should_stop+0x0/0x20
[  433.430826] [8c02da60] autoremove_wake_function+0x0/0x40
[  433.430826] [8c02da60] autoremove_wake_function+0x0/0x40
[  433.430826] [8c02d2b6] kthread+0x36/0x80
[  433.430826] [8c0135c0] complete+0x0/0xc0
[  433.430826] [8c029720] worker_thread+0x0/0xe0
[  433.430826] [8c02d260] kthread_should_stop+0x0/0x20
[  433.430826] [8c003844] kernel_thread_helper+0x4/0x20
[  433.430826] [8c02d280] kthread+0x0/0x80
[  433.430826] [8c003840] kernel_thread_helper+0x0/0x20
[  433.430826] 
[  433.430826] FIX maple_queue_cache: Restoring 0x8cacc000-0x8cacc01f=0x6b
[  433.430826] 
[  433.430826] FIX maple_queue_cache: Marking all objects used
[  433.474526] Maple bus at (0, 2): Connected function 0x10
[  433.474865] No maple driver found for this device

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in

Re: kobject oops with maple bus

2008-01-28 Thread Adrian McMenamin
On Sat, January 26, 2008 8:44 pm, Greg KH wrote:
> On Sat, Jan 26, 2008 at 07:53:20PM +0000, Adrian McMenamin wrote:
>> Greg,
>>
>> Just updated my git to the latest sources and get these (seemingly
>> non-fatal) oops with the Dreamcast maple bus. I'll investigate further,
>> but they may mean something to out out of the box.
>>
>> Adrian



>> [0.00] kobject (8cc2d360): tried to init an initialized object,
>> something is seriously wrong.
>
> The problem is here.  You have possibly already initialized this object,
> or called 'kobject_get' on it before registering it with the driver
> core.  This is a new sanity check that has been in the -mm tree for
> years :)
>
> So I think something needs to be fixed in the code.  Do you want me to
> take a look at it?
>
> thanks,
>
> greg k-h
> -
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Greg,

Have now patched that. But I am trying to hunt down another bug - which
seems memory related. After N hotplug events (where N is greater than two
and less than about 100) I get this below - either indicating something
very wrong in SLUB (unlikely) or a memory leak in my driver (sadly, much
more likely).

I cannot see anything obvious and my best guess is that I am freeing up
the underlying struct device incorrectly - this is allocated currently as
staticly allocated member of a dynamically allocated struct maple_device.
It gets hit by the kfree(mdev) - is that going to cause a problem?


[   41.491053] Maple bus device detaching at (0, 2)
[   42.509136] Maple bus at (0, 2): Connected function 0x10
[   42.513939] No maple driver found for this device
[   44.504875] Maple bus device detaching at (0, 2)
[   45.523250] Maple bus at (0, 2): Connected function 0x10
[   45.529272] No maple driver found for this device
[   46.514861] Maple bus device detaching at (0, 1)
[   47.516651] Maple bus device detaching at (0, 2)
[   48.539093] Maple bus at (0, 1): Connected function 0xE
[   48.545090] No maple driver found for this device
[   48.565052] Maple bus at (0, 2): Connected function 0x10
[   48.569995] No maple driver found for this device
[   49.528324] Maple bus device detaching at (0, 2)
[   51.551459] Maple bus at (0, 2): Connected function 0x10
[   51.557579] No maple driver found for this device
[   52.542771] Maple bus device detaching at (0, 2)
[   53.560892] Maple bus at (0, 2): Connected function 0x10
[   53.566011] No maple driver found for this device
[   55.556921] Maple bus device detaching at (0, 2)
[   56.574966] Maple bus at (0, 2): Connected function 0x10
[   56.580969] No maple driver found for this device
[   58.570982] Maple bus device detaching at (0, 2)
[   59.589076] Maple bus at (0, 2): Connected function 0x10
[   59.594105] No maple driver found for this device
[   60.579944] Maple bus device detaching at (0, 2)
[   61.598478] Maple bus at (0, 2): Connected function 0x10
[   61.602238] No maple driver found for this device
[   61.615106] Fault in unaligned fixup:  [#1]
[   61.616970] Modules linked in: nbd
[   61.616970]
[   61.616970] Pid : 752, Comm:udevd
[   61.616970] PC is at kmem_cache_alloc+0x2e/0xc0
[   61.616970] PC  : 8c074a4e SP  : 8c88ddc4 SR  : 400080f0 TEA :
c00077c4Not tainted
[   61.616970] R0  :  R1  :  R2  :  R3  :
8ce1d000
[   61.616970] R4  : 8c2b03b0 R5  : 80d0 R6  : 7fff R7  :
8c0c09e0
[   61.616970] R8  :  R9  :  R10 : 8c2b03f4 R11 :
80d0
[   61.616970] R12 : 8c88dee4 R13 : 7fff R14 : 8c88ddc4
[   61.616970] MACH: 0002 MACL:  GBR : 29708440 PR  :
8c0c09e0
[   61.616970]
[   61.616970] Call trace:
[   61.616970] [<8c0c09e0>] show_stat+0x20/0x3e0
[   61.616970] [<8c0556b4>] rmqueue_bulk+0x34/0xa0
[   61.616970] [<8c056e2e>] get_page_from_freelist+0x32e/0x540
[   61.616970] [<8c057088>] __alloc_pages+0x48/0x3c0
[   61.616970] [<8c09baa6>] seq_open+0x66/0xa0
[   61.616970] [<8c09bbde>] single_open+0x3e/0xa0
[   61.616970] [<8c0c09c0>] show_stat+0x0/0x3e0
[   61.616970] [<8c0c094a>] stat_open+0x2a/0xa0
[   61.616970] [<8c0b87d4>] proc_reg_open+0x54/0xc0
[   61.616970] [<8c0c0920>] stat_open+0x0/0xa0
[   61.616970] [<8c0b87dc>] proc_reg_open+0x5c/0xc0
[   61.616970] [<8c075944>] __dentry_open+0xe4/0x2c0
[   61.616970] [<8c0b8780>] proc_reg_open+0x0/0xc0
[   61.616970] [<8c09bcae>] seq_read+0x6e/0x360
[   61.616970] [<8c0b82c4>] proc_reg_read+0x64/0x100
[   61.616970] [<8c09bc40>] seq_read+0x0/0x360
[   61.616970] [<8c0781c4>] vfs_read+0x84/0xe0
[   61.616970] [<8c07899c>] sys_read+0x3c/0xa0
[   61.616970] [<8c008240>] syscall_call+0xc/0x10
[   61.616970] [&

Re: kobject oops with maple bus

2008-01-28 Thread Adrian McMenamin
On Sat, January 26, 2008 8:44 pm, Greg KH wrote:
 On Sat, Jan 26, 2008 at 07:53:20PM +, Adrian McMenamin wrote:
 Greg,

 Just updated my git to the latest sources and get these (seemingly
 non-fatal) oops with the Dreamcast maple bus. I'll investigate further,
 but they may mean something to out out of the box.

 Adrian



 [0.00] kobject (8cc2d360): tried to init an initialized object,
 something is seriously wrong.

 The problem is here.  You have possibly already initialized this object,
 or called 'kobject_get' on it before registering it with the driver
 core.  This is a new sanity check that has been in the -mm tree for
 years :)

 So I think something needs to be fixed in the code.  Do you want me to
 take a look at it?

 thanks,

 greg k-h
 -
 To unsubscribe from this list: send the line unsubscribe linux-sh in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


Greg,

Have now patched that. But I am trying to hunt down another bug - which
seems memory related. After N hotplug events (where N is greater than two
and less than about 100) I get this below - either indicating something
very wrong in SLUB (unlikely) or a memory leak in my driver (sadly, much
more likely).

I cannot see anything obvious and my best guess is that I am freeing up
the underlying struct device incorrectly - this is allocated currently as
staticly allocated member of a dynamically allocated struct maple_device.
It gets hit by the kfree(mdev) - is that going to cause a problem?


[   41.491053] Maple bus device detaching at (0, 2)
[   42.509136] Maple bus at (0, 2): Connected function 0x10
[   42.513939] No maple driver found for this device
[   44.504875] Maple bus device detaching at (0, 2)
[   45.523250] Maple bus at (0, 2): Connected function 0x10
[   45.529272] No maple driver found for this device
[   46.514861] Maple bus device detaching at (0, 1)
[   47.516651] Maple bus device detaching at (0, 2)
[   48.539093] Maple bus at (0, 1): Connected function 0xE
[   48.545090] No maple driver found for this device
[   48.565052] Maple bus at (0, 2): Connected function 0x10
[   48.569995] No maple driver found for this device
[   49.528324] Maple bus device detaching at (0, 2)
[   51.551459] Maple bus at (0, 2): Connected function 0x10
[   51.557579] No maple driver found for this device
[   52.542771] Maple bus device detaching at (0, 2)
[   53.560892] Maple bus at (0, 2): Connected function 0x10
[   53.566011] No maple driver found for this device
[   55.556921] Maple bus device detaching at (0, 2)
[   56.574966] Maple bus at (0, 2): Connected function 0x10
[   56.580969] No maple driver found for this device
[   58.570982] Maple bus device detaching at (0, 2)
[   59.589076] Maple bus at (0, 2): Connected function 0x10
[   59.594105] No maple driver found for this device
[   60.579944] Maple bus device detaching at (0, 2)
[   61.598478] Maple bus at (0, 2): Connected function 0x10
[   61.602238] No maple driver found for this device
[   61.615106] Fault in unaligned fixup:  [#1]
[   61.616970] Modules linked in: nbd
[   61.616970]
[   61.616970] Pid : 752, Comm:udevd
[   61.616970] PC is at kmem_cache_alloc+0x2e/0xc0
[   61.616970] PC  : 8c074a4e SP  : 8c88ddc4 SR  : 400080f0 TEA :
c00077c4Not tainted
[   61.616970] R0  :  R1  :  R2  :  R3  :
8ce1d000
[   61.616970] R4  : 8c2b03b0 R5  : 80d0 R6  : 7fff R7  :
8c0c09e0
[   61.616970] R8  :  R9  :  R10 : 8c2b03f4 R11 :
80d0
[   61.616970] R12 : 8c88dee4 R13 : 7fff R14 : 8c88ddc4
[   61.616970] MACH: 0002 MACL:  GBR : 29708440 PR  :
8c0c09e0
[   61.616970]
[   61.616970] Call trace:
[   61.616970] [8c0c09e0] show_stat+0x20/0x3e0
[   61.616970] [8c0556b4] rmqueue_bulk+0x34/0xa0
[   61.616970] [8c056e2e] get_page_from_freelist+0x32e/0x540
[   61.616970] [8c057088] __alloc_pages+0x48/0x3c0
[   61.616970] [8c09baa6] seq_open+0x66/0xa0
[   61.616970] [8c09bbde] single_open+0x3e/0xa0
[   61.616970] [8c0c09c0] show_stat+0x0/0x3e0
[   61.616970] [8c0c094a] stat_open+0x2a/0xa0
[   61.616970] [8c0b87d4] proc_reg_open+0x54/0xc0
[   61.616970] [8c0c0920] stat_open+0x0/0xa0
[   61.616970] [8c0b87dc] proc_reg_open+0x5c/0xc0
[   61.616970] [8c075944] __dentry_open+0xe4/0x2c0
[   61.616970] [8c0b8780] proc_reg_open+0x0/0xc0
[   61.616970] [8c09bcae] seq_read+0x6e/0x360
[   61.616970] [8c0b82c4] proc_reg_read+0x64/0x100
[   61.616970] [8c09bc40] seq_read+0x0/0x360
[   61.616970] [8c0781c4] vfs_read+0x84/0xe0
[   61.616970] [8c07899c] sys_read+0x3c/0xa0
[   61.616970] [8c008240] syscall_call+0xc/0x10
[   61.616970] [8c078960] sys_read+0x0/0xa0
[   61.616970]
[   61.616970] Process: udevd (pid: 752, stack limit = 8c88c001)
[   61.616970] Stack: (0x8c88ddc4 to 0x8c88e000)
[   61.616970] ddc0:  8c0c09e0 8c88dddc 8c4103c0 8cef3f80
0001 8c4103c0 8c0556b4
[   61.616970] dde0: 8c88ddfc 8c2bd6f0   0001

Re: kobject oops with maple bus

2008-01-26 Thread Adrian McMenamin

On Sat, 2008-01-26 at 12:44 -0800, Greg KH wrote:
> On Sat, Jan 26, 2008 at 07:53:20PM +0000, Adrian McMenamin wrote:
> > Greg,
> > 
> > Just updated my git to the latest sources and get these (seemingly 
> > non-fatal) oops with the Dreamcast maple bus. I'll investigate further, but 
> > they may mean something to out out of the box.
> > 
> > Adrian
> > 
> > 
> > 
> > 
> > dreamy:~# [0.00] Linux version 2.6.24-gf0ea9c3d-dirty ([EMAIL 
> > PROTECTED]) (gcc version 3.4.6) #328 PREEMPT Sat Jan 26 19:45:30 GMT 2008
> > [0.00] console [sercon0] enabled
> > [0.00] Booting machvec: Sega Dreamcast
> > [0.00] Node 0: start_pfn = 0xc000, low = 0xd000
> > [0.00] Zone PFN ranges:
> > [0.00]   Normal  49152 ->53248
> > [0.00] Movable zone start PFN for each node
> > [0.00] early_node_map[1] active PFN ranges
> > [0.00] 0:49152 ->53248
> > [0.00] Built 1 zonelists in Zone order, mobility grouping on.  
> > Total pages: 4064
> > [0.00] Kernel command line: root=/dev/nfs rw 
> > nfsroot=192.168.61.50:/home/adrian/debdist ip=dhcp earlyprintk=serial 
> > video=pvr2fb:[EMAIL PROTECTED] consol7
> > [0.00] PID hash table entries: 64 (order: 6, 256 bytes)
> > [0.00] Using tmu for system timer
> > [0.00] Using 12.469 MHz high precision timer.
> > [0.00] Console: colour dummy device 80x25
> > [0.00] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
> > [0.00] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
> > [0.00] Memory: 13468k/16384k available (1918k kernel code, 645k 
> > data, 96k init)
> > [0.00] PVR=040205c1 CVR= PRR=
> > [0.00] I-cache : n_ways=1 n_sets=256 way_incr=8192
> > [0.00] I-cache : entry_mask=0x1fe0 alias_mask=0x1000 
> > n_aliases=2
> > [0.00] D-cache : n_ways=1 n_sets=512 way_incr=16384
> > [0.00] D-cache : entry_mask=0x3fe0 alias_mask=0x3000 
> > n_aliases=4
> > [0.00] SLUB: Genslabs=9, HWalign=32, Order=0-1, MinObjects=4, 
> > CPUs=1, Nodes=1
> > [0.00] Mount-cache hash table entries: 512
> > [0.00] CPU: SH7750
> > [0.00] net_namespace: 64 bytes
> > [0.00] NET: Registered protocol family 16
> > [0.00] Maple bus at (0, 0): Connected function 0x0
> > [0.00] No maple driver found for this device
> > [0.00] Maple bus at (1, 0): Connected function 0x0
> > [0.00] No maple driver found for this device
> > [0.00] Maple bus at (2, 0): Connected function 0x0
> > [0.00] No maple driver found for this device
> > [0.00] Maple bus at (3, 0): Connected function 0x0
> > [0.00] No maple driver found for this device
> > [0.00] Maple bus core now registered.
> > [0.00] DMA: Registering DMA API.
> > [0.00] DMA: Registering sh_dmac handler (4 channels).
> > [0.00] Maple bus at (0, 0): Connected function 0x1
> > [0.00] No maple driver found for this device
> > [0.00] kobject (8cc2d360): tried to init an initialized object, 
> > something is seriously wrong.
> 
> The problem is here.  You have possibly already initialized this object,
> or called 'kobject_get' on it before registering it with the driver
> core.  This is a new sanity check that has been in the -mm tree for
> years :)
> 
> So I think something needs to be fixed in the code.  Do you want me to
> take a look at it?
> 

I think it is probably registering the "dummy" driver a second or
further time. Does that make sense? By all means have a look, but I'll
have a go - I'm sure you have better things to do than mess about with
Dreamcast code :)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kobject oops with maple bus

2008-01-26 Thread Adrian McMenamin
On 26/01/2008, Adrian McMenamin <[EMAIL PROTECTED]> wrote:
> Greg,
>
> Just updated my git to the latest sources and get these (seemingly non-fatal) 
> oops with the Dreamcast maple bus. I'll investigate further, but they may 
> mean something to out out of the box.
>
> Adrian
>
>
>
>
> dreamy:~# [0.00] Linux version 2.6.24-gf0ea9c3d-dirty ([EMAIL 
> PROTECTED]) (gcc version 3.4.6) #328 PREEMPT Sat Jan 26 19:45:30 GMT 2008
> [0.00] console [sercon0] enabled
> [0.00] Booting machvec: Sega Dreamcast
> [0.00] Node 0: start_pfn = 0xc000, low = 0xd000
> [0.00] Zone PFN ranges:
> [0.00]   Normal  49152 ->53248
> [0.00] Movable zone start PFN for each node
> [0.00] early_node_map[1] active PFN ranges


Oh, and I've just noticed everythung appears to be timed to 0 too. Very odd.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


kobject oops with maple bus

2008-01-26 Thread Adrian McMenamin
Greg,

Just updated my git to the latest sources and get these (seemingly non-fatal) 
oops with the Dreamcast maple bus. I'll investigate further, but they may mean 
something to out out of the box.

Adrian




dreamy:~# [0.00] Linux version 2.6.24-gf0ea9c3d-dirty ([EMAIL 
PROTECTED]) (gcc version 3.4.6) #328 PREEMPT Sat Jan 26 19:45:30 GMT 2008
[0.00] console [sercon0] enabled
[0.00] Booting machvec: Sega Dreamcast
[0.00] Node 0: start_pfn = 0xc000, low = 0xd000
[0.00] Zone PFN ranges:
[0.00]   Normal  49152 ->53248
[0.00] Movable zone start PFN for each node
[0.00] early_node_map[1] active PFN ranges
[0.00] 0:49152 ->53248
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 4064
[0.00] Kernel command line: root=/dev/nfs rw 
nfsroot=192.168.61.50:/home/adrian/debdist ip=dhcp earlyprintk=serial 
video=pvr2fb:[EMAIL PROTECTED] consol7
[0.00] PID hash table entries: 64 (order: 6, 256 bytes)
[0.00] Using tmu for system timer
[0.00] Using 12.469 MHz high precision timer.
[0.00] Console: colour dummy device 80x25
[0.00] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.00] Memory: 13468k/16384k available (1918k kernel code, 645k data, 
96k init)
[0.00] PVR=040205c1 CVR= PRR=
[0.00] I-cache : n_ways=1 n_sets=256 way_incr=8192
[0.00] I-cache : entry_mask=0x1fe0 alias_mask=0x1000 n_aliases=2
[0.00] D-cache : n_ways=1 n_sets=512 way_incr=16384
[0.00] D-cache : entry_mask=0x3fe0 alias_mask=0x3000 n_aliases=4
[0.00] SLUB: Genslabs=9, HWalign=32, Order=0-1, MinObjects=4, CPUs=1, 
Nodes=1
[0.00] Mount-cache hash table entries: 512
[0.00] CPU: SH7750
[0.00] net_namespace: 64 bytes
[0.00] NET: Registered protocol family 16
[0.00] Maple bus at (0, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus at (1, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus at (2, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus at (3, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus core now registered.
[0.00] DMA: Registering DMA API.
[0.00] DMA: Registering sh_dmac handler (4 channels).
[0.00] Maple bus at (0, 0): Connected function 0x1
[0.00] No maple driver found for this device
[0.00] kobject (8cc2d360): tried to init an initialized object, 
something is seriously wrong.
[0.00] Stack: (0x8cc1be88 to 0x8cc1c000)
[0.00] be80:   8c00762e 8cc1be98 8c27d050 8cc2d360 
8c103890 8cc1bea0 
[0.00] bea0: 8c14435e 8cc1beb0 8cc2d200 8cc2d2f8 8cc2d200 8c144aae 
8cc1bec0 8cc2d2f8 
[0.00] bec0: 8c159aa8 8cc1becc 0001 8c159e58 8cc1beec 8cc69880 
fffe 8c159d20 
[0.00] bee0: 8c27e14c 8cc2d200 8c27e13c 8cc1bf10 8c02e7c0 8cc0ea3c 
8c1dbf60 8c02a2da 
[0.00] bf00: 8cc1bf1c 8c018b60 fffe 8c159d20 ff0f 8cc01240 
8c27e13c 8c02a428 
[0.00] bf20: 8cc1bf3c 8c02e7c0 <6>DMA: Registering pvr2_dmac handler (1 
channel).
[0.00] 8c02a220 8c02e940 8c02e200 8cc01248 8cc01240  
[0.00] bf40: <6>DMA: Registering g2_dmac handler (4 channels).
[0.00] 8cc0e9c0 8c02e9c0 8cc1bf48 8cc1bf48  8cc0e9c0 8c02e9c0 
8cc1bf48 
[0.00] bf60: 8cc1bf48 8c02e25a 8cc1bf84  fffc 8c013900 
8c02a3a0 8cc01240 
[0.00] bf80: 8c02e200 8c0038c4     
  
[0.00] bfa0:  Autoconfig PCI channel 0x8c27e36c
[0.00] Scanning bus 00, I/O 0x01001600:0x01003600, Mem 
0x0184:0x01848000
[0.00] 00:00.0 Class 0200: 11db:1234 (rev 10)
[0.00] I/O at 0x01001600 [size=0x100]
[0.00] Mem at 0x0184 [size=0x100]
[0.00]    8cc11ec8 8c02e220   
[0.00] bfc0:      <5>PCI: 
Fixing up device :00:00.0
[0.00]   8cc1bfa0 
[0.00] bfe0: 8c0038c0  4000    
  
[0.00] 
[0.00] Call trace: 
[0.00] [<8c00762e>] dump_stack+0xe/0x9e0
[0.00] [<8c103890>] kobject_init+0x30/0xa0
[0.00] [<8c14435e>] device_initialize+0x1e/0xa0
[0.00] [<8c144aae>] device_register+0xe/0x40
[0.00] [<8c159aa8>] maple_attach_driver+0x128/0x1c0
[0.00] [<8c159e58>] maple_dma_handler+0x138/0x300
[0.00] [<8c159d20>] maple_dma_handler+0x0/0x300
[0.00] [<8c02e7c0>] prepare_to_wait+0x0/0xc0
[0.00] 

kobject oops with maple bus

2008-01-26 Thread Adrian McMenamin
Greg,

Just updated my git to the latest sources and get these (seemingly non-fatal) 
oops with the Dreamcast maple bus. I'll investigate further, but they may mean 
something to out out of the box.

Adrian




dreamy:~# [0.00] Linux version 2.6.24-gf0ea9c3d-dirty ([EMAIL 
PROTECTED]) (gcc version 3.4.6) #328 PREEMPT Sat Jan 26 19:45:30 GMT 2008
[0.00] console [sercon0] enabled
[0.00] Booting machvec: Sega Dreamcast
[0.00] Node 0: start_pfn = 0xc000, low = 0xd000
[0.00] Zone PFN ranges:
[0.00]   Normal  49152 -53248
[0.00] Movable zone start PFN for each node
[0.00] early_node_map[1] active PFN ranges
[0.00] 0:49152 -53248
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 4064
[0.00] Kernel command line: root=/dev/nfs rw 
nfsroot=192.168.61.50:/home/adrian/debdist ip=dhcp earlyprintk=serial 
video=pvr2fb:[EMAIL PROTECTED] consol7
[0.00] PID hash table entries: 64 (order: 6, 256 bytes)
[0.00] Using tmu for system timer
[0.00] Using 12.469 MHz high precision timer.
[0.00] Console: colour dummy device 80x25
[0.00] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.00] Memory: 13468k/16384k available (1918k kernel code, 645k data, 
96k init)
[0.00] PVR=040205c1 CVR= PRR=
[0.00] I-cache : n_ways=1 n_sets=256 way_incr=8192
[0.00] I-cache : entry_mask=0x1fe0 alias_mask=0x1000 n_aliases=2
[0.00] D-cache : n_ways=1 n_sets=512 way_incr=16384
[0.00] D-cache : entry_mask=0x3fe0 alias_mask=0x3000 n_aliases=4
[0.00] SLUB: Genslabs=9, HWalign=32, Order=0-1, MinObjects=4, CPUs=1, 
Nodes=1
[0.00] Mount-cache hash table entries: 512
[0.00] CPU: SH7750
[0.00] net_namespace: 64 bytes
[0.00] NET: Registered protocol family 16
[0.00] Maple bus at (0, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus at (1, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus at (2, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus at (3, 0): Connected function 0x0
[0.00] No maple driver found for this device
[0.00] Maple bus core now registered.
[0.00] DMA: Registering DMA API.
[0.00] DMA: Registering sh_dmac handler (4 channels).
[0.00] Maple bus at (0, 0): Connected function 0x1
[0.00] No maple driver found for this device
[0.00] kobject (8cc2d360): tried to init an initialized object, 
something is seriously wrong.
[0.00] Stack: (0x8cc1be88 to 0x8cc1c000)
[0.00] be80:   8c00762e 8cc1be98 8c27d050 8cc2d360 
8c103890 8cc1bea0 
[0.00] bea0: 8c14435e 8cc1beb0 8cc2d200 8cc2d2f8 8cc2d200 8c144aae 
8cc1bec0 8cc2d2f8 
[0.00] bec0: 8c159aa8 8cc1becc 0001 8c159e58 8cc1beec 8cc69880 
fffe 8c159d20 
[0.00] bee0: 8c27e14c 8cc2d200 8c27e13c 8cc1bf10 8c02e7c0 8cc0ea3c 
8c1dbf60 8c02a2da 
[0.00] bf00: 8cc1bf1c 8c018b60 fffe 8c159d20 ff0f 8cc01240 
8c27e13c 8c02a428 
[0.00] bf20: 8cc1bf3c 8c02e7c0 6DMA: Registering pvr2_dmac handler (1 
channel).
[0.00] 8c02a220 8c02e940 8c02e200 8cc01248 8cc01240  
[0.00] bf40: 6DMA: Registering g2_dmac handler (4 channels).
[0.00] 8cc0e9c0 8c02e9c0 8cc1bf48 8cc1bf48  8cc0e9c0 8c02e9c0 
8cc1bf48 
[0.00] bf60: 8cc1bf48 8c02e25a 8cc1bf84  fffc 8c013900 
8c02a3a0 8cc01240 
[0.00] bf80: 8c02e200 8c0038c4     
  
[0.00] bfa0:  Autoconfig PCI channel 0x8c27e36c
[0.00] Scanning bus 00, I/O 0x01001600:0x01003600, Mem 
0x0184:0x01848000
[0.00] 00:00.0 Class 0200: 11db:1234 (rev 10)
[0.00] I/O at 0x01001600 [size=0x100]
[0.00] Mem at 0x0184 [size=0x100]
[0.00]    8cc11ec8 8c02e220   
[0.00] bfc0:      5PCI: 
Fixing up device :00:00.0
[0.00]   8cc1bfa0 
[0.00] bfe0: 8c0038c0  4000    
  
[0.00] 
[0.00] Call trace: 
[0.00] [8c00762e] dump_stack+0xe/0x9e0
[0.00] [8c103890] kobject_init+0x30/0xa0
[0.00] [8c14435e] device_initialize+0x1e/0xa0
[0.00] [8c144aae] device_register+0xe/0x40
[0.00] [8c159aa8] maple_attach_driver+0x128/0x1c0
[0.00] [8c159e58] maple_dma_handler+0x138/0x300
[0.00] [8c159d20] maple_dma_handler+0x0/0x300
[0.00] [8c02e7c0] prepare_to_wait+0x0/0xc0
[0.00] [8c1dbf60] 

Re: kobject oops with maple bus

2008-01-26 Thread Adrian McMenamin
On 26/01/2008, Adrian McMenamin [EMAIL PROTECTED] wrote:
 Greg,

 Just updated my git to the latest sources and get these (seemingly non-fatal) 
 oops with the Dreamcast maple bus. I'll investigate further, but they may 
 mean something to out out of the box.

 Adrian




 dreamy:~# [0.00] Linux version 2.6.24-gf0ea9c3d-dirty ([EMAIL 
 PROTECTED]) (gcc version 3.4.6) #328 PREEMPT Sat Jan 26 19:45:30 GMT 2008
 [0.00] console [sercon0] enabled
 [0.00] Booting machvec: Sega Dreamcast
 [0.00] Node 0: start_pfn = 0xc000, low = 0xd000
 [0.00] Zone PFN ranges:
 [0.00]   Normal  49152 -53248
 [0.00] Movable zone start PFN for each node
 [0.00] early_node_map[1] active PFN ranges


Oh, and I've just noticed everythung appears to be timed to 0 too. Very odd.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kobject oops with maple bus

2008-01-26 Thread Adrian McMenamin

On Sat, 2008-01-26 at 12:44 -0800, Greg KH wrote:
 On Sat, Jan 26, 2008 at 07:53:20PM +, Adrian McMenamin wrote:
  Greg,
  
  Just updated my git to the latest sources and get these (seemingly 
  non-fatal) oops with the Dreamcast maple bus. I'll investigate further, but 
  they may mean something to out out of the box.
  
  Adrian
  
  
  
  
  dreamy:~# [0.00] Linux version 2.6.24-gf0ea9c3d-dirty ([EMAIL 
  PROTECTED]) (gcc version 3.4.6) #328 PREEMPT Sat Jan 26 19:45:30 GMT 2008
  [0.00] console [sercon0] enabled
  [0.00] Booting machvec: Sega Dreamcast
  [0.00] Node 0: start_pfn = 0xc000, low = 0xd000
  [0.00] Zone PFN ranges:
  [0.00]   Normal  49152 -53248
  [0.00] Movable zone start PFN for each node
  [0.00] early_node_map[1] active PFN ranges
  [0.00] 0:49152 -53248
  [0.00] Built 1 zonelists in Zone order, mobility grouping on.  
  Total pages: 4064
  [0.00] Kernel command line: root=/dev/nfs rw 
  nfsroot=192.168.61.50:/home/adrian/debdist ip=dhcp earlyprintk=serial 
  video=pvr2fb:[EMAIL PROTECTED] consol7
  [0.00] PID hash table entries: 64 (order: 6, 256 bytes)
  [0.00] Using tmu for system timer
  [0.00] Using 12.469 MHz high precision timer.
  [0.00] Console: colour dummy device 80x25
  [0.00] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
  [0.00] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
  [0.00] Memory: 13468k/16384k available (1918k kernel code, 645k 
  data, 96k init)
  [0.00] PVR=040205c1 CVR= PRR=
  [0.00] I-cache : n_ways=1 n_sets=256 way_incr=8192
  [0.00] I-cache : entry_mask=0x1fe0 alias_mask=0x1000 
  n_aliases=2
  [0.00] D-cache : n_ways=1 n_sets=512 way_incr=16384
  [0.00] D-cache : entry_mask=0x3fe0 alias_mask=0x3000 
  n_aliases=4
  [0.00] SLUB: Genslabs=9, HWalign=32, Order=0-1, MinObjects=4, 
  CPUs=1, Nodes=1
  [0.00] Mount-cache hash table entries: 512
  [0.00] CPU: SH7750
  [0.00] net_namespace: 64 bytes
  [0.00] NET: Registered protocol family 16
  [0.00] Maple bus at (0, 0): Connected function 0x0
  [0.00] No maple driver found for this device
  [0.00] Maple bus at (1, 0): Connected function 0x0
  [0.00] No maple driver found for this device
  [0.00] Maple bus at (2, 0): Connected function 0x0
  [0.00] No maple driver found for this device
  [0.00] Maple bus at (3, 0): Connected function 0x0
  [0.00] No maple driver found for this device
  [0.00] Maple bus core now registered.
  [0.00] DMA: Registering DMA API.
  [0.00] DMA: Registering sh_dmac handler (4 channels).
  [0.00] Maple bus at (0, 0): Connected function 0x1
  [0.00] No maple driver found for this device
  [0.00] kobject (8cc2d360): tried to init an initialized object, 
  something is seriously wrong.
 
 The problem is here.  You have possibly already initialized this object,
 or called 'kobject_get' on it before registering it with the driver
 core.  This is a new sanity check that has been in the -mm tree for
 years :)
 
 So I think something needs to be fixed in the code.  Do you want me to
 take a look at it?
 

I think it is probably registering the dummy driver a second or
further time. Does that make sense? By all means have a look, but I'll
have a go - I'm sure you have better things to do than mess about with
Dreamcast code :)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SG - fix SH Kconfig

2008-01-20 Thread Adrian McMenamin

On Sun, 2008-01-20 at 11:54 -0800, Randy Dunlap wrote:
> On Sun, 20 Jan 2008 18:18:29 +0000 Adrian McMenamin wrote:
> 
> > From: Adrian McMenamin <[EMAIL PROTECTED]>
> > 
> > 
> > Remove reference to board deleted in commit 
> > 758e06ded4c48024835ef0a14627afcde2e25929
> > 
> > Submitted-by: Adrian McMenamin <[EMAIL PROTECTED]>
> 
> s/Submitted/Signed-off/
> 
> What is "SG" in $subject for?

Oops. Double error. SG is Badtypist for SH.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] SG - fix SH Kconfig

2008-01-20 Thread Adrian McMenamin
From: Adrian McMenamin <[EMAIL PROTECTED]>


Remove reference to board deleted in commit 
758e06ded4c48024835ef0a14627afcde2e25929

Submitted-by: Adrian McMenamin <[EMAIL PROTECTED]>
---

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 85bd9ac..e94430b 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -518,7 +518,6 @@ config SH_CAYMAN
 
 endmenu
 
-source "arch/sh/boards/renesas/hs7751rvoip/Kconfig"
 source "arch/sh/boards/renesas/rts7751r2d/Kconfig"
 source "arch/sh/boards/renesas/r7780rp/Kconfig"
 source "arch/sh/boards/magicpanelr2/Kconfig"

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] SG - fix SH Kconfig

2008-01-20 Thread Adrian McMenamin
From: Adrian McMenamin [EMAIL PROTECTED]


Remove reference to board deleted in commit 
758e06ded4c48024835ef0a14627afcde2e25929

Submitted-by: Adrian McMenamin [EMAIL PROTECTED]
---

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 85bd9ac..e94430b 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -518,7 +518,6 @@ config SH_CAYMAN
 
 endmenu
 
-source arch/sh/boards/renesas/hs7751rvoip/Kconfig
 source arch/sh/boards/renesas/rts7751r2d/Kconfig
 source arch/sh/boards/renesas/r7780rp/Kconfig
 source arch/sh/boards/magicpanelr2/Kconfig

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SG - fix SH Kconfig

2008-01-20 Thread Adrian McMenamin

On Sun, 2008-01-20 at 11:54 -0800, Randy Dunlap wrote:
 On Sun, 20 Jan 2008 18:18:29 + Adrian McMenamin wrote:
 
  From: Adrian McMenamin [EMAIL PROTECTED]
  
  
  Remove reference to board deleted in commit 
  758e06ded4c48024835ef0a14627afcde2e25929
  
  Submitted-by: Adrian McMenamin [EMAIL PROTECTED]
 
 s/Submitted/Signed-off/
 
 What is SG in $subject for?

Oops. Double error. SG is Badtypist for SH.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-17 Thread Adrian McMenamin
From: Adrian McMenamin <[EMAIL PROTECTED]>

This patch adds support for the GD-Rom drive, SEGA's proprietary
implementation of an IDE CD Rom for the SEGA Dreamcast. This driver
implements Sega's Packet Interface (SPI) - at least partially. It will
also read disks in SEGA's propreitary GD format.

Unlike previous drivers (which were never in mainline) this uses DMA and
not PIO to read disks. It is a new driver, not a refactoring of old
drivers. 

I hope I've fixed all the white space and other issues now!

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>

---

diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-14 22:32:26.0 +
+++ b/drivers/block/Kconfig 2008-01-14 22:35:38.0 +
@@ -105,6 +105,17 @@ config PARIDE
  "MicroSolutions backpack protocol", "DataStor Commuter protocol"
  etc.).
 
+config GDROM
+   tristate "SEGA Dreamcast GD-ROM drive"
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ "GD-ROM" by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say "Y" here.
+ You can also build this as a module which will be called gdrom.ko
+
 source "drivers/block/paride/Kconfig"
 
 config BLK_CPQ_DA
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-17 22:19:22.0 +
@@ -0,0 +1,867 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GDROM_DEV_NAME "gdrom"
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)

+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#define GDROM_HARD_SECTOR  2048
+#define BLOCK_LAYER_SECTOR 512
+#define GD_TO_BLK  4
+
+#define GDROM_DEFAULT_TIMEOUT  (HZ * 7)
+
+static const struct {
+   int sense_key;
+   const char * const text;
+} sense_texts[] = {
+   {NO_SENSE, "OK"},
+   {RECOVERED_ERROR, "Recovered from error"},
+   {NOT_READY, "Device not ready"},
+   {MEDIUM_ERROR, "Disk not ready"},
+   {HARDWARE_ERROR, "Hardware error"},
+   {ILLEGAL_REQUEST, "Command has failed"},
+   {UNIT_ATTENTION, "Device needs attention - disk may have been changed&

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-17 Thread Adrian McMenamin
From: Adrian McMenamin [EMAIL PROTECTED]

This patch adds support for the GD-Rom drive, SEGA's proprietary
implementation of an IDE CD Rom for the SEGA Dreamcast. This driver
implements Sega's Packet Interface (SPI) - at least partially. It will
also read disks in SEGA's propreitary GD format.

Unlike previous drivers (which were never in mainline) this uses DMA and
not PIO to read disks. It is a new driver, not a refactoring of old
drivers. 

I hope I've fixed all the white space and other issues now!

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

---

diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-14 22:32:26.0 +
+++ b/drivers/block/Kconfig 2008-01-14 22:35:38.0 +
@@ -105,6 +105,17 @@ config PARIDE
  MicroSolutions backpack protocol, DataStor Commuter protocol
  etc.).
 
+config GDROM
+   tristate SEGA Dreamcast GD-ROM drive
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ GD-ROM by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say Y here.
+ You can also build this as a module which will be called gdrom.ko
+
 source drivers/block/paride/Kconfig
 
 config BLK_CPQ_DA
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-17 22:19:22.0 +
@@ -0,0 +1,867 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/fs.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/dma-mapping.h
+#include linux/cdrom.h
+#include linux/genhd.h
+#include linux/bio.h
+#include linux/blkdev.h
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/wait.h
+#include linux/workqueue.h
+#include linux/platform_device.h
+#include scsi/scsi.h
+#include asm/io.h
+#include asm/dma.h
+#include asm/delay.h
+#include asm/mach/dma.h
+#include asm/mach/sysasic.h
+
+#define GDROM_DEV_NAME gdrom
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)

+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#define GDROM_HARD_SECTOR  2048
+#define BLOCK_LAYER_SECTOR 512
+#define GD_TO_BLK  4
+
+#define GDROM_DEFAULT_TIMEOUT  (HZ * 7)
+
+static const struct {
+   int sense_key;
+   const char * const text;
+} sense_texts[] = {
+   {NO_SENSE, OK},
+   {RECOVERED_ERROR, Recovered from error},
+   {NOT_READY, Device not ready},
+   {MEDIUM_ERROR, Disk not ready},
+   {HARDWARE_ERROR, Hardware error

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-16 Thread Adrian McMenamin

On Mon, 2008-01-14 at 23:17 +, Adrian McMenamin wrote:
> On Mon, 2008-01-14 at 23:00 +0000, Adrian McMenamin wrote:
> > From: Adrian McMenamin <[EMAIL PROTECTED]>
> >  
> > This patch adds support for the GD-Rom drive, SEGA's proprietary
> > implementation of an IDE CD Rom for the SEGA Dreamcast. This driver
> > implements Sega's Packet Interface (SPI) - at least partially. It will
> > also read disks in SEGA's propreitary GD format.
> > 
> > Unlike previous drivers (which were never in mainline) this uses DMA and
> > not PIO to read disks. It is a new driver, not a refactoring of old
> > drivers. 
> > 
> > Hopefully this patch addresses some issues that have been raised by
> > Andrew. Jens previously ack'ed this, but I've left that off (though the
> > IO code hasn't really been touched).
> >  
> > Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
> >  
> > (Jens - this awaits your ack before going in Paul's queue for the 2.6.25
> > window)
> >  
> 
I think I have now removed all the whitespace issues.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>


---

diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-14 22:32:26.0 +
+++ b/drivers/block/Kconfig 2008-01-14 22:35:38.0 +
@@ -105,6 +105,17 @@ config PARIDE
  "MicroSolutions backpack protocol", "DataStor Commuter protocol"
  etc.).
 
+config GDROM
+   tristate "SEGA Dreamcast GD-ROM drive"
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ "GD-ROM" by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say "Y" here.
+ You can also build this as a module which will be called gdrom.ko
+
 source "drivers/block/paride/Kconfig"
 
 config BLK_CPQ_DA
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-16 23:47:36.0 +
@@ -0,0 +1,867 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GDROM_DEV_NAME "gdrom"
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-15 Thread Adrian McMenamin
On 15/01/2008, Paul Mundt <[EMAIL PROTECTED]> wrote:
> On Mon, Jan 14, 2008 at 11:17:15PM +0000, Adrian McMenamin wrote:

>
> > +static bool gdrom_data_request(void)
> > +{
> > + return (ctrl_inb(GDROM_ALTSTATUS_REG) & 0x88) == 8;
> > +}
> > +
> Andrew first pointed this out, and this is still broken.
>

Eh, no, he didn't. What is wrong with it?

He compalined about excessively long busy waiting and then not
checking if the busy wait failed. Both those have been fixed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-15 Thread Adrian McMenamin
On 15/01/2008, Paul Mundt [EMAIL PROTECTED] wrote:
 On Mon, Jan 14, 2008 at 11:17:15PM +, Adrian McMenamin wrote:


  +static bool gdrom_data_request(void)
  +{
  + return (ctrl_inb(GDROM_ALTSTATUS_REG)  0x88) == 8;
  +}
  +
 Andrew first pointed this out, and this is still broken.


Eh, no, he didn't. What is wrong with it?

He compalined about excessively long busy waiting and then not
checking if the busy wait failed. Both those have been fixed.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-14 Thread Adrian McMenamin

On Mon, 2008-01-14 at 23:00 +, Adrian McMenamin wrote:
> From: Adrian McMenamin <[EMAIL PROTECTED]>
>  
> This patch adds support for the GD-Rom drive, SEGA's proprietary
> implementation of an IDE CD Rom for the SEGA Dreamcast. This driver
> implements Sega's Packet Interface (SPI) - at least partially. It will
> also read disks in SEGA's propreitary GD format.
> 
> Unlike previous drivers (which were never in mainline) this uses DMA and
> not PIO to read disks. It is a new driver, not a refactoring of old
> drivers. 
> 
> Hopefully this patch addresses some issues that have been raised by
> Andrew. Jens previously ack'ed this, but I've left that off (though the
> IO code hasn't really been touched).
>  
> Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
>  
> (Jens - this awaits your ack before going in Paul's queue for the 2.6.25
> window)
>  

Apologies. Obviously something extraeous from loop.c slipped in the
previous patch - presumably resulting from the differences between the
2.6.25 queue and 2.6.24-rc7.

Here's a corrected version.



diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-14 22:32:26.0 +
+++ b/drivers/block/Kconfig 2008-01-14 22:35:38.0 +
@@ -105,6 +105,17 @@ config PARIDE
  "MicroSolutions backpack protocol", "DataStor Commuter protocol"
  etc.).
 
+config GDROM
+   tristate "SEGA Dreamcast GD-ROM drive"
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ "GD-ROM" by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say "Y" here.
+ You can also build this as a module which will be called gdrom.ko
+
 source "drivers/block/paride/Kconfig"
 
 config BLK_CPQ_DA
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-14 22:35:39.0 +
@@ -0,0 +1,867 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GDROM_DEV_NAME "gdrom"
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#define GDROM_HARD_SECTOR  2048
+#define BLOCK_LA

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-14 Thread Adrian McMenamin
From: Adrian McMenamin <[EMAIL PROTECTED]>
 
This patch adds support for the GD-Rom drive, SEGA's proprietary
implementation of an IDE CD Rom for the SEGA Dreamcast. This driver
implements Sega's Packet Interface (SPI) - at least partially. It will
also read disks in SEGA's propreitary GD format.

Unlike previous drivers (which were never in mainline) this uses DMA and
not PIO to read disks. It is a new driver, not a refactoring of old
drivers. 

Hopefully this patch addresses some issues that have been raised by
Andrew. Jens previously ack'ed this, but I've left that off (though the
IO code hasn't really been touched).
 
Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
 
(Jens - this awaits your ack before going in Paul's queue for the 2.6.25
window)
 
 
 
diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-14 22:32:26.0 +
+++ b/drivers/block/Kconfig 2008-01-14 22:35:38.0 +
@@ -105,6 +105,17 @@ config PARIDE
  "MicroSolutions backpack protocol", "DataStor Commuter protocol"
  etc.).
 
+config GDROM
+   tristate "SEGA Dreamcast GD-ROM drive"
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ "GD-ROM" by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say "Y" here.
+ You can also build this as a module which will be called gdrom.ko
+
 source "drivers/block/paride/Kconfig"
 
 config BLK_CPQ_DA
diff -rupN a/drivers/block/loop.c b/drivers/block/loop.c
--- a/drivers/block/loop.c  2008-01-14 22:32:26.0 +
+++ b/drivers/block/loop.c  2008-01-14 22:35:38.0 +
@@ -610,7 +610,7 @@ static int loop_thread(void *data)
 static int loop_switch(struct loop_device *lo, struct file *file)
 {
struct switch_request w;
-   struct bio *bio = bio_alloc(GFP_KERNEL, 1);
+   struct bio *bio = bio_alloc(GFP_KERNEL, 0);
if (!bio)
return -ENOMEM;
init_completion();
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-14 22:35:39.0 +
@@ -0,0 +1,867 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GDROM_DEV_NAME "gdrom"
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG 

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-14 Thread Adrian McMenamin

On Mon, 2008-01-14 at 23:00 +, Adrian McMenamin wrote:
 From: Adrian McMenamin [EMAIL PROTECTED]
  
 This patch adds support for the GD-Rom drive, SEGA's proprietary
 implementation of an IDE CD Rom for the SEGA Dreamcast. This driver
 implements Sega's Packet Interface (SPI) - at least partially. It will
 also read disks in SEGA's propreitary GD format.
 
 Unlike previous drivers (which were never in mainline) this uses DMA and
 not PIO to read disks. It is a new driver, not a refactoring of old
 drivers. 
 
 Hopefully this patch addresses some issues that have been raised by
 Andrew. Jens previously ack'ed this, but I've left that off (though the
 IO code hasn't really been touched).
  
 Signed-off by: Adrian McMenamin [EMAIL PROTECTED]
  
 (Jens - this awaits your ack before going in Paul's queue for the 2.6.25
 window)
  

Apologies. Obviously something extraeous from loop.c slipped in the
previous patch - presumably resulting from the differences between the
2.6.25 queue and 2.6.24-rc7.

Here's a corrected version.



diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-14 22:32:26.0 +
+++ b/drivers/block/Kconfig 2008-01-14 22:35:38.0 +
@@ -105,6 +105,17 @@ config PARIDE
  MicroSolutions backpack protocol, DataStor Commuter protocol
  etc.).
 
+config GDROM
+   tristate SEGA Dreamcast GD-ROM drive
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ GD-ROM by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say Y here.
+ You can also build this as a module which will be called gdrom.ko
+
 source drivers/block/paride/Kconfig
 
 config BLK_CPQ_DA
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-14 22:35:39.0 +
@@ -0,0 +1,867 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/fs.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/dma-mapping.h
+#include linux/cdrom.h
+#include linux/genhd.h
+#include linux/bio.h
+#include linux/blkdev.h
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/wait.h
+#include linux/workqueue.h
+#include linux/platform_device.h
+#include scsi/scsi.h
+#include asm/io.h
+#include asm/dma.h
+#include asm/delay.h
+#include asm/mach/dma.h
+#include asm/mach/sysasic.h
+
+#define GDROM_DEV_NAME gdrom
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-14 Thread Adrian McMenamin
From: Adrian McMenamin [EMAIL PROTECTED]
 
This patch adds support for the GD-Rom drive, SEGA's proprietary
implementation of an IDE CD Rom for the SEGA Dreamcast. This driver
implements Sega's Packet Interface (SPI) - at least partially. It will
also read disks in SEGA's propreitary GD format.

Unlike previous drivers (which were never in mainline) this uses DMA and
not PIO to read disks. It is a new driver, not a refactoring of old
drivers. 

Hopefully this patch addresses some issues that have been raised by
Andrew. Jens previously ack'ed this, but I've left that off (though the
IO code hasn't really been touched).
 
Signed-off by: Adrian McMenamin [EMAIL PROTECTED]
 
(Jens - this awaits your ack before going in Paul's queue for the 2.6.25
window)
 
 
 
diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-14 22:32:26.0 +
+++ b/drivers/block/Kconfig 2008-01-14 22:35:38.0 +
@@ -105,6 +105,17 @@ config PARIDE
  MicroSolutions backpack protocol, DataStor Commuter protocol
  etc.).
 
+config GDROM
+   tristate SEGA Dreamcast GD-ROM drive
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ GD-ROM by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say Y here.
+ You can also build this as a module which will be called gdrom.ko
+
 source drivers/block/paride/Kconfig
 
 config BLK_CPQ_DA
diff -rupN a/drivers/block/loop.c b/drivers/block/loop.c
--- a/drivers/block/loop.c  2008-01-14 22:32:26.0 +
+++ b/drivers/block/loop.c  2008-01-14 22:35:38.0 +
@@ -610,7 +610,7 @@ static int loop_thread(void *data)
 static int loop_switch(struct loop_device *lo, struct file *file)
 {
struct switch_request w;
-   struct bio *bio = bio_alloc(GFP_KERNEL, 1);
+   struct bio *bio = bio_alloc(GFP_KERNEL, 0);
if (!bio)
return -ENOMEM;
init_completion(w.wait);
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-14 22:35:39.0 +
@@ -0,0 +1,867 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/fs.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/dma-mapping.h
+#include linux/cdrom.h
+#include linux/genhd.h
+#include linux/bio.h
+#include linux/blkdev.h
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/wait.h
+#include linux/workqueue.h
+#include linux/platform_device.h
+#include scsi/scsi.h
+#include asm/io.h
+#include asm/dma.h
+#include asm/delay.h
+#include asm/mach/dma.h
+#include asm/mach/sysasic.h
+
+#define GDROM_DEV_NAME gdrom
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-13 Thread Adrian McMenamin
On 12/01/2008, Andrew Morton <[EMAIL PROTECTED]> wrote:
> On Sat, 12 Jan 2008 14:14:01 +0000 Adrian McMenamin <[EMAIL PROTECTED]> wrote:
>
> >
> > > > + spin_command->cmd[0] = 0x70;
> > > > + spin_command->cmd[2] = 0x1f;
> > > > + spin_command->buflen = 0;
> > > > + gd.pending = 1;
> > > > + gdrom_packetcommand(gd.cd_info, spin_command);
> > > > + /* 60 second timeout */
> > > > + wait_event_interruptible_timeout(command_queue, gd.pending == 0, HZ * 
> > > > 60);
> > > > + gd.pending = 0;
> > > > + kfree(spin_command);
> > > > + if (gd.status & 0x01) {
> > > > + /* log an error */
> > > > + gdrom_getsense(NULL);
> > > > + return -EIO;
> > > > + }
> > > > + return 0;
> > > > +}
> > >
> > > If the wait_event_interruptible_timeout() indeed times out, we go ahead 
> > > and
> > > free spin_command.  But someone else could potentially be using it.
> > >
> > > Suppose gdrom_packetcommand() got stuck for a minute due to bad hardware,
> > > or some SCHED_FIFO task preempting us here and running for 61 seconds 
> > > without
> > > yielding or something similarly weird.
> > >
> >
> >
> > Maybe I am being stupid here, but I don't follow this. They'll get a
> > non-fatal error, that's all. Who else would be using spin_command? It's
> > just a series of bytes to plug into the GD Rom registers, that's all.
> >
>
> After programming the registers we need to wait for the interrupt to clear
> gd.pending, don't we?
>
> 
>
> oh, I see.  gd is a global singleton and we only support one command at a
> time and one device.  hrm.
>

OK, at the risk of looking like a fool:

Yes, it does treat this as only one device per box as that's the way
the things are made.

The hardware will stop you from running two commands in parallel - the
device will be flagged as busy and so you won't be able to get it do
anything sensible. I have now added in some additional checks so that
a user cannot start another command before the old one finishes - but
I still don't see what the problem is with freeing the memory.

The variable is a local, and an automatic, not a global or a static,
so I don't see how kfree() could be releasing somebody else's lump of
memory anyway. Or have I missed something obvious?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-13 Thread Adrian McMenamin
On 12/01/2008, Andrew Morton [EMAIL PROTECTED] wrote:
 On Sat, 12 Jan 2008 14:14:01 + Adrian McMenamin [EMAIL PROTECTED] wrote:

 
+ spin_command-cmd[0] = 0x70;
+ spin_command-cmd[2] = 0x1f;
+ spin_command-buflen = 0;
+ gd.pending = 1;
+ gdrom_packetcommand(gd.cd_info, spin_command);
+ /* 60 second timeout */
+ wait_event_interruptible_timeout(command_queue, gd.pending == 0, HZ * 
60);
+ gd.pending = 0;
+ kfree(spin_command);
+ if (gd.status  0x01) {
+ /* log an error */
+ gdrom_getsense(NULL);
+ return -EIO;
+ }
+ return 0;
+}
  
   If the wait_event_interruptible_timeout() indeed times out, we go ahead 
   and
   free spin_command.  But someone else could potentially be using it.
  
   Suppose gdrom_packetcommand() got stuck for a minute due to bad hardware,
   or some SCHED_FIFO task preempting us here and running for 61 seconds 
   without
   yielding or something similarly weird.
  
 
 
  Maybe I am being stupid here, but I don't follow this. They'll get a
  non-fatal error, that's all. Who else would be using spin_command? It's
  just a series of bytes to plug into the GD Rom registers, that's all.
 

 After programming the registers we need to wait for the interrupt to clear
 gd.pending, don't we?

 looks

 oh, I see.  gd is a global singleton and we only support one command at a
 time and one device.  hrm.


OK, at the risk of looking like a fool:

Yes, it does treat this as only one device per box as that's the way
the things are made.

The hardware will stop you from running two commands in parallel - the
device will be flagged as busy and so you won't be able to get it do
anything sensible. I have now added in some additional checks so that
a user cannot start another command before the old one finishes - but
I still don't see what the problem is with freeing the memory.

The variable is a local, and an automatic, not a global or a static,
so I don't see how kfree() could be releasing somebody else's lump of
memory anyway. Or have I missed something obvious?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-12 Thread Adrian McMenamin

On Sat, 2008-01-12 at 05:36 -0800, Andrew Morton wrote:
> On Fri, 11 Jan 2008 21:56:49 +0000 Adrian McMenamin <[EMAIL PROTECTED]> wrote:
> 
> > 
> > On Thu, 2008-01-10 at 23:25 +, Adrian McMenamin wrote:
> > > From: Adrian McMenamin <[EMAIL PROTECTED]>
> > > 
> > > This patch adds support for the GD-Rom drive, SEGA's proprietary 
> > > implementation of an IDE CD Rom for the SEGA Dreamcast. This driver 
> > > implements Sega's Packet Interface (SPI) - at least partially. It will 
> > > also read disks in SEGA's propreitary GD format.
> > > 
> > > Unlike previous drivers (which were never in mainline) this uses DMA and 
> > > not PIO to read disks. It is a new driver, not a refactoring of old 
> > > drivers. 
> > > 
> >
> > ...
> >
> > +
> > +static bool gdrom_is_busy(void)
> > +{
> > +   return (ctrl_inb(GDROM_ALTSTATUS_REG) & 0x80) != 0;
> > +}
> > +
> > +static bool gdrom_data_request(void)
> > +{
> > +   return (ctrl_inb(GDROM_ALTSTATUS_REG) & 0x88) == 8;
> > +}
> > +
> > +static void gdrom_wait_clrbusy(void)
> > +{
> > +   /* long timeouts - typical for a CD Rom */
> > +   unsigned long timeout = jiffies + HZ * 60;
> > +   while ((ctrl_inb(GDROM_ALTSTATUS_REG) & 0x80) && (time_before(jiffies, 
> > timeout)))
> > +   cpu_relax();
> > +}
> 
> That's a heck of a long busywait, and no indication is made to either the
> calling function or to the system operator that this funtction timed out.
> 

There is a 60 second timeout on one of the basic read fuctions in
cdrom.c, which I think is where I got this from. But the default timeout
there is 7 seconds, which I suppose I could use.


> > +static void gdrom_wait_busy_sleeps(void)
> > +{
> > +   unsigned long timeout;
> > +   /* Wait to get busy first */
> > +   timeout = jiffies + HZ * 60;
> > +   while (!gdrom_is_busy() && time_before(jiffies, timeout))
> > +   cpu_relax();
> > +   /* Now wait for busy to clear */
> > +   gdrom_wait_clrbusy();
> > +}
> 
> Ditto * 2.
> 
> > +static void gdrom_identifydevice(void *buf)
> > +{
> > +   int c;
> > +   short *data = buf;
> > +   gdrom_wait_clrbusy();
> > +   ctrl_outb(GDROM_COM_IDDEV, GDROM_STATUSCOMMAND_REG);
> > +   gdrom_wait_busy_sleeps();
> > +   /* now read in the data */
> > +   for (c = 0; c < 40; c++)
> > +   data[c] = ctrl_inw(GDROM_DATA_REG);
> > +}
> 
> Most kernel code puts a blank line after the definition of the locals and
> before start-of-code.  We don't make a big fuss over code which omits the
> blanks line but please consider.
> 
> > +static void gdrom_spicommand(void *spi_string, int buflen)
> > +{
> > +   short *cmd = spi_string;
> > +   /* ensure IRQ_WAIT is set */
> > +   ctrl_outb(0x08, GDROM_ALTSTATUS_REG);
> > +   /* specify how many bytes we expect back */
> > +   ctrl_outb(buflen & 0xFF, GDROM_BCL_REG);
> > +   ctrl_outb((buflen >> 8) & 0xFF, GDROM_BCH_REG);
> > +   /* other parameters */
> > +   ctrl_outb(0, GDROM_INTSEC_REG);
> > +   ctrl_outb(0, GDROM_SECNUM_REG);
> > +   ctrl_outb(0, GDROM_ERROR_REG);
> > +   /* Wait until we can go */
> > +   gdrom_wait_clrbusy();
> > +   ctrl_outb(GDROM_COM_PACKET, GDROM_STATUSCOMMAND_REG);
> > +   while (!gdrom_data_request())
> > +   cpu_relax();
> 
> No timeout at all here?


True enough. If the bits never cleared that would be broken hardware,
but not a reason not to catch it.

> 
> > +   outsw(PHYSADDR(GDROM_DATA_REG), cmd, 6);
> > +}
> > +




> > +static int gdrom_preparedisk_cmd(void)
> > +{
> > +   struct packet_command *spin_command;
> > +   spin_command = kzalloc(sizeof(struct packet_command), GFP_KERNEL);
> > +   if (!spin_command)
> > +   return -ENOMEM;
> > +   spin_command->cmd[0] = 0x70;
> > +   spin_command->cmd[2] = 0x1f;
> > +   spin_command->buflen = 0;
> > +   gd.pending = 1;
> > +   gdrom_packetcommand(gd.cd_info, spin_command);
> > +   /* 60 second timeout */
> > +   wait_event_interruptible_timeout(command_queue, gd.pending == 0, HZ * 
> > 60);
> > +   gd.pending = 0;
> > +   kfree(spin_command);
> > +   if (gd.status & 0x01) {
> > +   /* log an error */
> > +   gdrom_getsense(NULL);
> > +   return -EIO;
> > +   }
> > +   return 0;
> > +}
> 
> If the wait_event_interruptible_timeout() indeed times out, we go 

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-12 Thread Adrian McMenamin

On Sat, 2008-01-12 at 05:36 -0800, Andrew Morton wrote:
 On Fri, 11 Jan 2008 21:56:49 + Adrian McMenamin [EMAIL PROTECTED] wrote:
 
  
  On Thu, 2008-01-10 at 23:25 +, Adrian McMenamin wrote:
   From: Adrian McMenamin [EMAIL PROTECTED]
   
   This patch adds support for the GD-Rom drive, SEGA's proprietary 
   implementation of an IDE CD Rom for the SEGA Dreamcast. This driver 
   implements Sega's Packet Interface (SPI) - at least partially. It will 
   also read disks in SEGA's propreitary GD format.
   
   Unlike previous drivers (which were never in mainline) this uses DMA and 
   not PIO to read disks. It is a new driver, not a refactoring of old 
   drivers. 
   
 
  ...
 
  +
  +static bool gdrom_is_busy(void)
  +{
  +   return (ctrl_inb(GDROM_ALTSTATUS_REG)  0x80) != 0;
  +}
  +
  +static bool gdrom_data_request(void)
  +{
  +   return (ctrl_inb(GDROM_ALTSTATUS_REG)  0x88) == 8;
  +}
  +
  +static void gdrom_wait_clrbusy(void)
  +{
  +   /* long timeouts - typical for a CD Rom */
  +   unsigned long timeout = jiffies + HZ * 60;
  +   while ((ctrl_inb(GDROM_ALTSTATUS_REG)  0x80)  (time_before(jiffies, 
  timeout)))
  +   cpu_relax();
  +}
 
 That's a heck of a long busywait, and no indication is made to either the
 calling function or to the system operator that this funtction timed out.
 

There is a 60 second timeout on one of the basic read fuctions in
cdrom.c, which I think is where I got this from. But the default timeout
there is 7 seconds, which I suppose I could use.


  +static void gdrom_wait_busy_sleeps(void)
  +{
  +   unsigned long timeout;
  +   /* Wait to get busy first */
  +   timeout = jiffies + HZ * 60;
  +   while (!gdrom_is_busy()  time_before(jiffies, timeout))
  +   cpu_relax();
  +   /* Now wait for busy to clear */
  +   gdrom_wait_clrbusy();
  +}
 
 Ditto * 2.
 
  +static void gdrom_identifydevice(void *buf)
  +{
  +   int c;
  +   short *data = buf;
  +   gdrom_wait_clrbusy();
  +   ctrl_outb(GDROM_COM_IDDEV, GDROM_STATUSCOMMAND_REG);
  +   gdrom_wait_busy_sleeps();
  +   /* now read in the data */
  +   for (c = 0; c  40; c++)
  +   data[c] = ctrl_inw(GDROM_DATA_REG);
  +}
 
 Most kernel code puts a blank line after the definition of the locals and
 before start-of-code.  We don't make a big fuss over code which omits the
 blanks line but please consider.
 
  +static void gdrom_spicommand(void *spi_string, int buflen)
  +{
  +   short *cmd = spi_string;
  +   /* ensure IRQ_WAIT is set */
  +   ctrl_outb(0x08, GDROM_ALTSTATUS_REG);
  +   /* specify how many bytes we expect back */
  +   ctrl_outb(buflen  0xFF, GDROM_BCL_REG);
  +   ctrl_outb((buflen  8)  0xFF, GDROM_BCH_REG);
  +   /* other parameters */
  +   ctrl_outb(0, GDROM_INTSEC_REG);
  +   ctrl_outb(0, GDROM_SECNUM_REG);
  +   ctrl_outb(0, GDROM_ERROR_REG);
  +   /* Wait until we can go */
  +   gdrom_wait_clrbusy();
  +   ctrl_outb(GDROM_COM_PACKET, GDROM_STATUSCOMMAND_REG);
  +   while (!gdrom_data_request())
  +   cpu_relax();
 
 No timeout at all here?


True enough. If the bits never cleared that would be broken hardware,
but not a reason not to catch it.

 
  +   outsw(PHYSADDR(GDROM_DATA_REG), cmd, 6);
  +}
  +




  +static int gdrom_preparedisk_cmd(void)
  +{
  +   struct packet_command *spin_command;
  +   spin_command = kzalloc(sizeof(struct packet_command), GFP_KERNEL);
  +   if (!spin_command)
  +   return -ENOMEM;
  +   spin_command-cmd[0] = 0x70;
  +   spin_command-cmd[2] = 0x1f;
  +   spin_command-buflen = 0;
  +   gd.pending = 1;
  +   gdrom_packetcommand(gd.cd_info, spin_command);
  +   /* 60 second timeout */
  +   wait_event_interruptible_timeout(command_queue, gd.pending == 0, HZ * 
  60);
  +   gd.pending = 0;
  +   kfree(spin_command);
  +   if (gd.status  0x01) {
  +   /* log an error */
  +   gdrom_getsense(NULL);
  +   return -EIO;
  +   }
  +   return 0;
  +}
 
 If the wait_event_interruptible_timeout() indeed times out, we go ahead and
 free spin_command.  But someone else could potentially be using it. 
 
 Suppose gdrom_packetcommand() got stuck for a minute due to bad hardware,
 or some SCHED_FIFO task preempting us here and running for 61 seconds without
 yielding or something similarly weird.
 


Maybe I am being stupid here, but I don't follow this. They'll get a
non-fatal error, that's all. Who else would be using spin_command? It's
just a series of bytes to plug into the GD Rom registers, that's all.




  ...
 
  +/* keep the function looking like the universal CD Rom specification - 
  returning int*/
  +static int gdrom_packetcommand(struct cdrom_device_info *cd_info, struct 
  packet_command *command)
  +{
  +   gdrom_spicommand(command-cmd, command-buflen);
  +   return 0;
  +}
 
 Please pass the diff through scripts/checkpatch.pl.  Some things, like the
 above, you may choose to fix.  Some you definitely will.


I did. I'll recheck it though, of course.

 
  +/* Get Sense SPI command
  + * From

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-11 Thread Adrian McMenamin

On Thu, 2008-01-10 at 23:25 +, Adrian McMenamin wrote:
> From: Adrian McMenamin <[EMAIL PROTECTED]>
> 
> This patch adds support for the GD-Rom drive, SEGA's proprietary 
> implementation of an IDE CD Rom for the SEGA Dreamcast. This driver 
> implements Sega's Packet Interface (SPI) - at least partially. It will also 
> read disks in SEGA's propreitary GD format.
> 
> Unlike previous drivers (which were never in mainline) this uses DMA and not 
> PIO to read disks. It is a new driver, not a refactoring of old drivers. 
> 
> Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
> 
> (Jens - this awaits your ack before going in Paul's queue for the 2.6.25 
> window)
> 
> 
> 
> 

Unfortunately, there was one small mistake (a repeated assignment), in
the patch posted yesterday. Here is a corrected version.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>


diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-11 21:33:18.0 +
+++ b/drivers/block/Kconfig 2008-01-11 20:55:40.0 +
@@ -105,6 +105,17 @@ config PARIDE
  "MicroSolutions backpack protocol", "DataStor Commuter protocol"
  etc.).
 
+config GDROM
+   tristate "SEGA Dreamcast GD-ROM drive"
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ "GD-ROM" by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say "Y" here.
+ You can also build this as a module which will be called gdrom.ko
+
 source "drivers/block/paride/Kconfig"
 
 config BLK_CPQ_DA
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-11 20:55:40.0 +
@@ -0,0 +1,785 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GDROM_DEV_NAME "gdrom"
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#define GDROM_HARD_SECTOR  2048
+#define BLOCK_LAYER_SECTOR 512
+#define GD_TO_BLK  4
+
+static const struct {
+   int sense_key;
+   const char * const text;
+} sense_texts[] = {
+   {NO_SENSE, "OK"},
+

Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-11 Thread Adrian McMenamin

On Thu, 2008-01-10 at 23:25 +, Adrian McMenamin wrote:
 From: Adrian McMenamin [EMAIL PROTECTED]
 
 This patch adds support for the GD-Rom drive, SEGA's proprietary 
 implementation of an IDE CD Rom for the SEGA Dreamcast. This driver 
 implements Sega's Packet Interface (SPI) - at least partially. It will also 
 read disks in SEGA's propreitary GD format.
 
 Unlike previous drivers (which were never in mainline) this uses DMA and not 
 PIO to read disks. It is a new driver, not a refactoring of old drivers. 
 
 Signed-off by: Adrian McMenamin [EMAIL PROTECTED]
 
 (Jens - this awaits your ack before going in Paul's queue for the 2.6.25 
 window)
 
 
 
 

Unfortunately, there was one small mistake (a repeated assignment), in
the patch posted yesterday. Here is a corrected version.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]


diff -rupN a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig 2008-01-11 21:33:18.0 +
+++ b/drivers/block/Kconfig 2008-01-11 20:55:40.0 +
@@ -105,6 +105,17 @@ config PARIDE
  MicroSolutions backpack protocol, DataStor Commuter protocol
  etc.).
 
+config GDROM
+   tristate SEGA Dreamcast GD-ROM drive
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ GD-ROM by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say Y here.
+ You can also build this as a module which will be called gdrom.ko
+
 source drivers/block/paride/Kconfig
 
 config BLK_CPQ_DA
diff -rupN a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
--- a/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ b/drivers/cdrom/gdrom.c 2008-01-11 20:55:40.0 +
@@ -0,0 +1,785 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/fs.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/dma-mapping.h
+#include linux/cdrom.h
+#include linux/genhd.h
+#include linux/bio.h
+#include linux/blkdev.h
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/wait.h
+#include linux/workqueue.h
+#include linux/platform_device.h
+#include scsi/scsi.h
+#include asm/io.h
+#include asm/dma.h
+#include asm/delay.h
+#include asm/mach/dma.h
+#include asm/mach/sysasic.h
+
+#define GDROM_DEV_NAME gdrom
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#define GDROM_HARD_SECTOR  2048
+#define BLOCK_LAYER_SECTOR 512
+#define GD_TO_BLK  4
+
+static const struct

[PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-10 Thread Adrian McMenamin
From: Adrian McMenamin <[EMAIL PROTECTED]>

This patch adds support for the GD-Rom drive, SEGA's proprietary implementation 
of an IDE CD Rom for the SEGA Dreamcast. This driver implements Sega's Packet 
Interface (SPI) - at least partially. It will also read disks in SEGA's 
propreitary GD format.

Unlike previous drivers (which were never in mainline) this uses DMA and not 
PIO to read disks. It is a new driver, not a refactoring of old drivers. 

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>

(Jens - this awaits your ack before going in Paul's queue for the 2.6.25 window)





diff -rupN linux-2.6/drivers/block/Kconfig linux-2.6-new/drivers/block/Kconfig
--- linux-2.6/drivers/block/Kconfig 2008-01-10 22:25:43.0 +
+++ linux-2.6-new/drivers/block/Kconfig 2008-01-10 23:05:10.0 +
@@ -105,6 +105,17 @@ config PARIDE
  "MicroSolutions backpack protocol", "DataStor Commuter protocol"
  etc.).
 
+config GDROM
+   tristate "SEGA Dreamcast GD-ROM drive"
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ "GD-ROM" by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say "Y" here.
+ You can also build this as a module which will be called gdrom.ko
+
 source "drivers/block/paride/Kconfig"
 
 config BLK_CPQ_DA
diff -rupN linux-2.6/drivers/cdrom/gdrom.c linux-2.6-new/drivers/cdrom/gdrom.c
--- linux-2.6/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ linux-2.6-new/drivers/cdrom/gdrom.c 2008-01-10 23:05:11.0 +
@@ -0,0 +1,786 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GDROM_DEV_NAME "gdrom"
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#define GDROM_HARD_SECTOR  2048
+#define BLOCK_LAYER_SECTOR 512
+#define GD_TO_BLK  4
+
+static const struct {
+   int sense_key;
+   const char * const text;
+} sense_texts[] = {
+   {NO_SENSE, "OK"},
+   {RECOVERED_ERROR, "Recovered from error"},
+   {NOT_READY, "Device not ready"},
+   {MEDIUM_ERROR, "Disk not ready"},
+   {HARDWARE_ERROR, "Hardware error"},
+   {ILLEGAL_REQUEST, "Command has

[PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast

2008-01-10 Thread Adrian McMenamin
From: Adrian McMenamin [EMAIL PROTECTED]

This patch adds support for the GD-Rom drive, SEGA's proprietary implementation 
of an IDE CD Rom for the SEGA Dreamcast. This driver implements Sega's Packet 
Interface (SPI) - at least partially. It will also read disks in SEGA's 
propreitary GD format.

Unlike previous drivers (which were never in mainline) this uses DMA and not 
PIO to read disks. It is a new driver, not a refactoring of old drivers. 

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

(Jens - this awaits your ack before going in Paul's queue for the 2.6.25 window)





diff -rupN linux-2.6/drivers/block/Kconfig linux-2.6-new/drivers/block/Kconfig
--- linux-2.6/drivers/block/Kconfig 2008-01-10 22:25:43.0 +
+++ linux-2.6-new/drivers/block/Kconfig 2008-01-10 23:05:10.0 +
@@ -105,6 +105,17 @@ config PARIDE
  MicroSolutions backpack protocol, DataStor Commuter protocol
  etc.).
 
+config GDROM
+   tristate SEGA Dreamcast GD-ROM drive
+   depends on SH_DREAMCAST
+   help
+ A standard SEGA Dreamcast comes with a modified CD ROM drive called a
+ GD-ROM by SEGA to signify it is capable of reading special disks
+ with up to 1 GB of data. This drive will also read standard CD ROM
+ disks. Select this option to access any disks in your GD ROM drive.
+ Most users will want to say Y here.
+ You can also build this as a module which will be called gdrom.ko
+
 source drivers/block/paride/Kconfig
 
 config BLK_CPQ_DA
diff -rupN linux-2.6/drivers/cdrom/gdrom.c linux-2.6-new/drivers/cdrom/gdrom.c
--- linux-2.6/drivers/cdrom/gdrom.c 1970-01-01 01:00:00.0 +0100
+++ linux-2.6-new/drivers/cdrom/gdrom.c 2008-01-10 23:05:11.0 +
@@ -0,0 +1,786 @@
+/* GD ROM driver for the SEGA Dreamcast
+ * copyright Adrian McMenamin, 2007
+ * With thanks to Marcus Comstedt and Nathan Keynes
+ * for work in reversing PIO and DMA
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/fs.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/dma-mapping.h
+#include linux/cdrom.h
+#include linux/genhd.h
+#include linux/bio.h
+#include linux/blkdev.h
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/wait.h
+#include linux/workqueue.h
+#include linux/platform_device.h
+#include scsi/scsi.h
+#include asm/io.h
+#include asm/dma.h
+#include asm/delay.h
+#include asm/mach/dma.h
+#include asm/mach/sysasic.h
+
+#define GDROM_DEV_NAME gdrom
+#define GD_SESSION_OFFSET 150
+
+/* GD Rom commands */
+#define GDROM_COM_SOFTRESET 0x08
+#define GDROM_COM_EXECDIAG 0x90
+#define GDROM_COM_PACKET 0xA0
+#define GDROM_COM_IDDEV 0xA1
+
+/* GD Rom registers */
+#define GDROM_BASE_REG 0xA05F7000
+#define GDROM_ALTSTATUS_REG(GDROM_BASE_REG + 0x18)
+#define GDROM_DATA_REG (GDROM_BASE_REG + 0x80)
+#define GDROM_ERROR_REG(GDROM_BASE_REG + 0x84)
+#define GDROM_INTSEC_REG   (GDROM_BASE_REG + 0x88)
+#define GDROM_SECNUM_REG   (GDROM_BASE_REG + 0x8C)
+#define GDROM_BCL_REG  (GDROM_BASE_REG + 0x90)
+#define GDROM_BCH_REG  (GDROM_BASE_REG + 0x94)
+#define GDROM_DSEL_REG (GDROM_BASE_REG + 0x98)
+#define GDROM_STATUSCOMMAND_REG(GDROM_BASE_REG + 0x9C)
+#define GDROM_RESET_REG(GDROM_BASE_REG + 0x4E4)
+
+#define GDROM_DMA_STARTADDR_REG(GDROM_BASE_REG + 0x404)
+#define GDROM_DMA_LENGTH_REG   (GDROM_BASE_REG + 0x408)
+#define GDROM_DMA_DIRECTION_REG(GDROM_BASE_REG + 0x40C)
+#define GDROM_DMA_ENABLE_REG   (GDROM_BASE_REG + 0x414)
+#define GDROM_DMA_STATUS_REG   (GDROM_BASE_REG + 0x418)
+#define GDROM_DMA_WAIT_REG (GDROM_BASE_REG + 0x4A0)
+#define GDROM_DMA_ACCESS_CTRL_REG  (GDROM_BASE_REG + 0x4B8)
+
+#define GDROM_HARD_SECTOR  2048
+#define BLOCK_LAYER_SECTOR 512
+#define GD_TO_BLK  4
+
+static const struct {
+   int sense_key;
+   const char * const text;
+} sense_texts[] = {
+   {NO_SENSE, OK},
+   {RECOVERED_ERROR, Recovered from error},
+   {NOT_READY, Device not ready

  1   2   3   4   >