QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1338|回复: 0

at91rm9200 红外驱动

[复制链接]
发表于 2006-4-25 16:05:00 | 显示全部楼层 |阅读模式
现在做9200的红外,用irtty-sir+dongle做,dongle是模访driver/net/irda/ep7211_ir.c写的.就是在在OPEN里使能UART的红外模式,编译通过了。但我用irattach绑定ttyS3时,irda_config_fsm出错,找到函数看,说是dongle没注册。我用的是2。6。15内核,里面用的是新的irtty,Kconfig里说:和ep7211_ir类似的要用旧的irtty,有没有做过呢?我在网上看到,Linux 2.6.8.1 for Cirrus Logic ARM Processors(http://arm.cirrus.com/)里边的红外驱动和我的类似,但它是和新的irtty-sir.c一起用的,是不是我内核配置不对呢?帮帮忙,指条明路。
谢谢!
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/tty.h>
#include <linux/sched.h>
#include <linux/init.h>

#include <net/irda/irda.h>
#include <net/irda/irmod.h>
#include <net/irda/irda_device.h>

#include <asm/io.h>
#include <asm/hardware.h>
#include <asm/arch/at91rm9200_usart.h>
#include <asm/mach/serial_at91rm9200.h>
#include <asm/arch/board.h>
#include <asm/arch/pio.h>

#if 0
#undef DEBUG
//#define DEBUG 1
#ifdef DEBUG
#define DPRINTK( x... ) printk( ##x )
#else
#define DPRINTK( x... )
#endif
#endif

#define DPRINTK(...) printk( WDEBUG_HDR \
"Oliver :"__VA_ARGS__ )

static void __iomem *membase=(void __iomem *) AT91_VA_BASE_US2;

/*
* We need access to the UART2 control register so we can
* do a read-modify-write and enable SIR.
*/

static void at91_sir_open(dongle_t *self, struct qos_info *qos);
static void at91_sir_close(dongle_t *self);
static int at91_sir_change_speed(struct irda_task *task);
static int at91_sir_reset(struct irda_task *task);

static struct dongle_reg dongle = {
Q_NULL,
IRDA_at91_SIR,
at91_sir_open,
at91_sir_close,
at91_sir_reset,
at91_sir_change_speed
};


static void at91_sir_open(dongle_t *self, struct qos_info *qos)
{
unsigned int uiTemp;

DPRINTK("----------------\n at91_sir_open \n-----------------\n");

/*
* Set UART3 to be an IrDA interface
*/
uiTemp = readl(membase + AT91_US_MR);
uiTemp |= AT91_US_USMODE_IRDA;
writel(membase + AT91_US_MR,uiTemp);
writel(membase + AT91_US_IF);

}

static void at91_sir_close(dongle_t *self)
{
unsigned int uiTemp;

DPRINTK("----------------\n at91_sir_close \n-----------------\n");


/*
* Set UART3 to be an UART
*/
uiTemp = readl( membase + AT91_US_MR );
writel(membase + AT91_US_MR, uiTemp & 0xfffffff0);
}

/*
* Function at91_sir_change_speed (task)
*
* Change speed of the at91 I/R port. We don't have to do anything
* here as long as the rate is being changed at the serial port
* level. irtty.c should take care of that.
*/
static int at91_sir_change_speed(struct irda_task *task)
{
DPRINTK("----------------\n at91_sir_change_speed \n-----------------\n");
irda_task_next_state(task, IRDA_TASK_DONE);
return 0;
}

/*
* Function at91_sir_reset (task)
*
* Reset the at91 IrDA. We don't really have to do anything.
*
*/
static int at91_sir_reset(struct irda_task *task)
{
DPRINTK("----------------\n at91_sir_reset \n-----------------\n");
irda_task_next_state(task, IRDA_TASK_DONE);
return 0;
}

/*
* Function at91_sir_init(void)
*
* Initialize at91 IrDA block in SIR mode.
*
*/
int __init at91_sir_init(void)
{
printk( WDEBUG_HDR "Oliver in at91_sir_init\r\n" );
DPRINTK("----------------\n at91_sir_init \n-----------------\n");
return irda_device_register_dongle(&dongle);
}

/*
* Function at91_sir_cleanup(void)
*
* Cleanup at91 IrDA module
*
*/
static void __exit at91_sir_cleanup(void)
{
DPRINTK("----------------\n at91_sir_cleanup \n-----------------\n");
irda_device_unregister_dongle(&dongle);
}


module_init(at91_sir_init);
module_exit(at91_sir_cleanup);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-27 04:45 , Processed in 0.043987 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表