Re: new comer to understanding PCI device drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bond wrote:
> Hi,
> I have been reading some books about device driver development etc.I
> made a char driver of bond (dummy) device.
> My book says that PCI devices contain three addressable regions,
> configuration space,IO ports,and device memory,the book talks about a
> file include/linux/pci_ids.h and PCI addressing etc.I read about
> following functions
> 1) pci_read_config_
> 2) pci_write_config_
> 
> some thing known as offset is defined to be passed on as an argument
> to above functions

If you don't know what exactly happens with these functions then you don't 
need them. Really. The kernel sets up the structs it passes to the drivers in 
a correct way, you barely ever need to touch the config space yourself. For 
most things where you need it there are proper accessor functions.

> 3) IRQ number assigned to a card function pci_read_config_byte_
> ,configuration register offsets

You will never do this yourself. You just call pci_request_irq() and the 
kernel core will do anything for you that happens in PCI config space.

> 4) pci_request_region

With this function you map the PCI BAR to a kernel accessible address so you 
can read and write to them (e.g. with ioread32() and friends).

> I want to write a pci driver for my own understanding and I am reading
> some books about it.
> I am not clear with terms
> 1) configuration space,
> 2) I/O ports

You don't need that. Really.

> 3) device memory

That's the PCI BARs, e.g. the address range the PCI device is accessed by. It 
is device specific what happens there. You request access to that memory from 
the kernel and then read and write how ever the device needs it.

> 4) the offsets defined in include/linux/pci_ids.h

There are no offsets. The class codes are usually of no interest to you. You 
only need the vendor ids if they match a device you would like to handle. If 
there is no such define: no problem, just pass the numbers in struct 
pci_device_id.

> 5) PCI addressing.

Whatever you mean with that. In general you don't need to care about any PCI 
specific stuff. The kernel has function for you to talk to the device. Use them 
and let the kernel do anything else. It knows better than you what he needs to 
do.

Eike

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux