标签: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
标签:time 操作 gpio 设备 sources linu void 定时器 __iomem
原文地址:http://www.cnblogs.com/gaoningbo/p/6159563.html