[PATCH] Dreamcast AICA sound driver G2 bus handling

2007-09-15 Thread Adrian McMenamin
This patch handles instability on the Dreamcast G2 bus while PIO or
DMA is underway on the System -> AICA channel.

Without the suspension of interrupts when PIO or DMA is underway the
G2 bus is prone to timeouts leading to seemingly random crashes. This
is particularly visible in cases such as maple bus (see
http://lkml.org/lkml/2007/9/15/181) hotplugging but the patch is good
for all conditions.

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


diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 7397865..54aed1d 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,7 +44,8 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 #include "aica.h"

 MODULE_AUTHOR("Adrian McMenamin <[EMAIL PROTECTED]>");
@@ -106,11 +108,14 @@ static void spu_write_wait(void)
 static void spu_memset(u32 toi, u32 what, int length)
 {
int i;
+   unsigned long flags;
snd_assert(length % 4 == 0, return);
for (i = 0; i < length; i++) {
if (!(i % 8))
spu_write_wait();
+   local_irq_save(flags);
writel(what, toi + SPU_MEMORY_BASE);
+   local_irq_restore(flags);
toi++;
}
 }
@@ -118,6 +123,7 @@ static void spu_memset(u32 toi, u32 what, int length)
 /* spu_memload - write to SPU address space */
 static void spu_memload(u32 toi, void *from, int length)
 {
+   unsigned long flags;
u32 *froml = from;
u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi);
int i;
@@ -128,7 +134,9 @@ static void spu_memload(u32 toi, void *from, int length)
if (!(i % 8))
spu_write_wait();
val = *froml;
+   local_irq_save(flags);
writel(val, to);
+   local_irq_restore(flags);
froml++;
to++;
}
@@ -138,28 +146,36 @@ static void spu_memload(u32 toi, void *from, int length)
 static void spu_disable(void)
 {
int i;
+   unsigned long flags;
u32 regval;
spu_write_wait();
regval = readl(ARM_RESET_REGISTER);
regval |= 1;
spu_write_wait();
+   local_irq_save(flags);
writel(regval, ARM_RESET_REGISTER);
+   local_irq_restore(flags);
for (i = 0; i < 64; i++) {
spu_write_wait();
regval = readl(SPU_REGISTER_BASE + (i * 0x80));
regval = (regval & ~0x4000) | 0x8000;
spu_write_wait();
+   local_irq_save(flags);
writel(regval, SPU_REGISTER_BASE + (i * 0x80));
+   local_irq_restore(flags);
}
 }

 /* spu_enable - set spu registers to enable sound output */
 static void spu_enable(void)
 {
+   unsigned long flags;
u32 regval = readl(ARM_RESET_REGISTER);
regval &= ~1;
spu_write_wait();
+   local_irq_save(flags);
writel(regval, ARM_RESET_REGISTER);
+   local_irq_restore(flags);
 }

 /*
@@ -178,15 +194,21 @@ static void spu_reset(void)
 /* aica_chn_start - write to spu to start playback */
 static void aica_chn_start(void)
 {
+   unsigned long flags;
spu_write_wait();
+   local_irq_save(flags);
writel(AICA_CMD_KICK | AICA_CMD_START, (u32 *) AICA_CONTROL_POINT);
+   local_irq_restore(flags);
 }

 /* aica_chn_halt - write to spu to halt playback */
 static void aica_chn_halt(void)
 {
+   unsigned long flags;
spu_write_wait();
+   local_irq_save(flags);
writel(AICA_CMD_KICK | AICA_CMD_STOP, (u32 *) AICA_CONTROL_POINT);
+   local_irq_restore(flags);
 }

 /* ALSA code below */
@@ -211,6 +233,7 @@ static int aica_dma_transfer(int channels, int buffer_size,
 struct snd_pcm_substream *substream)
 {
int q, err, period_offset;
+   unsigned long flags;
struct snd_card_aica *dreamcastcard;
struct snd_pcm_runtime *runtime;
err = 0;
@@ -218,6 +241,7 @@ static int aica_dma_transfer(int channels, int buffer_size,
period_offset = dreamcastcard->clicks;
period_offset %= (AICA_PERIOD_NUMBER / channels);
runtime = substream->runtime;
+   local_irq_save(flags);  
for (q = 0; q < channels; q++) {
err = dma_xfer(AICA_DMA_CHANNEL,
   (unsigned long) (runtime->dma_area +
@@ -232,6 +256,7 @@ static int aica_dma_transfer(int channels, int buffer_size,
break;
dma_wait_for_completion(AICA_DMA_CHANNEL);
}
+   local_irq_restore(flags);
return err;
 }

@@ -277,18 +302,21 @@ static void aica_period_elapsed(unsigned long timer_var)
 {
/*timer function - so cannot sleep */
int play_period;
+   unsigned long flags;
struct snd_pcm_

[PATCH 1/2] Add Maple bus support for the SEGA Dreamcast - core maplebus

2007-09-15 Thread Adrian McMenamin
This adds support for the maple bus (SEGA's proprietary serial bus on
the Dreamcast) to the kernel.

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

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..077438f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default "0xb800" if CF_AREA6
default "0xb400" if CF_AREA5

+config MAPLE
+   bool "Maple Bus Support"
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source "arch/sh/drivers/pci/Kconfig"

 source "drivers/pci/Kconfig"
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..604ce33
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-$(CONFIG_MAPLE) := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..486
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,731 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * Licensed under version 2 of the GPL
+ * See the COPYING file that came with this
+ * distribution for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin");
+MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
+MODULE_LICENSE("GPL v2");
+MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}");
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+static DEFINE_MUTEX(maple_list_lock);
+
+static struct maple_driver maple_dummy_driver;
+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 struct kmem_cache *maple_queue_cache;
+
+struct maple_device_specify {
+   int port;
+   int unit;
+};
+
+/**
+ *  maple_driver_register - register a device driver
+ *  automatically makes the driver bus a maple bus
+ *  @drv: the driver to be registered
+ */
+int maple_driver_register(struct device_driver *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);
+}
+
+/**
+ * maple_getcond_callback - setup handling MAPLE_COMMAND_GETCOND
+ * @dev: device responding
+ * @callback: handler callback
+ * @interval: interval in jiffies between callbacks
+ * @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)
+{
+   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;
+}
+
+static void maple_release_device(struct device *dev)
+{
+   if (dev->type) {
+   kfree(dev->type->name);
+   kfree(dev->type);
+   }
+}
+
+/**
+ * maple_add_packet - add a single instruction to the queue
+ * @mq: instruction to add to

[PATCH 2/2] Add Maple bus support for the SEGA Dreamcast - maple keyboard

2007-09-15 Thread Adrian McMenamin
This patch adds support for the keyboard on the SEGA Dreamcast

Signed-off by Adrian McMenamin <[EMAIL PROTECTED]>
Acked-by: Arjan van de Ven <[EMAIL PROTECTED]>
Acked-by: Dmitry Torokhov <[EMAIL PROTECTED]>


diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate "Maple bus keyboard"
+   depends on SH_DREAMCAST && MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..3bb58e1
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin");
+MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
+MODULE_LICENSE("GPL");
+
+struct dc_kbd {
+   struct input_dev *dev;
+   unsigned char keycode[NR_SCANCODES];
+   unsigned char new[8];
+   unsigned char old[8];
+};
+
+const static unsigned char 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_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_RESERV

[PATCH 0/2] Add Maple bus support for the SEGA Dreamcast

2007-09-15 Thread Adrian McMenamin
The Maple bus is SEGA's proprietary serial bus for peripherals
(keyboard, mouse, controller etc). The bus is capable of some
(limited) hotplugging and operates at up to 2 M/bits.

Drivers of one sort or another existed/exist for 2.4 and a rudimentary
port, which didn't support the 2.6 device driver modei was also in
existence.

This driver - for the bus logic itself and for the keyboard (other
drivers will follow) are based on the code and concepts of those old
drivers but have lots of completely rewritten parts.

I have the maplebus code a built in now as that seems the sane and
rational way to handle something like that - you either want the bus
or you don't.

maplebus.c: adds the core bus support
maple_keyb.c: adds the keyboard

Signed off by Adrian McMenamin <[EMAIL PROTECTED]>
-
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 0/2] Add Maple bus support for the SEGA Dreamcast

2007-09-15 Thread Adrian McMenamin
The Maple bus is SEGA's proprietary serial bus for peripherals
(keyboard, mouse, controller etc). The bus is capable of some
(limited) hotplugging and operates at up to 2 M/bits.

Drivers of one sort or another existed/exist for 2.4 and a rudimentary
port, which didn't support the 2.6 device driver modei was also in
existence.

This driver - for the bus logic itself and for the keyboard (other
drivers will follow) are based on the code and concepts of those old
drivers but have lots of completely rewritten parts.

I have the maplebus code a built in now as that seems the sane and
rational way to handle something like that - you either want the bus
or you don't.

maplebus.c: adds the core bus support
maple_keyb.c: adds the keyboard

Signed off by Adrian McMenamin [EMAIL PROTECTED]
-
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] Add Maple bus support for the SEGA Dreamcast - core maplebus

2007-09-15 Thread Adrian McMenamin
This adds support for the maple bus (SEGA's proprietary serial bus on
the Dreamcast) to the kernel.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..077438f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default 0xb800 if CF_AREA6
default 0xb400 if CF_AREA5

+config MAPLE
+   bool Maple Bus Support
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source arch/sh/drivers/pci/Kconfig

 source drivers/pci/Kconfig
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..604ce33
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-$(CONFIG_MAPLE) := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..486
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,731 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * Licensed under version 2 of the GPL
+ * See the COPYING file that came with this
+ * distribution for more details.
+ */
+
+#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
+#include linux/slab.h
+#include linux/maple.h
+#include linux/dma-mapping.h
+#include asm/cacheflush.h
+#include asm/dma.h
+#include asm/io.h
+#include asm/mach/dma.h
+#include asm/mach/sysasic.h
+#include asm/mach/maple.h
+
+MODULE_AUTHOR(Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin);
+MODULE_DESCRIPTION(Maple bus driver for Dreamcast);
+MODULE_LICENSE(GPL v2);
+MODULE_SUPPORTED_DEVICE({{SEGA, Dreamcast/Maple}});
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+static DEFINE_MUTEX(maple_list_lock);
+
+static struct maple_driver maple_dummy_driver;
+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 struct kmem_cache *maple_queue_cache;
+
+struct maple_device_specify {
+   int port;
+   int unit;
+};
+
+/**
+ *  maple_driver_register - register a device driver
+ *  automatically makes the driver bus a maple bus
+ *  @drv: the driver to be registered
+ */
+int maple_driver_register(struct device_driver *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);
+}
+
+/**
+ * maple_getcond_callback - setup handling MAPLE_COMMAND_GETCOND
+ * @dev: device responding
+ * @callback: handler callback
+ * @interval: interval in jiffies between callbacks
+ * @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)
+{
+   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;
+}
+
+static void maple_release_device(struct device *dev)
+{
+   if (dev-type) {
+   kfree(dev-type-name);
+   kfree(dev-type);
+   }
+}
+
+/**
+ * maple_add_packet - add a single

[PATCH 2/2] Add Maple bus support for the SEGA Dreamcast - maple keyboard

2007-09-15 Thread Adrian McMenamin
This patch adds support for the keyboard on the SEGA Dreamcast

Signed-off by Adrian McMenamin [EMAIL PROTECTED]
Acked-by: Arjan van de Ven [EMAIL PROTECTED]
Acked-by: Dmitry Torokhov [EMAIL PROTECTED]


diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate Maple bus keyboard
+   depends on SH_DREAMCAST  MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..3bb58e1
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#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
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR(YAEGASHI Takeshi, Adrian McMenamin);
+MODULE_DESCRIPTION(SEGA Dreamcast keyboard driver);
+MODULE_LICENSE(GPL);
+
+struct dc_kbd {
+   struct input_dev *dev;
+   unsigned char keycode[NR_SCANCODES];
+   unsigned char new[8];
+   unsigned char old[8];
+};
+
+const static unsigned char 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_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

[PATCH] Dreamcast AICA sound driver G2 bus handling

2007-09-15 Thread Adrian McMenamin
This patch handles instability on the Dreamcast G2 bus while PIO or
DMA is underway on the System - AICA channel.

Without the suspension of interrupts when PIO or DMA is underway the
G2 bus is prone to timeouts leading to seemingly random crashes. This
is particularly visible in cases such as maple bus (see
http://lkml.org/lkml/2007/9/15/181) hotplugging but the patch is good
for all conditions.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]


diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 7397865..54aed1d 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -35,6 +35,7 @@
 #include linux/timer.h
 #include linux/delay.h
 #include linux/workqueue.h
+#include linux/maple.h
 #include sound/driver.h
 #include sound/core.h
 #include sound/control.h
@@ -43,7 +44,8 @@
 #include sound/info.h
 #include asm/io.h
 #include asm/dma.h
-#include asm/dreamcast/sysasic.h
+#include asm/mach/sysasic.h
+#include asm/mach/maple.h
 #include aica.h

 MODULE_AUTHOR(Adrian McMenamin [EMAIL PROTECTED]);
@@ -106,11 +108,14 @@ static void spu_write_wait(void)
 static void spu_memset(u32 toi, u32 what, int length)
 {
int i;
+   unsigned long flags;
snd_assert(length % 4 == 0, return);
for (i = 0; i  length; i++) {
if (!(i % 8))
spu_write_wait();
+   local_irq_save(flags);
writel(what, toi + SPU_MEMORY_BASE);
+   local_irq_restore(flags);
toi++;
}
 }
@@ -118,6 +123,7 @@ static void spu_memset(u32 toi, u32 what, int length)
 /* spu_memload - write to SPU address space */
 static void spu_memload(u32 toi, void *from, int length)
 {
+   unsigned long flags;
u32 *froml = from;
u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi);
int i;
@@ -128,7 +134,9 @@ static void spu_memload(u32 toi, void *from, int length)
if (!(i % 8))
spu_write_wait();
val = *froml;
+   local_irq_save(flags);
writel(val, to);
+   local_irq_restore(flags);
froml++;
to++;
}
@@ -138,28 +146,36 @@ static void spu_memload(u32 toi, void *from, int length)
 static void spu_disable(void)
 {
int i;
+   unsigned long flags;
u32 regval;
spu_write_wait();
regval = readl(ARM_RESET_REGISTER);
regval |= 1;
spu_write_wait();
+   local_irq_save(flags);
writel(regval, ARM_RESET_REGISTER);
+   local_irq_restore(flags);
for (i = 0; i  64; i++) {
spu_write_wait();
regval = readl(SPU_REGISTER_BASE + (i * 0x80));
regval = (regval  ~0x4000) | 0x8000;
spu_write_wait();
+   local_irq_save(flags);
writel(regval, SPU_REGISTER_BASE + (i * 0x80));
+   local_irq_restore(flags);
}
 }

 /* spu_enable - set spu registers to enable sound output */
 static void spu_enable(void)
 {
+   unsigned long flags;
u32 regval = readl(ARM_RESET_REGISTER);
regval = ~1;
spu_write_wait();
+   local_irq_save(flags);
writel(regval, ARM_RESET_REGISTER);
+   local_irq_restore(flags);
 }

 /*
@@ -178,15 +194,21 @@ static void spu_reset(void)
 /* aica_chn_start - write to spu to start playback */
 static void aica_chn_start(void)
 {
+   unsigned long flags;
spu_write_wait();
+   local_irq_save(flags);
writel(AICA_CMD_KICK | AICA_CMD_START, (u32 *) AICA_CONTROL_POINT);
+   local_irq_restore(flags);
 }

 /* aica_chn_halt - write to spu to halt playback */
 static void aica_chn_halt(void)
 {
+   unsigned long flags;
spu_write_wait();
+   local_irq_save(flags);
writel(AICA_CMD_KICK | AICA_CMD_STOP, (u32 *) AICA_CONTROL_POINT);
+   local_irq_restore(flags);
 }

 /* ALSA code below */
@@ -211,6 +233,7 @@ static int aica_dma_transfer(int channels, int buffer_size,
 struct snd_pcm_substream *substream)
 {
int q, err, period_offset;
+   unsigned long flags;
struct snd_card_aica *dreamcastcard;
struct snd_pcm_runtime *runtime;
err = 0;
@@ -218,6 +241,7 @@ static int aica_dma_transfer(int channels, int buffer_size,
period_offset = dreamcastcard-clicks;
period_offset %= (AICA_PERIOD_NUMBER / channels);
runtime = substream-runtime;
+   local_irq_save(flags);  
for (q = 0; q  channels; q++) {
err = dma_xfer(AICA_DMA_CHANNEL,
   (unsigned long) (runtime-dma_area +
@@ -232,6 +256,7 @@ static int aica_dma_transfer(int channels, int buffer_size,
break;
dma_wait_for_completion(AICA_DMA_CHANNEL);
}
+   local_irq_restore(flags);
return err;
 }

@@ -277,18 +302,21 @@ static void aica_period_elapsed(unsigned long timer_var)
 {
/*timer function

[PATCH 3/2] Add Maple bus support for the SEGA Dreamcast - the missing header files

2007-09-15 Thread Adrian McMenamin
Apologies - these are the patches to add header files to the series
beginning here: http://lkml.org/lkml/2007/9/15/181

Add maplebus headers

Signed off by Adrian McMenamin [EMAIL PROTECTED]

diff --git a/include/linux/input.h b/include/linux/input.h
diff --git a/include/linux/maple.h b/include/linux/maple.h
new file mode 100644
index 000..e297cce
--- /dev/null
+++ b/include/linux/maple.h
@@ -0,0 +1,87 @@
+/**
+ * maple.h
+ *
+ * porting to 2.6 driver model
+ * copyright Adrian McMenamin, 2007
+ *
+ */
+#ifndef __LINUX_MAPLE_H
+#define __LINUX_MAPLE_H
+
+extern struct bus_type maple_bus_type;
+
+/* Maple Bus command and response codes */
+enum maple_code {
+   MAPLE_RESPONSE_FILEERR = -5,
+   MAPLE_RESPONSE_AGAIN = -4,  /* request should be retransmitted */
+   MAPLE_RESPONSE_BADCMD = -3,
+   MAPLE_RESPONSE_BADFUNC = -2,
+   MAPLE_RESPONSE_NONE = -1,   /* unit didn't respond at all */
+   MAPLE_COMMAND_DEVINFO = 1,
+   MAPLE_COMMAND_ALLINFO = 2,
+   MAPLE_COMMAND_RESET = 3,
+   MAPLE_COMMAND_KILL = 4,
+   MAPLE_RESPONSE_DEVINFO = 5,
+   MAPLE_RESPONSE_ALLINFO = 6,
+   MAPLE_RESPONSE_OK = 7,
+   MAPLE_RESPONSE_DATATRF = 8,
+   MAPLE_COMMAND_GETCOND = 9,
+   MAPLE_COMMAND_GETMINFO = 10,
+   MAPLE_COMMAND_BREAD = 11,
+   MAPLE_COMMAND_BWRITE = 12,
+   MAPLE_COMMAND_SETCOND = 14
+};
+
+struct mapleq {
+   struct list_head list;
+   struct maple_device *dev;
+   void *sendbuf, *recvbuf, *recvbufdcsp;
+   unsigned char length;
+   enum maple_code command;
+};
+
+struct maple_devinfo {
+   unsigned long function;
+   unsigned long function_data[3];
+   unsigned char area_code;
+   unsigned char connector_directon;
+   char product_name[31];
+   char product_licence[61];
+   unsigned short standby_power;
+   unsigned short max_power;
+};
+
+struct maple_device {
+   struct maple_driver *driver;
+   struct mapleq *mq;
+   void *private_data;
+   void (*callback) (struct mapleq * mq);
+   unsigned long when, interval, function;
+   struct maple_devinfo devinfo;
+   unsigned char port, unit;
+   char product_name[32];
+   char product_licence[64];
+   int registered;
+   struct device dev;
+};
+
+struct maple_driver {
+   unsigned long function;
+   int (*connect) (struct maple_device * dev);
+   void (*disconnect) (struct maple_device * dev);
+   struct device_driver drv;
+};
+
+void maple_getcond_callback(struct maple_device *dev,
+   void (*callback) (struct mapleq * mq),
+   unsigned long interval,
+   unsigned long function);
+
+int maple_driver_register(struct device_driver *drv);
+
+void maple_add_packet(struct mapleq *mq);
+
+#define to_maple_dev(n) container_of(n, struct maple_device, dev)
+#define to_maple_driver(n) container_of(n, struct maple_driver, drv)
+
+#endif /* __LINUX_MAPLE_H */
diff --git a/include/asm-sh/dreamcast/maple.h b/include/asm-sh/dreamcast/maple.h
new file mode 100644
index 000..4836d24
--- /dev/null
+++ b/include/asm-sh/dreamcast/maple.h
@@ -0,0 +1,36 @@
+#ifndef __ASM_MAPLE_H
+#define __ASM_MAPLE_H
+
+#define MAPLE_PORTS 4
+#define MAPLE_PNP_INTERVAL HZ
+#define MAPLE_MAXPACKETS 8
+#define MAPLE_DMA_ORDER 14
+#define MAPLE_DMA_SIZE (1  MAPLE_DMA_ORDER)
+#define MAPLE_DMA_PAGES ((MAPLE_DMA_ORDER  PAGE_SHIFT) ?
MAPLE_DMA_ORDER - PAGE_SHIFT : 0)
+
+/* Maple Bus registers */
+#define MAPLE_BASE 0xa05f6c00
+#define MAPLE_DMAADDR  (MAPLE_BASE+0x04)
+#define MAPLE_TRIGTYPE (MAPLE_BASE+0x10)
+#define MAPLE_ENABLE   (MAPLE_BASE+0x14)
+#define MAPLE_STATE(MAPLE_BASE+0x18)
+#define MAPLE_SPEED(MAPLE_BASE+0x80)
+#define MAPLE_RESET(MAPLE_BASE+0x8c)
+
+#define MAPLE_MAGIC0x6155404f
+#define MAPLE_2MBPS0
+#defineMAPLE_TIMEOUT(n) ((n)15)
+
+/* Function codes */
+#define MAPLE_FUNC_CONTROLLER 0x001
+#define MAPLE_FUNC_MEMCARD0x002
+#define MAPLE_FUNC_LCD0x004
+#define MAPLE_FUNC_CLOCK  0x008
+#define MAPLE_FUNC_MICROPHONE 0x010
+#define MAPLE_FUNC_ARGUN  0x020
+#define MAPLE_FUNC_KEYBOARD   0x040
+#define MAPLE_FUNC_LIGHTGUN   0x080
+#define MAPLE_FUNC_PURUPURU   0x100
+#define MAPLE_FUNC_MOUSE  0x200
+
+#endif /* __ASM_MAPLE_H */
-
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/


Latest git won't compile

2007-09-15 Thread Adrian McMenamin
CC  drivers/char/tty_ioctl.o
drivers/char/tty_ioctl.c: In function 'n_tty_ioctl':
drivers/char/tty_ioctl.c:799: error: implicit declaration of function
'kernel_termios_to_user_termios_1'
drivers/char/tty_ioctl.c:806: error: implicit declaration of function
'user_termios_to_kernel_termios_1'
make[2]: *** [drivers/char/tty_ioctl.o] Error 1
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2
-
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: time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
On 12/09/2007, Björn Steinbrink <[EMAIL PROTECTED]> wrote:

>
> A fix would likely initialize "when" to jiffies.
>
> Björn
>

Thanks, I'll try 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: time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
On 12/09/2007, Björn Steinbrink <[EMAIL PROTECTED]> wrote:
> On 2007.09.12 00:19:09 +0200, Rene Herman wrote:
> > On 09/12/2007 12:15 AM, Adrian McMenamin wrote:
> >
> >> On 11/09/2007, Rene Herman <[EMAIL PROTECTED]> wrote:
> >>> On 09/12/2007 12:05 AM, Adrian McMenamin wrote:
> >>>
> >>>> OK, why does this line occasionally return true:
>
> What exactly is "occassionally"?  Does it happen more than once per
> boot? If not, and it happens after a certain time after booting, it
> might be wrapping of the jiffie counter (see below).
>
> >>>>
> >>>>   if ((maple_dev->interval > 0) && (jiffies >maple_dev->when))
> >>>>
> >>>> while this one never does (no other changes made):
> >>>>
> >>>> if  ((maple_dev->interval > 0) && (time_after(jiffies,
> >>>> maple_dev->when)))
> >>> Is maple_dev->when an unsigned long?
> >>>
> >> Yes. Does that make a difference?
> >
> > If it had been a signed type, it could've wrapped to something you didn't
> > expect, explaining the difference at least...
> >
> > With an unsigned long, the only diference should be that time_after() deals
> > with jiffie wrapping which I assume is not an actual problem here. I'll
> > retreat into the shades again... ;-(
>
> If "occasionally" is limited to once per boot, it might be jiffie
> wrapping. IIRC jiffies are initialized so that they wrap after about 5
> minutes of uptime to reveal such bugs without forcing you to wait for
> ages just to have the counter wrap for the first time.
>

No, I mean "works properly" - ie occasionally evaluates as true
-
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: time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
On 11/09/2007, Rene Herman <[EMAIL PROTECTED]> wrote:
> On 09/12/2007 12:05 AM, Adrian McMenamin wrote:
>
> > OK, why does this line occasionally return true:
> >
> >   if ((maple_dev->interval > 0) && (jiffies >maple_dev->when))
> >
> > while this one never does (no other changes made):
> >
> > if  ((maple_dev->interval > 0) && (time_after(jiffies, maple_dev->when)))
>
> Is maple_dev->when an unsigned long?
>
Yes. Does that make a difference?
-
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/


time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
OK, why does this line occasionally return true:

if ((maple_dev->interval > 0) && (jiffies >maple_dev->when))

while this one never does (no other changes made):

if  ((maple_dev->interval > 0) && (time_after(jiffies, maple_dev->when)))


Is this a gcc issue or what?
-
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] Maple Bus support for SEGA Dreamcast

2007-09-11 Thread Adrian McMenamin
On Tue, 2007-09-11 at 13:27 +0900, Paul Mundt wrote:
> (Adding GregKH to the CC, he needs to Ack this before I can merge it).
> 

> > diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
> > new file mode 100644
> > index 000..4662463
> > --- /dev/null
> > +++ b/drivers/sh/maple/maplebus.c
> > @@ -0,0 +1,747 @@
> > +/* maplebus.c
> > + * Core maple bus functionality
> > + * Original 2.4 code used here copyright
> > + * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
> > + * Porting to 2.6 Copyright Adrian McMenamin, 2007
> > + *
> > + * 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.
> > + *
> I don't believe the 'or any later version' thing was intended by any of
> the original authors, this should probably be dropped. The original file
> lacked explicit terms, so the default behaviour there is to fall back to
> what the top-level COPYING says, which has the 'or any later version'
> garbage removed.

On 30th of August you wrote this in an email to the linuxsh list:

"Both Marcus and I intended all of our code to be v2 only, so that
should probably be statically defined here. However, I believe
Yaegashi-san wrote a lot of this initial version, and I'm sure there
were others that hacked on it as well. So we may simply have to leave it
as GPLv2 with the unfortunate + any later version garbage."

I think you were right the first time.



> 
> > +static DEFINE_MUTEX(maple_list_lock);
> > +
> > +DEFINE_MUTEX(maple_dma_lock);
> > +EXPORT_SYMBOL_GPL(maple_dma_lock);
> > +
> It would be better to have accessors for this rather than exporting the
> mutex globally.


Actually the mutex is accessed in the aica code so it, or any wrappers
need to be exported
> 


> 
> > +/* use init call to ensure bus is registered ahead of devices */
> > +fs_initcall(maple_bus_init);
> 
> Please use subsys_initcall() or something like that, this isn't a file
> system. The comment is also pointless, it's obvious what the initcall is
> for if you use the proper one.
> 

Except performance of the driver is very poor when I use subsys_initcall
- detecting devices on a phase-of-the-noon related basis. Not an issue
when I use the later call.


> > index 000..8a37c7e
> > --- /dev/null
> > +++ b/include/linux/maple.h
> > @@ -0,0 +1,126 @@
> > +/**
> > + * maple.h


> 
> > +void maple_setup_port_rescan(struct maple_device *mdev);
> > +
> > +void maplebus_init_hardware(void);
> > +
> Why would these ever be accessible to drivers?
> 
You are right about the rescan - a relic of an earlier iteration but the
maplebus_init_hardware is used to control the DMA in the aica 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 1/2] Maple Bus support for SEGA Dreamcast

2007-09-11 Thread Adrian McMenamin
On Tue, 2007-09-11 at 13:27 +0900, Paul Mundt wrote:
 (Adding GregKH to the CC, he needs to Ack this before I can merge it).
 

  diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
  new file mode 100644
  index 000..4662463
  --- /dev/null
  +++ b/drivers/sh/maple/maplebus.c
  @@ -0,0 +1,747 @@
  +/* maplebus.c
  + * Core maple bus functionality
  + * Original 2.4 code used here copyright
  + * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
  + * Porting to 2.6 Copyright Adrian McMenamin, 2007
  + *
  + * 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.
  + *
 I don't believe the 'or any later version' thing was intended by any of
 the original authors, this should probably be dropped. The original file
 lacked explicit terms, so the default behaviour there is to fall back to
 what the top-level COPYING says, which has the 'or any later version'
 garbage removed.

On 30th of August you wrote this in an email to the linuxsh list:

Both Marcus and I intended all of our code to be v2 only, so that
should probably be statically defined here. However, I believe
Yaegashi-san wrote a lot of this initial version, and I'm sure there
were others that hacked on it as well. So we may simply have to leave it
as GPLv2 with the unfortunate + any later version garbage.

I think you were right the first time.



 
  +static DEFINE_MUTEX(maple_list_lock);
  +
  +DEFINE_MUTEX(maple_dma_lock);
  +EXPORT_SYMBOL_GPL(maple_dma_lock);
  +
 It would be better to have accessors for this rather than exporting the
 mutex globally.


Actually the mutex is accessed in the aica code so it, or any wrappers
need to be exported
 


 
  +/* use init call to ensure bus is registered ahead of devices */
  +fs_initcall(maple_bus_init);
 
 Please use subsys_initcall() or something like that, this isn't a file
 system. The comment is also pointless, it's obvious what the initcall is
 for if you use the proper one.
 

Except performance of the driver is very poor when I use subsys_initcall
- detecting devices on a phase-of-the-noon related basis. Not an issue
when I use the later call.


  index 000..8a37c7e
  --- /dev/null
  +++ b/include/linux/maple.h
  @@ -0,0 +1,126 @@
  +/**
  + * maple.h


 
  +void maple_setup_port_rescan(struct maple_device *mdev);
  +
  +void maplebus_init_hardware(void);
  +
 Why would these ever be accessible to drivers?
 
You are right about the rescan - a relic of an earlier iteration but the
maplebus_init_hardware is used to control the DMA in the aica 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/


time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
OK, why does this line occasionally return true:

if ((maple_dev-interval  0)  (jiffies maple_dev-when))

while this one never does (no other changes made):

if  ((maple_dev-interval  0)  (time_after(jiffies, maple_dev-when)))


Is this a gcc issue or what?
-
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: time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
On 11/09/2007, Rene Herman [EMAIL PROTECTED] wrote:
 On 09/12/2007 12:05 AM, Adrian McMenamin wrote:

  OK, why does this line occasionally return true:
 
if ((maple_dev-interval  0)  (jiffies maple_dev-when))
 
  while this one never does (no other changes made):
 
  if  ((maple_dev-interval  0)  (time_after(jiffies, maple_dev-when)))

 Is maple_dev-when an unsigned long?

Yes. Does that make a difference?
-
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: time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
On 12/09/2007, Björn Steinbrink [EMAIL PROTECTED] wrote:
 On 2007.09.12 00:19:09 +0200, Rene Herman wrote:
  On 09/12/2007 12:15 AM, Adrian McMenamin wrote:
 
  On 11/09/2007, Rene Herman [EMAIL PROTECTED] wrote:
  On 09/12/2007 12:05 AM, Adrian McMenamin wrote:
 
  OK, why does this line occasionally return true:

 What exactly is occassionally?  Does it happen more than once per
 boot? If not, and it happens after a certain time after booting, it
 might be wrapping of the jiffie counter (see below).

 
if ((maple_dev-interval  0)  (jiffies maple_dev-when))
 
  while this one never does (no other changes made):
 
  if  ((maple_dev-interval  0)  (time_after(jiffies,
  maple_dev-when)))
  Is maple_dev-when an unsigned long?
 
  Yes. Does that make a difference?
 
  If it had been a signed type, it could've wrapped to something you didn't
  expect, explaining the difference at least...
 
  With an unsigned long, the only diference should be that time_after() deals
  with jiffie wrapping which I assume is not an actual problem here. I'll
  retreat into the shades again... ;-(

 If occasionally is limited to once per boot, it might be jiffie
 wrapping. IIRC jiffies are initialized so that they wrap after about 5
 minutes of uptime to reveal such bugs without forcing you to wait for
 ages just to have the counter wrap for the first time.


No, I mean works properly - ie occasionally evaluates as true
-
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: time_after - what on earth???

2007-09-11 Thread Adrian McMenamin
On 12/09/2007, Björn Steinbrink [EMAIL PROTECTED] wrote:


 A fix would likely initialize when to jiffies.

 Björn


Thanks, I'll try 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/


[PATCH 2/2] Maple bus support for the SEGA Dreamcast - Dreamcast keyboard support

2007-09-10 Thread Adrian McMenamin
Support for the Maple bus keyboard on the SEGA Dreamcast.

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

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate "Maple bus keyboard"
+   depends on SH_DREAMCAST && MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..c368b54
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin");
+MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
+MODULE_LICENSE("GPL");
+
+struct dc_kbd {
+   struct input_dev *dev;
+   unsigned char keycode[NR_SCANCODES];
+   unsigned char new[8];
+   unsigned char old[8];
+};
+
+const static unsigned char 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_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_RESE

[PATCH 1/2] Maple Bus support for SEGA Dreamcast

2007-09-10 Thread Adrian McMenamin
This adds support for the Maple Bus - Sega's proprietary serial if
with peripherals - for the Dreamcast.

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

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..c1771b7 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default "0xb800" if CF_AREA6
default "0xb400" if CF_AREA5

+config MAPLE
+   tristate "Maple Bus Support"
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source "arch/sh/drivers/pci/Kconfig"

 source "drivers/pci/Kconfig"
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..f8c39f2
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-y  := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..4662463
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,747 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin");
+MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
+MODULE_LICENSE("GPL");
+MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}");
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+static DEFINE_MUTEX(maple_list_lock);
+
+DEFINE_MUTEX(maple_dma_lock);
+EXPORT_SYMBOL_GPL(maple_dma_lock);
+
+static struct maple_driver maple_null_driver;
+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 struct kmem_cache *maple_cache;
+
+int maple_driver_register(struct device_driver *drv)
+{
+   if (!drv)
+   return -EINVAL;
+   drv->bus = _bus_type;
+   return driver_register(drv);
+}
+EXPORT_SYMBOL_GPL(maple_driver_register);
+
+void maplebus_init_hardware(void)
+{
+   mutex_lock(_dma_lock);
+   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);
+   mutex_unlock(_dma_lock);
+}
+EXPORT_SYMBOL_GPL(maplebus_init_hardware);
+
+void maple_getcond_callback(struct maple_device *dev,
+   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 = 0;
+}
+EXPORT_SYMBOL_GPL(maple_getcond_callback);
+
+int maple_dma_done(void)
+{
+   return (ctrl_inl(MAPLE_STATE) & 1) == 0;
+}
+EXPORT_SYMBOL_GPL(maple_dma_done);
+
+static void maple_release_device(stru

[PATCH 0/2] Maple bus support for the SEGA Dreamcast

2007-09-10 Thread Adrian McMenamin
Hopefully these patches are now up to standard.

I have reworked the aica patch also, but I am not including it as I
seem to have the occasional deadlock problem.

I haven't been able to crash these patches without the sound driver
running, so I that seems to be where the issue is - the usual G2 bus
problems.

Following requests the bus driver now has a mutex to guard against a
rogue process adding to the waitq.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
-
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/3] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-10 Thread Adrian McMenamin
On 10/09/2007, Dmitry Torokhov <[EMAIL PROTECTED]> wrote:
> Hi Adrian,
>

Thanks for the comments - will get on with this but


> > + for (i = 0; i < NR_SCANCODES; i++)
> > + kbd->keycode[i] = dc_kbd_keycode[i];
>
> memcpy?
>

I see that other drivers use memcpy - and will happily convert over -
but, out of interest, is there a reasopn why it is superior?

>
> maple_device appears to be fully integrated in sysfs, please add:
>kbd->dev->dev.parent = >dev;
>

The bus code already correctly ids the parent device (the above code
would appear to assign the device as the device's parent
incidentally). Is it wrong to make that assignment in the central bus
code as opposed to the driver?

Thanks

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 2/3] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-10 Thread Adrian McMenamin
On 10/09/2007, Dmitry Torokhov [EMAIL PROTECTED] wrote:
 Hi Adrian,


Thanks for the comments - will get on with this but


  + for (i = 0; i  NR_SCANCODES; i++)
  + kbd-keycode[i] = dc_kbd_keycode[i];

 memcpy?


I see that other drivers use memcpy - and will happily convert over -
but, out of interest, is there a reasopn why it is superior?


 maple_device appears to be fully integrated in sysfs, please add:
kbd-dev-dev.parent = dev-dev;


The bus code already correctly ids the parent device (the above code
would appear to assign the device as the device's parent
incidentally). Is it wrong to make that assignment in the central bus
code as opposed to the driver?

Thanks

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 0/2] Maple bus support for the SEGA Dreamcast

2007-09-10 Thread Adrian McMenamin
Hopefully these patches are now up to standard.

I have reworked the aica patch also, but I am not including it as I
seem to have the occasional deadlock problem.

I haven't been able to crash these patches without the sound driver
running, so I that seems to be where the issue is - the usual G2 bus
problems.

Following requests the bus driver now has a mutex to guard against a
rogue process adding to the waitq.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]
-
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] Maple Bus support for SEGA Dreamcast

2007-09-10 Thread Adrian McMenamin
This adds support for the Maple Bus - Sega's proprietary serial if
with peripherals - for the Dreamcast.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..c1771b7 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default 0xb800 if CF_AREA6
default 0xb400 if CF_AREA5

+config MAPLE
+   tristate Maple Bus Support
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source arch/sh/drivers/pci/Kconfig

 source drivers/pci/Kconfig
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..f8c39f2
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-y  := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..4662463
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,747 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include linux/init.h
+#include linux/device.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/list.h
+#include linux/io.h
+#include linux/slab.h
+#include linux/maple.h
+#include asm/cacheflush.h
+#include asm/dma.h
+#include asm/mach/sysasic.h
+
+MODULE_AUTHOR(Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin);
+MODULE_DESCRIPTION(Maple bus driver for Dreamcast);
+MODULE_LICENSE(GPL);
+MODULE_SUPPORTED_DEVICE({{SEGA, Dreamcast/Maple}});
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+static DEFINE_MUTEX(maple_list_lock);
+
+DEFINE_MUTEX(maple_dma_lock);
+EXPORT_SYMBOL_GPL(maple_dma_lock);
+
+static struct maple_driver maple_null_driver;
+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 struct kmem_cache *maple_cache;
+
+int maple_driver_register(struct device_driver *drv)
+{
+   if (!drv)
+   return -EINVAL;
+   drv-bus = maple_bus_type;
+   return driver_register(drv);
+}
+EXPORT_SYMBOL_GPL(maple_driver_register);
+
+void maplebus_init_hardware(void)
+{
+   mutex_lock(maple_dma_lock);
+   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);
+   mutex_unlock(maple_dma_lock);
+}
+EXPORT_SYMBOL_GPL(maplebus_init_hardware);
+
+void maple_getcond_callback(struct maple_device *dev,
+   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 = 0;
+}
+EXPORT_SYMBOL_GPL(maple_getcond_callback);
+
+int maple_dma_done(void)
+{
+   return (ctrl_inl(MAPLE_STATE)  1) == 0;
+}
+EXPORT_SYMBOL_GPL(maple_dma_done);
+
+static void maple_release_device

[PATCH 2/2] Maple bus support for the SEGA Dreamcast - Dreamcast keyboard support

2007-09-10 Thread Adrian McMenamin
Support for the Maple bus keyboard on the SEGA Dreamcast.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate Maple bus keyboard
+   depends on SH_DREAMCAST  MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..c368b54
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#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
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR(YAEGASHI Takeshi, Adrian McMenamin);
+MODULE_DESCRIPTION(SEGA Dreamcast keyboard driver);
+MODULE_LICENSE(GPL);
+
+struct dc_kbd {
+   struct input_dev *dev;
+   unsigned char keycode[NR_SCANCODES];
+   unsigned char new[8];
+   unsigned char old[8];
+};
+
+const static unsigned char 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_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

Re: [PATCH 2/3] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-09 Thread Adrian McMenamin
On 09/09/07, Arjan van de Ven <[EMAIL PROTECTED]> wrote:
> On Sun, 9 Sep 2007 21:35:11 +0100
> "Adrian McMenamin" <[EMAIL PROTECTED]> wrote:

>
> I think this has a bug; mutex_trylock has the opposite return code as
> down_trylock (mutex follows the same convention as the spinlock
> trylock) so you probably need to add a ! here...
>

Quite right. Also explains the big fall in the keyboard's
responsiveness - though, to be honest, I don't see how it worked at
all.

Here's the correct patch.

Add maple bus keyboard support to the kernel.

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


diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate "Maple bus keyboard"
+   depends on SH_DREAMCAST && MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..0e580c7
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin");
+MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
+MODULE_LICENSE("GPL");
+
+extern int maple_driver_register(struct device_driver *drv);
+
+const static unsigned char 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_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
, K

Re: [PATCH 2/3] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-09 Thread Adrian McMenamin
On 09/09/07, Arjan van de Ven <[EMAIL PROTECTED]> wrote:
> On Sun, 9 Sep 2007 18:01:26 +0100
> "Adrian McMenamin" <[EMAIL PROTECTED]> wrote:
>
> > This patch adds support for the SEGA Dreamcast keyboard.
> >
> > Following suggestions from the inout maintainer it has been somewhat
> > rewritten since the previous posting
> > (http://lkml.org/lkml/2007/9/4/168).
>
> Hi,
>
> this driver in general is quite clean as well; I have only one
> suggestion for improvement. Right now you use a semaphore for locking,
> while all you really use it for is mutex semantics, I think it would be
> a good idea to convert the driver to use the actual mutex primitive;
> this will buy you a lot of extra automatic checking for bugs...
>
> Greetings,
>Arjan van de Ven
>

OK... here's a redone patch:

Maple bus keyboard support for the SEGA Dreamcast.

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

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate "Maple bus keyboard"
+   depends on SH_DREAMCAST && MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..0334c60
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin");
+MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
+MODULE_LICENSE("GPL");
+
+extern int maple_driver_register(struct device_driver *drv);
+
+const static unsigned char 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_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,

[PATCH] Patch Dreamcast AICA driver to handle Maple bus support

2007-09-09 Thread Adrian McMenamin
This patches the AICA sound driver for the Dreamcast to handle the
well known flakiness of the Dreamcast's G2 bus.

This is dependent on getting Maple bus support (see
http://lkml.org/lkml/2007/9/9/70) into the kernel.

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

diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 7397865..a42c58f 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,7 +44,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "aica.h"

 MODULE_AUTHOR("Adrian McMenamin <[EMAIL PROTECTED]>");
@@ -218,6 +219,12 @@ static int aica_dma_transfer(int channels, int buffer_size,
period_offset = dreamcastcard->clicks;
period_offset %= (AICA_PERIOD_NUMBER / channels);
runtime = substream->runtime;
+   /* If maple dma is running, wait for it to finish */
+   do{ cpu_relax();}
+   while (!maple_dma_done());
+   /* Turn off the maple dma now */
+   ctrl_outl(0, MAPLE_ENABLE);
+   local_irq_disable();
for (q = 0; q < channels; q++) {
err = dma_xfer(AICA_DMA_CHANNEL,
   (unsigned long) (runtime->dma_area +
@@ -232,6 +239,9 @@ static int aica_dma_transfer(int channels, int buffer_size,
break;
dma_wait_for_completion(AICA_DMA_CHANNEL);
}
+   /* restore maple dma */
+   local_irq_enable();
+   maplebus_init_hardware();
return err;
 }
-
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/3] Maple bus support for the Sega Dreamcast

2007-09-09 Thread Adrian McMenamin
On 09/09/07, Arjan van de Ven <[EMAIL PROTECTED]> wrote:
> On Sun, 9 Sep 2007 17:46:54 +0100
> "Adrian McMenamin" <[EMAIL PROTECTED]> wrote:
>
> > This patch adds support for Sega's proprietary Maple bus - which is
> > required to support the Dreamcast's peripherals.
>

>
> First of all, I'm a little concerned about the lack of locking that
> this driver seems to have; what guarantees the integrity of the lists
> used in the driver?
>
Could you explain what you think the issue is? The lists are only
handled by this driver and not anything else.


> Second, you have a lot of use of likely() and unlikely(); so much that I 
> think it's wy overkill. The code it's in generally isn't hotpath, and gcc 
> also does a pretty decent job without giving these hints in general.
>
>
>

Fair enough.

> > +
> > +void maple_add_packet(struct mapleq *mq)
> > +{
> > + list_add((struct list_head *) mq, _waitq);
> > +}
>
> for example this list.. what makes sure that no 2 pieces of code muck with it 
> at the same time?
>
>

Because everything is handled by one kernel thread on a uniprocessor machine.


> > +static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id)
> > +{
> > + /* Load everything into the bottom half */
> > + schedule_work(_dma_process);
> > + return IRQ_HANDLED;
> > +}
>
> I wonder if you want to at least check if the work was really for you before 
> returning IRQ_HANDLED
>

It's *always* for me - this is an end of DMA interrupt for the bus.
-
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] Maple bus support for the Sega Dreamcast - consequential change to pvr2 driver

2007-09-09 Thread Adrian McMenamin
Make the VBLANK interrupt shareable.

This is the third time I have posted this patch. This is required to
allow the Maple bus driver to work (Maple hardware is synced with the
VBLANK interrupt).

Signed off: Adrian McMenamin <[EMAIL PROTECTED]>

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
"pvr2 VBL handler", fb_info)) {
return -EBUSY;
}
-
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] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-09 Thread Adrian McMenamin
This patch adds support for the SEGA Dreamcast keyboard.

Following suggestions from the inout maintainer it has been somewhat
rewritten since the previous posting
(http://lkml.org/lkml/2007/9/4/168).

It is dependent on patch 1 in this series
(http://lkml.org/lkml/2007/9/9/70)  - which provides the core maple
bus support.

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


diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate "Maple bus keyboard"
+   depends on SH_DREAMCAST && MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..8836e40
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Very simple mutex to ensure proper cleanup */
+DECLARE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin");
+MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
+MODULE_LICENSE("GPL");
+
+extern int maple_driver_register(struct device_driver *drv);
+
+const static unsigned char 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_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, 

[PATCH 1/3] Maple bus support for the Sega Dreamcast

2007-09-09 Thread Adrian McMenamin
This patch adds support for Sega's proprietary Maple bus - which is
required to support the Dreamcast's peripherals.

This driver represents a substantial re-write of the old 2.4 driver.

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

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..c1771b7 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default "0xb800" if CF_AREA6
default "0xb400" if CF_AREA5

+config MAPLE
+   tristate "Maple Bus Support"
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source "arch/sh/drivers/pci/Kconfig"

 source "drivers/pci/Kconfig"
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..f8c39f2
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-y  := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..0f2223c
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,737 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin");
+MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
+MODULE_LICENSE("GPL");
+MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}");
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+
+static struct maple_driver maple_null_driver;
+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 struct kmem_cache *maple_cache;
+
+int maple_driver_register(struct device_driver *drv)
+{
+   if (!drv)
+   return -EINVAL;
+   drv->bus = _bus_type;
+   return driver_register(drv);
+}
+EXPORT_SYMBOL_GPL(maple_driver_register);
+
+void maplebus_init_hardware(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);
+}
+EXPORT_SYMBOL_GPL(maplebus_init_hardware);
+
+void maple_getcond_callback(struct maple_device *dev,
+   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 = 0;
+}
+EXPORT_SYMBOL_GPL(maple_getcond_callback);
+
+int maple_dma_done(void)
+{
+   return (ctrl_inl(MAPLE_STATE) & 1) == 0;
+}
+EXPORT_SYMBOL_GPL(maple_dma_done);
+
+static void maple_release_device(struct device *dev)
+{
+   if (dev->type) {
+   kfree(dev->type->name);
+   kf

[PATCH 1/3] Maple bus support for the Sega Dreamcast

2007-09-09 Thread Adrian McMenamin
This patch adds support for Sega's proprietary Maple bus - which is
required to support the Dreamcast's peripherals.

This driver represents a substantial re-write of the old 2.4 driver.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..c1771b7 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default 0xb800 if CF_AREA6
default 0xb400 if CF_AREA5

+config MAPLE
+   tristate Maple Bus Support
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source arch/sh/drivers/pci/Kconfig

 source drivers/pci/Kconfig
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..f8c39f2
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-y  := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..0f2223c
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,737 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include linux/init.h
+#include linux/device.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/list.h
+#include linux/io.h
+#include linux/slab.h
+#include linux/maple.h
+#include asm/cacheflush.h
+#include asm/dma.h
+#include asm/mach/sysasic.h
+
+MODULE_AUTHOR(Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin);
+MODULE_DESCRIPTION(Maple bus driver for Dreamcast);
+MODULE_LICENSE(GPL);
+MODULE_SUPPORTED_DEVICE({{SEGA, Dreamcast/Maple}});
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+
+static struct maple_driver maple_null_driver;
+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 struct kmem_cache *maple_cache;
+
+int maple_driver_register(struct device_driver *drv)
+{
+   if (!drv)
+   return -EINVAL;
+   drv-bus = maple_bus_type;
+   return driver_register(drv);
+}
+EXPORT_SYMBOL_GPL(maple_driver_register);
+
+void maplebus_init_hardware(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);
+}
+EXPORT_SYMBOL_GPL(maplebus_init_hardware);
+
+void maple_getcond_callback(struct maple_device *dev,
+   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 = 0;
+}
+EXPORT_SYMBOL_GPL(maple_getcond_callback);
+
+int maple_dma_done(void)
+{
+   return (ctrl_inl(MAPLE_STATE)  1) == 0;
+}
+EXPORT_SYMBOL_GPL(maple_dma_done);
+
+static void maple_release_device(struct device *dev)
+{
+   if (dev-type) {
+   kfree(dev-type-name

[PATCH 2/3] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-09 Thread Adrian McMenamin
This patch adds support for the SEGA Dreamcast keyboard.

Following suggestions from the inout maintainer it has been somewhat
rewritten since the previous posting
(http://lkml.org/lkml/2007/9/4/168).

It is dependent on patch 1 in this series
(http://lkml.org/lkml/2007/9/9/70)  - which provides the core maple
bus support.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]


diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate Maple bus keyboard
+   depends on SH_DREAMCAST  MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..8836e40
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#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
+
+/* Very simple mutex to ensure proper cleanup */
+DECLARE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR(YAEGASHI Takeshi, Adrian McMenamin);
+MODULE_DESCRIPTION(SEGA Dreamcast keyboard driver);
+MODULE_LICENSE(GPL);
+
+extern int maple_driver_register(struct device_driver *drv);
+
+const static unsigned char 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_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

[PATCH 3/3] Maple bus support for the Sega Dreamcast - consequential change to pvr2 driver

2007-09-09 Thread Adrian McMenamin
Make the VBLANK interrupt shareable.

This is the third time I have posted this patch. This is required to
allow the Maple bus driver to work (Maple hardware is synced with the
VBLANK interrupt).

Signed off: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
pvr2 VBL handler, fb_info)) {
return -EBUSY;
}
-
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/3] Maple bus support for the Sega Dreamcast

2007-09-09 Thread Adrian McMenamin
On 09/09/07, Arjan van de Ven [EMAIL PROTECTED] wrote:
 On Sun, 9 Sep 2007 17:46:54 +0100
 Adrian McMenamin [EMAIL PROTECTED] wrote:

  This patch adds support for Sega's proprietary Maple bus - which is
  required to support the Dreamcast's peripherals.



 First of all, I'm a little concerned about the lack of locking that
 this driver seems to have; what guarantees the integrity of the lists
 used in the driver?

Could you explain what you think the issue is? The lists are only
handled by this driver and not anything else.


 Second, you have a lot of use of likely() and unlikely(); so much that I 
 think it's wy overkill. The code it's in generally isn't hotpath, and gcc 
 also does a pretty decent job without giving these hints in general.




Fair enough.

  +
  +void maple_add_packet(struct mapleq *mq)
  +{
  + list_add((struct list_head *) mq, maple_waitq);
  +}

 for example this list.. what makes sure that no 2 pieces of code muck with it 
 at the same time?



Because everything is handled by one kernel thread on a uniprocessor machine.


  +static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id)
  +{
  + /* Load everything into the bottom half */
  + schedule_work(maple_dma_process);
  + return IRQ_HANDLED;
  +}

 I wonder if you want to at least check if the work was really for you before 
 returning IRQ_HANDLED


It's *always* for me - this is an end of DMA interrupt for the bus.
-
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] Patch Dreamcast AICA driver to handle Maple bus support

2007-09-09 Thread Adrian McMenamin
This patches the AICA sound driver for the Dreamcast to handle the
well known flakiness of the Dreamcast's G2 bus.

This is dependent on getting Maple bus support (see
http://lkml.org/lkml/2007/9/9/70) into the kernel.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 7397865..a42c58f 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -35,6 +35,7 @@
 #include linux/timer.h
 #include linux/delay.h
 #include linux/workqueue.h
+#include linux/maple.h
 #include sound/driver.h
 #include sound/core.h
 #include sound/control.h
@@ -43,7 +44,7 @@
 #include sound/info.h
 #include asm/io.h
 #include asm/dma.h
-#include asm/dreamcast/sysasic.h
+#include asm/mach/sysasic.h
 #include aica.h

 MODULE_AUTHOR(Adrian McMenamin [EMAIL PROTECTED]);
@@ -218,6 +219,12 @@ static int aica_dma_transfer(int channels, int buffer_size,
period_offset = dreamcastcard-clicks;
period_offset %= (AICA_PERIOD_NUMBER / channels);
runtime = substream-runtime;
+   /* If maple dma is running, wait for it to finish */
+   do{ cpu_relax();}
+   while (!maple_dma_done());
+   /* Turn off the maple dma now */
+   ctrl_outl(0, MAPLE_ENABLE);
+   local_irq_disable();
for (q = 0; q  channels; q++) {
err = dma_xfer(AICA_DMA_CHANNEL,
   (unsigned long) (runtime-dma_area +
@@ -232,6 +239,9 @@ static int aica_dma_transfer(int channels, int buffer_size,
break;
dma_wait_for_completion(AICA_DMA_CHANNEL);
}
+   /* restore maple dma */
+   local_irq_enable();
+   maplebus_init_hardware();
return err;
 }
-
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/3] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-09 Thread Adrian McMenamin
On 09/09/07, Arjan van de Ven [EMAIL PROTECTED] wrote:
 On Sun, 9 Sep 2007 18:01:26 +0100
 Adrian McMenamin [EMAIL PROTECTED] wrote:

  This patch adds support for the SEGA Dreamcast keyboard.
 
  Following suggestions from the inout maintainer it has been somewhat
  rewritten since the previous posting
  (http://lkml.org/lkml/2007/9/4/168).

 Hi,

 this driver in general is quite clean as well; I have only one
 suggestion for improvement. Right now you use a semaphore for locking,
 while all you really use it for is mutex semantics, I think it would be
 a good idea to convert the driver to use the actual mutex primitive;
 this will buy you a lot of extra automatic checking for bugs...

 Greetings,
Arjan van de Ven


OK... here's a redone patch:

Maple bus keyboard support for the SEGA Dreamcast.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate Maple bus keyboard
+   depends on SH_DREAMCAST  MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..0334c60
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#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
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR(YAEGASHI Takeshi, Adrian McMenamin);
+MODULE_DESCRIPTION(SEGA Dreamcast keyboard driver);
+MODULE_LICENSE(GPL);
+
+extern int maple_driver_register(struct device_driver *drv);
+
+const static unsigned char 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_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

Re: [PATCH 2/3] Maple bus support for the Sega Dreamcast - keyboard support

2007-09-09 Thread Adrian McMenamin
On 09/09/07, Arjan van de Ven [EMAIL PROTECTED] wrote:
 On Sun, 9 Sep 2007 21:35:11 +0100
 Adrian McMenamin [EMAIL PROTECTED] wrote:


 I think this has a bug; mutex_trylock has the opposite return code as
 down_trylock (mutex follows the same convention as the spinlock
 trylock) so you probably need to add a ! here...


Quite right. Also explains the big fall in the keyboard's
responsiveness - though, to be honest, I don't see how it worked at
all.

Here's the correct patch.

Add maple bus keyboard support to the kernel.

Signed-off by Adrian McMenamin [EMAIL PROTECTED]


diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..056cc52 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate Maple bus keyboard
+   depends on SH_DREAMCAST  MAPLE
+   help
+ Say Y here if you have a Dreamcast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..0e580c7
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,234 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#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
+
+/* Very simple mutex to ensure proper cleanup */
+static DEFINE_MUTEX(maple_keyb_mutex);
+
+#define NR_SCANCODES 256
+
+MODULE_AUTHOR(YAEGASHI Takeshi, Adrian McMenamin);
+MODULE_DESCRIPTION(SEGA Dreamcast keyboard driver);
+MODULE_LICENSE(GPL);
+
+extern int maple_driver_register(struct device_driver *drv);
+
+const static unsigned char 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_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

Re: [PATCH] Add support for keyboard on SEGA Dreamcast

2007-09-07 Thread Adrian McMenamin
On 05/09/07, Dmitry Torokhov <[EMAIL PROTECTED]> wrote:

>
> Are we guaranteed that the dc_kbd_callback is not running in a separate
> thread?
>
> Please also consider implementing support for changing keyma. Since
> the keymap is pretty full I think the best way is to copy the vanilla
> keymap into a per-device memory and set up keymap, keycodesize and
> keycodemax in input device structure.
>
> Thank you.
>
> --
> Dmitry
>

Dmitry - have now worked out at least one alternative keymap - for
European keyboards. But could you explain the above point? I have to
admit I am not too familiar with the input layer - having really taken
an old, and bit rot infested 2.4 driver and brought it up to standard
for 2.6 - and so I don't follow this point too well!

Can I treat keymaps as firmware and load from userspace? Or is there a
way of making this completely user configurable at runtime?

Any help from you, or any other reader, much appreciated.

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] Add support for keyboard on SEGA Dreamcast

2007-09-07 Thread Adrian McMenamin
On 05/09/07, Dmitry Torokhov [EMAIL PROTECTED] wrote:


 Are we guaranteed that the dc_kbd_callback is not running in a separate
 thread?

 Please also consider implementing support for changing keyma. Since
 the keymap is pretty full I think the best way is to copy the vanilla
 keymap into a per-device memory and set up keymap, keycodesize and
 keycodemax in input device structure.

 Thank you.

 --
 Dmitry


Dmitry - have now worked out at least one alternative keymap - for
European keyboards. But could you explain the above point? I have to
admit I am not too familiar with the input layer - having really taken
an old, and bit rot infested 2.4 driver and brought it up to standard
for 2.6 - and so I don't follow this point too well!

Can I treat keymaps as firmware and load from userspace? Or is there a
way of making this completely user configurable at runtime?

Any help from you, or any other reader, much appreciated.

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] Add support for keyboard on SEGA Dreamcast

2007-09-04 Thread Adrian McMenamin
This patch will add support for the Dreamcast keyboard when used
alongside the maple bus patch (http://lkml.org/lkml/2007/9/4/165) and
the pvr2 patch.

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

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..1689f73 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate "Maple bus keyboard"
+   depends on SH_DREAMCAST && MAPLE
+   help
+ Say Y here if you have a DreamCast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..12e4692
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,222 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin");
+MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
+MODULE_LICENSE("GPL");
+
+static unsigned char dc_kbd_keycode[256] = {
+   0, 0, 0, 0, 30, 48, 46, 32,
+   18, 33, 34, 35, 23, 36, 37, 38,
+   50, 49, 24, 25, 16, 19, 31, 20,
+   22, 47, 17, 45, 21, 44, 2, 3,
+   4, 5, 6, 7, 8, 9, 10, 11, 28,
+   1, 14, 15, 57, 12, 13, 26,
+   27, 43, 43, 39, 40, 41, 51,
+   52, 53, 58, 59, 60, 61, 62, 63, 64,
+   65, 66, 67, 68, 87, 88, 99,
+   70, 119, 110, 102, 104, 111,
+   107, 109, 106, 105, 108, 103,
+   69, 98, 55, 74, 78, 96, 79, 80,
+   81, 75, 76, 77, 71, 72, 73, 82, 83,
+   86, 127, 116, 117, 183, 184, 185,
+   186, 187, 188, 189, 190,
+   191, 192, 193, 194, 134, 138, 130, 132,
+   128, 129, 131, 137, 133, 135, 136, 113,
+   115, 114, 0, 0, 0, 121, 0, 89, 93, 124,
+   92, 94, 95, 0, 0, 0,
+   122, 123, 90, 91, 85, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   29, 42, 56, 125, 97, 54, 100, 126,
+   164, 166, 165, 163, 161, 115, 114, 113,
+   150, 158, 159, 128, 136, 177, 178, 176, 142,
+   152, 173, 140
+};
+
+struct dc_kbd {
+   struct input_dev *dev;
+   unsigned char new[8];
+   unsigned char old[8];
+};
+
+static void dc_scan_kbd(struct dc_kbd *kbd)
+{
+   int i;
+   struct input_dev *dev = kbd->dev;
+   for (i = 0; i < 8; i++)
+   input_report_key(dev,
+dc_kbd_keycode[i + 224],
+(kbd->new[0] >> i) & 1);
+
+   for (i = 2; i < 8; i++) {
+   if (kbd->old[i] > 3
+   && memchr(kbd->new + 2, kbd->old[i], 6) == NULL) {
+   if (dc_kbd_keycode[kbd->old[i]])
+   input_report_key(dev,
+   dc_kbd_keycode[kbd->old[i]], 0);
+   else
+   printk
+ 

[PATCH - RESUBMiT] Minor patch to pvr2 driver required for maple bus support on SEGA Dreamcast

2007-09-04 Thread Adrian McMenamin
The maple bus driver (http://lkml.org/lkml/2007/9/4/165) uses hardware
synchronisation between the maple bus and the VBLANK to poll the maple
bus. This patch makes the interrupt shareable.

By definition the interrupt is for both devices.

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

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
"pvr2 VBL handler", fb_info)) {
return -EBUSY;
}
-
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] Add maple bus support for the SEGA Dreamcast

2007-09-04 Thread Adrian McMenamin
This patch adds support for SEGA's proprietary Maple bus. Maple is a
serial communications bus and support is required to operate Dreamcast
peripherals. A keyboard driver is also available and will be posted
separately.

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

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..077438f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default "0xb800" if CF_AREA6
default "0xb400" if CF_AREA5

+config MAPLE
+   bool "Maple Bus Support"
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source "arch/sh/drivers/pci/Kconfig"

 source "drivers/pci/Kconfig"
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..f8c39f2
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-y  := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..e6fd696
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,738 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin");
+MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
+MODULE_LICENSE("GPL");
+MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}");
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+
+static struct maple_driver maple_null_driver;
+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 struct kmem_cache *maple_cache;
+
+int maple_driver_register(struct device_driver *drv)
+{
+   if (unlikely(!drv))
+   return -EINVAL;
+   drv->bus = _bus_type;
+   return driver_register(drv);
+}
+EXPORT_SYMBOL_GPL(maple_driver_register);
+
+void maplebus_init_hardware(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);
+}
+EXPORT_SYMBOL_GPL(maplebus_init_hardware);
+
+void maple_getcond_callback(struct maple_device *dev,
+   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 = 0;
+}
+EXPORT_SYMBOL_GPL(maple_getcond_callback);
+
+int maple_dma_done(void)
+{
+   return (ctrl_inl(MAPLE_STATE) & 1) == 0;
+}
+EXPORT_SYMBOL_GPL(maple_dma_done);
+
+static void maple_release_device(struct device *dev)
+{
+   if (likely(dev->type)) {
+ 

[PATCH] Add maple bus support for the SEGA Dreamcast

2007-09-04 Thread Adrian McMenamin
This patch adds support for SEGA's proprietary Maple bus. Maple is a
serial communications bus and support is required to operate Dreamcast
peripherals. A keyboard driver is also available and will be posted
separately.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 54878f0..077438f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -702,6 +702,17 @@ config CF_BASE_ADDR
default 0xb800 if CF_AREA6
default 0xb400 if CF_AREA5

+config MAPLE
+   bool Maple Bus Support
+   depends on SH_DREAMCAST
+   help
+ The Maple Bus is SEGA's serial communication bus for peripherals
+ on the Dreamcast. Without this bus support you won't be able to
+ get your Dreamcast keyboard etc to work, so most users
+ probably want to say 'Y' here, unless you are only using the
+ Dreamcast with a serial line terminal or a remote network
+ connection.
+
 source arch/sh/drivers/pci/Kconfig

 source drivers/pci/Kconfig
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index 8a14389..f0a1f4f 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,4 +3,5 @@
 #

 obj-$(CONFIG_SUPERHYWAY) += superhyway/
+obj-$(CONFIG_MAPLE) += maple/

diff --git a/drivers/sh/maple/Makefile b/drivers/sh/maple/Makefile
new file mode 100644
index 000..f8c39f2
--- /dev/null
+++ b/drivers/sh/maple/Makefile
@@ -0,0 +1,3 @@
+#Makefile for Maple Bus
+
+obj-y  := maplebus.o
diff --git a/drivers/sh/maple/maplebus.c b/drivers/sh/maple/maplebus.c
new file mode 100644
index 000..e6fd696
--- /dev/null
+++ b/drivers/sh/maple/maplebus.c
@@ -0,0 +1,738 @@
+/* maplebus.c
+ * Core maple bus functionality
+ * Original 2.4 code used here copyright
+ * YAEGASHI Takeshi, Paul Mundt, M. R. Brown and others
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include linux/init.h
+#include linux/device.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/list.h
+#include linux/io.h
+#include linux/slab.h
+#include linux/maple.h
+#include asm/cacheflush.h
+#include asm/dma.h
+#include asm/mach/sysasic.h
+
+MODULE_AUTHOR(Yaegshi Takeshi, Paul Mundt, MR Brown, Adrian McMenamin);
+MODULE_DESCRIPTION(Maple bus driver for Dreamcast);
+MODULE_LICENSE(GPL);
+MODULE_SUPPORTED_DEVICE({{SEGA, Dreamcast/Maple}});
+
+static void maple_dma_handler(struct work_struct *work);
+static void maple_vblank_handler(struct work_struct *work);
+
+static DECLARE_WORK(maple_dma_process, maple_dma_handler);
+static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
+
+static LIST_HEAD(maple_waitq);
+static LIST_HEAD(maple_sentq);
+
+
+static struct maple_driver maple_null_driver;
+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 struct kmem_cache *maple_cache;
+
+int maple_driver_register(struct device_driver *drv)
+{
+   if (unlikely(!drv))
+   return -EINVAL;
+   drv-bus = maple_bus_type;
+   return driver_register(drv);
+}
+EXPORT_SYMBOL_GPL(maple_driver_register);
+
+void maplebus_init_hardware(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);
+}
+EXPORT_SYMBOL_GPL(maplebus_init_hardware);
+
+void maple_getcond_callback(struct maple_device *dev,
+   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 = 0;
+}
+EXPORT_SYMBOL_GPL(maple_getcond_callback);
+
+int maple_dma_done(void)
+{
+   return (ctrl_inl(MAPLE_STATE)  1) == 0;
+}
+EXPORT_SYMBOL_GPL(maple_dma_done);
+
+static void maple_release_device(struct device *dev)
+{
+   if (likely(dev-type

[PATCH - RESUBMiT] Minor patch to pvr2 driver required for maple bus support on SEGA Dreamcast

2007-09-04 Thread Adrian McMenamin
The maple bus driver (http://lkml.org/lkml/2007/9/4/165) uses hardware
synchronisation between the maple bus and the VBLANK to poll the maple
bus. This patch makes the interrupt shareable.

By definition the interrupt is for both devices.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
pvr2 VBL handler, fb_info)) {
return -EBUSY;
}
-
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] Add support for keyboard on SEGA Dreamcast

2007-09-04 Thread Adrian McMenamin
This patch will add support for the Dreamcast keyboard when used
alongside the maple bus patch (http://lkml.org/lkml/2007/9/4/165) and
the pvr2 patch.

Signed off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c97d5eb..1689f73 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -253,4 +253,14 @@ config KEYBOARD_GPIO
  To compile this driver as a module, choose M here: the
  module will be called gpio-keys.

+
+config KEYBOARD_MAPLE
+   tristate Maple bus keyboard
+   depends on SH_DREAMCAST  MAPLE
+   help
+ Say Y here if you have a DreamCast console running Linux and have
+ a keyboard attached to its Maple bus.
+
+ To compile this driver as a module, choose M here: the
+ module will be called maple_keyb. 
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 28d211b..3f775ed 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keyboard.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
 obj-$(CONFIG_KEYBOARD_GPIO)+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_MAPLE)   += maple_keyb.o

diff --git a/drivers/input/keyboard/maple_keyb.c
b/drivers/input/keyboard/maple_keyb.c
new file mode 100644
index 000..12e4692
--- /dev/null
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -0,0 +1,222 @@
+/*
+ * SEGA Dreamcast keyboard driver
+ * Based on drivers/usb/usbkbd.c
+ * Copyright YAEGASHI Takeshi, 2001
+ * Porting to 2.6 Copyright Adrian McMenamin, 2007
+ *
+ * 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, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#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
+
+MODULE_AUTHOR(YAEGASHI Takeshi, Adrian McMenamin);
+MODULE_DESCRIPTION(SEGA Dreamcast keyboard driver);
+MODULE_LICENSE(GPL);
+
+static unsigned char dc_kbd_keycode[256] = {
+   0, 0, 0, 0, 30, 48, 46, 32,
+   18, 33, 34, 35, 23, 36, 37, 38,
+   50, 49, 24, 25, 16, 19, 31, 20,
+   22, 47, 17, 45, 21, 44, 2, 3,
+   4, 5, 6, 7, 8, 9, 10, 11, 28,
+   1, 14, 15, 57, 12, 13, 26,
+   27, 43, 43, 39, 40, 41, 51,
+   52, 53, 58, 59, 60, 61, 62, 63, 64,
+   65, 66, 67, 68, 87, 88, 99,
+   70, 119, 110, 102, 104, 111,
+   107, 109, 106, 105, 108, 103,
+   69, 98, 55, 74, 78, 96, 79, 80,
+   81, 75, 76, 77, 71, 72, 73, 82, 83,
+   86, 127, 116, 117, 183, 184, 185,
+   186, 187, 188, 189, 190,
+   191, 192, 193, 194, 134, 138, 130, 132,
+   128, 129, 131, 137, 133, 135, 136, 113,
+   115, 114, 0, 0, 0, 121, 0, 89, 93, 124,
+   92, 94, 95, 0, 0, 0,
+   122, 123, 90, 91, 85, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 0,
+   29, 42, 56, 125, 97, 54, 100, 126,
+   164, 166, 165, 163, 161, 115, 114, 113,
+   150, 158, 159, 128, 136, 177, 178, 176, 142,
+   152, 173, 140
+};
+
+struct dc_kbd {
+   struct input_dev *dev;
+   unsigned char new[8];
+   unsigned char old[8];
+};
+
+static void dc_scan_kbd(struct dc_kbd *kbd)
+{
+   int i;
+   struct input_dev *dev = kbd-dev;
+   for (i = 0; i  8; i++)
+   input_report_key(dev,
+dc_kbd_keycode[i + 224],
+(kbd-new[0]  i)  1);
+
+   for (i = 2; i  8; i++) {
+   if (kbd-old[i]  3
+memchr(kbd-new + 2, kbd-old[i], 6) == NULL) {
+   if (dc_kbd_keycode[kbd-old[i]])
+   input_report_key(dev,
+   dc_kbd_keycode[kbd-old[i]], 0);
+   else
+   printk
+   (Unknown key (scancode %#x) released

Re: [PATCH] Patch pvr2 driver to allow development of maple bus driver

2007-09-01 Thread Adrian McMenamin
On Fri, 2007-08-31 at 23:02 -0400, Mike Frysinger wrote:

> i really dont know how the maple bus works or what piece of hardware is wired 
> up to the same interrupt line.  my point is that if the other device fires an 
> interrupt, the pvr interrupt handler may be executed and attempt to do work 
> when in reality the pvr was not the source of the interrupt.
> -mike

The interrupt is *always* fired by the PVR - it is the VBLANK - ie
essentially screen refresh. It is *never* generated by the maple bus.

However, the maple bus is/can be hardware synced - which means once that
setting is made then the hardware will *always* be polled on the VBLANK.

In other words there is no need to check which device is interrupt is
for, because it is *always* going to be for both of them.
-
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] Patch pvr2 driver to allow development of maple bus driver

2007-09-01 Thread Adrian McMenamin
On Fri, 2007-08-31 at 23:02 -0400, Mike Frysinger wrote:

 i really dont know how the maple bus works or what piece of hardware is wired 
 up to the same interrupt line.  my point is that if the other device fires an 
 interrupt, the pvr interrupt handler may be executed and attempt to do work 
 when in reality the pvr was not the source of the interrupt.
 -mike

The interrupt is *always* fired by the PVR - it is the VBLANK - ie
essentially screen refresh. It is *never* generated by the maple bus.

However, the maple bus is/can be hardware synced - which means once that
setting is made then the hardware will *always* be polled on the VBLANK.

In other words there is no need to check which device is interrupt is
for, because it is *always* going to be for both of them.
-
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] Patch pvr2 driver to allow development of maple bus driver

2007-08-31 Thread Adrian McMenamin
On 31/08/2007, Mike Frysinger <[EMAIL PROTECTED]> wrote:
> On 8/31/07, Adrian McMenamin <[EMAIL PROTECTED]> wrote:
> > This patch makes the PVR2 VBLANK interrupt on the SEGA Dreamcast
> > shareable - a small but necessary change to enable ongoing efforts to
> > develop a driver for the maple bus on the Dreamcast. (Maple is Sega's
> > proprietary serial interface for the Dreamcast and can be set to
> > synchronise dma transfers to the VBLANK).
> >
> > This has no impact on the performance of the PVR2.
>
> sharable implies the interrupt handler checks to see if it actually
> caused the interrupt ... which it doesnt at the moment ... presumably,
> you're making it shared because another device will be using that
> interrupt as well ... so when that other device gets an interrupt, how
> do you know it's for that device and not PVR2 ?


If the interrupt occurs then it will be for both of them. The hardware
cannot be removed and the maple bus driver is set for hardware sync.

The question seems redundant to me.
-
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/


Fwd: [PATCH] Patch pvr2 driver to allow development of maple bus driver

2007-08-31 Thread Adrian McMenamin
Apologies, sent this Bcc by mistake the first time

-- Forwarded message --
From: Adrian McMenamin <[EMAIL PROTECTED]>
Date: 31 Aug 2007 21:00
Subject: [PATCH] Patch pvr2 driver to allow development of maple bus driver
To: "Antonino A. Daplas" <[EMAIL PROTECTED]>


This patch makes the PVR2 VBLANK interrupt on the SEGA Dreamcast
shareable - a small but necessary change to enable ongoing efforts to
develop a driver for the maple bus on the Dreamcast. (Maple is Sega's
proprietary serial interface for the Dreamcast and can be set to
synchronise dma transfers to the VBLANK).

This has no impact on the performance of the PVR2.

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

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
"pvr2 VBL handler", fb_info)) {
return -EBUSY;
}
-
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] Patch pvr2 driver to allow development of maple bus driver

2007-08-31 Thread Adrian McMenamin
This patch makes the PVR2 VBLANK interrupt on the SEGA Dreamcast
shareable - a small but necessary change to enable ongoing efforts to
develop a driver for the maple bus on the Dreamcast. (Maple is Sega's
proprietary serial interface for the Dreamcast and can be set to
synchronise dma transfers to the VBLANK).

This has no impact on the performance of the PVR2.

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

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
"pvr2 VBL handler", fb_info)) {
return -EBUSY;
}
-
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] Patch pvr2 driver to allow development of maple bus driver

2007-08-31 Thread Adrian McMenamin
This patch makes the PVR2 VBLANK interrupt on the SEGA Dreamcast
shareable - a small but necessary change to enable ongoing efforts to
develop a driver for the maple bus on the Dreamcast. (Maple is Sega's
proprietary serial interface for the Dreamcast and can be set to
synchronise dma transfers to the VBLANK).

This has no impact on the performance of the PVR2.

Signed-off by Adrian McMenamin [EMAIL PROTECTED]

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
pvr2 VBL handler, fb_info)) {
return -EBUSY;
}
-
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/


Fwd: [PATCH] Patch pvr2 driver to allow development of maple bus driver

2007-08-31 Thread Adrian McMenamin
Apologies, sent this Bcc by mistake the first time

-- Forwarded message --
From: Adrian McMenamin [EMAIL PROTECTED]
Date: 31 Aug 2007 21:00
Subject: [PATCH] Patch pvr2 driver to allow development of maple bus driver
To: Antonino A. Daplas [EMAIL PROTECTED]


This patch makes the PVR2 VBLANK interrupt on the SEGA Dreamcast
shareable - a small but necessary change to enable ongoing efforts to
develop a driver for the maple bus on the Dreamcast. (Maple is Sega's
proprietary serial interface for the Dreamcast and can be set to
synchronise dma transfers to the VBLANK).

This has no impact on the performance of the PVR2.

Signed-off by Adrian McMenamin [EMAIL PROTECTED]

diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 7d6c298..13de07f 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -890,7 +890,7 @@ static int __init pvr2fb_dc_init(void)
pvr2_fix.mmio_start = 0xa05f8000;   /* registers start here */
pvr2_fix.mmio_len   = 0x2000;

-   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+   if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, IRQF_SHARED,
pvr2 VBL handler, fb_info)) {
return -EBUSY;
}
-
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] Patch pvr2 driver to allow development of maple bus driver

2007-08-31 Thread Adrian McMenamin
On 31/08/2007, Mike Frysinger [EMAIL PROTECTED] wrote:
 On 8/31/07, Adrian McMenamin [EMAIL PROTECTED] wrote:
  This patch makes the PVR2 VBLANK interrupt on the SEGA Dreamcast
  shareable - a small but necessary change to enable ongoing efforts to
  develop a driver for the maple bus on the Dreamcast. (Maple is Sega's
  proprietary serial interface for the Dreamcast and can be set to
  synchronise dma transfers to the VBLANK).
 
  This has no impact on the performance of the PVR2.

 sharable implies the interrupt handler checks to see if it actually
 caused the interrupt ... which it doesnt at the moment ... presumably,
 you're making it shared because another device will be using that
 interrupt as well ... so when that other device gets an interrupt, how
 do you know it's for that device and not PVR2 ?


If the interrupt occurs then it will be for both of them. The hardware
cannot be removed and the maple bus driver is set for hardware sync.

The question seems redundant to me.
-
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: add machine-ops and Dreamcast specific fix-up

2007-08-04 Thread Adrian McMenamin
On Sat, 2007-08-04 at 12:06 +0900, Paul Mundt wrote:
> On Fri, Aug 03, 2007 at 08:26:17PM +0100, Adrian McMenamin wrote:
> > diff --git a/arch/sh/boards/dreamcast/Makefile
> > b/arch/sh/boards/dreamcast/Makefile
> > index e6fcd3d..7b97546 100644
> > --- a/arch/sh/boards/dreamcast/Makefile
> > +++ b/arch/sh/boards/dreamcast/Makefile
> > @@ -2,5 +2,5 @@
> >  # Makefile for the Sega Dreamcast specific parts of the kernel
> >  #
> > 
> > -obj-y   := setup.o irq.o rtc.o reboot.o
> > +obj-y   := setup.o irq.o rtc.o
> > 
> 
> You've created this diff against a bogus kernel.

True. My apologies - I missed that.

> 
> > diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
> > index bdb30ba..7ab2359 100644
> > --- a/arch/sh/kernel/Makefile
> > +++ b/arch/sh/kernel/Makefile



> > 
> >  void machine_crash_shutdown(struct pt_regs *regs)
> >  {
> 
> You've missed machine_crash_shutdown().
> 

Apologies - though I am a bit puzzled as why the code compiled and
linked with the two definitions, but that's not much of an excuse.


> > +static void mach_reboot_fixups(void)
> > +{
> > +   if (mach_is_dreamcast()) {
> > +   writel(0x7611, 0xA05F6890);
> > +   }
> > +}
> > +
> Whether it's only the dreamcast or not is irrelevant, why bother adding
> abstraction if you intend to add pointless hacks that completely
> side-steps it?
> 

I don't understand the point you are trying to make. Please explain with
more clarity. What have I completely side stepped? I have followed,
broadly, the same pattern used in i386. Just that there, afaics, they
pick up on various PCI cards as the basis on which to modify the reboot.


> > diff --git a/include/asm-sh/emergency-restart.h
> > b/include/asm-sh/emergency-restart.h
> > index 108d8c4..d6bec92 100644
> > --- a/include/asm-sh/emergency-restart.h
> > +++ b/include/asm-sh/emergency-restart.h
> > @@ -1,6 +1,6 @@
> > -#ifndef _ASM_EMERGENCY_RESTART_H
> > -#define _ASM_EMERGENCY_RESTART_H
> > +#ifndef _ASM_SH_EMERGENCY_RESTART_H
> > +#define _ASM_SH_EMERGENCY_RESTART_H
> > 
> > -#include 
> > +extern void machine_emergency_restart(void);
> > 
> > -#endif /* _ASM_EMERGENCY_RESTART_H */
> > +#endif /* _ASM_SH_EMERGENCY_RESTART_H */
> > 
> Pointless. Separating out machine_emergency_restart() buys us nothing,
> leave this alone and just kill it off from the machine_ops entirely.
> You've also ignored my earlier mail where I suggested this and killing
> off some of the other ops we had no use for (as well as consolidating
> machine_crash_shutdown()). I do wish you would read these things and wait
> until there's been a resolution one way or another.

I haven't ignored it. It was just explained with your customary
clarity :)


-
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: add machine-ops and Dreamcast specific fix-up

2007-08-04 Thread Adrian McMenamin
On Sat, 2007-08-04 at 12:06 +0900, Paul Mundt wrote:
 On Fri, Aug 03, 2007 at 08:26:17PM +0100, Adrian McMenamin wrote:
  diff --git a/arch/sh/boards/dreamcast/Makefile
  b/arch/sh/boards/dreamcast/Makefile
  index e6fcd3d..7b97546 100644
  --- a/arch/sh/boards/dreamcast/Makefile
  +++ b/arch/sh/boards/dreamcast/Makefile
  @@ -2,5 +2,5 @@
   # Makefile for the Sega Dreamcast specific parts of the kernel
   #
  
  -obj-y   := setup.o irq.o rtc.o reboot.o
  +obj-y   := setup.o irq.o rtc.o
  
 
 You've created this diff against a bogus kernel.

True. My apologies - I missed that.

 
  diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
  index bdb30ba..7ab2359 100644
  --- a/arch/sh/kernel/Makefile
  +++ b/arch/sh/kernel/Makefile



  
   void machine_crash_shutdown(struct pt_regs *regs)
   {
 
 You've missed machine_crash_shutdown().
 

Apologies - though I am a bit puzzled as why the code compiled and
linked with the two definitions, but that's not much of an excuse.


  +static void mach_reboot_fixups(void)
  +{
  +   if (mach_is_dreamcast()) {
  +   writel(0x7611, 0xA05F6890);
  +   }
  +}
  +
 Whether it's only the dreamcast or not is irrelevant, why bother adding
 abstraction if you intend to add pointless hacks that completely
 side-steps it?
 

I don't understand the point you are trying to make. Please explain with
more clarity. What have I completely side stepped? I have followed,
broadly, the same pattern used in i386. Just that there, afaics, they
pick up on various PCI cards as the basis on which to modify the reboot.


  diff --git a/include/asm-sh/emergency-restart.h
  b/include/asm-sh/emergency-restart.h
  index 108d8c4..d6bec92 100644
  --- a/include/asm-sh/emergency-restart.h
  +++ b/include/asm-sh/emergency-restart.h
  @@ -1,6 +1,6 @@
  -#ifndef _ASM_EMERGENCY_RESTART_H
  -#define _ASM_EMERGENCY_RESTART_H
  +#ifndef _ASM_SH_EMERGENCY_RESTART_H
  +#define _ASM_SH_EMERGENCY_RESTART_H
  
  -#include asm-generic/emergency-restart.h
  +extern void machine_emergency_restart(void);
  
  -#endif /* _ASM_EMERGENCY_RESTART_H */
  +#endif /* _ASM_SH_EMERGENCY_RESTART_H */
  
 Pointless. Separating out machine_emergency_restart() buys us nothing,
 leave this alone and just kill it off from the machine_ops entirely.
 You've also ignored my earlier mail where I suggested this and killing
 off some of the other ops we had no use for (as well as consolidating
 machine_crash_shutdown()). I do wish you would read these things and wait
 until there's been a resolution one way or another.

I haven't ignored it. It was just explained with your customary
clarity :)


-
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: add machine-ops and Dreamcast specific fix-up

2007-08-03 Thread Adrian McMenamin
(This code is closely modelled on the i386 machine-ops, though
currently the only board specific fixup is for the Dreamcast and so
there is not a separate set of mach fixups.)

This needs to be tested against a wide range of SH boards and would be
good to go in -mm if Paul acks it.

Add machine-ops code to the SH code base, allowing board specific
reboot and halt code. Currently only Dreamcast specific warm reboot
fixup in code.

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

diff --git a/arch/sh/boards/dreamcast/Makefile
b/arch/sh/boards/dreamcast/Makefile
index e6fcd3d..7b97546 100644
--- a/arch/sh/boards/dreamcast/Makefile
+++ b/arch/sh/boards/dreamcast/Makefile
@@ -2,5 +2,5 @@
 # Makefile for the Sega Dreamcast specific parts of the kernel
 #

-obj-y   := setup.o irq.o rtc.o reboot.o
+obj-y   := setup.o irq.o rtc.o

diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index bdb30ba..7ab2359 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -5,15 +5,11 @@
 extra-y:= head.o init_task.o vmlinux.lds

 obj-y  := debugtraps.o io.o io_generic.o irq.o machvec.o process.o ptrace.o \
-  semaphore.o setup.o signal.o sys_sh.o syscalls.o \
+  reboot.o semaphore.o setup.o signal.o sys_sh.o syscalls.o \
   time.o topology.o traps.o

 obj-y  += cpu/ timers/

-ifneq ($(CONFIG_SH_DREAMCAST),y)
-   obj-y   += reboot.o
-endif
-
 obj-$(CONFIG_VSYSCALL) += vsyscall/

 obj-$(CONFIG_SMP)  += smp.o
diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c
index 790ed69..201b370 100644
--- a/arch/sh/kernel/machine_kexec.c
+++ b/arch/sh/kernel/machine_kexec.c
@@ -29,9 +29,6 @@ extern const unsigned char relocate_new_kernel[];
 extern const unsigned int relocate_new_kernel_size;
 extern void *gdb_vbr_vector;

-void machine_shutdown(void)
-{
-}

 void machine_crash_shutdown(struct pt_regs *regs)
 {
diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c
new file mode 100644
index 000..c6247ae
--- /dev/null
+++ b/arch/sh/kernel/reboot.c
@@ -0,0 +1,107 @@
+/*
+ *  linux/arch/sh/kernel/reboot.c
+ *
+ *  Essentially copied from i386 code
+ *  and process.c
+ *
+ *  Copyright (C) 1995  Linus Torvalds
+ *
+ *  SuperH version:  Copyright (C) 1999, 2000  Niibe Yutaka & Kaz Kojima
+ *  Copyright (C) 2006 Lineo Solutions Inc. support SH4A UBC
+ *  Copyright (C) 2002 - 2007  Paul Mundt
+ *  Copyright 2007 Adrian McMenamin
+ *
+ *  Licensed under the terms of version 2 of GNU GPL
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Power off function, if any
+ */
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
+
+/* fixups for individual machines -
+ * in i386 this is in a file of its own
+ * but we only have the Dreamcast for now.
+ */
+
+static void mach_reboot_fixups(void)
+{
+   if (mach_is_dreamcast()) {
+   writel(0x7611, 0xA05F6890);
+   }
+}
+
+static void native_machine_shutdown(void)
+{
+}
+
+static void native_machine_emergency_restart(void)
+{
+   mach_reboot_fixups();
+   /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
+   asm volatile("ldc %0, sr\n\t"
+"mov.l @%1, %0" : : "r" (0x1000), "r" (0x8001));
+}
+
+static void native_machine_restart(char * __unused)
+{
+   native_machine_shutdown();
+   native_machine_emergency_restart();
+}
+
+static void native_machine_halt(void)
+{
+   local_irq_disable();
+
+   while (1)
+   cpu_sleep();
+}
+
+static void native_machine_power_off(void)
+{
+   if (pm_power_off) {
+   native_machine_shutdown();
+   pm_power_off();
+   }
+}
+
+struct machine_ops machine_ops = {
+   .power_off = native_machine_power_off,
+   .shutdown = native_machine_shutdown,
+   .emergency_restart = native_machine_emergency_restart,
+   .restart = native_machine_restart,
+   .halt = native_machine_halt,
+};
+
+void machine_power_off(void)
+{
+   machine_ops.power_off();
+}
+
+void machine_shutdown(void)
+{
+   machine_ops.shutdown();
+}
+
+void machine_emergency_restart(void)
+{
+   machine_ops.emergency_restart();
+}
+
+void machine_restart(char *cmd)
+{
+   machine_ops.restart(cmd);
+}
+
+void machine_halt(void)
+{
+   machine_ops.halt();
+}
diff --git a/include/asm-sh/emergency-restart.h
b/include/asm-sh/emergency-restart.h
index 108d8c4..d6bec92 100644
--- a/include/asm-sh/emergency-restart.h
+++ b/include/asm-sh/emergency-restart.h
@@ -1,6 +1,6 @@
-#ifndef _ASM_EMERGENCY_RESTART_H
-#define _ASM_EMERGENCY_RESTART_H
+#ifndef _ASM_SH_EMERGENCY_RESTART_H
+#define _ASM_SH_EMERGENCY_RESTART_H

-#include 
+extern void machine_emergency_restart(void);

-#endif /* _ASM_EMERGENCY_RESTART_H */
+#endif /* _ASM_SH_EMERGENCY_RESTART_H */
-
To unsu

[PATCH] SH: add machine-ops and Dreamcast specific fix-up

2007-08-03 Thread Adrian McMenamin
(This code is closely modelled on the i386 machine-ops, though
currently the only board specific fixup is for the Dreamcast and so
there is not a separate set of mach fixups.)

This needs to be tested against a wide range of SH boards and would be
good to go in -mm if Paul acks it.

Add machine-ops code to the SH code base, allowing board specific
reboot and halt code. Currently only Dreamcast specific warm reboot
fixup in code.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/arch/sh/boards/dreamcast/Makefile
b/arch/sh/boards/dreamcast/Makefile
index e6fcd3d..7b97546 100644
--- a/arch/sh/boards/dreamcast/Makefile
+++ b/arch/sh/boards/dreamcast/Makefile
@@ -2,5 +2,5 @@
 # Makefile for the Sega Dreamcast specific parts of the kernel
 #

-obj-y   := setup.o irq.o rtc.o reboot.o
+obj-y   := setup.o irq.o rtc.o

diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index bdb30ba..7ab2359 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -5,15 +5,11 @@
 extra-y:= head.o init_task.o vmlinux.lds

 obj-y  := debugtraps.o io.o io_generic.o irq.o machvec.o process.o ptrace.o \
-  semaphore.o setup.o signal.o sys_sh.o syscalls.o \
+  reboot.o semaphore.o setup.o signal.o sys_sh.o syscalls.o \
   time.o topology.o traps.o

 obj-y  += cpu/ timers/

-ifneq ($(CONFIG_SH_DREAMCAST),y)
-   obj-y   += reboot.o
-endif
-
 obj-$(CONFIG_VSYSCALL) += vsyscall/

 obj-$(CONFIG_SMP)  += smp.o
diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c
index 790ed69..201b370 100644
--- a/arch/sh/kernel/machine_kexec.c
+++ b/arch/sh/kernel/machine_kexec.c
@@ -29,9 +29,6 @@ extern const unsigned char relocate_new_kernel[];
 extern const unsigned int relocate_new_kernel_size;
 extern void *gdb_vbr_vector;

-void machine_shutdown(void)
-{
-}

 void machine_crash_shutdown(struct pt_regs *regs)
 {
diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c
new file mode 100644
index 000..c6247ae
--- /dev/null
+++ b/arch/sh/kernel/reboot.c
@@ -0,0 +1,107 @@
+/*
+ *  linux/arch/sh/kernel/reboot.c
+ *
+ *  Essentially copied from i386 code
+ *  and process.c
+ *
+ *  Copyright (C) 1995  Linus Torvalds
+ *
+ *  SuperH version:  Copyright (C) 1999, 2000  Niibe Yutaka  Kaz Kojima
+ *  Copyright (C) 2006 Lineo Solutions Inc. support SH4A UBC
+ *  Copyright (C) 2002 - 2007  Paul Mundt
+ *  Copyright 2007 Adrian McMenamin
+ *
+ *  Licensed under the terms of version 2 of GNU GPL
+ */
+
+#include linux/mm.h
+#include linux/module.h
+#include linux/delay.h
+#include linux/init.h
+#include asm/io.h
+#include asm/reboot.h
+
+/*
+ * Power off function, if any
+ */
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
+
+/* fixups for individual machines -
+ * in i386 this is in a file of its own
+ * but we only have the Dreamcast for now.
+ */
+
+static void mach_reboot_fixups(void)
+{
+   if (mach_is_dreamcast()) {
+   writel(0x7611, 0xA05F6890);
+   }
+}
+
+static void native_machine_shutdown(void)
+{
+}
+
+static void native_machine_emergency_restart(void)
+{
+   mach_reboot_fixups();
+   /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
+   asm volatile(ldc %0, sr\n\t
+mov.l @%1, %0 : : r (0x1000), r (0x8001));
+}
+
+static void native_machine_restart(char * __unused)
+{
+   native_machine_shutdown();
+   native_machine_emergency_restart();
+}
+
+static void native_machine_halt(void)
+{
+   local_irq_disable();
+
+   while (1)
+   cpu_sleep();
+}
+
+static void native_machine_power_off(void)
+{
+   if (pm_power_off) {
+   native_machine_shutdown();
+   pm_power_off();
+   }
+}
+
+struct machine_ops machine_ops = {
+   .power_off = native_machine_power_off,
+   .shutdown = native_machine_shutdown,
+   .emergency_restart = native_machine_emergency_restart,
+   .restart = native_machine_restart,
+   .halt = native_machine_halt,
+};
+
+void machine_power_off(void)
+{
+   machine_ops.power_off();
+}
+
+void machine_shutdown(void)
+{
+   machine_ops.shutdown();
+}
+
+void machine_emergency_restart(void)
+{
+   machine_ops.emergency_restart();
+}
+
+void machine_restart(char *cmd)
+{
+   machine_ops.restart(cmd);
+}
+
+void machine_halt(void)
+{
+   machine_ops.halt();
+}
diff --git a/include/asm-sh/emergency-restart.h
b/include/asm-sh/emergency-restart.h
index 108d8c4..d6bec92 100644
--- a/include/asm-sh/emergency-restart.h
+++ b/include/asm-sh/emergency-restart.h
@@ -1,6 +1,6 @@
-#ifndef _ASM_EMERGENCY_RESTART_H
-#define _ASM_EMERGENCY_RESTART_H
+#ifndef _ASM_SH_EMERGENCY_RESTART_H
+#define _ASM_SH_EMERGENCY_RESTART_H

-#include asm-generic/emergency-restart.h
+extern void machine_emergency_restart(void);

-#endif /* _ASM_EMERGENCY_RESTART_H */
+#endif

Re: Fwd: [PATCH] Reboot Dreamcast under software control

2007-07-29 Thread Adrian McMenamin
On Mon, 2007-07-30 at 07:50 +0900, Paul Mundt wrote:
> On Sun, Jul 29, 2007 at 07:25:21PM +0100, Adrian McMenamin wrote:
> > diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
> > index 6334a4c..6f5e9e4 100644
> > --- a/arch/sh/kernel/process.c
> > +++ b/arch/sh/kernel/process.c
> > @@ -97,6 +97,11 @@ void cpu_idle(void)
> > 
> >  void machine_restart(char * __unused)
> >  {
> > +
> > +#ifdef CONFIG_SH_DREAMCAST
> > +   /*reboot the Dreamcast under software control*/
> > +   writel(0x7611, 0xA05F6890);
> > +#endif
> > /* SR.BL=1 and invoke address error to let CPU reset (manual reset) 
> > */
> > asm volatile("ldc %0, sr\n\t"
> >  "mov.l @%1, %0" : : "r" (0x1000), "r" 
> > (0x8001));
> 
> No, if you want to do this, at least use a function pointer and leave
> this as the default implementation. The dreamcast presumably only needs
> this magic write anyways, rather than the SR.BL trick.
> 

Well, when I tested it, it did have a "return" in after the call and it
worked - but I took that out as it looked like code bloat to me :)

Explain what you mean by using a function pointer and I'll do that.

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/


Fwd: [PATCH] Reboot Dreamcast under software control

2007-07-29 Thread Adrian McMenamin
Apologies. I meant to cc: this to the lists first time round and
appear to have bcc'ed it instead.

-- Forwarded message --
From: Adrian McMenamin <[EMAIL PROTECTED]>
Date: 29-Jul-2007 19:04
Subject: [PATCH] Reboot Dreamcast under software control
To: [EMAIL PROTECTED]


In the light of more up to date technical information I have
discovered there is a register at physical address 0x005F6890 on the
Dreamcast that if written a magic number (0x7611) will force a
reboot under software control.

Presumably a better option than the current catch-all mechanism.

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

diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 6334a4c..6f5e9e4 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -97,6 +97,11 @@ void cpu_idle(void)

 void machine_restart(char * __unused)
 {
+
+#ifdef CONFIG_SH_DREAMCAST
+   /*reboot the Dreamcast under software control*/
+   writel(0x7611, 0xA05F6890);
+#endif
/* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
asm volatile("ldc %0, sr\n\t"
 "mov.l @%1, %0" : : "r" (0x1000), "r" (0x8001));
-
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] Reboot Dreamcast under software control

2007-07-29 Thread Adrian McMenamin
In the light of more up to date technical information I have
discovered there is a register at physical address 0x005F6890 on the
Dreamcast that if written a magic number (0x7611) will force a
reboot under software control.

Presumably a better option than the current catch-all mechanism.

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

diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 6334a4c..6f5e9e4 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -97,6 +97,11 @@ void cpu_idle(void)

 void machine_restart(char * __unused)
 {
+
+#ifdef CONFIG_SH_DREAMCAST
+   /*reboot the Dreamcast under software control*/
+   writel(0x7611, 0xA05F6890);
+#endif
/* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
asm volatile("ldc %0, sr\n\t"
 "mov.l @%1, %0" : : "r" (0x1000), "r" (0x8001));
-
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] Reboot Dreamcast under software control

2007-07-29 Thread Adrian McMenamin
In the light of more up to date technical information I have
discovered there is a register at physical address 0x005F6890 on the
Dreamcast that if written a magic number (0x7611) will force a
reboot under software control.

Presumably a better option than the current catch-all mechanism.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 6334a4c..6f5e9e4 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -97,6 +97,11 @@ void cpu_idle(void)

 void machine_restart(char * __unused)
 {
+
+#ifdef CONFIG_SH_DREAMCAST
+   /*reboot the Dreamcast under software control*/
+   writel(0x7611, 0xA05F6890);
+#endif
/* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
asm volatile(ldc %0, sr\n\t
 mov.l @%1, %0 : : r (0x1000), r (0x8001));
-
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/


Fwd: [PATCH] Reboot Dreamcast under software control

2007-07-29 Thread Adrian McMenamin
Apologies. I meant to cc: this to the lists first time round and
appear to have bcc'ed it instead.

-- Forwarded message --
From: Adrian McMenamin [EMAIL PROTECTED]
Date: 29-Jul-2007 19:04
Subject: [PATCH] Reboot Dreamcast under software control
To: [EMAIL PROTECTED]


In the light of more up to date technical information I have
discovered there is a register at physical address 0x005F6890 on the
Dreamcast that if written a magic number (0x7611) will force a
reboot under software control.

Presumably a better option than the current catch-all mechanism.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 6334a4c..6f5e9e4 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -97,6 +97,11 @@ void cpu_idle(void)

 void machine_restart(char * __unused)
 {
+
+#ifdef CONFIG_SH_DREAMCAST
+   /*reboot the Dreamcast under software control*/
+   writel(0x7611, 0xA05F6890);
+#endif
/* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
asm volatile(ldc %0, sr\n\t
 mov.l @%1, %0 : : r (0x1000), r (0x8001));
-
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: Fwd: [PATCH] Reboot Dreamcast under software control

2007-07-29 Thread Adrian McMenamin
On Mon, 2007-07-30 at 07:50 +0900, Paul Mundt wrote:
 On Sun, Jul 29, 2007 at 07:25:21PM +0100, Adrian McMenamin wrote:
  diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
  index 6334a4c..6f5e9e4 100644
  --- a/arch/sh/kernel/process.c
  +++ b/arch/sh/kernel/process.c
  @@ -97,6 +97,11 @@ void cpu_idle(void)
  
   void machine_restart(char * __unused)
   {
  +
  +#ifdef CONFIG_SH_DREAMCAST
  +   /*reboot the Dreamcast under software control*/
  +   writel(0x7611, 0xA05F6890);
  +#endif
  /* SR.BL=1 and invoke address error to let CPU reset (manual reset) 
  */
  asm volatile(ldc %0, sr\n\t
   mov.l @%1, %0 : : r (0x1000), r 
  (0x8001));
 
 No, if you want to do this, at least use a function pointer and leave
 this as the default implementation. The dreamcast presumably only needs
 this magic write anyways, rather than the SR.BL trick.
 

Well, when I tested it, it did have a return in after the call and it
worked - but I took that out as it looked like code bloat to me :)

Explain what you mean by using a function pointer and I'll do that.

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] Framebuffer: Consolidated cleanup of pvr2fb.c for Sega Dreamcast

2007-07-28 Thread Adrian McMenamin
On 29/07/07, Adrian McMenamin <[EMAIL PROTECTED]> wrote:
> Tony,
>
> Second time attempt at this and a much better job I think.
>
Sorry, given I've jsut said this *does* work at 24bpp and 32bpp I'd
better clean up the Documentation patch,,,
diff --git a/Documentation/fb/pvr2fb.txt b/Documentation/fb/pvr2fb.txt
index 2bf6c23..0e4a3c6 100644
--- a/Documentation/fb/pvr2fb.txt
+++ b/Documentation/fb/pvr2fb.txt
@@ -9,14 +9,14 @@ one found in the Dreamcast.
 Advantages:
 
  * It provides a nice large console (128 cols + 48 lines with 1024x768)
-   without using tiny, unreadable fonts.
+   without using tiny, unreadable fonts (this size is NOT available on the 
+   Dreamcast)
  * You can run XF86_FBDev on top of /dev/fb0
  * Most important: boot logo :-)
 
 Disadvantages:
 
- * Driver is currently limited to the Dreamcast PowerVR 2 implementation
-   at the time of this writing.
+ * Driver is largely untested on non-Dreamcast systems.
 
 Configuration
 =
@@ -29,11 +29,13 @@ Accepted options:
 font:X- default font to use. All fonts are supported, including the
 SUN12x22 font which is very nice at high resolutions.
 
-mode:X- default video mode. The following video modes are supported:
-640x240-60, 640x480-60.
+mode:X- default video mode
+The following video modes are supported:
+[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] The Dreamcast
+	defaults to [EMAIL PROTECTED]
 	
 Note: the 640x240 mode is currently broken, and should not be
-used for any reason. It is only mentioned as a reference.
+used for any reason. It is only mentioned here as a reference.
 
 inverse   - invert colors on screen (for LCD displays)
 
@@ -49,13 +51,20 @@ cable:X   - cable type. This can be any of the following: vga, rgb, and
 output:X  - output type. This can be any of the following: pal, ntsc, and
 vga. If none is specified, we guess.
 
+Video mode may also be specified in the form:
+
+	   [xres]x[yres][-[EMAIL PROTECTED]
+
+	   eg [EMAIL PROTECTED]
+
+
 X11
 ===
 
-XF86_FBDev should work, in theory. At the time of this writing it is
-totally untested and may or may not even portray the beginnings of
-working. If you end up testing this, please let me know!
+XF86_FBDev has been shown to work on the Dremcast in the past - though not yet
+on any 2.6 series kernel.
 
 --
 Paul Mundt <[EMAIL PROTECTED]>
+Updated by Adrian McMenamin <[EMAIL PROTECTED]>
 
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 3ac32f3..264b6a6 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -94,6 +94,7 @@
 #define DISP_DIWCONF (DISP_BASE + 0xe8)
 #define DISP_DIWHSTRT (DISP_BASE + 0xec)
 #define DISP_DIWVSTRT (DISP_BASE + 0xf0)
+#define DISP_PIXDEPTH (DISP_BASE + 0x108)
 
 /* Pixel clocks, one for TV output, doubled for VGA output */
 #define TV_CLK 74239
@@ -143,6 +144,7 @@ static struct pvr2fb_par {
 	unsigned char is_lowres;	/* Is horizontal pixel-doubling enabled? */
 
 	unsigned long mmio_base;	/* MMIO base */
+	u32 palette[16];
 } *currentpar;
 
 static struct fb_info *fb_info;
@@ -320,7 +322,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 
 	if (regno > info->cmap.len)
 		return 1;
-
+	
 	/*
 	 * We only support the hardware palette for 16 and 32bpp. It's also
 	 * expected that the palette format has been set by the time we get
@@ -333,24 +335,25 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 		  ((blue  & 0xf800) >> 11);
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u16*)(info->pseudo_palette))[regno] = tmp;
 		break;
 	case 24: /* RGB 888 */
 		red >>= 8; green >>= 8; blue >>= 8;
-		((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue;
+		tmp = (red << 16) | (green << 8) | blue;
 		break;
 	case 32: /* ARGB  */
 		red >>= 8; green >>= 8; blue >>= 8;
 		tmp = (transp << 24) | (red << 16) | (green << 8) | blue;
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u32*)(info->pseudo_palette))[regno] = tmp;
 		break;
 	default:
 		pr_debug("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
 		return 1;
 	}
 
+	if (regno < 16)
+		((u32*)(info->pseudo_palette))[regno] = tmp;
+
 	return 0;
 }
 
@@ -598,6 +601,7 @@ static void pvr2_init_display(struct fb_info *info)
 
 	/* bits per pixel */
 	fb_writel(fb_readl(DISP_DIWMODE) | (--bytesperpixel << 2), DISP_DIWMODE);
+	fb_writel(bytesperpixel << 2, DISP_PIXDEPTH);
 
 	/* video enable, color sync, interlace,
 	 * hsync and vsync polarity (currently unused) */
@@ -789,7 +793,7 @@ static int __devinit pvr2fb_common_init(void)
 	fb_info->fbops		= _ops;
 	fb_info->fix		= pvr2_fix;
 	fb_info->par		= currentpar;
-	fb_info->pseudo_palette	= (void *)(fb_info->par + 1);

[PATCH] Framebuffer: Consolidated cleanup of pvr2fb.c for Sega Dreamcast

2007-07-28 Thread Adrian McMenamin
Tony,

Second time attempt at this and a much better job I think.

This patch consolidates your earlier patch, some cleanup of the
documentation and, crucially, some better handling of the pvr2
registers based on more up to date information.

Testing shows that it seems to work pretty well at 16bpp, 24bpp and
32bpp - including proper rendering of the boot logo at all levels
(previously this was a bit broken even at 16bpp) and giving white
against black text. Really detailed testing (eg with X11) requires
support for the maple bus - which isn't (currently - next project
assuming this is okay) available, but I have no reason to think this
is broken.

Incidentally, substituing DIRECTCOLOR for TRUECOLOR appears to break the driver.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
diff --git a/Documentation/fb/pvr2fb.txt b/Documentation/fb/pvr2fb.txt
index 2bf6c23..3d08551 100644
--- a/Documentation/fb/pvr2fb.txt
+++ b/Documentation/fb/pvr2fb.txt
@@ -9,14 +9,14 @@ one found in the Dreamcast.
 Advantages:
 
  * It provides a nice large console (128 cols + 48 lines with 1024x768)
-   without using tiny, unreadable fonts.
+   without using tiny, unreadable fonts (this size is NOT available on the 
+   Dreamcast)
  * You can run XF86_FBDev on top of /dev/fb0
  * Most important: boot logo :-)
 
 Disadvantages:
 
