What I have is Linux kernel module code that was originally written for a different type of processor than what I have...a Freescale Modelo which is a Coldfire v4. But the functionality of the code is what I need. So I'm looking to port the code to work with my BeagleBone. The problem is the code is referencing its target processor's memory offsets directly instead of through macros. At the simplest level, what I need to know is how I get the memory offsets for the UART I plan to use into this code. However if I can take the opportunity to clean up the code to be more usable in the future, I'd like to. For example, I'd like a single H-file to update when either the processor or the target UART changes.
Since this is a beaglebone, I'm limited to only the UARTs that have been made accessible. I'm open to suggestion as to which UART is the best to use.I believe there's an RS485 cape coming out this month and I plan to get one of them, so I'm fine writing the code assuming I'll use that UART.
I also have heard from others that Linux has some kind of UART subsystem to work with that it doesn't appear this code is using. This kernel module code uses a tasket to respond to incoming characters on the UART and appears to be manually configuring every aspect of the UART in the way the target processor's UART worked. Am I right in assuming that Linux already has a standard subsystem for kernel modules to use for doing generic things like set the baud, stop bits, data bits, etc? Or are those things all expected to be done explicitly through the custom kernel module code? Are there standard macros that are expected to be used? It might help to look at some similar code that targets the TI AM335x if anybody can direct me to that so I can see how other ARM kernel modules handle this.
I did grep through the arch/arm/mach-omap2 directory looking for UART marcos to see if anything stood out that was obvious. I did see stuff that might have been macros, but I thought before I went looking in the wrong direction, people here might be able to get me moving in the direction I need to be a little faster.
To give a little background of what I'm trying to attempt, I need a kernel module to interface to a UART because some of the things being done on the UART need to be done in as close to real time as possible. For example, there's a network token that is passed around an RS485 network. I don't want the "characters" for a token to have to be handed off to a user task. I want tokens to be recognized and handled by this kernel module using the rules of the protocol I'm writing for. Likewise, when packets other than tokens come in, I want the kernel module to determine if the packet is meant for some other device or for this device so that only data meant for this device makes it out to the user app to be processed as incoming data. Add to this, if the user app takes too long formulating a response, the kernel module needs to know to reply with a REPLY POSTPONED and pass the token to keep the network traffic moving. When the user app finally does cough up the response to transmit, the kernel module should buffer the response for the next time the token comes around to this device along with any other outgoing packets needing to be sent by that time.