Linux platform device Application---beep

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.