|
From: Adrian M. <ad...@mc...> - 2004-06-16 23:05:21
|
This is pretty crude stuff and doesn't even work properly in the limited =
way=20
it is impolemented so far, but here it is for your perusal. (NB: these ar=
e=20
against the maple code in the linuxsh repository).
I have been working on rewriting the maple driver to match the driver mod=
el in=20
the 2.6 kernel. I've had trouble finding the time to do this properly, so=
the=20
results are very limited - but this will give you entries of a sort in sy=
sfs=20
if nothing else :)
Apologies for the stray bits of code loitering here too.
More to follow in the next few days
Adrian
--- maple.c=092004-06-16 23:52:30.000000000 +0100
+++ tmpspace/linux-2.6.6/drivers/maple/maple.c=092004-06-16 23:54:04.0000=
00000=20
+0100
@@ -1,7 +1,20 @@
/*
+ *=09
*=09Maple Bus device driver
*/
=20
+/*************************
+ * Maple Bus Driver for *
+ * SEGA Dreamcast =09 *
+ * Copyright Paul Mundt *
+ * 2000 - 2004 *
+ * Sections copyright *
+ * Adrian McMenamin *
+ * 2004 *
+ * Licensed under=09 *
+ * version 2 of the GPL *
+ *************************/
+
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -13,6 +26,7 @@
#include <linux/string.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
+#include <linux/device.h>
=20
#include <asm/page.h>
#include <asm/io.h>
@@ -36,15 +50,33 @@
static DECLARE_COMPLETION(kmapled_exited);
static int kmapled_pid =3D 0;
=20
+
struct timer_list maple_timer;
=20
unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
unsigned long maple_pnp_time;
=20
+static int maple_bus_match(struct device * dev, struct device_driver * d=
rv)=20
+{
+=09pr_info("MAPLE: maple_bus_match called automagically\n");
+=09return 0;
+}
+
+
+/* Work with new driver structures for 2.6 */
+struct bus_type maple_bus_type =3D {
+ .name=09=3D "maple",
+ .match=09=3D maple_bus_match,
+};
+
+
+
+
static struct maple_driver maple_dummy_driver =3D {
=09.name=09=09=3D "Dummy",
};
=20
+
static void maple_dump_devinfo(struct maple_devinfo *devinfo)
{
=09pr_debug(" function: 0x%08x\n", be32_to_cpu(devinfo->function));
@@ -65,7 +97,7 @@
=09struct list_head *lh =3D (void *)driver;
=09list_add(lh, &maple_driver_list);
=20
-=09MOD_INC_USE_COUNT;
+=09/* MOD_INC_USE_COUNT; Redundant under 2.6 module code */
=20
=09pr_info("maple: registered driver: %s (function 0x%lx)\n",
=09 driver->name, driver->function);
@@ -77,7 +109,7 @@
=09struct list_head *lh =3D (void *)driver;
=09list_del(lh);
=20
-=09MOD_DEC_USE_COUNT;
+=09/* MOD_DEC_USE_COUNT; */
=20
=09pr_info("maple: unregistered driver: %s (function 0x%lx)\n",
=09 driver->name, driver->function);
@@ -120,6 +152,9 @@
=09=09kfree(dev);
=09=09return NULL;
=09}
+=09/* Setup kernel device */
+=09dev->sys_maple_dev.bus =3D &maple_bus_type;
+
=20
=09return dev;
}
@@ -139,6 +174,7 @@
{
=09struct list_head *lh =3D (void *)dev;
=09list_add_tail(lh, &maple_dev_list);
+=09
}
=20
=20
@@ -227,6 +263,7 @@
=20
=09pr_info("maple(%d,%d): Connected(function 0x%lx)\n",
=09 dev->port, dev->unit, function);
+=09
=20
=09list_for_each(lh, &maple_driver_list) {
=09=09driver =3D (struct maple_driver *)lh;
@@ -244,6 +281,18 @@
=09=09maple_dump_devinfo(&dev->devinfo);
=09=09dev->driver =3D &maple_dummy_driver;
=09}
+=09
+
+=09/* Add this device to the sysfs list */
+=09list_add_tail(&dev->sys_maple_dev.bus_list, &maple_bus_type.devices.l=
ist);
+=09sprintf(dev->sys_maple_dev.bus_id, "maple:%d:%d.0x%lx\n", dev->port,=20
dev->unit, function);
+=09sprintf(dev->sys_maple_dev.kobj.name, dev->product_name);
+=09dev->sys_maple_dev.bus =3D &maple_bus_type;
+=09device_register(&dev->sys_maple_dev);
+=09pr_info("MAPLE: device registered\n");
+
+
+
=20
}
=20
@@ -456,6 +505,12 @@
=20
=09pr_info("SEGA Dreamcast MAPLE Bus drivers\n");
=20
+=09/* Register with sysfs */
+ =09if (bus_register(&maple_bus_type) !=3D 0)
+=09=09goto cleanup;
+=09pr_info("Maple bus registered\n");
+=20
+
=09/* Allocate DMA buffer */
=09maple_sendbuf =3D (void *)__get_dma_pages(GFP_KERNEL, MAPLE_DMA_PAGES=
);
=09if (maple_sendbuf =3D=3D NULL)
@@ -481,10 +536,10 @@
=20
=09/* Start to scan ports */
=09maple_pnp_time =3D 0;
-
- /* Initialize hardware */
+=09
+=09/* Initialize hardware */
ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
- ctrl_outl(0, MAPLE_RESET2);
+=09ctrl_outl(0, MAPLE_RESET2);
ctrl_outl(MAPLE_2MBPS|MAPLE_TIMEOUT(50000), MAPLE_SPEED);
=09ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
ctrl_outl(1, MAPLE_ENABLE);
@@ -494,7 +549,6 @@
maple_timer.expires =3D jiffies + MAPLE_SCANHZ;
maple_timer.function =3D maple_timer_handler;
add_timer(&maple_timer);
-
return 0;
=20
cleanup:
@@ -526,6 +580,9 @@
EXPORT_SYMBOL(maple_register_driver);
EXPORT_SYMBOL(maple_unregister_driver);
EXPORT_SYMBOL(maple_getcond_callback);
+EXPORT_SYMBOL(maple_bus_type);
+
+MODULE_LICENSE("GPL"); //avoid kernel tainting
=20
/*
* Local variables:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
--- maple.h=092004-06-16 23:56:32.000000000 +0100
+++ tmpspace/linux-2.6.6/include/linux/maple.h=092004-06-16 22:47:26.0000=
00000=20
+0100
@@ -89,8 +89,10 @@
};
=20
=20
+
struct maple_device {
=09struct list_head list;
+=09struct list_head sysfs_list;
=09struct maple_driver *driver;
=09struct mapleq *mq;
=09void *private_data;
@@ -101,8 +103,17 @@
=09unsigned char port, unit;
=09char product_name[32];
=09char product_license[64];
+=09
+=09/* 2.6.x kernel compliance */
+=09struct device sys_maple_dev;
+=09
};
=20
+extern struct bus_type maple_bus_type;
+
+
+
+
=20
struct maple_driver {
=09struct list_head list;
|