- * Driver is currently limited to the Dreamcast PowerVR 2 implementation
-   at the time of this writing.
+ * Driver is largely untested on non-Dremcast systems.
 
 Configuration
 =
@@ -29,11 +29,15 @@ Accepted options:
 font:X- default font to use. All fonts are supported, including the
 SUN12x22 font which is very nice at high resolutions.
 
-mode:X- default video mode. The following video modes are supported:
-640x240-60, 640x480-60.
+mode:X- default video mode
+The following video modes are supported:
+[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] The Dreamcast
+	defaults to [EMAIL PROTECTED] At the time of writing the 
+24bpp and 32bpp modes function poorly. Work to fix that is
+ongoing
 	
 Note: the 640x240 mode is currently broken, and should not be
-used for any reason. It is only mentioned as a reference.
+used for any reason. It is only mentioned here as a reference.
 
 inverse   - invert colors on screen (for LCD displays)
 
@@ -49,13 +53,20 @@ cable:X   - cable type. This can be any of the following: vga, rgb, and
 output:X  - output type. This can be any of the following: pal, ntsc, and
 vga. If none is specified, we guess.
 
+Video mode may also be specified in the form:
+
+	   [xres]x[yres][-[EMAIL PROTECTED]
+
+	   eg [EMAIL PROTECTED]
+
+
 X11
 ===
 
-XF86_FBDev should work, in theory. At the time of this writing it is
-totally untested and may or may not even portray the beginnings of
-working. If you end up testing this, please let me know!
+XF86_FBDev has been shown to work on the Dremcast in the past - though not yet
+on any 2.6 series kernel.
 
 --
 Paul Mundt <[EMAIL PROTECTED]>
+Updated by Adrian McMenamin <[EMAIL PROTECTED]>
 
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 3ac32f3..264b6a6 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -94,6 +94,7 @@
 #define DISP_DIWCONF (DISP_BASE + 0xe8)
 #define DISP_DIWHSTRT (DISP_BASE + 0xec)
 #define DISP_DIWVSTRT (DISP_BASE + 0xf0)
+#define DISP_PIXDEPTH (DISP_BASE + 0x108)
 
 /* Pixel clocks, one for TV output, doubled for VGA output */
 #define TV_CLK 74239
@@ -143,6 +144,7 @@ static struct pvr2fb_par {
 	unsigned char is_lowres;	/* Is horizontal pixel-doubling enabled? */
 
 	unsigned long mmio_base;	/* MMIO base */
+	u32 palette[16];
 } *currentpar;
 
 static struct fb_info *fb_info;
@@ -320,7 +322,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 
 	if (regno > info->cmap.len)
 		return 1;
-
+	
 	/*
 	 * We only support the hardware palette for 16 and 32bpp. It's also
 	 * expected that the palette format has been set by the time we get
@@ -333,24 +335,25 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 		  ((blue  & 0xf800) >> 11);
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u16*)(info->pseudo_palette))[regno] = tmp;
 		break;
 	case 24: /* RGB 888 */
 		red >>= 8; green >>= 8; blue >>= 8;
-		((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue;
+		tmp = (red << 16) | (green << 8) | blue;
 		break;
 	case 32: /* ARGB  */
 		red >>= 8; green >>= 8; blue >>= 8;
 		tmp = (transp << 24) | (red << 16) | (green << 8) | blue;
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u32*)(info->pseudo_palette))[regno] = tmp;
 		break;
 	default:
 		pr_debug("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
 

Re: [PATCH] Framebuffer: Fix 16bpp colour output in Dreamcast pvr2fb

2007-07-28 Thread Adrian McMenamin
On 28/07/07, Ondrej Zajicek <[EMAIL PROTECTED]> wrote:
> On Sat, Jul 28, 2007 at 03:51:38PM +0100, Adrian McMenamin wrote:
> > Tony,
> >
> > This patch - on top of your others - fixes the colour output for 16bpp
> > RGB565 output in the Dreamcast - it was a simple out by one error in
> > the bit shift.
>
> > @@ -330,27 +331,28 @@ static int pvr2fb_setcolreg(unsigned int regno, 
> > unsigned int red,
> >   case 16: /* RGB 565 */
> >   tmp =  (red   & 0xf800)   |
> > ((green & 0xfc00) >> 5) |
> > -   ((blue  & 0xf800) >> 11);
> > +   ((blue  & 0xf800) >> 10);
>
> This mixes lsb of green with msb of blue. If you want RGB 565,
> then >> 11 is correct. If you want RGB 555, green should
> be anded with 0xf800.
>
You are, of course, quite right, which makes it all the more the
strange that it appeared to fix the problem. Back to the drawing board
then.
-
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] Documentation - update Documentation/fb/pvr2fb.txt

2007-07-28 Thread Adrian McMenamin
The current version is very old and does not correctly specify how to
set the video mode.

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

diff --git a/Documentation/fb/pvr2fb.txt b/Documentation/fb/pvr2fb.txt
index 2bf6c23..1489f9b 100644
--- a/Documentation/fb/pvr2fb.txt
+++ b/Documentation/fb/pvr2fb.txt
@@ -9,14 +9,13 @@ one found in the Dreamcast.
 Advantages:

  * It provides a nice large console (128 cols + 48 lines with 1024x768)
-   without using tiny, unreadable fonts.
+   without using tiny, unreadable fonts (NOT on the Dreamcast)
  * You can run XF86_FBDev on top of /dev/fb0
  * Most important: boot logo :-)

 Disadvantages:

- * Driver is currently limited to the Dreamcast PowerVR 2 implementation
-   at the time of this writing.
+ * Driver is largely untested on non-Dremcast systems.

 Configuration
 =
@@ -29,11 +28,15 @@ Accepted options:
 font:X- default font to use. All fonts are supported, including the
 SUN12x22 font which is very nice at high resolutions.

-mode:X- default video mode. The following video modes are supported:
-640x240-60, 640x480-60.
+mode:X- default video mode with format [xres]x[yres]-@
+The following video modes are supported:
+[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] The 
Dreamcast
+   defaults to [EMAIL PROTECTED] At the time of writing the
+24bpp and 32bpp modes function poorly. Work to fix that is
+ongoing

 Note: the 640x240 mode is currently broken, and should not be
-used for any reason. It is only mentioned as a reference.
+used for any reason. It is only mentioned here as a reference.

 inverse   - invert colors on screen (for LCD displays)

@@ -52,10 +55,10 @@ output:X  - output type. This can be any of the
following: pal, ntsc, and
 X11
 ===

-XF86_FBDev should work, in theory. At the time of this writing it is
-totally untested and may or may not even portray the beginnings of
-working. If you end up testing this, please let me know!
+XF86_FBDev has been shown to work on the Dremcast in the past - though not yet
+on any 2.6 series kernel.

 --
 Paul Mundt <[EMAIL PROTECTED]>
+Updated by Adrian McMenamin <[EMAIL PROTECTED]>
-
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] Framebuffer: Fix 16bpp colour output in Dreamcast pvr2fb

2007-07-28 Thread Adrian McMenamin
Tony,

This patch - on top of your others - fixes the colour output for 16bpp
RGB565 output in the Dreamcast - it was a simple out by one error in
the bit shift.

Still looking at the 24bpp and 32bpp issues.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 3ac32f3..383e87e 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -330,27 +331,28 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 	case 16: /* RGB 565 */
 		tmp =  (red   & 0xf800)   |
 		  ((green & 0xfc00) >> 5) |
-		  ((blue  & 0xf800) >> 11);
+		  ((blue  & 0xf800) >> 10);
 
 		pvr2fb_set_pal_entry(par, regno, tmp);


[PATCH] Framebuffer: Fix 16bpp colour output in Dreamcast pvr2fb

2007-07-28 Thread Adrian McMenamin
Tony,

This patch - on top of your others - fixes the colour output for 16bpp
RGB565 output in the Dreamcast - it was a simple out by one error in
the bit shift.

Still looking at the 24bpp and 32bpp issues.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 3ac32f3..383e87e 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -330,27 +331,28 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 	case 16: /* RGB 565 */
 		tmp =  (red0xf800)   |
 		  ((green  0xfc00)  5) |
-		  ((blue   0xf800)  11);
+		  ((blue   0xf800)  10);
 
 		pvr2fb_set_pal_entry(par, regno, tmp);


