0

I want to allocate a I/O memory for my UART4 with the base address 0x4806 E000 and size is 1KB.

struct resource *request_mem_region(unsigned long start, unsigned long len,
char *name);

What value should be given to the 2nd and 3rd function parameters/

  1. len - since the size is 1KB is it 1000?
  2. name - I have no idea of where this pointer pointing to..

Please clear my doubts

ddpd
  • 603
  • 1
  • 10
  • 25
  • Traditionally in the computing world 1kB has always been 1024 bytes. It's lately that some want to change it, and for hard-drives 1kB has been 1000 bytes for a long time (which is somewhat confusing). – Some programmer dude Apr 02 '14 at 06:51
  • @JoachimPileborg what value does it suit in my situation as it is a memory region ?1000 or 1024 ? – ddpd Apr 02 '14 at 06:59
  • @Dino len: If suppose uart4 controller has 10 32bit registers then len would be 10 * 4bytes = 40 bytes. Name, would be usually device or module name, which will be used for "proc" file system purpose. – Gautham Kantharaju Apr 02 '14 at 09:00
  • @GauthamKantharaju.Thanks Gautam.But how will I get to know the number of registers? The register manual of the UART(omap 4460) has many number of registers.should I Count all of these?/will it be mentioned elsewhere? Also some registers are having the same address.what does this count for? – ddpd Apr 02 '14 at 09:23
  • 1
    @Dino, Consider all the registers to be safe and will be mapped also and can be used at later point of time if needed. UART related registers will be mentioned in OMAP technical reference manual TRM. Yes for ex: UART "THR" and "RHR" and some other registers will be having the same address. Based on for ex: EFR register configuration, supported registers are mapped and used. – Gautham Kantharaju Apr 03 '14 at 04:42
  • @GauthamKantharaju.Can you please answer this question [link](http://stackoverflow.com/questions/22809480/sdifference-between-device-register-and-driver-register). – ddpd Apr 03 '14 at 05:37
  • @GauthamKantharaju.When I use request_mem_region I am getting an error "undeclared (first use in this function).As per the LDD book the interface for memory allocation is defined in linux/ioport.h.Hence i am just calling like 'req_mem = (*request_mem_region)(UART_BASE,UART_SIZE,UART_DRIV)' and this is the same with ioremap function.Will the function name change since the function is defined for kernel 2.6 and below But I am using 3.4. Please help .Iam stuck – ddpd Apr 03 '14 at 12:06
  • @GauthamKantharaju :: Can you please answer this [Question](http://stackoverflow.com/questions/23078968/call-to-request-mem-region-fails) – ddpd Apr 15 '14 at 09:24
  • @Dino, request_mem_region is present in linux 3.4 kernel http://lxr.free-electrons.com/ident?v=3.4;i=request_mem_region. Before requesting, check if the requested region is already requested i.e. by checking the output of "cat /proc/iomem", in such case you can directly go ahead and use "ioremap" and configure the UART related registers. Share your code snippet if possible. – Gautham Kantharaju Apr 16 '14 at 04:04
  • @GauthamKantharaju: Yeah the requested region is already present in /proc/iomem.So I have skipped request_mem_region and using only ioremap.After the pad configuration(UART4), I am doing a software reset which fails as the loop goes to infinite loop.device name is "tty0uart". – ddpd Apr 16 '14 at 04:24
  • @Dino, maybe polling logic w.r.t reset bit is not correct and thus it's going to infinite loop. Check and give me link to your code snippet or add it here. – Gautham Kantharaju Apr 16 '14 at 04:37
  • @GauthamKantharaju:I still have doubt whether data has written exactly to a mentioned address. `unsigned long pad_value = 0xFFF8FFF8; /* Pad Configuration */ pad_map = ioremap(UART4_PADCONF_RX_TX,4); if(pad_map == NULL) { printk(KERN_ALERT " unable to pad_remap \n"); } writel(pad_value,pad_map); /* Software reset */ serial_out(&uper,UART_OMAP_SYSC,swreset); while(((serial_in(&uper,UART_OMAP_SYSS)) & 0x01)!= 1 );` – ddpd Apr 16 '14 at 04:59
  • @GauthamKantharaju:serial out and serial_in goes like this `static inline void serial_out(struct uart_omap_port *up, int offset, int value) { offset <<= up->port.regshift; writew(value,io_map + offset); }static inline unsigned int serial_in(struct uart_omap_port *up, int offset) { offset <<= up->port.regshift; return readw(io_map + offset); }` – ddpd Apr 16 '14 at 04:59
  • @Dino, use ioread[8|16|32] and iowrite[8|16|32] instead of writew or readw. Is "io_map" is the return virtual address from ioremap? – Gautham Kantharaju Apr 16 '14 at 05:38
  • @GauthamKantharaju:Yeah I will try using ioread.yeah ioremap is defined as `io_map = ioremap(UART4_BASE,UART_SIZE);#define UART4_BASE 0x4806E000 #define UART_SIZE 256` – ddpd Apr 16 '14 at 05:50
  • @Dino, compare "offset" value with that of register offset value as in reference manual. I am doubting offset calculation related code. There is no need to calculate offset, you can use the same offset of the register as defined in reference manual, only thing is that you need to add offset with the return value got from ioremap api and pass it to ioread|iowrite api. For ex: If THR register offset is 0x100 then ioread(val, io_map + 0x100); – Gautham Kantharaju Apr 16 '14 at 06:19
  • @GauthamKantharaju:`offset` seems fine as the value is for `regshift` is always 2.Since this method and the offset is defined in the [omap-serial.c](http://lxr.free-electrons.com/source/drivers/tty/serial/omap-serial.c?v=3.4) I had retained the same – ddpd Apr 16 '14 at 06:46
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/50757/discussion-between-gautham-kantharaju-and-dino) – Gautham Kantharaju Apr 16 '14 at 07:59

0 Answers0