Ok6410 key interrupt driver

Source: Internet
Author: User

# Include <Linux/module. h> # include <Linux/init. h> # include <Linux/miscdevice. h> # include <Linux/interrupt. h> # include <Linux/Fs. h> # include <Linux/Io. h> # define gpncon 0x7f008830 // address used by ioremap, irqreturn_t key_int (int irq, void * dev_id) {printk ("key down! \ N "); Return 0;} void key_hw_init (void) {unsigned short data; unsigned int * gpio_config; gpio_config = ioremap (gpncon, 4); Data = readw (gpio_config ); data & = ~ 0b11; Data | = 0b10; writew (data, gpio_config);} int key_open (struct inode * node, struct file * filp) {return 0;} struct file_operations key_fops = {. open = key_open,}; struct miscdevice key_miscdev = {. minor = 200 ,. name = "ok6410key ",. foPs = & key_fops,}; static int button_init (void) {int err; misc_register (& key_miscdev); key_hw_init (); If (ERR = request_irq (initi_eint (0 ), key_int, ir1__trigger_falling, "ok6410key", 0) <0) {printk ("Err = % d \ n", err); goto irq_err;} return 0; irq_err: misc_deregister (& activities); Return-1;} static void button_exit (void) {free_irq (initi_eint (0), 0); misc_deregister (& key_miscdev);} module_init (button_init ); module_exit (button_exit); module_license ("GPL"); module_description ("key driver ");

1. First, check the schematic and find the key and CPU link location and interrupt number. As shown in, this program uses keyint1 as an example to describe how to write the key driver. You can see that keyint1 is connected to gpn0, And the interrupt number used is xeint0.


2. Check Datasheet and find gpn0. The gpncon address is 0x7f008830, which is used in ioremap. You can also see that the interruption trigger method is to set bits [1:0] of gpn0 to 10.


3. Open Linux/ARCH/ARM/mach-s3c64xx/include/Mach/irqs. h under the kernel directory to find the interrupt number definition for External Interrupt 0. This definition is found in Row 3.



Ok6410 key interrupt driver

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.