|
@@ -240,70 +240,6 @@ void pcicore_deinit(struct pcicore_info *pch)
|
|
|
kfree(pch);
|
|
|
}
|
|
|
|
|
|
-/* return cap_offset if requested capability exists in the PCI config space */
|
|
|
-/* Note that it's caller's responsibility to make sure it's a pci bus */
|
|
|
-u8
|
|
|
-pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id,
|
|
|
- unsigned char *buf, u32 *buflen)
|
|
|
-{
|
|
|
- u8 cap_id;
|
|
|
- u8 cap_ptr = 0;
|
|
|
- u32 bufsize;
|
|
|
- u8 byte_val;
|
|
|
-
|
|
|
- /* check for Header type 0 */
|
|
|
- pci_read_config_byte(dev, PCI_HEADER_TYPE, &byte_val);
|
|
|
- if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
|
|
|
- goto end;
|
|
|
-
|
|
|
- /* check if the capability pointer field exists */
|
|
|
- pci_read_config_byte(dev, PCI_STATUS, &byte_val);
|
|
|
- if (!(byte_val & PCI_STATUS_CAP_LIST))
|
|
|
- goto end;
|
|
|
-
|
|
|
- pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &cap_ptr);
|
|
|
- /* check if the capability pointer is 0x00 */
|
|
|
- if (cap_ptr == 0x00)
|
|
|
- goto end;
|
|
|
-
|
|
|
- /* loop thru the capability list
|
|
|
- * and see if the pcie capability exists
|
|
|
- */
|
|
|
-
|
|
|
- pci_read_config_byte(dev, cap_ptr, &cap_id);
|
|
|
-
|
|
|
- while (cap_id != req_cap_id) {
|
|
|
- pci_read_config_byte(dev, cap_ptr + 1, &cap_ptr);
|
|
|
- if (cap_ptr == 0x00)
|
|
|
- break;
|
|
|
- pci_read_config_byte(dev, cap_ptr, &cap_id);
|
|
|
- }
|
|
|
- if (cap_id != req_cap_id)
|
|
|
- goto end;
|
|
|
-
|
|
|
- /* found the caller requested capability */
|
|
|
- if (buf != NULL && buflen != NULL) {
|
|
|
- u8 cap_data;
|
|
|
-
|
|
|
- bufsize = *buflen;
|
|
|
- if (!bufsize)
|
|
|
- goto end;
|
|
|
- *buflen = 0;
|
|
|
- /* copy the capability data excluding cap ID and next ptr */
|
|
|
- cap_data = cap_ptr + 2;
|
|
|
- if ((bufsize + cap_data) > PCI_SZPCR)
|
|
|
- bufsize = PCI_SZPCR - cap_data;
|
|
|
- *buflen = bufsize;
|
|
|
- while (bufsize--) {
|
|
|
- pci_read_config_byte(dev, cap_data, buf);
|
|
|
- cap_data++;
|
|
|
- buf++;
|
|
|
- }
|
|
|
- }
|
|
|
-end:
|
|
|
- return cap_ptr;
|
|
|
-}
|
|
|
-
|
|
|
/* ***** Register Access API */
|
|
|
static uint
|
|
|
pcie_readreg(struct bcma_device *core, uint addrtype, uint offset)
|