Add lm device required by dwc_otg driver. Signed-off-by: Layne Edwards <ledwa...@astrumtech.net>
Index: target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile =================================================================== --- target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile (revision 26476) +++ target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile (working copy) @@ -7,7 +7,7 @@ # under the terms of the GNU General Public License version 2 as published # by the Free Software Foundation. -obj-y := irq.o setup.o devices.o rt305x.o clock.o +obj-y := irq.o setup.o devices.o rt305x.o clock.o lm.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o Index: target/linux/ramips/files/arch/mips/ralink/rt305x/lm.c =================================================================== --- target/linux/ramips/files/arch/mips/ralink/rt305x/lm.c (revision 0) +++ target/linux/ramips/files/arch/mips/ralink/rt305x/lm.c (revision 0) @@ -0,0 +1,109 @@ +/* + * linux/arch/mips/ralink/rt305x/lm.c + * + * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/device.h> + +#include <asm/mach-ralink/lm.h> + +#define to_lm_device(d) container_of(d, struct lm_device, dev) +#define to_lm_driver(d) container_of(d, struct lm_driver, drv) + +static int lm_match(struct device *dev, struct device_driver *drv) +{ + return 1; +} + +static struct bus_type lm_bustype = { + .name = "logicmodule", + .match = lm_match, +// .suspend = lm_suspend, +// .resume = lm_resume, +}; + +static int __init lm_init(void) +{ + return bus_register(&lm_bustype); +} + +postcore_initcall(lm_init); + +static int lm_bus_probe(struct device *dev) +{ + struct lm_device *lmdev = to_lm_device(dev); + struct lm_driver *lmdrv = to_lm_driver(dev->driver); + + if(lmdrv->probe !=NULL) { + return lmdrv->probe(lmdev); + } + return 0; +} + +static int lm_bus_remove(struct device *dev) +{ + struct lm_device *lmdev = to_lm_device(dev); + struct lm_driver *lmdrv = to_lm_driver(dev->driver); + + if(lmdrv->remove != NULL) { + lmdrv->remove(lmdev); + } + return 0; +} + +int lm_driver_register(struct lm_driver *drv) +{ + drv->drv.bus = &lm_bustype; + drv->drv.probe = lm_bus_probe; + drv->drv.remove = lm_bus_remove; + + return driver_register(&drv->drv); +} + +void lm_driver_unregister(struct lm_driver *drv) +{ + driver_unregister(&drv->drv); +} + +static void lm_device_release(struct device *dev) +{ + struct lm_device *d = to_lm_device(dev); + + kfree(d); +} + +int lm_device_register(struct lm_device *dev) +{ + int ret; + char devname[20]; + + dev->dev.release = lm_device_release; + dev->dev.bus = &lm_bustype; + + snprintf(devname, sizeof(devname), "lm%d", dev->id); + dev_set_name(&dev->dev, devname); + dev->resource.name = dev_name(&dev->dev); +// snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id); +// dev->resource.name = dev->dev.bus_id; + + ret = request_resource(&iomem_resource, &dev->resource); + if (ret == 0) { + ret = device_register(&dev->dev); + if (ret) + release_resource(&dev->resource); + } + return ret; +} + +MODULE_LICENSE("GPL"); +EXPORT_SYMBOL(lm_device_register); //FIXME +EXPORT_SYMBOL(lm_driver_register); +EXPORT_SYMBOL(lm_driver_unregister); Index: target/linux/ramips/files/arch/mips/include/asm/mach-ralink/lm.h =================================================================== --- target/linux/ramips/files/arch/mips/include/asm/mach-ralink/lm.h (revision 0) +++ target/linux/ramips/files/arch/mips/include/asm/mach-ralink/lm.h (revision 0) @@ -0,0 +1,32 @@ +#include <linux/version.h> + +struct lm_device { + struct device dev; + struct resource resource; + unsigned int irq; + unsigned int id; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) + void *lm_drvdata; +#endif +}; + +struct lm_driver { + struct device_driver drv; + int (*probe)(struct lm_device *); + void (*remove)(struct lm_device *); + int (*suspend)(struct lm_device *, u32); + int (*resume)(struct lm_device *); +}; + +int lm_driver_register(struct lm_driver *drv); +void lm_driver_unregister(struct lm_driver *drv); + +int lm_device_register(struct lm_device *dev); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) +#define lm_get_drvdata(lm) ((lm)->lm_drvdata) +#define lm_set_drvdata(lm,d) do { (lm)->lm_drvdata = (d); } while (0) +#else +#define lm_get_drvdata(lm) dev_get_drvdata(&(lm)->dev) +#define lm_set_drvdata(lm,d) dev_set_drvdata(&(lm)->dev, d) +#endif _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel