Tag: time operation Gpio device sources linu void timer __IOMEM
One beep platform-driven authoring
Gpio Resources:
Gpdcon, r/w, Address = 0xe030_0080
Timer resources: 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
For example: I want to operate the Tcon register
Pbeep->reg[timer] + TCON
Idea: To find the base address and then add the offset, you can find the corresponding register
I want to operate the TCMPB register
Pbeep->reg[timer1] + TCMPB
Linux platform device Application---beep