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

📄 at91_uart_open.c

📁 at91rm9200 linux 下t6963的驱动
💻 C
字号:
/* * can_open - can4linux CAN driver module * * * can4linux -- LINUX CAN device driver source *  * Copyright (c) 2001 port GmbH Halle/Saale * (c) 2001 Heinz-J黵gen Oertel (oe@port.de) *          Claus Schroeter (clausi@chemie.fu-berlin.de) * derived from the the LDDK can4linux version *     (c) 1996,1997 Claus Schroeter (clausi@chemie.fu-berlin.de) *------------------------------------------------------------------ * $Header: /z2/cvsroot/products/0530/software/can4linux/src/can_open.c,v 1.9 2004/12/14 09:36:35 oe Exp $ * *-------------------------------------------------------------------------- * * * modification history * -------------------- * $Log: can_open.c,v $ * Revision 1.9  2004/12/14 09:36:35  oe * - Release for kernel 2.6 with support for 82527 included * * Revision 1.8  2004/05/14 10:02:54  oe * - started supporting CPC-Card * - version number in can4linux.h available * - only one structure type for Config_par_t Command_par_t * - new ioctl command CMD_CLEARBUFFERS * * Revision 1.7  2003/08/27 13:06:27  oe * - Version 3.0 * * Revision 1.6  2003/07/05 14:28:55  oe * - all changes for the new 3.0: try to eliminate hw depedencies at run-time. *   configure for HW at compile time * * Revision 1.5  2002/08/08 18:03:41  oe * *** empty log message *** * * Revision 1.4  2001/09/14 14:58:09  oe * first free release * * Revision 1.3  2001/09/04 15:51:44  oe * changed struct file_operations can_fops * * Revision 1.2  2001/06/15 15:32:44  oe * - added PCI support EMS CPC-PCI * * Revision 1.1.1.1  2001/06/11 18:30:54  oe * minimal version can4linux embedded, compile time Konfigurierbar * * Revision 1.1  2001/06/07 08:29:24  oe * Initial revision * * * * *-------------------------------------------------------------------------- *//*** \file can_open.c* \author Heinz-J黵gen Oertel, port GmbH* $Revision: 1.9 $* $Date: 2004/12/14 09:36:35 $***//* header of standard C - libraries *//* #include <linux/module.h>			 *//* header of common types *//* shared common header *//* header of project specific types *//* project headers */#include "at91_uart_defs.h"/* local header *//* constant definitions---------------------------------------------------------------------------*//* local defined data types---------------------------------------------------------------------------*//* list of external used functions, if not in headers---------------------------------------------------------------------------*//* list of global defined functions---------------------------------------------------------------------------*//* list of local defined functions---------------------------------------------------------------------------*//* external variables---------------------------------------------------------------------------*//* global variables---------------------------------------------------------------------------*//* local defined variables---------------------------------------------------------------------------*//* static char _rcsid[] = "$Id: can_open.c,v 1.9 2004/12/14 09:36:35 oe Exp $"; *//***************************************************************************//**** \brief int open(const char *pathname, int flags);* opens the CAN device for following operations* \param pathname device pathname, usual /dev/can?* \param flags is one of \c O_RDONLY, \c O_WRONLY or \c O_RDWR which request*       opening  the  file  read-only,  write-only  or read/write,*       respectively.*** The open call is used to "open" the device.* Doing a first initialization according the to values in the /proc/sys/Can* file system.* Additional an ISR function is assigned to the IRQ.** The CLK OUT pin is configured for creating the same frequency* like the chips input frequency fclk (XTAL). ** If Vendor Option \a VendOpt is set to 's' the driver performs* an hardware reset befor initializing the chip.** \returns* open return the new file descriptor,* or -1 if an error occurred (in which case, errno is set appropriately).** \par ERRORS* the following errors can occur* \arg \c ENXIO  the file is a device special file* and no corresponding device exists.* \arg \c EINVAL illegal \b minor device number* \arg \c EINVAL wrong IO-model format in /proc/sys/Can/IOmodel* \arg \c EBUSY  IRQ for hardware is not available* \arg \c EBUSY  I/O region for hardware is not available*/int at91_uart_open( __LDDK_OPEN_PARAM ){int retval = 0;	unsigned int minor = __LDDK_MINOR;		struct at91_uart_port *port=&at91_ports[minor];	file->private_data = &at91_ports[minor]; 		(*port->fun)();		if( port->Can_isopen == 1) {	    return -ENXIO;	}		if(NULL == request_mem_region(port->base, 0x4000, "at91_uart_mem")) {		return -EBUSY;	}		port->membase = ioremap(port->base, 0x4000);	at91_startup(port);	++(port->Can_isopen);    return retval;}

⌨️ 快捷键说明

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