Question

How will I map register addresses specifically UART registers to kernel for writing device drivers for UART?

I have gone through the omap-serial.c.But I did not find the mapping of the registers defined in it.

Is it different from the mapping of standalone UART driver?

Was it helpful?

Solution

As a device driver writer, it is your job to read the hardware documentation. The serial port documentation will specify the bits in the control and status registers and provide guidance on how to determine their addresses. Usually that guidance is in a system integrator's document.

Let's say your research determines that the UART's registers are at 0x31080220. Your code would then have:

struct resource *uart_res;  // resource handle
uint  *uart;                // pointer to actual control/status registers
uart_res = request_mem_region (0x31080220, 4*4, "my_uart");   // map 16 bytes
if (!uart_res)
{
     error ("unable to map memory region");
     return -ENOMEM;
}
uart = ioremap (0x31080220, 4*4);
if (!uart)
{
      release_mem_region (0x31080220, 4*4);
      error ("unable to map");
      return -ENOMEM;
}

Then you can use the uart pointer to access the registers.

status = ioread32 (uart + 0);   // read the status register
iowrite32 (0xf0f0, uart + 4);   // foo foo to control register

Give precise target information for the manufacturer, model, and options—just like an automobile—and someone will help you find the specifics.

OTHER TIPS

Mapping uart in kernel may be definded as uart device (not driver) in the some place: kernel/arch/arm/'machine'/(devices | serial or some else).

Usualy there is no neet for mapping. When uart driver probe, it connects to device and create tty character driver. To operate tty from kernel, you may add your own line discipline to tty. Then user space progam can open needed ttySX port and attach it to your line discipline. Then your code in kernel will operates communication thrue the uart port (tty->driver).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top