⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bus.c

📁 Linux Kernel 2.6.9 for OMAP1710
💻 C
字号:
/*  * linux/arch/arm/mach-omap2/bus.c *  * Virtual bus for OMAP. Allows better power management, such as managing * shared clocks, and mapping of bus addresses to Local Bus addresses. * * Copyright (C) 2004 Texas Instruments, Inc.  *  * This package 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.  *  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.  */#include <linux/config.h>#include <linux/module.h>#include <linux/init.h>#include <linux/kernel.h>#include <linux/delay.h>#include <linux/ptrace.h>#include <linux/errno.h>#include <linux/ioport.h>#include <linux/device.h>#include <linux/slab.h>#include <linux/spinlock.h>#include <asm/hardware.h>#include <asm/mach-types.h>#include <asm/io.h>#include <asm/irq.h>#include <asm/mach/irq.h>#include <asm/arch/bus.h>static int omap2_bus_match(struct device *_dev, struct device_driver *_drv);static int omap2_bus_suspend(struct device *dev, u32 state);static int omap2_bus_resume(struct device *dev);static struct device omap2_bus_devices[OMAP_NR_BUSES] = {	{	 .bus_id = OMAP_BUS_NAME_L3}, {				       .bus_id = OMAP_BUS_NAME_L4},};static struct bus_type omap2_bus_types[OMAP_NR_BUSES] = {	{	 .name = OMAP_BUS_NAME_L3,	 .match = omap2_bus_match,	 .suspend = omap2_bus_suspend,	 .resume = omap2_bus_resume,	 }, {	     .name = OMAP_BUS_NAME_L4,	     .match = omap2_bus_match,	     .suspend = omap2_bus_suspend,	     .resume = omap2_bus_resume,	     },};static int omap2_bus_match(struct device *dev, struct device_driver *drv){	struct omap_dev *omapdev = OMAP_DEV(dev);	struct omap_driver *omapdrv = OMAP_DRV(drv);	return omapdev->devid == omapdrv->devid;}static int omap2_bus_suspend(struct device *dev, u32 state){	struct omap_dev *omapdev = OMAP_DEV(dev);	struct omap_driver *omapdrv = OMAP_DRV(dev->driver);	int ret = 0;	if (omapdrv && omapdrv->suspend)		ret = omapdrv->suspend(omapdev, state);	return ret;}static int omap2_bus_resume(struct device *dev){	struct omap_dev *omapdev = OMAP_DEV(dev);	struct omap_driver *omapdrv = OMAP_DRV(dev->driver);	int ret = 0;	if (omapdrv && omapdrv->resume)		ret = omapdrv->resume(omapdev);	return ret;}static int omap2_device_probe(struct device *dev){	struct omap_dev *omapdev = OMAP_DEV(dev);	struct omap_driver *omapdrv = OMAP_DRV(dev->driver);	int ret = -ENODEV;	if (omapdrv && omapdrv->probe)		ret = omapdrv->probe(omapdev);	return ret;}static int omap2_device_remove(struct device *dev){	struct omap_dev *omapdev = OMAP_DEV(dev);	struct omap_driver *omapdrv = OMAP_DRV(dev->driver);	int ret = 0;	if (omapdrv && omapdrv->remove)		ret = omapdrv->remove(omapdev);	return ret;}int omap_device_register(struct omap_dev *odev){	if (!odev)		return -EINVAL;	if (odev->busid < 0 || odev->busid >= OMAP_NR_BUSES) {		printk(KERN_ERR "%s: busid invalid: %s: bus: %i\n",		       __FUNCTION__, odev->name, odev->busid);		return -EINVAL;	}	odev->dev.parent = &omap2_bus_devices[odev->busid];	odev->dev.bus = &omap2_bus_types[odev->busid];	snprintf(odev->dev.bus_id, BUS_ID_SIZE, "%s%u",		 odev->name, odev->devid);	printk("Registering OMAP device '%s'. Parent at %s\n",	       odev->dev.bus_id, odev->dev.parent->bus_id);	return device_register(&odev->dev);}void omap_device_unregister(struct omap_dev *odev){	if (odev)		device_unregister(&odev->dev);}int omap_driver_register(struct omap_driver *driver){	int ret;	if (driver->busid < 0 || driver->busid >= OMAP_NR_BUSES) {		printk(KERN_ERR "%s: busid invalid: bus: %i device: %i\n",		       __FUNCTION__, driver->busid, driver->devid);		return -EINVAL;	}	driver->drv.probe = omap2_device_probe;	driver->drv.remove = omap2_device_remove;	driver->drv.bus = &omap2_bus_types[driver->busid];	/*	 * driver_register calls bus_add_driver	 */	ret = driver_register(&driver->drv);	return ret;}void omap_driver_unregister(struct omap_driver *driver){	driver_unregister(&driver->drv);}static int __init omap2_bus_init(void){	int i, ret;	/* Initialize all OMAP virtual buses */	for (i = 0; i < OMAP_NR_BUSES; i++) {		ret = device_register(&omap2_bus_devices[i]);		if (ret != 0) {			printk(KERN_ERR "Unable to register bus device %s\n",			       omap2_bus_devices[i].bus_id);			continue;		}		ret = bus_register(&omap2_bus_types[i]);		if (ret != 0) {			printk(KERN_ERR "Unable to register bus %s\n",			       omap2_bus_types[i].name);			device_unregister(&omap2_bus_devices[i]);		}	}	printk("OMAP virtual buses initialized\n");	return ret;}static void __exit omap2_bus_exit(void){	int i;	/* Unregister all OMAP virtual buses */	for (i = 0; i < OMAP_NR_BUSES; i++) {		bus_unregister(&omap2_bus_types[i]);		device_unregister(&omap2_bus_devices[i]);	}}module_init(omap2_bus_init);module_exit(omap2_bus_exit);MODULE_DESCRIPTION("Virtual bus for OMAP");MODULE_LICENSE("GPL");EXPORT_SYMBOL(omap2_bus_types);EXPORT_SYMBOL(omap_driver_register);EXPORT_SYMBOL(omap_driver_unregister);EXPORT_SYMBOL(omap_device_register);EXPORT_SYMBOL(omap_device_unregister);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -