码迷,mamicode.com
首页 > 系统相关 > 详细

14 Linux平台设备应用---beep

时间:2016-12-11 15:17:25      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:time   操作   gpio   设备   sources   linu   void   定时器   __iomem   

一 beep平台驱动编写

GPIO资源:
GPDCON, R/W, Address = 0xE030_0080


定时器资源:TIMER1


#define S5PC100_PA_GPIO 0xE0300080
#define S5PC100_PA_TIMER 0xEA000000
#define S5PC100_PA_TIMER1 0xEA000018
#define SZ_4 0x00000004


struct resource s5pc100_beep_resource = {
[0] = {
.start = S5PC100_PA_GPIO,
.end = S5PC100_PA_GPIO + SZ_4 - 1,
.flags = IORESOURCE_MEM,
},

[1] = {
.start = S5PC100_PA_TIMER,
.end = S5PC100_PA_TIMER + SZ_4*3 - 1,
.flags = IORESOURCE_MEM,
},

[2] = {
.start = S5PC100_PA_TIMER1,
.end = S5PC100_PA_TIMER1 + SZ_4*3 - 1,
.flags = IORESOURCE_MEM,
},

}

struct platform_device = {
.name = "s5pc100-beep",
.id = -1,
.resource = s5pc100_beep_resource,
.num_resources = ARRAY_SIZE(s5pc100_beep_resource),
.dev = {
.release = s5pc100beep_release,
},
};

 

----------------------------------------------------------------------------------

enum reg_type = {
GPIO,
TIMER,
TIMER1,
};

struct beep_device
{
dev_t dev_num;
void * __iomem reg[3];
struct cdev cdev;
struct class *cls;
struct device *device;
struct resource *res[3];
};


for(i = 0;i < 3;i ++)
pbeep->reg[i] = ioremap;

 

#define TCFG0 0
#define TCFG1 4
#define TCON 8

#define TCNTB 0
#define TCMPB 4


例如:我想操作TCON寄存器

pbeep->reg[TIMER] + TCON

思路:先找基地址然后加上偏移,就可以找到对应的寄存器
我想操作TCMPB寄存器
pbeep->reg[TIMER1] + TCMPB

 

14 Linux平台设备应用---beep

标签:time   操作   gpio   设备   sources   linu   void   定时器   __iomem   

原文地址:http://www.cnblogs.com/gaoningbo/p/6159563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!