[PATCH] Documentation - update Documentation/fb/pvr2fb.txt

2007-07-28 Thread Adrian McMenamin
The current version is very old and does not correctly specify how to
set the video mode.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]

diff --git a/Documentation/fb/pvr2fb.txt b/Documentation/fb/pvr2fb.txt
index 2bf6c23..1489f9b 100644
--- a/Documentation/fb/pvr2fb.txt
+++ b/Documentation/fb/pvr2fb.txt
@@ -9,14 +9,13 @@ one found in the Dreamcast.
 Advantages:

  * It provides a nice large console (128 cols + 48 lines with 1024x768)
-   without using tiny, unreadable fonts.
+   without using tiny, unreadable fonts (NOT on the Dreamcast)
  * You can run XF86_FBDev on top of /dev/fb0
  * Most important: boot logo :-)

 Disadvantages:

- * Driver is currently limited to the Dreamcast PowerVR 2 implementation
-   at the time of this writing.
+ * Driver is largely untested on non-Dremcast systems.

 Configuration
 =
@@ -29,11 +28,15 @@ Accepted options:
 font:X- default font to use. All fonts are supported, including the
 SUN12x22 font which is very nice at high resolutions.

-mode:X- default video mode. The following video modes are supported:
-640x240-60, 640x480-60.
+mode:X- default video mode with format [xres]x[yres]-bpp@refresh rate
+The following video modes are supported:
+[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] The 
Dreamcast
+   defaults to [EMAIL PROTECTED] At the time of writing the
+24bpp and 32bpp modes function poorly. Work to fix that is
+ongoing

 Note: the 640x240 mode is currently broken, and should not be
-used for any reason. It is only mentioned as a reference.
+used for any reason. It is only mentioned here as a reference.

 inverse   - invert colors on screen (for LCD displays)

@@ -52,10 +55,10 @@ output:X  - output type. This can be any of the
following: pal, ntsc, and
 X11
 ===

-XF86_FBDev should work, in theory. At the time of this writing it is
-totally untested and may or may not even portray the beginnings of
-working. If you end up testing this, please let me know!
+XF86_FBDev has been shown to work on the Dremcast in the past - though not yet
+on any 2.6 series kernel.

 --
 Paul Mundt [EMAIL PROTECTED]
+Updated by Adrian McMenamin [EMAIL PROTECTED]
-
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] Framebuffer: Fix 16bpp colour output in Dreamcast pvr2fb

2007-07-28 Thread Adrian McMenamin
On 28/07/07, Ondrej Zajicek [EMAIL PROTECTED] wrote:
 On Sat, Jul 28, 2007 at 03:51:38PM +0100, Adrian McMenamin wrote:
  Tony,
 
  This patch - on top of your others - fixes the colour output for 16bpp
  RGB565 output in the Dreamcast - it was a simple out by one error in
  the bit shift.

  @@ -330,27 +331,28 @@ static int pvr2fb_setcolreg(unsigned int regno, 
  unsigned int red,
case 16: /* RGB 565 */
tmp =  (red0xf800)   |
  ((green  0xfc00)  5) |
  -   ((blue   0xf800)  11);
  +   ((blue   0xf800)  10);

 This mixes lsb of green with msb of blue. If you want RGB 565,
 then  11 is correct. If you want RGB 555, green should
 be anded with 0xf800.

You are, of course, quite right, which makes it all the more the
strange that it appeared to fix the problem. Back to the drawing board
then.
-
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] Framebuffer: Consolidated cleanup of pvr2fb.c for Sega Dreamcast

2007-07-28 Thread Adrian McMenamin
Tony,

Second time attempt at this and a much better job I think.

This patch consolidates your earlier patch, some cleanup of the
documentation and, crucially, some better handling of the pvr2
registers based on more up to date information.

Testing shows that it seems to work pretty well at 16bpp, 24bpp and
32bpp - including proper rendering of the boot logo at all levels
(previously this was a bit broken even at 16bpp) and giving white
against black text. Really detailed testing (eg with X11) requires
support for the maple bus - which isn't (currently - next project
assuming this is okay) available, but I have no reason to think this
is broken.

Incidentally, substituing DIRECTCOLOR for TRUECOLOR appears to break the driver.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]
diff --git a/Documentation/fb/pvr2fb.txt b/Documentation/fb/pvr2fb.txt
index 2bf6c23..3d08551 100644
--- a/Documentation/fb/pvr2fb.txt
+++ b/Documentation/fb/pvr2fb.txt
@@ -9,14 +9,14 @@ one found in the Dreamcast.
 Advantages:
 
  * It provides a nice large console (128 cols + 48 lines with 1024x768)
-   without using tiny, unreadable fonts.
+   without using tiny, unreadable fonts (this size is NOT available on the 
+   Dreamcast)
  * You can run XF86_FBDev on top of /dev/fb0
  * Most important: boot logo :-)
 
 Disadvantages:
 
- * Driver is currently limited to the Dreamcast PowerVR 2 implementation
-   at the time of this writing.
+ * Driver is largely untested on non-Dremcast systems.
 
 Configuration
 =
@@ -29,11 +29,15 @@ Accepted options:
 font:X- default font to use. All fonts are supported, including the
 SUN12x22 font which is very nice at high resolutions.
 
-mode:X- default video mode. The following video modes are supported:
-640x240-60, 640x480-60.
+mode:X- default video mode
+The following video modes are supported:
+[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] The Dreamcast
+	defaults to [EMAIL PROTECTED] At the time of writing the 
+24bpp and 32bpp modes function poorly. Work to fix that is
+ongoing
 	
 Note: the 640x240 mode is currently broken, and should not be
-used for any reason. It is only mentioned as a reference.
+used for any reason. It is only mentioned here as a reference.
 
 inverse   - invert colors on screen (for LCD displays)
 
@@ -49,13 +53,20 @@ cable:X   - cable type. This can be any of the following: vga, rgb, and
 output:X  - output type. This can be any of the following: pal, ntsc, and
 vga. If none is specified, we guess.
 
+Video mode may also be specified in the form:
+
+	   [xres]x[yres][-bpp[EMAIL PROTECTED]
+
+	   eg [EMAIL PROTECTED]
+
+
 X11
 ===
 
-XF86_FBDev should work, in theory. At the time of this writing it is
-totally untested and may or may not even portray the beginnings of
-working. If you end up testing this, please let me know!
+XF86_FBDev has been shown to work on the Dremcast in the past - though not yet
+on any 2.6 series kernel.
 
 --
 Paul Mundt [EMAIL PROTECTED]
+Updated by Adrian McMenamin [EMAIL PROTECTED]
 
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 3ac32f3..264b6a6 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -94,6 +94,7 @@
 #define DISP_DIWCONF (DISP_BASE + 0xe8)
 #define DISP_DIWHSTRT (DISP_BASE + 0xec)
 #define DISP_DIWVSTRT (DISP_BASE + 0xf0)
+#define DISP_PIXDEPTH (DISP_BASE + 0x108)
 
 /* Pixel clocks, one for TV output, doubled for VGA output */
 #define TV_CLK 74239
@@ -143,6 +144,7 @@ static struct pvr2fb_par {
 	unsigned char is_lowres;	/* Is horizontal pixel-doubling enabled? */
 
 	unsigned long mmio_base;	/* MMIO base */
+	u32 palette[16];
 } *currentpar;
 
 static struct fb_info *fb_info;
@@ -320,7 +322,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 
 	if (regno  info-cmap.len)
 		return 1;
-
+	
 	/*
 	 * We only support the hardware palette for 16 and 32bpp. It's also
 	 * expected that the palette format has been set by the time we get
@@ -333,24 +335,25 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 		  ((blue   0xf800)  11);
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u16*)(info-pseudo_palette))[regno] = tmp;
 		break;
 	case 24: /* RGB 888 */
 		red = 8; green = 8; blue = 8;
-		((u32*)(info-pseudo_palette))[regno] = (red  16) | (green  8) | blue;
+		tmp = (red  16) | (green  8) | blue;
 		break;
 	case 32: /* ARGB  */
 		red = 8; green = 8; blue = 8;
 		tmp = (transp  24) | (red  16) | (green  8) | blue;
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u32*)(info-pseudo_palette))[regno] = tmp;
 		break;
 	default:
 		pr_debug(Invalid bit depth %d?!?\n, info-var.bits_per_pixel);
 		return 1;
 	}
 
+	if (regno  16)
+		((u32*)(info-pseudo_palette))[regno] = tmp;
+
 	return 0;
 }
 
@@ -598,6 +601,7 @@ static void pvr2_init_display(struct fb_info *info)
 
 	/* bits per

Re: [PATCH] Framebuffer: Consolidated cleanup of pvr2fb.c for Sega Dreamcast

2007-07-28 Thread Adrian McMenamin
On 29/07/07, Adrian McMenamin [EMAIL PROTECTED] wrote:
 Tony,

 Second time attempt at this and a much better job I think.

Sorry, given I've jsut said this *does* work at 24bpp and 32bpp I'd
better clean up the Documentation patch,,,
diff --git a/Documentation/fb/pvr2fb.txt b/Documentation/fb/pvr2fb.txt
index 2bf6c23..0e4a3c6 100644
--- a/Documentation/fb/pvr2fb.txt
+++ b/Documentation/fb/pvr2fb.txt
@@ -9,14 +9,14 @@ one found in the Dreamcast.
 Advantages:
 
  * It provides a nice large console (128 cols + 48 lines with 1024x768)
-   without using tiny, unreadable fonts.
+   without using tiny, unreadable fonts (this size is NOT available on the 
+   Dreamcast)
  * You can run XF86_FBDev on top of /dev/fb0
  * Most important: boot logo :-)
 
 Disadvantages:
 
- * Driver is currently limited to the Dreamcast PowerVR 2 implementation
-   at the time of this writing.
+ * Driver is largely untested on non-Dreamcast systems.
 
 Configuration
 =
@@ -29,11 +29,13 @@ Accepted options:
 font:X- default font to use. All fonts are supported, including the
 SUN12x22 font which is very nice at high resolutions.
 
-mode:X- default video mode. The following video modes are supported:
-640x240-60, 640x480-60.
+mode:X- default video mode
+The following video modes are supported:
+[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] The Dreamcast
+	defaults to [EMAIL PROTECTED]
 	
 Note: the 640x240 mode is currently broken, and should not be
-used for any reason. It is only mentioned as a reference.
+used for any reason. It is only mentioned here as a reference.
 
 inverse   - invert colors on screen (for LCD displays)
 
@@ -49,13 +51,20 @@ cable:X   - cable type. This can be any of the following: vga, rgb, and
 output:X  - output type. This can be any of the following: pal, ntsc, and
 vga. If none is specified, we guess.
 
+Video mode may also be specified in the form:
+
+	   [xres]x[yres][-bpp[EMAIL PROTECTED]
+
+	   eg [EMAIL PROTECTED]
+
+
 X11
 ===
 
-XF86_FBDev should work, in theory. At the time of this writing it is
-totally untested and may or may not even portray the beginnings of
-working. If you end up testing this, please let me know!
+XF86_FBDev has been shown to work on the Dremcast in the past - though not yet
+on any 2.6 series kernel.
 
 --
 Paul Mundt [EMAIL PROTECTED]
+Updated by Adrian McMenamin [EMAIL PROTECTED]
 
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 3ac32f3..264b6a6 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -94,6 +94,7 @@
 #define DISP_DIWCONF (DISP_BASE + 0xe8)
 #define DISP_DIWHSTRT (DISP_BASE + 0xec)
 #define DISP_DIWVSTRT (DISP_BASE + 0xf0)
+#define DISP_PIXDEPTH (DISP_BASE + 0x108)
 
 /* Pixel clocks, one for TV output, doubled for VGA output */
 #define TV_CLK 74239
@@ -143,6 +144,7 @@ static struct pvr2fb_par {
 	unsigned char is_lowres;	/* Is horizontal pixel-doubling enabled? */
 
 	unsigned long mmio_base;	/* MMIO base */
+	u32 palette[16];
 } *currentpar;
 
 static struct fb_info *fb_info;
@@ -320,7 +322,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 
 	if (regno  info-cmap.len)
 		return 1;
-
+	
 	/*
 	 * We only support the hardware palette for 16 and 32bpp. It's also
 	 * expected that the palette format has been set by the time we get
@@ -333,24 +335,25 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
 		  ((blue   0xf800)  11);
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u16*)(info-pseudo_palette))[regno] = tmp;
 		break;
 	case 24: /* RGB 888 */
 		red = 8; green = 8; blue = 8;
-		((u32*)(info-pseudo_palette))[regno] = (red  16) | (green  8) | blue;
+		tmp = (red  16) | (green  8) | blue;
 		break;
 	case 32: /* ARGB  */
 		red = 8; green = 8; blue = 8;
 		tmp = (transp  24) | (red  16) | (green  8) | blue;
 
 		pvr2fb_set_pal_entry(par, regno, tmp);
-		((u32*)(info-pseudo_palette))[regno] = tmp;
 		break;
 	default:
 		pr_debug(Invalid bit depth %d?!?\n, info-var.bits_per_pixel);
 		return 1;
 	}
 
+	if (regno  16)
+		((u32*)(info-pseudo_palette))[regno] = tmp;
+
 	return 0;
 }
 
@@ -598,6 +601,7 @@ static void pvr2_init_display(struct fb_info *info)
 
 	/* bits per pixel */
 	fb_writel(fb_readl(DISP_DIWMODE) | (--bytesperpixel  2), DISP_DIWMODE);
+	fb_writel(bytesperpixel  2, DISP_PIXDEPTH);
 
 	/* video enable, color sync, interlace,
 	 * hsync and vsync polarity (currently unused) */
@@ -789,7 +793,7 @@ static int __devinit pvr2fb_common_init(void)
 	fb_info-fbops		= pvr2fb_ops;
 	fb_info-fix		= pvr2_fix;
 	fb_info-par		= currentpar;
-	fb_info-pseudo_palette	= (void *)(fb_info-par + 1);
+	fb_info-pseudo_palette	= currentpar-palette;
 	fb_info-flags		= FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
 
 	if (video_output == VO_VGA)
@@ -806,6 +810,8 @@ static int __devinit pvr2fb_common_init(void)
 
 	if (register_framebuffer(fb_info)  0

Re: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 28/07/07, Antonino A. Daplas <[EMAIL PROTECTED]> wrote:

>
> Is this with commit a66ad56eb2c9644717da4d7f05f971d6786145e3 reverted?
> Reapply this commit again, it might (fingers crossed) correct the color
> problem.
>
> As to your display doubling/quadrupling with bpp 24/32, I don't have any
> answers (no hardware) though it seems to be a framebuffer pitch/display
> width mismatch.
>

Mostly solved the colour problem at 16bpp (black background but pale
blue text - had previously been white). At 32bpp just as before -
oversized and yellow.

At 24bpp much as before too - all against black but two boot logos in
greenish shade and everything doubled up on screen in greenish shade
(ie around half of pixels in console text message on left, around half
in repeat on right).

But certainly better at 16bpp

Can mess about with it later to see if I can get the colours right I suppose.

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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 28/07/07, Antonino A. Daplas <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-07-27 at 23:25 +0100, Adrian McMenamin wrote:
> > On 27/07/07, Antonino A. Daplas <[EMAIL PROTECTED]> wrote:
> > > On Fri, 2007-07-27 at 21:18 +0100, Adrian McMenamin wrote:
> > > > On 27/07/07, Adrian McMenamin <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > With the patch reverted and 24bpp, it oopses before freezing (with two
> > > > > odd looking boot logos on the screen):
> > > > >
> > > > Tested this further and it fails on:
> > > >
> > > > rev = fb_readl(par->mmio_base + 0x04);
> > >
> > > Doubtful if this line is the point of failure, this line is executed
> > > only once, on initialization.
> >
> >
> > par->mmio_base is corrupted in some way during the call to
> > register_framebuffer - still investigating how/why.
>
> Possible, par->mmio_base is the last field in struct pvr2fb_par,
> after that is the pseudo_palette. The oops did not manifest when the
> pseudo_palette was written as u16, but oops'ed when written as u32.
> Memory alignment problems?
>
> Try the patch I posted before, might help.
>
Apologies, missed the patch before.

With the patch applied the Dreamcast no longer crashes or locks with
either 16, 24 or 32 bpp, so that's good.

With 24bpp everything is doubled up (eg two boot logos on screen) and
about twice (?) the size it should be - though with a black screen.

With 32 bpp everything is about 4 (?) times the size it should be and
all on a yellow background.

With 16bpp then everything is on a blue background as before, but is
also the correct size (as before).

So, it's better certainly, but there are still a few issues with the
driver, though nothing that takes down the box.

So thanks!

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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 27/07/07, Antonino A. Daplas <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-07-27 at 21:18 +0100, Adrian McMenamin wrote:
> > On 27/07/07, Adrian McMenamin <[EMAIL PROTECTED]> wrote:
> >
> > > With the patch reverted and 24bpp, it oopses before freezing (with two
> > > odd looking boot logos on the screen):
> > >
> > Tested this further and it fails on:
> >
> > rev = fb_readl(par->mmio_base + 0x04);
>
> Doubtful if this line is the point of failure, this line is executed
> only once, on initialization.


par->mmio_base is corrupted in some way during the call to
register_framebuffer - still investigating how/why.
-
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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 27/07/07, Adrian McMenamin <[EMAIL PROTECTED]> wrote:

> With the patch reverted and 24bpp, it oopses before freezing (with two
> odd looking boot logos on the screen):
>
Tested this further and it fails on:

rev = fb_readl(par->mmio_base + 0x04);

Will try to see what's up - but if anyone knows what is likely to be
wrong here please shout out!
-
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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 26/07/07, Antonino A. Daplas <[EMAIL PROTECTED]> wrote:

>
> I'm also confused. Can you change the color depth to 32 bpp ('fbset
> -depth 32')?  I'm thinking of a possible pseudo_palette overrun.
>

The code behaves in exactly the same way with the bit depth set to 32
and without the patch reversion (ie forces a reboot).

With the parch reverted there is a flicker of output on the screen
before a reboot is forced (it will boot with 16bpp though the colour
is a bit iffy)

With the patch reverted and 24bpp, it oopses before freezing (with two
odd looking boot logos on the screen):

[1.485628] Console: switching to colour frame buffer device 80x30
[1.553925] Unable to handle kernel paging request at virtual
address 55ff5504
[1.562351] pc = 8c0033a0
[1.565402] Unable to handle kernel paging request at virtual
address 0c1e8688
[1.573784] pc = 8c00b9e2
[1.576833] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.585205] pc = 8c00b9e2
[1.588258] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.596641] pc = 8c00b9e2
[1.599688] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.608069] pc = 8c00b9e2
[1.67] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.619488] pc = 8c00b9e2
[1.622549] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.630927] pc = 8c00b9e2
[1.633979] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.642370] pc = 8c00b9e2
[1.645421] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.653793] pc = 8c00b9e2
[1.656854] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.665226] pc = 8c00b9e2
[1.668273] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.676664] pc = 8c00b9e2
[1.679715] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.688086] pc = 8c00b9e2
[1.691191] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.699557] pc = 8c00b9e2
[1.702603] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.710988] pc = 8c00b9e2
[1.714036] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.722408] pc = 8c00b9e2
[1.725468] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.733837] pc = 8c00b9e2
[1.736884] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.745270] pc = 8c00b9e2
[1.748314] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.756696] pc = 8c00b9e2
[1.759745] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.768111] pc = 8c00b9e2
[1.771155] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.779538] pc = 8c00b9e2
[1.782584] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.790997] pc = 8c00b9e2
[1.794045] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.802452] pc = 8c00b9e2
[1.805500] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.813888] pc = 8c00b9e2
[1.816937] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.825326] pc = 8c00b9e2
[1.828378] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.836753] pc = 8c00b9e2
[1.839846] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.848215] pc = 8c00b9e2
[1.851263] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.859649] pc = 8c00b9e2
[1.862695] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.871066] pc = 8c00b9e2


