LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Serial port module in kernel. (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/serial-port-module-in-kernel-4175509034/)

ar1234mo 06-24-2014 12:47 PM

Serial port module in kernel.
 
Hi,
I consulted a old thread which talked about this http://www.linuxquestions.org/questi...959/page2.html
I am doing an expermient with TDMA on wifi for which I need access to serial port so that I can log receiving data from Wifi.I figured if I can just have a RTS pin toggled on demand I can do my work.

Reading te post I first recompiled my kernel to modularize serial port.Now if I insmod and serial_core.ko and 8250.ko the serial mode starts working (I test using a loopback test) the dmesg at that time says
"Serial :8250/16550 driver ,4 ports IRQ sharing disbaled"
:serial8250.o: ttyS0 at MMIO 0x70006000 (irq=68) is a Xscale"
SO i assume the port address is 0x70006000
no here is the kernel code I have written.Right now I am just trying to make a square wave to see if I can toggle a pin on deman

Code:
Code:

#include <linux/module.h>
#include <linux/version.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/serial_reg.h>
#define MOD_NAME "serialmodule"
#define SERIAL_PORT_BASE 0x70006000


int __init enter_module(void)

{

        int n=0;
        int err;



 

 if(!request_region(SERIAL_PORT_BASE,8,MOD_NAME))

return 0;

else {

printk("working");

        //turn off dlab

  outb((~(UART_LCR_DLAB)), SERIAL_PORT_BASE+UART_LCR);

       

        //disable interrupts

    outb((~(UART_IER_MSI|UART_IER_RLSI|UART_IER_THRI|UART_IER_RDI)), SERIAL_PORT_BASE+UART_IER);

                        while(n<50)

        {

                outb((~(UART_MCR_RTS)), SERIAL_PORT_BASE+UART_MCR);

               

                msleep(500);

               

               

                outb(UART_MCR_RTS, SERIAL_PORT_BASE+UART_MCR);

                msleep(500);

                n++;

        }

        return 0;}

}



void __exit cleanup_module1(void)

{ release_region(SERIAL_PORT_BASE, 8);

}



module_init(enter_module);

module_exit(cleanup_module1);



MODULE_LICENSE("GPL");

MODULE_AUTHOR("ARul Moondra_ISIS");

MODULE_DESCRIPTION("RTS SQAURE WAVE");


This never enters the "else" block also when I rmmod see in dmesg "trying to free nonexistent resource <000000070006000-00000000700060007>"

Can some one help me.I am using trimslice by compulab with kernel 3.1.10

smallpond 06-26-2014 11:05 AM

MMIO refers to mapping I/O space to memory space, so that the I/O instructions (inb, outb, etc) are not used. The memory address is not fixed so you can't use a fixed value in your code.


All times are GMT -5. The time now is 10:47 AM.