<div dir="ltr"><div>retval = pci_enable_device(dev);<br> if (retval)<br> {<br> printk(KERN_ERR "Unable to enable this PCI device\n");<br> return retval;<br> }<br> else<br> {<br> printk(KERN_INFO "PCI device enabled\n");<br> }<br><br> display_pci_config_space(dev);<br><br> retval = pci_request_regions(dev, "expt_pci");<br> if (retval)<br> {<br> printk(KERN_ERR "Unable to acquire regions of this PCI device\n");<br> pci_disable_device(dev);<br> return retval;<br> }<br> else<br> {<br> printk(KERN_INFO "PCI device regions acquired\n");<br> }<br><br> if ((dpv->reg_base = ioremap(pci_resource_start(dev, 2), pci_resource_len(dev, 2))) == NULL)<br> {<br> printk(KERN_ERR "Unable to map registers of this PCI device\n");<br> pci_release_regions(dev);<br> pci_disable_device(dev);<br> return -ENODEV;<br> }<br> printk(KERN_INFO "Register Base: %p\n", dpv->reg_base);<br><br> printk(KERN_INFO "IRQ: %u\n", dev->irq);<br> <br> printk(KERN_INFO "dpv->reg_base value is: %x\n",dpv->reg_base);<br><br> pci_set_drvdata(dev, dpv);<br><br>printk(KERN_INFO "PCI device registered\n");<br><br> printk(KERN_INFO "Expt: In write\n"); <br> //iowrite8(MY_BYTE,dev->resource[0].start);<br> uint32_t a = 0x01;<br> uint32_t addr;<br> iowrite8(a, dpv->reg_base);<br> printk("value written is %d\n",a);<br> printk(KERN_INFO "Expt: In read\n");<br> //addr = ioread8(dev->resource[0].start );<br> addr = ioread8(dpv->reg_base );<br> printk("Value read is %d\n",addr);<br><br></div>THE OUTPUT i am getting is this:<br><div><br>[ 6482.783371] PCI device regions acquired<br>[ 6482.795801] Register Base: ffffc90015b00000<br>[ 6482.795803] IRQ: 16<br>[ 6482.795804] dpv->reg_base value is: 15b00000<br>[ 6482.795805] PCI device registered<br><b>[ 6482.795806] Expt: In write<br>[ 6482.795807] value written is 1<br>[ 6482.795808] Expt: In read<br>[ 6482.795810] Value read is 0</b><br>[ 6482.795836] Expt PCI driver registered<br><br><br></div><div>Can you tell me what am i doing wrong?<br><br></div><div>Regards<br><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 28, 2015 at 10:36 AM, Sudip Mukherjee <span dir="ltr"><<a href="mailto:sudipm.mukherjee@gmail.com" target="_blank">sudipm.mukherjee@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Apr 28, 2015 at 10:25 AM, Robert Clove <<a href="mailto:cloverobert@gmail.com">cloverobert@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I am trying to write and read PCI BAR address but not getting the expected<br>
> output.<br>
> I am using the ioremap api to get the address.<br>
> Any leads will be fruit full.<br>
<br>
</div></div>can you please post what you have tried till now...<br>
<br>
regards<br>
<span class="HOEnZb"><font color="#888888">sudip<br>
</font></span></blockquote></div><br></div>