In short all versions of the driver seem to be broken in some way, but
it won't boot at all unless the patch is reverted
-
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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 26/07/07, Antonino A. Daplas [EMAIL PROTECTED] wrote:


 I'm also confused. Can you change the color depth to 32 bpp ('fbset
 -depth 32')?  I'm thinking of a possible pseudo_palette overrun.


The code behaves in exactly the same way with the bit depth set to 32
and without the patch reversion (ie forces a reboot).

With the parch reverted there is a flicker of output on the screen
before a reboot is forced (it will boot with 16bpp though the colour
is a bit iffy)

With the patch reverted and 24bpp, it oopses before freezing (with two
odd looking boot logos on the screen):

[1.485628] Console: switching to colour frame buffer device 80x30
[1.553925] Unable to handle kernel paging request at virtual
address 55ff5504
[1.562351] pc = 8c0033a0
[1.565402] Unable to handle kernel paging request at virtual
address 0c1e8688
[1.573784] pc = 8c00b9e2
[1.576833] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.585205] pc = 8c00b9e2
[1.588258] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.596641] pc = 8c00b9e2
[1.599688] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.608069] pc = 8c00b9e2
[1.67] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.619488] pc = 8c00b9e2
[1.622549] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.630927] pc = 8c00b9e2
[1.633979] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.642370] pc = 8c00b9e2
[1.645421] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.653793] pc = 8c00b9e2
[1.656854] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.665226] pc = 8c00b9e2
[1.668273] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.676664] pc = 8c00b9e2
[1.679715] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.688086] pc = 8c00b9e2
[1.691191] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.699557] pc = 8c00b9e2
[1.702603] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.710988] pc = 8c00b9e2
[1.714036] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.722408] pc = 8c00b9e2
[1.725468] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.733837] pc = 8c00b9e2
[1.736884] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.745270] pc = 8c00b9e2
[1.748314] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.756696] pc = 8c00b9e2
[1.759745] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.768111] pc = 8c00b9e2
[1.771155] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.779538] pc = 8c00b9e2
[1.782584] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.790997] pc = 8c00b9e2
[1.794045] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.802452] pc = 8c00b9e2
[1.805500] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.813888] pc = 8c00b9e2
[1.816937] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.825326] pc = 8c00b9e2
[1.828378] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.836753] pc = 8c00b9e2
[1.839846] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.848215] pc = 8c00b9e2
[1.851263] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.859649] pc = 8c00b9e2
[1.862695] Unable to handle kernel paging request at virtual
address 0c1e81ec
[1.871066] pc = 8c00b9e2


In short all versions of the driver seem to be broken in some way, but
it won't boot at all unless the patch is reverted
-
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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 27/07/07, Adrian McMenamin [EMAIL PROTECTED] wrote:

 With the patch reverted and 24bpp, it oopses before freezing (with two
 odd looking boot logos on the screen):

Tested this further and it fails on:

rev = fb_readl(par-mmio_base + 0x04);

Will try to see what's up - but if anyone knows what is likely to be
wrong here please shout out!
-
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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 27/07/07, Antonino A. Daplas [EMAIL PROTECTED] wrote:
 On Fri, 2007-07-27 at 21:18 +0100, Adrian McMenamin wrote:
  On 27/07/07, Adrian McMenamin [EMAIL PROTECTED] wrote:
 
   With the patch reverted and 24bpp, it oopses before freezing (with two
   odd looking boot logos on the screen):
  
  Tested this further and it fails on:
 
  rev = fb_readl(par-mmio_base + 0x04);

 Doubtful if this line is the point of failure, this line is executed
 only once, on initialization.


par-mmio_base is corrupted in some way during the call to
register_framebuffer - still investigating how/why.
-
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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 28/07/07, Antonino A. Daplas [EMAIL PROTECTED] wrote:
 On Fri, 2007-07-27 at 23:25 +0100, Adrian McMenamin wrote:
  On 27/07/07, Antonino A. Daplas [EMAIL PROTECTED] wrote:
   On Fri, 2007-07-27 at 21:18 +0100, Adrian McMenamin wrote:
On 27/07/07, Adrian McMenamin [EMAIL PROTECTED] wrote:
   
 With the patch reverted and 24bpp, it oopses before freezing (with two
 odd looking boot logos on the screen):

Tested this further and it fails on:
   
rev = fb_readl(par-mmio_base + 0x04);
  
   Doubtful if this line is the point of failure, this line is executed
   only once, on initialization.
 
 
  par-mmio_base is corrupted in some way during the call to
  register_framebuffer - still investigating how/why.

 Possible, par-mmio_base is the last field in struct pvr2fb_par,
 after that is the pseudo_palette. The oops did not manifest when the
 pseudo_palette was written as u16, but oops'ed when written as u32.
 Memory alignment problems?

 Try the patch I posted before, might help.

Apologies, missed the patch before.

With the patch applied the Dreamcast no longer crashes or locks with
either 16, 24 or 32 bpp, so that's good.

With 24bpp everything is doubled up (eg two boot logos on screen) and
about twice (?) the size it should be - though with a black screen.

With 32 bpp everything is about 4 (?) times the size it should be and
all on a yellow background.

With 16bpp then everything is on a blue background as before, but is
also the correct size (as before).

So, it's better certainly, but there are still a few issues with the
driver, though nothing that takes down the box.

So thanks!

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: Problems with framebuffer in 2.6.22-git17

2007-07-27 Thread Adrian McMenamin
On 28/07/07, Antonino A. Daplas [EMAIL PROTECTED] wrote:


 Is this with commit a66ad56eb2c9644717da4d7f05f971d6786145e3 reverted?
 Reapply this commit again, it might (fingers crossed) correct the color
 problem.

 As to your display doubling/quadrupling with bpp 24/32, I don't have any
 answers (no hardware) though it seems to be a framebuffer pitch/display
 width mismatch.


Mostly solved the colour problem at 16bpp (black background but pale
blue text - had previously been white). At 32bpp just as before -
oversized and yellow.

At 24bpp much as before too - all against black but two boot logos in
greenish shade and everything doubled up on screen in greenish shade
(ie around half of pixels in console text message on left, around half
in repeat on right).

But certainly better at 16bpp

Can mess about with it later to see if I can get the colours right I suppose.

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: Problems with framebuffer in 2.6.22-git17

2007-07-24 Thread Adrian McMenamin

On 23/07/07, Antonino A. Daplas <[EMAIL PROTECTED]> wrote:

On Sun, 2007-07-22 at 19:41 +0100, Adrian McMenamin wrote:
> I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
> - when the code is executed it appears to lock the Dreamcast up.
>
> The problem seems to be:
>
>  fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, );
>
> In drivers/video/fbmem.c
>
> This hasn't been an issue before, so are there any recent changes that
> might have caused this?

What's the last kernel that worked for you? Can you also post your
config?

>
> (fb_notifier_call_chain calls a succession of stubs ending in
> __blocking_notifier_call_chain in kernel/sys.c)
>

Try reverting commit a66ad56eb2c9644717da4d7f05f971d6786145e3.

Tony



Tony,

I have checked this a few times now, including against Paul's git as
well as Linus's and the Dreamcast won't boot without its reversion.
Don't know why, but it needs to be reverted until a better fix is
available.

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: Problems with framebuffer in 2.6.22-git17

2007-07-24 Thread Adrian McMenamin

On 23/07/07, Antonino A. Daplas [EMAIL PROTECTED] wrote:

On Sun, 2007-07-22 at 19:41 +0100, Adrian McMenamin wrote:
 I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
 - when the code is executed it appears to lock the Dreamcast up.

 The problem seems to be:

  fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, event);

 In drivers/video/fbmem.c

 This hasn't been an issue before, so are there any recent changes that
 might have caused this?

What's the last kernel that worked for you? Can you also post your
config?


 (fb_notifier_call_chain calls a succession of stubs ending in
 __blocking_notifier_call_chain in kernel/sys.c)


Try reverting commit a66ad56eb2c9644717da4d7f05f971d6786145e3.

Tony



Tony,

I have checked this a few times now, including against Paul's git as
well as Linus's and the Dreamcast won't boot without its reversion.
Don't know why, but it needs to be reverted until a better fix is
available.

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] Fix Dreamcast DMA issues

2007-07-23 Thread Adrian McMenamin

The current SH DMA API is somewhat broken, not correctly matching
virtual channel to the correct SH DMAC. This wasn't noticeable when
using g2 DMA for the sound driver - one channel 0 is as good as any
other! - but caused the pvr2 driver to fail.

This patch fixes the pvr2 problem and consequently fixes the sound
driver to ensure it continues to function.

Signed-off by: Adrian McMenamin <[EMAIL PROTECTED]>
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index cf8e119..76ed816 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -31,8 +31,8 @@ struct dma_info *get_dma_info(unsigned int chan)
 	 * the channel is.
 	 */
 	list_for_each_entry(info, _dmac_list, list) {
-		if ((chan <  info->first_channel_nr) ||
-		(chan >= info->first_channel_nr + info->nr_channels))
+		if ((chan <  info->first_vchannel_nr) ||
+		(chan >= info->first_vchannel_nr + info->nr_channels))
 			continue;
 
 		return info;
@@ -82,7 +82,7 @@ struct dma_channel *get_dma_channel(unsigned int chan)
 
 	for (i = 0; i < info->nr_channels; i++) {
 		channel = >channels[i];
-		if (channel->chan == chan)
+		if (channel->vchan == chan)
 			return channel;
 	}
 
@@ -369,6 +369,7 @@ int register_dmac(struct dma_info *info)
 	}
 
 	total_channels = get_nr_channels();
+	info->first_vchannel_nr = total_channels;
 	for (i = 0; i < info->nr_channels; i++) {
 		struct dma_channel *chan = >channels[i];
 
diff --git a/include/asm-sh/dma.h b/include/asm-sh/dma.h
index 6034d4a..4c75b70 100644
--- a/include/asm-sh/dma.h
+++ b/include/asm-sh/dma.h
@@ -111,6 +111,7 @@ struct dma_info {
 
 	struct list_head list;
 	int first_channel_nr;
+	int first_vchannel_nr;
 };
 
 struct dma_chan_caps {
diff --git a/sound/sh/aica.h b/sound/sh/aica.h
index 8c11e3d..d098baa 100644
--- a/sound/sh/aica.h
+++ b/sound/sh/aica.h
@@ -52,7 +52,7 @@
 #define AICA_CHANNEL1_OFFSET 0x21000
 #define CHANNEL_OFFSET 0x1
 
-#define AICA_DMA_CHANNEL 0
+#define AICA_DMA_CHANNEL 5
 #define AICA_DMA_MODE 5
 
 #define SND_AICA_DRIVER "AICA"


Re: Problems with framebuffer in 2.6.22-git17

2007-07-23 Thread Adrian McMenamin

(Apologies to those getting this a second time: resending as text/plain only)

On 23/07/07, Adrian McMenamin <[EMAIL PROTECTED]> wrote:




On 7/23/07, Antonino A. Daplas <[EMAIL PROTECTED]> wrote:
>  On Sun, 2007-07-22 at 19:41 +0100, Adrian McMenamin wrote:
> > I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
> > - when the code is executed it appears to lock the Dreamcast up.
> >
>  > The problem seems to be:
> >
> >  fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, );
> >
> > In drivers/video/fbmem.c
> >
> > This hasn't been an issue before, so are there any recent changes that
> > might have caused this?
>
> What's the last kernel that worked for you? Can you also post your
> config?



One of the recent 2.6.22 gits, not sure which one, I'm afraid.


> >
> > (fb_notifier_call_chain calls a succession of stubs ending in
> > __blocking_notifier_call_chain in kernel/sys.c)
> >
>
> Try reverting commit a66ad56eb2c9644717da4d7f05f971d6786145e3.
>

OK, that certainly seems to make a difference - the box doesn't crash but it 
generates a lot of error messages - though as I have patched this with my dma 
patch that isn't one of them:

/ # modprobe pvr2fb
[   31.642623] Console: switching to colour frame buffer device 80x30
[   31.677360] fb0: NEC PowerVR2 (rev 1.1) frame buffer device, using 
600k/8192k of video memory
[   31.686139] fb0: Mode 640x480-16 pitch = 1280 cable: VGA video output: VGA
[   31.693205] fb0: registering with SQ API
[   31.762406] sqremap:NEC PowerVR2  [2048 pages]  va 0xe000   pa 
0xa500
[   31.769537] fb0: Mapped video memory to SQ addr 0xe000
/ # [   31.912380 ] BUG: scheduling while atomic: 10-udev.hotplug/0x1002/775
[   31.918676] Stack: (0x8c91de0c to 0x8c91e000)
[   31.923145] de00:8c15a80c 1000 8c91c000 
8c8c5a10 8c00f782
[   31.931582 ] de20: 8c91de3c 8c33d000 8c1ff00c c0003000 0c33d53e 1000 
8c91c000 8c15adf4
[   31.940115] de40: 8c91de4c 2958be20 8c1e917c 8c15b6ba 8cc14000 8c00c606 
8c91c000 8c03b3fa
[   31.948648] de60: 0001  0001 8cceb8f4 8cceb8b4 8c2087a0 
8c91c000 0001
[   31.957181] de80: 000e 2958b000 8c21a280 0200 8c915560 2958be20 
8c03b958 8c954294
[   31.965725] dea0: 0001 2958be20 8cceb8b4 062c 00030002  
8c954294 000e
[   31.974293] dec0: 0001  8c915560 8c2545a0 2958b000 8c915560 
8cceb8b4 8c00b890
[   31.982781] dee0: 8c91dfa0 8c8c5880 8c915560 8c915594 2958be20 00030002 
8cceb8b4 8c8da140
[   31.991314] df00: 8c8da140 8c8da0d4 8c8da148 1000 0012  
0001 8cc09e9c
[   31.999892] df20: 8c03e09e 000e 2958b000 8c9155a0 1000 0003 
8c2545a0 0073
[   32.008380] df40: 0073 000e 0001 0001 8c00528a 2958b000 
fff7 8c00529a
[   32.016913] df60: 2958b000 000e 8c2545a0 0012 8c91c000 00fc 
0e20 0001
[   32.025494] df80: 8c0070e8 7bb2aa44 2956d000 2956c008 ff0f 40008000 
2958be20 0001
[   32.033979] dfa0: 2958b000 0fff 2958be20  2958b000 2956c008 
0003 0012
[   32.042512] dfc0: 29561054 0fff 29561000  2956c008 2956d000 
7bb2aa44 7bb2aa44
[   32.051091] dfe0: 29559bfe 2955a1ae 8000  031b 0168 
 0060
[   32.059573]
[   32.059591] Call trace:
[   32.063730] [<8c00f782>] __cond_resched+0x1a/0x40
[   32.068621] [<8c15adf4>] cond_resched+0x30/0x48
[   32.073286] [<8c15b6ba>] mutex_lock+0xa/0x50
[   32.077687] [<8c00c606>] copy_user_page+0x86/0x134
[   32.082639] [<8c03b3fa>] __do_fault+0x142/0x340
[   32.087309] [<8c03b958>] handle_mm_fault+0x2c6/0x556
[   32.092428] [<8c00b890>] do_page_fault+0xa4/0x2c0
[   32.097279] [<8c03e09e>] do_mmap_pgoff+0x23e/0x26c
[   32.102215] [<8c00528a>] old_mmap+0x66/0xb4
[   32.106517] [<8c00529a>] old_mmap+0x76/0xb4
[   32.110834] [<8c0070e8>] ret_from_exception+0x0/0x14
[   32.116014]
[   32.217342] BUG: scheduling while atomic: hotplug/0x1002/792
[   32.222868] Stack: (0x8c8c7e20 to 0x8c8c8000)
[   32.227357] 7e20: 8c15a80c 1000 8c8c6000 8cca5cb0 8c00f782 8c8c7e50 
8c956000 8c1ff004
[   32.235822] 7e40: c0001000 0c95653e 1000 8c8c6000 8c15adf4 8c8c7e60 
7bf85a7c 8c1e9164
[   32.244355] 7e60: 8c15b6ba 8c948000 8c00c606 8c8c6000 8c03ac92 8c1f0c30 
7bf85a7c 8c93480c
[   32.252888] 7e80: 8c214ac0 8c913e14 8c214900 8c8c6000 8c915d80  
 8c03bb62
[   32.261421] 7ea0: 8c9167bc 0001 7bf85a7c 8c93480c 0e14 00030002 
0c94855c 8c9167bc
[   32.269954] 7ec0: 8c915dc0 0c94855c 8c915d80 295bc0cc 295bc134 295bc190 
295bc1cc 8c00b890
[   32.278487] 7ee0: 8c8c7fa0 8cca5b20 8c915d80 8c915db4 7bf85a7c 00030002 
8c93480c 295bd51c
[   32.287020] 7f00: 295bd550 295bd534 295bd1d8 295bd110 295bd1c8 295bce40 
295bce40 295bce40
[   32.295553] 7f20: 295bd1d8 295d05f4 295d05f

Re: Problems with framebuffer in 2.6.22-git17

2007-07-23 Thread Adrian McMenamin

(Apologies to those getting this a second time: resending as text/plain only)

On 23/07/07, Adrian McMenamin [EMAIL PROTECTED] wrote:




On 7/23/07, Antonino A. Daplas [EMAIL PROTECTED] wrote:
  On Sun, 2007-07-22 at 19:41 +0100, Adrian McMenamin wrote:
  I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
  - when the code is executed it appears to lock the Dreamcast up.
 
   The problem seems to be:
 
   fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, event);
 
  In drivers/video/fbmem.c
 
  This hasn't been an issue before, so are there any recent changes that
  might have caused this?

 What's the last kernel that worked for you? Can you also post your
 config?



One of the recent 2.6.22 gits, not sure which one, I'm afraid.


 
  (fb_notifier_call_chain calls a succession of stubs ending in
  __blocking_notifier_call_chain in kernel/sys.c)
 

 Try reverting commit a66ad56eb2c9644717da4d7f05f971d6786145e3.


OK, that certainly seems to make a difference - the box doesn't crash but it 
generates a lot of error messages - though as I have patched this with my dma 
patch that isn't one of them:

/ # modprobe pvr2fb
[   31.642623] Console: switching to colour frame buffer device 80x30
[   31.677360] fb0: NEC PowerVR2 (rev 1.1) frame buffer device, using 
600k/8192k of video memory
[   31.686139] fb0: Mode 640x480-16 pitch = 1280 cable: VGA video output: VGA
[   31.693205] fb0: registering with SQ API
[   31.762406] sqremap:NEC PowerVR2  [2048 pages]  va 0xe000   pa 
0xa500
[   31.769537] fb0: Mapped video memory to SQ addr 0xe000
/ # [   31.912380 ] BUG: scheduling while atomic: 10-udev.hotplug/0x1002/775
[   31.918676] Stack: (0x8c91de0c to 0x8c91e000)
[   31.923145] de00:8c15a80c 1000 8c91c000 
8c8c5a10 8c00f782
[   31.931582 ] de20: 8c91de3c 8c33d000 8c1ff00c c0003000 0c33d53e 1000 
8c91c000 8c15adf4
[   31.940115] de40: 8c91de4c 2958be20 8c1e917c 8c15b6ba 8cc14000 8c00c606 
8c91c000 8c03b3fa
[   31.948648] de60: 0001  0001 8cceb8f4 8cceb8b4 8c2087a0 
8c91c000 0001
[   31.957181] de80: 000e 2958b000 8c21a280 0200 8c915560 2958be20 
8c03b958 8c954294
[   31.965725] dea0: 0001 2958be20 8cceb8b4 062c 00030002  
8c954294 000e
[   31.974293] dec0: 0001  8c915560 8c2545a0 2958b000 8c915560 
8cceb8b4 8c00b890
[   31.982781] dee0: 8c91dfa0 8c8c5880 8c915560 8c915594 2958be20 00030002 
8cceb8b4 8c8da140
[   31.991314] df00: 8c8da140 8c8da0d4 8c8da148 1000 0012  
0001 8cc09e9c
[   31.999892] df20: 8c03e09e 000e 2958b000 8c9155a0 1000 0003 
8c2545a0 0073
[   32.008380] df40: 0073 000e 0001 0001 8c00528a 2958b000 
fff7 8c00529a
[   32.016913] df60: 2958b000 000e 8c2545a0 0012 8c91c000 00fc 
0e20 0001
[   32.025494] df80: 8c0070e8 7bb2aa44 2956d000 2956c008 ff0f 40008000 
2958be20 0001
[   32.033979] dfa0: 2958b000 0fff 2958be20  2958b000 2956c008 
0003 0012
[   32.042512] dfc0: 29561054 0fff 29561000  2956c008 2956d000 
7bb2aa44 7bb2aa44
[   32.051091] dfe0: 29559bfe 2955a1ae 8000  031b 0168 
 0060
[   32.059573]
[   32.059591] Call trace:
[   32.063730] [8c00f782] __cond_resched+0x1a/0x40
[   32.068621] [8c15adf4] cond_resched+0x30/0x48
[   32.073286] [8c15b6ba] mutex_lock+0xa/0x50
[   32.077687] [8c00c606] copy_user_page+0x86/0x134
[   32.082639] [8c03b3fa] __do_fault+0x142/0x340
[   32.087309] [8c03b958] handle_mm_fault+0x2c6/0x556
[   32.092428] [8c00b890] do_page_fault+0xa4/0x2c0
[   32.097279] [8c03e09e] do_mmap_pgoff+0x23e/0x26c
[   32.102215] [8c00528a] old_mmap+0x66/0xb4
[   32.106517] [8c00529a] old_mmap+0x76/0xb4
[   32.110834] [8c0070e8] ret_from_exception+0x0/0x14
[   32.116014]
[   32.217342] BUG: scheduling while atomic: hotplug/0x1002/792
[   32.222868] Stack: (0x8c8c7e20 to 0x8c8c8000)
[   32.227357] 7e20: 8c15a80c 1000 8c8c6000 8cca5cb0 8c00f782 8c8c7e50 
8c956000 8c1ff004
[   32.235822] 7e40: c0001000 0c95653e 1000 8c8c6000 8c15adf4 8c8c7e60 
7bf85a7c 8c1e9164
[   32.244355] 7e60: 8c15b6ba 8c948000 8c00c606 8c8c6000 8c03ac92 8c1f0c30 
7bf85a7c 8c93480c
[   32.252888] 7e80: 8c214ac0 8c913e14 8c214900 8c8c6000 8c915d80  
 8c03bb62
[   32.261421] 7ea0: 8c9167bc 0001 7bf85a7c 8c93480c 0e14 00030002 
0c94855c 8c9167bc
[   32.269954] 7ec0: 8c915dc0 0c94855c 8c915d80 295bc0cc 295bc134 295bc190 
295bc1cc 8c00b890
[   32.278487] 7ee0: 8c8c7fa0 8cca5b20 8c915d80 8c915db4 7bf85a7c 00030002 
8c93480c 295bd51c
[   32.287020] 7f00: 295bd550 295bd534 295bd1d8 295bd110 295bd1c8 295bce40 
295bce40 295bce40
[   32.295553] 7f20: 295bd1d8 295d05f4 295d05fc 295d060c 295d0628 295d0640 
295ce5ac 295d0c80
[   32.304086] 7f40:   295b82a8 0001 295b8344  
 295b9414
[   32.312619] 7f60: 295b9424 295b9646 0001 2cd2 000e 2cd7 
000c 0001
[   32.321153

[PATCH] Fix Dreamcast DMA issues

2007-07-23 Thread Adrian McMenamin

The current SH DMA API is somewhat broken, not correctly matching
virtual channel to the correct SH DMAC. This wasn't noticeable when
using g2 DMA for the sound driver - one channel 0 is as good as any
other! - but caused the pvr2 driver to fail.

This patch fixes the pvr2 problem and consequently fixes the sound
driver to ensure it continues to function.

Signed-off by: Adrian McMenamin [EMAIL PROTECTED]
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index cf8e119..76ed816 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -31,8 +31,8 @@ struct dma_info *get_dma_info(unsigned int chan)
 	 * the channel is.
 	 */
 	list_for_each_entry(info, registered_dmac_list, list) {
-		if ((chan   info-first_channel_nr) ||
-		(chan = info-first_channel_nr + info-nr_channels))
+		if ((chan   info-first_vchannel_nr) ||
+		(chan = info-first_vchannel_nr + info-nr_channels))
 			continue;
 
 		return info;
@@ -82,7 +82,7 @@ struct dma_channel *get_dma_channel(unsigned int chan)
 
 	for (i = 0; i  info-nr_channels; i++) {
 		channel = info-channels[i];
-		if (channel-chan == chan)
+		if (channel-vchan == chan)
 			return channel;
 	}
 
@@ -369,6 +369,7 @@ int register_dmac(struct dma_info *info)
 	}
 
 	total_channels = get_nr_channels();
+	info-first_vchannel_nr = total_channels;
 	for (i = 0; i  info-nr_channels; i++) {
 		struct dma_channel *chan = info-channels[i];
 
diff --git a/include/asm-sh/dma.h b/include/asm-sh/dma.h
index 6034d4a..4c75b70 100644
--- a/include/asm-sh/dma.h
+++ b/include/asm-sh/dma.h
@@ -111,6 +111,7 @@ struct dma_info {
 
 	struct list_head list;
 	int first_channel_nr;
+	int first_vchannel_nr;
 };
 
 struct dma_chan_caps {
diff --git a/sound/sh/aica.h b/sound/sh/aica.h
index 8c11e3d..d098baa 100644
--- a/sound/sh/aica.h
+++ b/sound/sh/aica.h
@@ -52,7 +52,7 @@
 #define AICA_CHANNEL1_OFFSET 0x21000
 #define CHANNEL_OFFSET 0x1
 
-#define AICA_DMA_CHANNEL 0
+#define AICA_DMA_CHANNEL 5
 #define AICA_DMA_MODE 5
 
 #define SND_AICA_DRIVER AICA


Lots of scheduling bugs (?) with -rc1

2007-07-22 Thread Adrian McMenamin

Lots of this on the Dreamcast (nb the first pvr2fb oops is a different issue)


eg
Starting network...
Starting dropbear sshd: [   16.689047] BUG: scheduling while atomic:
dropbear/0x1001/722
[   16.694675] Stack: (0x8c3f7e58 to 0x8c3f8000)
[   16.699143] 7e40:
   8c15a80c 1000
[   16.707618] 7e60: 8c3f6000 8c3ec9b0 8c00f782 8c3f7e88 8cce9000
8c1ff008 c0002000 0cce953e
[   16.716151] 7e80: 1000 8c3f6000 8c15adf4 8c3f7e98 00436004
8c1e9170 8c15b6ba 8c1e9158
[   16.724684] 7ea0: 8c00c4d8 8c3f6000 8c03b7d0 8c3ef004 0001
00436004 8ccf7ef0 8cd6b0d8
[   16.733217] 7ec0: 8c21bd20 8c3f6000 8c29d520 8c0385bc 8c26995c
8ccf7f44 8c03cf04 8c00b890
[   16.741750] 7ee0: 8c3f7fa0 8c3ec820 8c29d520 8c29d554 00436004
00030002 8ccf7ef0 0003
[   16.750283] 7f00: 8c3ec850 8c3ec890 d04b 8c03d82e 7b860b6c
0436 00100077 8c03cbb6
[   16.758816] 7f20: 1000 8c29d520 8ccf7ef0 8ccf7ef0 8c03cbf8
8ccf7f30 8c269c14 8c03e298
[   16.767349] 7f40: 0001 8c29d520 00436000 8c269c14 8c269c14
8c2699b0 8c269c1c 0436
[   16.775883] 7f60: 8c03e3ba 8c03e3ca 8c29d59c 00437000 ff0f
8c29d59c 00437000 0001
[   16.784416] 7f80: 8c0070e8 7b860b68 1001 29637490 ff0f
40008000 00436004 0001
[   16.792949] 7fa0: 00437000 2963bb74 00436000 0001 00437000
7b860ed4 f000 2963bb74
[   16.801482] 7fc0: 295eba34  033c  29637490
1001 7b860b68 7b860b68
[   16.810015] 7fe0: 2961b424 2961b3b2 8001  04a8
0738305f  0060
[   16.818588]
[   16.818606] Call trace:
[   16.822686] [<8c00f782>] __cond_resched+0x1a/0x40
[   16.827589] [<8c15adf4>] cond_resched+0x30/0x48
[   16.832256] [<8c15b6ba>] mutex_lock+0xa/0x50
[   16.836656] [<8c00c4d8>] clear_user_page+0x84/0x12c
[   16.841686] [<8c03b7d0>] handle_mm_fault+0x13e/0x556
[   16.846810] [<8c0385bc>] vma_prio_tree_remove+0x0/0x9c
[   16.852106] [<8c03cf04>] vma_adjust+0x26c/0x2cc
[   16.856776] [<8c00b890>] do_page_fault+0xa4/0x2c0
[   16.861631] [<8c03d82e>] split_vma+0xde/0x10c
[   16.866117] [<8c03cbb6>] __vma_link+0x2e/0x40
[   16.870609] [<8c03cbf8>] vma_link+0x30/0xd0
[   16.874920] [<8c03e298>] do_brk+0x174/0x200
[   16.879235] [<8c03e3ba>] sys_brk+0x96/0xdc
[   16.883452] [<8c03e3ca>] sys_brk+0xa6/0xdc
[   16.887678] [<8c0070e8>] ret_from_exception+0x0/0x14
[   16.892801]

and...


/ # modprobe snd-aica
[   96.802031] ALSA Driver for Yamaha AICA Super Intelligent Sound Processor
[   98.238477] BUG: scheduling while atomic: hotplug/0x1002/1034
[   98.244120] Stack: (0x8ca65e20 to 0x8ca66000)
[   98.248588] 5e20: 8c15a80c 1000 8ca64000 8c8a2250 8c00f782
8ca65e50 8c98b000 8c1ff004
[   98.257047] 5e40: c0001000 0c98b53e 1000 8ca64000 8c15adf4
8ca65e60 0048d0fc 8c1e9164
[   98.265580] 5e60: 8c15b6ba 8c1e2000 8c00c606 8ca64000 8c03ac92
8c1f0c30 0048d0fc 8ccdb710
[   98.274113] 5e80: 8c215160 8ccda234 8c205c40 8ca64000 8ca160e0
  8c03bb62
[   98.282646] 5ea0: 8c947004 0001 0048d0fc 8ccdb710 0234
00030002 0c1e255c 8c947004
[   98.291179] 5ec0: 8ca16120 0c1e255c 8ca160e0 8ca65ee8 8c8a21b0
0016 7bb361a8 8c00b890
[   98.299712] 5ee0: 8ca65fa0 8c8a20c0 8ca160e0 8ca16114 0048d0fc
00030002 8ccdb710 8c8a2100
[   98.308292] 5f00: 0016 7bb361a8 0016 8c00e384 8ca65f1c
7bb361a8 8c00d83a 8ca65f20
[   98.316778] 5f20: 8c00dd56 8ca65f38 0016 8ca65f50 8c260420
8c1bb0e0 8c8a20c0 8ca16280
[   98.325311] 5f40: 8cc90bc0 06bd 8c15a8c2  8c8a224c
8c01448a 8c1c0444 8c8a21b0
[   98.333891] 5f60: 8c23fb20 8c1c0464 8c8a20c0 0010 8c8a23fc
8ca65f74 8ca65f74 0001
[   98.342377] 5f80: 8c0070e8 7bd5ca80   ff0f
40008000 0048d0fc 0001
[   98.350910] 5fa0:  0001 0048d0fc  004a7380
0048d26c  
[   98.359489] 5fc0: 00489418 004a7380   
 7bd5ca80 7bd5ca80
[   98.367977] 5fe0: 0042f152 0042f128 8001  004a
08f6  00c0
[   98.376505]
[   98.376523] Call trace:
[   98.380681] [<8c00f782>] __cond_resched+0x1a/0x40
[   98.38] [<8c15adf4>] cond_resched+0x30/0x48
[   98.390222] [<8c15b6ba>] mutex_lock+0xa/0x50
[   98.394618] [<8c1e2000>] igmp_mc_proc_init+0x30/0x50
[   98.399774] [<8c00c606>] copy_user_page+0x86/0x134
[   98.404719] [<8c03ac92>] do_wp_page+0x33a/0x494
[   98.409362] [<8c03bb62>] handle_mm_fault+0x4d0/0x556
[   98.414529] [<8c00b890>] do_page_fault+0xa4/0x2c0
[   98.419334] [<8c00e384>] dequeue_task+0x20/0x32
[   98.423992] [<8c00d83a>] update_stats_wait_end+0x86/0xb8
[   98.429471] [<8c00dd56>] pick_next_task_fair+0x32/0x58
[   98.434780] [<8c15a8c2>] schedule+0xf6/0x3c0
[   98.439173] [<8c01448a>] do_exit+0x682/0x6b8
[   98.443585] [<8c0070e8>] ret_from_exception+0x0/0x14
[   98.448721]
[   98.797235] BUG: scheduling while atomic: test/0x1001/1060
[   98.802577] Stack: (0x8c8a9e58 to 0x8c8aa000)
[   98.807061] 9e40:
   8c15a80c 1000
[   98.815533] 9e60: 8c8a8000 8cc88270 8c00f782 8c8a9e88 8c9c6000
8c1ff000 c000 0c9c653e
[   

Re: Problems with framebuffer in 2.6.22-git17

2007-07-22 Thread Adrian McMenamin

On 22/07/07, Adrian McMenamin <[EMAIL PROTECTED]> wrote:

I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
- when the code is executed it appears to lock the Dreamcast up.

The problem seems to be:

 fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, );

In drivers/video/fbmem.c

This hasn't been an issue before, so are there any recent changes that
might have caused this?

(fb_notifier_call_chain calls a succession of stubs ending in
__blocking_notifier_call_chain in kernel/sys.c)



Looking further, the problem can be further narrowed to

ret = nb->notifier_call(nb, val, v);


in

static int __kprobes notifier_call_chain(struct notifier_block **nl,
unsigned long val, void *v,
int nr_to_call, int *nr_calls)

In kernel/sys.c
-
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/


Problems with framebuffer in 2.6.22-git17

2007-07-22 Thread Adrian McMenamin

I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
- when the code is executed it appears to lock the Dreamcast up.

The problem seems to be:

fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, );

In drivers/video/fbmem.c

This hasn't been an issue before, so are there any recent changes that
might have caused this?

(fb_notifier_call_chain calls a succession of stubs ending in
__blocking_notifier_call_chain in kernel/sys.c)

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/


Problems with framebuffer in 2.6.22-git17

2007-07-22 Thread Adrian McMenamin

I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
- when the code is executed it appears to lock the Dreamcast up.

The problem seems to be:

fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, event);

In drivers/video/fbmem.c

This hasn't been an issue before, so are there any recent changes that
might have caused this?

(fb_notifier_call_chain calls a succession of stubs ending in
__blocking_notifier_call_chain in kernel/sys.c)

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: Problems with framebuffer in 2.6.22-git17

2007-07-22 Thread Adrian McMenamin

On 22/07/07, Adrian McMenamin [EMAIL PROTECTED] wrote:

I ma having problems with the pvr2 fb on the Dreamcast in 2.6.22-git17
- when the code is executed it appears to lock the Dreamcast up.

The problem seems to be:

 fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, event);

In drivers/video/fbmem.c

This hasn't been an issue before, so are there any recent changes that
might have caused this?

(fb_notifier_call_chain calls a succession of stubs ending in
__blocking_notifier_call_chain in kernel/sys.c)



Looking further, the problem can be further narrowed to

ret = nb-notifier_call(nb, val, v);


in

static int __kprobes notifier_call_chain(struct notifier_block **nl,
unsigned long val, void *v,
int nr_to_call, int *nr_calls)

In kernel/sys.c
-
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/


Lots of scheduling bugs (?) with -rc1

2007-07-22 Thread Adrian McMenamin

Lots of this on the Dreamcast (nb the first pvr2fb oops is a different issue)


eg
Starting network...
Starting dropbear sshd: [   16.689047] BUG: scheduling while atomic:
dropbear/0x1001/722
[   16.694675] Stack: (0x8c3f7e58 to 0x8c3f8000)
[   16.699143] 7e40:
   8c15a80c 1000
[   16.707618] 7e60: 8c3f6000 8c3ec9b0 8c00f782 8c3f7e88 8cce9000
8c1ff008 c0002000 0cce953e
[   16.716151] 7e80: 1000 8c3f6000 8c15adf4 8c3f7e98 00436004
8c1e9170 8c15b6ba 8c1e9158
[   16.724684] 7ea0: 8c00c4d8 8c3f6000 8c03b7d0 8c3ef004 0001
00436004 8ccf7ef0 8cd6b0d8
[   16.733217] 7ec0: 8c21bd20 8c3f6000 8c29d520 8c0385bc 8c26995c
8ccf7f44 8c03cf04 8c00b890
[   16.741750] 7ee0: 8c3f7fa0 8c3ec820 8c29d520 8c29d554 00436004
00030002 8ccf7ef0 0003
[   16.750283] 7f00: 8c3ec850 8c3ec890 d04b 8c03d82e 7b860b6c
0436 00100077 8c03cbb6
[   16.758816] 7f20: 1000 8c29d520 8ccf7ef0 8ccf7ef0 8c03cbf8
8ccf7f30 8c269c14 8c03e298
[   16.767349] 7f40: 0001 8c29d520 00436000 8c269c14 8c269c14
8c2699b0 8c269c1c 0436
[   16.775883] 7f60: 8c03e3ba 8c03e3ca 8c29d59c 00437000 ff0f
8c29d59c 00437000 0001
[   16.784416] 7f80: 8c0070e8 7b860b68 1001 29637490 ff0f
40008000 00436004 0001
[   16.792949] 7fa0: 00437000 2963bb74 00436000 0001 00437000
7b860ed4 f000 2963bb74
[   16.801482] 7fc0: 295eba34  033c  29637490
1001 7b860b68 7b860b68
[   16.810015] 7fe0: 2961b424 2961b3b2 8001  04a8
0738305f  0060
[   16.818588]
[   16.818606] Call trace:
[   16.822686] [8c00f782] __cond_resched+0x1a/0x40
[   16.827589] [8c15adf4] cond_resched+0x30/0x48
[   16.832256] [8c15b6ba] mutex_lock+0xa/0x50
[   16.836656] [8c00c4d8] clear_user_page+0x84/0x12c
[   16.841686] [8c03b7d0] handle_mm_fault+0x13e/0x556
[   16.846810] [8c0385bc] vma_prio_tree_remove+0x0/0x9c
[   16.852106] [8c03cf04] vma_adjust+0x26c/0x2cc
[   16.856776] [8c00b890] do_page_fault+0xa4/0x2c0
[   16.861631] [8c03d82e] split_vma+0xde/0x10c
[   16.866117] [8c03cbb6] __vma_link+0x2e/0x40
[   16.870609] [8c03cbf8] vma_link+0x30/0xd0
[   16.874920] [8c03e298] do_brk+0x174/0x200
[   16.879235] [8c03e3ba] sys_brk+0x96/0xdc
[   16.883452] [8c03e3ca] sys_brk+0xa6/0xdc
[   16.887678] [8c0070e8] ret_from_exception+0x0/0x14
[   16.892801]

and...


/ # modprobe snd-aica
[   96.802031] ALSA Driver for Yamaha AICA Super Intelligent Sound Processor
[   98.238477] BUG: scheduling while atomic: hotplug/0x1002/1034
[   98.244120] Stack: (0x8ca65e20 to 0x8ca66000)
[   98.248588] 5e20: 8c15a80c 1000 8ca64000 8c8a2250 8c00f782
8ca65e50 8c98b000 8c1ff004
[   98.257047] 5e40: c0001000 0c98b53e 1000 8ca64000 8c15adf4
8ca65e60 0048d0fc 8c1e9164
[   98.265580] 5e60: 8c15b6ba 8c1e2000 8c00c606 8ca64000 8c03ac92
8c1f0c30 0048d0fc 8ccdb710
[   98.274113] 5e80: 8c215160 8ccda234 8c205c40 8ca64000 8ca160e0
  8c03bb62
[   98.282646] 5ea0: 8c947004 0001 0048d0fc 8ccdb710 0234
00030002 0c1e255c 8c947004
[   98.291179] 5ec0: 8ca16120 0c1e255c 8ca160e0 8ca65ee8 8c8a21b0
0016 7bb361a8 8c00b890
[   98.299712] 5ee0: 8ca65fa0 8c8a20c0 8ca160e0 8ca16114 0048d0fc
00030002 8ccdb710 8c8a2100
[   98.308292] 5f00: 0016 7bb361a8 0016 8c00e384 8ca65f1c
7bb361a8 8c00d83a 8ca65f20
[   98.316778] 5f20: 8c00dd56 8ca65f38 0016 8ca65f50 8c260420
8c1bb0e0 8c8a20c0 8ca16280
[   98.325311] 5f40: 8cc90bc0 06bd 8c15a8c2  8c8a224c
8c01448a 8c1c0444 8c8a21b0
[   98.333891] 5f60: 8c23fb20 8c1c0464 8c8a20c0 0010 8c8a23fc
8ca65f74 8ca65f74 0001
[   98.342377] 5f80: 8c0070e8 7bd5ca80   ff0f
40008000 0048d0fc 0001
[   98.350910] 5fa0:  0001 0048d0fc  004a7380
0048d26c  
[   98.359489] 5fc0: 00489418 004a7380   
 7bd5ca80 7bd5ca80
[   98.367977] 5fe0: 0042f152 0042f128 8001  004a
08f6  00c0
[   98.376505]
[   98.376523] Call trace:
[   98.380681] [8c00f782] __cond_resched+0x1a/0x40
[   98.38] [8c15adf4] cond_resched+0x30/0x48
[   98.390222] [8c15b6ba] mutex_lock+0xa/0x50
[   98.394618] [8c1e2000] igmp_mc_proc_init+0x30/0x50
[   98.399774] [8c00c606] copy_user_page+0x86/0x134
[   98.404719] [8c03ac92] do_wp_page+0x33a/0x494
[   98.409362] [8c03bb62] handle_mm_fault+0x4d0/0x556
[   98.414529] [8c00b890] do_page_fault+0xa4/0x2c0
[   98.419334] [8c00e384] dequeue_task+0x20/0x32
[   98.423992] [8c00d83a] update_stats_wait_end+0x86/0xb8
[   98.429471] [8c00dd56] pick_next_task_fair+0x32/0x58
[   98.434780] [8c15a8c2] schedule+0xf6/0x3c0
[   98.439173] [8c01448a] do_exit+0x682/0x6b8
[   98.443585] [8c0070e8] ret_from_exception+0x0/0x14
[   98.448721]
[   98.797235] BUG: scheduling while atomic: test/0x1001/1060
[   98.802577] Stack: (0x8c8a9e58 to 0x8c8aa000)
[   98.807061] 9e40:
   8c15a80c 1000
[   98.815533] 9e60: 8c8a8000 8cc88270 8c00f782 8c8a9e88 8c9c6000
8c1ff000 c000 0c9c653e
[   98.824066] 9e80: 1000 8c8a8000 8c15adf4 8c8a9e98 0048c2ac

<    1   2   3   4   >