简体   繁体   中英

use uart driver from linux kernel

There is an external device (sensor keyboard) connected to processor thrue uart port (tx rx) and gpio interrupt line. Need to write driver for this keyboard (not standart own protocol, linux kernel 4.1).

I writed module whith a line discipline and requested irq on open() function (when open from user space /dev/ttymxc3). It's work, but line discipline structure has no released callbacks for suspend and resume functions.

It's need to release sleep keyboard when system is sleeping.

I try to write tty driver that use uart driver, but don't know how. How to communicate from kernel module with external devices thrue uart port?

Thanks.

You can use uart device in kernel space

    // call userspace
    {
            mm_segment_t fs;
            fs=get_fs();
            set_fs(get_ds());//KERNEL DS
            handle = sys_open(UTS_UART_DEV_NAME, O_RDWR | O_NOCTTY | O_NONBLOCK, 0);
            if( handle < 0 )
            {
                    printk(KERN_INFO "UTS Port Open Fail [%s] \n ", UTS_UART_DEV_NAME);
                    return -1;
            }

            set_fs(fs);
    }
    // call userspace

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM