Hi Jaski,
I tried the code in x86 based platform with 32 bit Ubuntu 16.04 OS and I am able to toggle the LED by writing to PCI register Offsets. The following code samples are working fine in x86 based platform with 32 bit Ubuntu 16.04 OS.
-
struct pci_dev *dev = NULL;
unsigned long base = 0, len = 0;
dev = pci_get_device(VENDOR_ID,DEVICE_ID,NULL);
pci_enable_device(dev);
base = pci_resource_start(dev, 0);
outb((0x01),(base+0x74));
-
struct pci_dev *dev = NULL;
unsigned long len = 0, baseaddress = 0;
dev = pci_get_device(VENDOR_ID,DEVICE_ID,NULL);
pci_enable_device(dev);
len = pci_resource_len(dev, 0);
baseaddress = pci_iomap(dev, 0, len);
outb((0x01),(baseaddress+0x74));
I have noticed that in Apalis imx6 Angstrom Linux which I am using, PCI is not listed in cat /proc/iomem
It seems like PCI is not mapped to memory and I am getting segmentation fault on accessing the address received from pci_resource_start as well as from pci_iomap.
I am receiving FFFFFF00 from pci_resource_start() function and FEEFFF00 from pci_iomap() function.
and the maximum address listed in cat /proc/iomem is
10000000 - 8FFFFFFF : System RAM
10008000 - 108ac063 : Kernel code
10900000 - 109b14cf : Kernel data
Please let me know whether we need to configure anything at the time of building the OS for the PCI bus to be mapped in /proc/iomem
I have found an article at [2/2] PCI: Do not call pci_enable_resource when specifying PCI_PROBE_ONLY - Patchwork saying that:
When using PCI_PROBE_ONLY, Linux does not assign resource to PCI devices.
This causes error when calling the pci_enable_resources function, and not
allowing driver to set the PCI_COMMAND_IO and PCI_COMMAND_MEMORY flag in
the config space of endpoint device since it checks if the resource parent
is set.
Do we need to do anything before building the imx6 Linux image such that this flag is not set.
Please provide your inputs.
Thanks,
bevincb