Hi Tiejun,<br><br>Thanks for the reply. I am sending you the updated dmesg O/P(after enabling CONFIG_PCI_DEBUG) as attachment as well as at the end of the mail. <br><br>As far as driver is concern, I am trying the pci_skel driver available as example with LDD book with slight modifications. <br>
 <br>Driver Code:<br>================================================================<br>#include <linux/kernel.h><br>#include <linux/module.h><br>#include <linux/pci.h><br><br>/* PCI IDs */<br>static struct pci_device_id ids[] = { <br>
  { PCI_DEVICE(0x1204, 0xe250) },<br>  { 0, }<br>};<br>MODULE_DEVICE_TABLE(pci, ids);<br><br>static unsigned char skel_get_revision(struct pci_dev *dev)<br>{<br>  u8 revision;<br><br>  pci_read_config_byte(dev, PCI_REVISION_ID, &revision);<br>
  return revision;<br>}<br><br>static u16 skel_get_vendor_id(struct pci_dev *dev)<br>{<br>  u16 vendor_id;<br><br>  pci_read_config_word(dev, PCI_VENDOR_ID, &vendor_id);<br>  return vendor_id;<br>}<br><br>static u16 skel_get_device_id(struct pci_dev *dev)<br>
{<br>  u16 device_id;<br><br>  pci_read_config_word(dev, PCI_DEVICE_ID, &device_id);<br>  return device_id;<br>}<br><br>static int probe(struct pci_dev *dev, const struct pci_device_id *id)<br>{<br>  /* Do probing type stuff here.  <br>
   * Like calling request_region();<br>   */<br>  int err, i;<br>  printk(KERN_ALERT "PCI driver: Probe function\n");<br><br>  /*<br>   * Enable the bus-master bit values.<br>   * Some PCI BIOSes fail to set the master-enable bit.<br>
   * Some demos support being an initiator, so need bus master ability.<br>   */<br>  err = pci_request_regions(dev, "pci_skell");<br>  if (err) {<br>    printk(KERN_ERR "request region failed :%d\n", err);<br>
    return err;<br>  }<br><br>  pci_set_master(dev);<br><br>  if ((err = pci_enable_device(dev)) != 0) {<br>    printk(KERN_ERR "Unable to Enable PCI device:%d\n", err);<br>    return err;<br>  }<br><br>  printk(KERN_ALERT "PCI driver Vendor ID = %x\n", skel_get_vendor_id(dev));<br>
  printk(KERN_ALERT "PCI driver Device ID = %x\n", skel_get_device_id(dev));<br>  printk(KERN_ALERT "PCI driver Revision = %d\n", skel_get_revision(dev));<br>  return 0;<br>}<br><br>static void remove(struct pci_dev *dev)<br>
{<br>  /* clean up any allocated resources and stuff here.<br>   * like call release_region();<br>   */<br>}<br><br>static struct pci_driver pci_driver = {<br>  .name = "pci_skel",<br>  .id_table = ids,<br>  .probe = probe,<br>
  .remove = remove,<br>};<br><br>static int __init pci_skel_init(void)<br>{<br>  printk(KERN_ALERT "PCI driver: Init function\n");<br>  return pci_register_driver(&pci_driver);<br>}<br><br>static void __exit pci_skel_exit(void)<br>
{<br>  printk(KERN_ALERT "PCI driver: Exit function\n");<br>  pci_unregister_driver(&pci_driver);<br>}<br><br>MODULE_LICENSE("GPL");<br><br>module_init(pci_skel_init);<br>module_exit(pci_skel_exit);<br>
================================================================<br><br>The above code fails at the pci_request_regions(dev, "pci_skell"); call, with -EBUSY(-16) i.e resource busy error. If I don't request for resources and directly enable the pci device by calling pci_device_enable(), it gives the error message<br>
<br>PCI driver: Init function<br>
PCI driver: Probe function<br>
pci_skel 0001:02:00.0: device not available (can't reserve [mem 0x00000000-0x0003ffff])<br>
Unable to Enable PCI device:-22<br>
pci_skel: probe of 0001:02:00.0 failed with error -22
                        
                <br><br><br><br>> Especially I want to know how/where you get<br>
> these two range, a8000000-a803ffff and a8040000-a807ffff. You wired them firstly<br>
> on the driver or allocated by the kernel?<br><br>Actually as I said before, I tried my device on i386 machine and there I got two ranges fe900000-fe93ffff and fe940000-fe97ffff, so from there I am guessing that on PowerPC also, it should allocate two ranges a8000000-a803ffff and a8040000-a807ffff resp.<br>
<br><br><br>lspci output<br>
================================================================<br>0000:00:00.0 Power PC: Freescale Semiconductor Inc Unknown device 00c6 (rev 21)<br>
0001:01:00.0 PCI bridge: Freescale Semiconductor Inc Unknown device 00c6 (rev 21)<br>
0001:02:00.0 Non-VGA unclassified device: Lattice Semiconductor Corporation Unknown device e250  
                        
                ----------> My device<br>
================================================================<br><br>
Dmesg with CONFIG_PCI_DEBUG enable.<br>
================================================================<br>
Using MPC837x RDB/WLAN machine description<br>Initializing cgroup subsys cpuset<br>Initializing cgroup subsys cpu<br>Linux version 2.6.35 (okapi@okapi) (gcc version 4.2.3 (Sourcery G++ Lite 4.2-171)) #13 Tue Sep 7 11:37:47 IST 2010<br>
Found initrd at 0xcf46d000:0xcf7b15b7<br>Found legacy serial port 0 for /immr@e0000000/serial@4500<br>  mem=e0004500, taddr=e0004500, irq=0, clk=399999996, speed=0<br>Found legacy serial port 1 for /immr@e0000000/serial@4600<br>
  mem=e0004600, taddr=e0004600, irq=0, clk=399999996, speed=0<br>bootconsole [udbg0] enabled<br>Found FSL PCI host bridge at 0x00000000e0008500. Firmware bus number: 0->0<br>PCI host bridge /pci@e0008500 (primary) ranges:<br>
 MEM 0x0000000090000000..0x000000009fffffff -> 0x0000000090000000 <br> MEM 0x0000000080000000..0x000000008fffffff -> 0x0000000080000000 Prefetch<br>  IO 0x00000000e0300000..0x00000000e03fffff -> 0x0000000000000000<br>
No pci config register base in dev tree, using default<br>Found FSL PCI host bridge at 0x00000000e0009000. Firmware bus number: 0->255<br>PCI host bridge /pcie@e0009000  ranges:<br> MEM 0x00000000a8000000..0x00000000b7ffffff -> 0x00000000a8000000 <br>
  IO 0x00000000b8000000..0x00000000b87fffff -> 0x0000000000000000<br>No pci config register base in dev tree, using default<br>Found FSL PCI host bridge at 0x00000000e000a000. Firmware bus number: 0->255<br>PCI host bridge /pcie@e000a000  ranges:<br>
 MEM 0x00000000c8000000..0x00000000d7ffffff -> 0x00000000c8000000 <br>  IO 0x00000000d8000000..0x00000000d87fffff -> 0x0000000000000000<br>Top of RAM: 0x10000000, Total RAM: 0x10000000<br>Memory hole size: 0MB<br>Zone PFN ranges:<br>
  DMA      0x00000000 -> 0x00010000<br>  Normal   empty<br>  HighMem  empty<br>Movable zone start PFN for each node<br>early_node_map[1] active PFN ranges<br>    0: 0x00000000 -> 0x00010000<br>On node 0 totalpages: 65536<br>
free_area_init_node: node 0, pgdat c04285e8, node_mem_map c0482000<br>  DMA zone: 512 pages used for memmap<br>  DMA zone: 0 pages reserved<br>  DMA zone: 65024 pages, LIFO batch:15<br>Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65024<br>
Kernel command line: root=/dev/ram ramdisk_size=120000 rw ip=10.20.50.230:10.20.50.70:10.20.50.50:255.255.0.0:PowerQUICC:eth0:off console=ttyS0,115200 mtdparts=nand:4m(kernel),-(jffs2)<br>PID hash table entries: 1024 (order: 0, 4096 bytes)<br>
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)<br>Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)<br>High memory: 0k<br>Memory: 251884k/262144k available (4072k kernel code, 10260k reserved, 244k data, 267k bss, 192k init)<br>
Kernel virtual memory layout:<br>  * 0xfffcf000..0xfffff000  : fixmap<br>  * 0xff800000..0xffc00000  : highmem PTEs<br>  * 0xfe6f7000..0xff800000  : early ioremap<br>  * 0xd1000000..0xfe6f7000  : vmalloc & ioremap<br>
Hierarchical RCU implementation.<br>    RCU-based detection of stalled CPUs is disabled.<br>    Verbose stalled-CPUs detection is disabled.<br>NR_IRQS:512<br>IPIC (128 IRQ sources) at d1000700<br>time_init: decrementer frequency = 99.999999 MHz<br>
time_init: processor frequency   = 799.999992 MHz<br>clocksource: timebase mult[2800000] shift[22] registered<br>clockevent: decrementer mult[19999995] shift[32] cpu[0]<br>Console: colour dummy device 80x25<br>pid_max: default: 32768 minimum: 301<br>
Security Framework initialized<br>SELinux:  Disabled at boot.<br>Mount-cache hash table entries: 512<br>Initializing cgroup subsys ns<br>Initializing cgroup subsys cpuacct<br>Initializing cgroup subsys devices<br>NET: Registered protocol family 16<br>
irq: irq 38 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 38<br>__irq_set_trigger: setting type, irq = 38, flags = 8<br>ipic_set_irq_type function, with virq = 38, flow = 8<br>irq: irq 74 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 74<br>
__irq_set_trigger: setting type, irq = 74, flags = 8<br>ipic_set_irq_type function, with virq = 74, flow = 8<br>irq: irq 75 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 75<br>__irq_set_trigger: setting type, irq = 75, flags = 8<br>
ipic_set_irq_type function, with virq = 75, flow = 8<br>PCI: Probing PCI hardware<br>pci_bus 0000:00: scanning bus<br>pci 0000:00:00.0: found [1957:00c6] class 000b20 header type 00<br>pci 0000:00:00.0: reg 10: [mem 0x00000000-0x000fffff]<br>
pci 0000:00:00.0: reg 18: [mem 0x00000000-0x0fffffff 64bit pref]<br>pci 0000:00:00.0: calling fixup_hide_host_resource_fsl+0x0/0x58<br>pci 0000:00:00.0: calling pcibios_fixup_resources+0x0/0x238<br>pci 0000:00:00.0: calling quirk_fsl_pcie_header+0x0/0x48<br>
pci 0000:00:00.0: calling quirk_resource_alignment+0x0/0x1c0<br>pci 0000:00:00.0: supports D1 D2<br>pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot<br>pci 0000:00:00.0: PME# disabled<br>pci_bus 0000:00: fixups for bus<br>
pci_bus 0000:00: bus scan returning with max=00<br>pci_bus 0001:01: scanning bus<br>pci 0001:01:00.0: found [1957:00c6] class 000b20 header type 01<br>pci 0001:01:00.0: ignoring class b20 (doesn't match header type 01)<br>
pci 0001:01:00.0: calling fixup_hide_host_resource_fsl+0x0/0x58<br>pci 0001:01:00.0: calling pcibios_fixup_resources+0x0/0x238<br>pci 0001:01:00.0: calling quirk_fsl_pcie_header+0x0/0x48<br>pci 0001:01:00.0: calling quirk_resource_alignment+0x0/0x1c0<br>
pci 0001:01:00.0: supports D1 D2<br>pci 0001:01:00.0: PME# supported from D0 D1 D2 D3hot<br>pci 0001:01:00.0: PME# disabled<br>pci_bus 0001:01: fixups for bus<br>pci 0001:01:00.0: scanning [bus 01-ff] behind bridge, pass 0<br>
pci 0001:01:00.0: bus configuration invalid, reconfiguring<br>pci 0001:01:00.0: scanning [bus 00-00] behind bridge, pass 1<br>pci_bus 0001:02: scanning bus<br>pci 0001:02:00.0: found [1204:e250] class 000000 header type 00<br>
pci 0001:02:00.0: reg 10: [mem 0xfffc0000-0xffffffff]<br>pci 0001:02:00.0: reg 14: [mem 0xfffc0000-0xffffffff]<br>pci 0001:02:00.0: calling pcibios_fixup_resources+0x0/0x238<br>pci 0001:02:00.0: calling quirk_resource_alignment+0x0/0x1c0<br>
pci_bus 0001:02: fixups for bus<br>pci 0001:01:00.0: PCI bridge to [bus 02-ff]<br>pci 0001:01:00.0:   bridge window [io  0x0000-0x0000] (disabled)<br>pci 0001:01:00.0:   bridge window [mem 0x00000000-0x000fffff] (disabled)<br>
pci 0001:01:00.0:   bridge window [mem 0x00000000-0x000fffff pref] (disabled)<br>irq: irq 1 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 16<br>__irq_set_trigger: setting type, irq = 16, flags = 8<br>
ipic_set_irq_type function, with virq = 16, flow = 8<br>pci_bus 0001:02: bus scan returning with max=02<br>pci_bus 0001:01: bus scan returning with max=02<br>pci_bus 0002:03: scanning bus<br>pci_bus 0002:03: fixups for bus<br>
pci_bus 0002:03: bus scan returning with max=03<br>PCI->OF bus map:<br>0 -> 0<br>1 -> 0<br>3 -> 0<br>PCI: Cannot allocate resource region 0 of device 0001:02:00.0, will remap<br>PCI: Cannot allocate resource region 1 of device 0001:02:00.0, will remap<br>
pci 0001:01:00.0: BAR 8: assigned [mem 0xa8000000-0xa80fffff]<br>pci 0001:01:00.0: PCI bridge to [bus 02-02]<br>pci 0001:01:00.0:   bridge window [io  disabled]<br>pci 0001:01:00.0:   bridge window [mem 0xa8000000-0xa80fffff]<br>
pci 0001:01:00.0:   bridge window [mem pref disabled]<br>pci_bus 0000:00: resource 0 [io  0x0000-0xfffff]<br>pci_bus 0000:00: resource 1 [mem 0x90000000-0x9fffffff]<br>pci_bus 0000:00: resource 2 [mem 0x80000000-0x8fffffff pref]<br>
pci_bus 0001:01: resource 0 [io  0xff7fe000-0xffffdfff]<br>pci_bus 0001:01: resource 1 [mem 0xa8000000-0xb7ffffff]<br>pci_bus 0001:02: resource 1 [mem 0xa8000000-0xa80fffff]<br>pci_bus 0002:03: resource 0 [io  0xfeffc000-0xff7fbfff]<br>
pci_bus 0002:03: resource 1 [mem 0xc8000000-0xd7ffffff]<br>Registering qe_ic with sysfs...<br>Registering ipic with sysfs...<br>bio: create slab <bio-0> at 0<br>vgaarb: loaded<br>SCSI subsystem initialized<br>Switching to clocksource timebase<br>
NET: Registered protocol family 2<br>IP route cache hash table entries: 2048 (order: 1, 8192 bytes)<br>TCP established hash table entries: 8192 (order: 4, 65536 bytes)<br>TCP bind hash table entries: 8192 (order: 3, 32768 bytes)<br>
TCP: Hash tables configured (established 8192 bind 8192)<br>TCP reno registered<br>UDP hash table entries: 256 (order: 0, 4096 bytes)<br>UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)<br>NET: Registered protocol family 1<br>
pci 0000:00:00.0: calling quirk_cardbus_legacy+0x0/0x44<br>pci 0000:00:00.0: calling quirk_usb_early_handoff+0x0/0x740<br>pci 0001:01:00.0: calling quirk_cardbus_legacy+0x0/0x44<br>pci 0001:01:00.0: calling quirk_usb_early_handoff+0x0/0x740<br>
pci 0001:02:00.0: calling quirk_cardbus_legacy+0x0/0x44<br>pci 0001:02:00.0: calling quirk_usb_early_handoff+0x0/0x740<br>PCI: CLS 32 bytes, default 32<br>Trying to unpack rootfs image as initramfs...<br>rootfs image is not initramfs (no cpio magic); looks like an initrd<br>
Freeing initrd memory: 3345k freed<br>irq: irq 9 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 17<br>__irq_set_trigger: setting type, irq = 17, flags = 8<br>ipic_set_irq_type function, with virq = 17, flow = 8<br>
irq: irq 10 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 18<br>__irq_set_trigger: setting type, irq = 18, flags = 8<br>ipic_set_irq_type function, with virq = 18, flow = 8<br>irq: irq 80 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 80<br>
__irq_set_trigger: setting type, irq = 80, flags = 8<br>ipic_set_irq_type function, with virq = 80, flow = 8<br>audit: initializing netlink socket (disabled)<br>type=2000 audit(0.212:1): initialized<br>JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.<br>
SGI XFS with security attributes, large block/inode numbers, no debug enabled<br>msgmni has been set to 498<br>alg: No test for cipher_null (cipher_null-generic)<br>alg: No test for ecb(cipher_null) (ecb-cipher_null)<br>alg: No test for digest_null (digest_null-generic)<br>
alg: No test for compress_null (compress_null-generic)<br>alg: No test for stdrng (krng)<br>Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)<br>io scheduler noop registered<br>io scheduler deadline registered<br>
io scheduler cfq registered (default)<br>Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled<br>serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 17) is a 16550A<br>console [ttyS0] enabled, bootconsole disabled<br>serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 18) is a 16550A<br>
brd: module loaded<br>of_mpc8xxx_spi_probe function called.<br>irq: irq 16 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 19<br>__irq_set_trigger: setting type, irq = 19, flags = 8<br>ipic_set_irq_type function, with virq = 19, flow = 8<br>
mpc8xxx_spi_probe function called.<br>mpc8xxx_spi e0007000.spi: at 0xd1078000 (irq = 19), CPU mode<br>irq: irq 32 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 32<br>__irq_set_trigger: setting type, irq = 32, flags = 8<br>
ipic_set_irq_type function, with virq = 32, flow = 8<br>irq: irq 33 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 33<br>__irq_set_trigger: setting type, irq = 33, flags = 8<br>ipic_set_irq_type function, with virq = 33, flow = 8<br>
irq: irq 34 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 34<br>__irq_set_trigger: setting type, irq = 34, flags = 8<br>ipic_set_irq_type function, with virq = 34, flow = 8<br>eth0: Gianfar Ethernet Controller Version 1.2, 04:00:00:00:00:0a<br>
eth0: Running with NAPI enabled<br>eth0: RX BD ring size for Q[0]: 256<br>eth0: TX BD ring size for Q[0]: 256<br>irq: irq 35 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 35<br>__irq_set_trigger: setting type, irq = 35, flags = 8<br>
ipic_set_irq_type function, with virq = 35, flow = 8<br>irq: irq 36 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 36<br>__irq_set_trigger: setting type, irq = 36, flags = 8<br>ipic_set_irq_type function, with virq = 36, flow = 8<br>
irq: irq 37 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 37<br>__irq_set_trigger: setting type, irq = 37, flags = 8<br>ipic_set_irq_type function, with virq = 37, flow = 8<br>eth1: Gianfar Ethernet Controller Version 1.2, 00:00:00:00:00:00<br>
eth1: Running with NAPI enabled<br>eth1: RX BD ring size for Q[0]: 256<br>eth1: TX BD ring size for Q[0]: 256<br>ucc_geth: QE UCC Gigabit Ethernet Controller<br>Freescale PowerQUICC MII Bus: probed<br>irq: irq 17 on host /immr@e0000000/interrupt-controller@700 mapped to virtual irq 20<br>
__irq_set_trigger: setting type, irq = 20, flags = 8<br>ipic_set_irq_type function, with virq = 20, flow = 8<br>Freescale PowerQUICC MII Bus: probed<br>mice: PS/2 mouse device common for all mice<br>Skipping unavailable LED gpio -19 (pwr)<br>
Skipping unavailable LED gpio -19 (hdd)<br>TCP cubic registered<br>NET: Registered protocol family 17<br>registered taskstats version 1<br>drivers/rtc/hctosys.c: unable to open rtc device (rtc0)<br>RAMDISK: gzip image found at block 0<br>
VFS: Mounted root (ext2 filesystem) on device 1:0.<br>Freeing unused kernel memory: 192k init<br>PHY: mdio@e0024520:02 - Link is Up - 10/Half<br>
================================================================<br>
<br>Regards<br>Ravi Gupta<br>