[PATCH] Add SuperHyway bus subsystem
ChangeSet 1.2027.3.1, 2005/03/09 12:14:18-08:00, [EMAIL PROTECTED] [PATCH] Add SuperHyway bus subsystem Signed-off-by: Paul Mundt <[EMAIL PROTECTED]> Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]> drivers/sh/Makefile |6 drivers/sh/superhyway/Makefile |7 + drivers/sh/superhyway/superhyway-sysfs.c | 45 ++ drivers/sh/superhyway/superhyway.c | 201 +++ include/linux/superhyway.h | 79 5 files changed, 338 insertions(+) diff -Nru a/drivers/sh/Makefile b/drivers/sh/Makefile --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/Makefile 2005-03-09 16:36:31 -08:00 @@ -0,0 +1,6 @@ +# +# Makefile for the SuperH specific drivers. +# + +obj-$(CONFIG_SUPERHYWAY) += superhyway/ + diff -Nru a/drivers/sh/superhyway/Makefile b/drivers/sh/superhyway/Makefile --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/superhyway/Makefile2005-03-09 16:36:31 -08:00 @@ -0,0 +1,7 @@ +# +# Makefile for the SuperHyway bus drivers. +# + +obj-$(CONFIG_SUPERHYWAY) += superhyway.o +obj-$(CONFIG_SYSFS)+= superhyway-sysfs.o + diff -Nru a/drivers/sh/superhyway/superhyway-sysfs.c b/drivers/sh/superhyway/superhyway-sysfs.c --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/superhyway/superhyway-sysfs.c 2005-03-09 16:36:31 -08:00 @@ -0,0 +1,45 @@ +/* + * drivers/sh/superhyway/superhyway-sysfs.c + * + * SuperHyway Bus sysfs interface + * + * Copyright (C) 2004, 2005 Paul Mundt <[EMAIL PROTECTED]> + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ +#include +#include +#include +#include + +#define superhyway_ro_attr(name, fmt, field) \ +static ssize_t name##_show(struct device *dev, char *buf) \ +{ \ + struct superhyway_device *s = to_superhyway_device(dev);\ + return sprintf(buf, fmt, s->field); \ +} + +/* VCR flags */ +superhyway_ro_attr(perr_flags, "0x%02x\n", vcr.perr_flags); +superhyway_ro_attr(merr_flags, "0x%02x\n", vcr.merr_flags); +superhyway_ro_attr(mod_vers, "0x%04x\n", vcr.mod_vers); +superhyway_ro_attr(mod_id, "0x%04x\n", vcr.mod_id); +superhyway_ro_attr(bot_mb, "0x%02x\n", vcr.bot_mb); +superhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb); + +/* Misc */ +superhyway_ro_attr(resource, "0x%08lx\n", resource.start); + +struct device_attribute superhyway_dev_attrs[] = { + __ATTR_RO(perr_flags), + __ATTR_RO(merr_flags), + __ATTR_RO(mod_vers), + __ATTR_RO(mod_id), + __ATTR_RO(bot_mb), + __ATTR_RO(top_mb), + __ATTR_RO(resource), + __ATTR_NULL, +}; + diff -Nru a/drivers/sh/superhyway/superhyway.c b/drivers/sh/superhyway/superhyway.c --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/superhyway/superhyway.c2005-03-09 16:36:31 -08:00 @@ -0,0 +1,201 @@ +/* + * drivers/sh/superhyway/superhyway.c + * + * SuperHyway Bus Driver + * + * Copyright (C) 2004, 2005 Paul Mundt <[EMAIL PROTECTED]> + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ +#include +#include +#include +#include +#include +#include +#include + +static int superhyway_devices; + +static struct device superhyway_bus_device = { + .bus_id = "superhyway", +}; + +static void superhyway_device_release(struct device *dev) +{ + kfree(to_superhyway_device(dev)); +} + +/** + * superhyway_add_device - Add a SuperHyway module + * @mod_id: Module ID (taken from MODULE.VCR.MOD_ID). + * @base: Physical address where module is mapped. + * @vcr: VCR value. + * + * This is responsible for adding a new SuperHyway module. This sets up a new + * struct superhyway_device for the module being added. Each one of @mod_id, + * @base, and @vcr are registered with the new device for further use + * elsewhere. + * + * Devices are initially added in the order that they are scanned (from the + * top-down of the memory map), and are assigned an ID based on the order that + * they are added. Any manual addition of a module will thus get the ID after + * the devices already discovered regardless of where it resides in memory. + * + * Further work can and should be done in superhyway_scan_bus(), to be sure + * that any new modules are properly discovered and subsequently registered. + */ +int superhyway_add_device(unsigned int mod_id, unsigned long base, + unsigned long long vcr) +{ + struct superhyway_device *dev; + + dev = kmalloc(sizeof(struct superhyway_device), GFP_KERNE
[PATCH] Add SuperHyway bus subsystem
ChangeSet 1.2027.3.1, 2005/03/09 12:14:18-08:00, [EMAIL PROTECTED] [PATCH] Add SuperHyway bus subsystem Signed-off-by: Paul Mundt [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] drivers/sh/Makefile |6 drivers/sh/superhyway/Makefile |7 + drivers/sh/superhyway/superhyway-sysfs.c | 45 ++ drivers/sh/superhyway/superhyway.c | 201 +++ include/linux/superhyway.h | 79 5 files changed, 338 insertions(+) diff -Nru a/drivers/sh/Makefile b/drivers/sh/Makefile --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/Makefile 2005-03-09 16:36:31 -08:00 @@ -0,0 +1,6 @@ +# +# Makefile for the SuperH specific drivers. +# + +obj-$(CONFIG_SUPERHYWAY) += superhyway/ + diff -Nru a/drivers/sh/superhyway/Makefile b/drivers/sh/superhyway/Makefile --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/superhyway/Makefile2005-03-09 16:36:31 -08:00 @@ -0,0 +1,7 @@ +# +# Makefile for the SuperHyway bus drivers. +# + +obj-$(CONFIG_SUPERHYWAY) += superhyway.o +obj-$(CONFIG_SYSFS)+= superhyway-sysfs.o + diff -Nru a/drivers/sh/superhyway/superhyway-sysfs.c b/drivers/sh/superhyway/superhyway-sysfs.c --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/superhyway/superhyway-sysfs.c 2005-03-09 16:36:31 -08:00 @@ -0,0 +1,45 @@ +/* + * drivers/sh/superhyway/superhyway-sysfs.c + * + * SuperHyway Bus sysfs interface + * + * Copyright (C) 2004, 2005 Paul Mundt [EMAIL PROTECTED] + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + */ +#include linux/kernel.h +#include linux/device.h +#include linux/types.h +#include linux/superhyway.h + +#define superhyway_ro_attr(name, fmt, field) \ +static ssize_t name##_show(struct device *dev, char *buf) \ +{ \ + struct superhyway_device *s = to_superhyway_device(dev);\ + return sprintf(buf, fmt, s-field); \ +} + +/* VCR flags */ +superhyway_ro_attr(perr_flags, 0x%02x\n, vcr.perr_flags); +superhyway_ro_attr(merr_flags, 0x%02x\n, vcr.merr_flags); +superhyway_ro_attr(mod_vers, 0x%04x\n, vcr.mod_vers); +superhyway_ro_attr(mod_id, 0x%04x\n, vcr.mod_id); +superhyway_ro_attr(bot_mb, 0x%02x\n, vcr.bot_mb); +superhyway_ro_attr(top_mb, 0x%02x\n, vcr.top_mb); + +/* Misc */ +superhyway_ro_attr(resource, 0x%08lx\n, resource.start); + +struct device_attribute superhyway_dev_attrs[] = { + __ATTR_RO(perr_flags), + __ATTR_RO(merr_flags), + __ATTR_RO(mod_vers), + __ATTR_RO(mod_id), + __ATTR_RO(bot_mb), + __ATTR_RO(top_mb), + __ATTR_RO(resource), + __ATTR_NULL, +}; + diff -Nru a/drivers/sh/superhyway/superhyway.c b/drivers/sh/superhyway/superhyway.c --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/drivers/sh/superhyway/superhyway.c2005-03-09 16:36:31 -08:00 @@ -0,0 +1,201 @@ +/* + * drivers/sh/superhyway/superhyway.c + * + * SuperHyway Bus Driver + * + * Copyright (C) 2004, 2005 Paul Mundt [EMAIL PROTECTED] + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + */ +#include linux/kernel.h +#include linux/device.h +#include linux/init.h +#include linux/module.h +#include linux/types.h +#include linux/list.h +#include linux/superhyway.h + +static int superhyway_devices; + +static struct device superhyway_bus_device = { + .bus_id = superhyway, +}; + +static void superhyway_device_release(struct device *dev) +{ + kfree(to_superhyway_device(dev)); +} + +/** + * superhyway_add_device - Add a SuperHyway module + * @mod_id: Module ID (taken from MODULE.VCR.MOD_ID). + * @base: Physical address where module is mapped. + * @vcr: VCR value. + * + * This is responsible for adding a new SuperHyway module. This sets up a new + * struct superhyway_device for the module being added. Each one of @mod_id, + * @base, and @vcr are registered with the new device for further use + * elsewhere. + * + * Devices are initially added in the order that they are scanned (from the + * top-down of the memory map), and are assigned an ID based on the order that + * they are added. Any manual addition of a module will thus get the ID after + * the devices already discovered regardless of where it resides in memory. + * + * Further work can and should be done in superhyway_scan_bus(), to be sure + * that any new modules are properly discovered and subsequently registered. + */ +int superhyway_add_device(unsigned int mod_id, unsigned long base, + unsigned long long vcr) +{ + struct superhyway_device *dev; + + dev = kmalloc(sizeof(struct superhyway_device), GFP_KERNEL