diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b57af3278a6..11f4717edf0 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2066,15 +2066,84 @@ int pci_dev_register(void) return register_driver("/dev/pci", &g_pci_fops, 0666, NULL); } +/**************************************************************************** + * Name: pci_bus_read_config_xxx + * + * Description: + * Read pci device config space + * + * Input Parameters: + * bus - The PCI device to belong to + * devfn - The PCI device number and function number + * where - The register address + * val - The data buf + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + PCI_BUS_READ_CONFIG(byte, uint8_t, 1) PCI_BUS_READ_CONFIG(word, uint16_t, 2) PCI_BUS_READ_CONFIG(dword, uint32_t, 4) + +/**************************************************************************** + * Name: pci_bus_write_config_xxx + * + * Description: + * Write pci device config space + * + * Input Parameters: + * bus - The PCI device to belong to + * devfn - The PCI device number and function number + * where - The register address + * val - The data + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + PCI_BUS_WRITE_CONFIG(byte, uint8_t, 1) PCI_BUS_WRITE_CONFIG(word, uint16_t, 2) PCI_BUS_WRITE_CONFIG(dword, uint32_t, 4) + +/**************************************************************************** + * Name: pci_bus_read_io_xxx + * + * Description: + * Read pci device io space + * + * Input Parameters: + * bus - The PCI device belong to + * where - The address to read + * val - The data buffer + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + PCI_BUS_READ_IO(byte, uint8_t, 1) PCI_BUS_READ_IO(word, uint16_t, 2) PCI_BUS_READ_IO(dword, uint32_t, 4) + +/**************************************************************************** + * Name: pci_bus_write_io_xxx + * + * Description: + * Write pci device io space + * + * Input Parameters: + * bus - The PCI device belong to + * where - The address to write + * val - The data + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + PCI_BUS_WRITE_IO(byte, uint8_t, 1) PCI_BUS_WRITE_IO(word, uint16_t, 2) PCI_BUS_WRITE_IO(dword, uint32_t, 4) diff --git a/include/nuttx/pci/pci.h b/include/nuttx/pci/pci.h index 142cc29b730..43c4ef1f048 100644 --- a/include/nuttx/pci/pci.h +++ b/include/nuttx/pci/pci.h @@ -359,11 +359,38 @@ int pci_bus_read_config(FAR struct pci_bus_s *bus, unsigned int devfn, int where, int size, FAR uint32_t *val); +/**************************************************************************** + * Name: pci_bus_read_config_xxx + * + * Description: + * Read pci device config space + * + * Input Parameters: + * bus - The PCI device to belong to + * devfn - The PCI device number and function number + * where - The register address + * val - The data buf + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + +int pci_bus_read_config_byte(FAR struct pci_bus_s *bus, + unsigned int devfn, int where, + FAR uint8_t *val); +int pci_bus_read_config_word(FAR struct pci_bus_s *bus, + unsigned int devfn, int where, + FAR uint16_t *val); +int pci_bus_read_config_dword(FAR struct pci_bus_s *bus, + unsigned int devfn, int where, + FAR uint32_t *val); + /**************************************************************************** * Name: pci_bus_write_config * * Description: - * read pci device config space + * Write pci device config space * * Input Parameters: * bus - The PCI device to belong to @@ -381,6 +408,33 @@ int pci_bus_write_config(FAR struct pci_bus_s *bus, unsigned int devfn, int where, int size, uint32_t val); +/**************************************************************************** + * Name: pci_bus_write_config_xxx + * + * Description: + * Write pci device config space + * + * Input Parameters: + * bus - The PCI device to belong to + * devfn - The PCI device number and function number + * where - The register address + * val - The data + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + +int pci_bus_write_config_byte(FAR struct pci_bus_s *bus, + unsigned int devfn, int where, + uint8_t val); +int pci_bus_write_config_word(FAR struct pci_bus_s *bus, + unsigned int devfn, int where, + uint16_t val); +int pci_bus_write_config_dword(FAR struct pci_bus_s *bus, + unsigned int devfn, int where, + uint32_t val); + /**************************************************************************** * Name: pci_bus_read_io * @@ -402,13 +456,36 @@ int pci_bus_read_io(FAR struct pci_bus_s *bus, uintptr_t addr, int size, FAR uint32_t *val); /**************************************************************************** - * Name: pci_bus_write_io + * Name: pci_bus_read_io_xxx * * Description: * Read pci device io space * * Input Parameters: * bus - The PCI device belong to + * where - The address to read + * val - The data buffer + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + +int pci_bus_read_io_byte(FAR struct pci_bus_s *bus, uintptr_t where, + FAR uint8_t *val); +int pci_bus_read_io_word(FAR struct pci_bus_s *bus, uintptr_t where, + FAR uint16_t *val); +int pci_bus_read_io_dword(FAR struct pci_bus_s *bus, uintptr_t where, + FAR uint32_t *val); + +/**************************************************************************** + * Name: pci_bus_write_io + * + * Description: + * Write pci device io space + * + * Input Parameters: + * bus - The PCI device belong to * addr - The address to write * size - The data length * val - The data @@ -421,6 +498,29 @@ int pci_bus_read_io(FAR struct pci_bus_s *bus, uintptr_t addr, int pci_bus_write_io(FAR struct pci_bus_s *bus, uintptr_t addr, int size, uint32_t val); +/**************************************************************************** + * Name: pci_bus_write_io_xxx + * + * Description: + * Write pci device io space + * + * Input Parameters: + * bus - The PCI device belong to + * where - The address to write + * val - The data + * + * Returned Value: + * Zero if success, otherwise nagative + * + ****************************************************************************/ + +int pci_bus_write_io_byte(FAR struct pci_bus_s *bus, uintptr_t where, + uint8_t value); +int pci_bus_write_io_word(FAR struct pci_bus_s *bus, uintptr_t where, + uint16_t value); +int pci_bus_write_io_dword(FAR struct pci_bus_s *bus, uintptr_t where, + uint32_t value); + /**************************************************************************** * Name: pci_set_master *