105 Parallel Port Device Drivers DevelopmentIssues, queries, suggestions or discussion related to Device drivers, parallel port device drivers, Linux based parallel port driver.
Normally when a computer is turned on, its the kernel who acquire the parallel ports and you can see it by going into proc/ioports. But if we want our device to communicate with the I/O port then we need to acquire those ports from the kernel. There are certain commands in linux by which we can get those ports . All these commands are defined in <linux/ioport.h> and <linux/io.h>.
struct resource *request_region(): Registration interface which allows your kernel to claim the ports it need. void release_region(): When things are done with the I/O ports, use this command to release them. int check_region(): If you want to check whether the requested address regions are available or not , use this command. unsigned inb() and void outb(): These commands are used to read/write to and from the parallel port. Used in byte transfer. unsigned inw() and void outw(): There are used to access 16 bit ports i.e one work transfer and receive. unsigned inl() and void outl(): these are used to access 32 bit ports or 32 bit longword.
// for parallel port check if ports are acquired or not //iomem_map_sanity_check(resource_size_t addr, unsigned long size); //ppret = check_region(DATA_PORT_ADD, 3); ppret = iomem_map_sanity_check(DATA_PORT_ADD, 3); if (ppret == 0) { request_region(DATA_PORT_ADD, 3, DEVNAME); } else { release_region(DATA_PORT_ADD,3); request_region(DATA_PORT_ADD, 3, DEVNAME); }
Since check_region did not work in 4.x kernel, i used iomem_map_sanity_check(DATA_PORT_ADD, 3); here DATA_PORT_ADD = 0x378.