53
53
\
54
54
if (!PCI_##len##_BAD) \
55
55
{ \
56
- ret = bus->ctrl->ops->read (bus, devfn, where, size, &data); \
56
+ ret = pci_bus_read_config (bus, devfn, where, size, &data); \
57
57
} \
58
58
\
59
59
*value = (type)data; \
68
68
\
69
69
if (!PCI_##len##_BAD) \
70
70
{ \
71
- ret = bus->ctrl->ops->write (bus, devfn, where, size, value); \
71
+ ret = pci_bus_write_config (bus, devfn, where, size, value); \
72
72
} \
73
73
\
74
74
return ret; \
83
83
\
84
84
if (!PCI_##len##_BAD) \
85
85
{ \
86
- ret = bus->ctrl->ops->read_io (bus, where, size, &data); \
86
+ ret = pci_bus_read_io (bus, where, size, &data); \
87
87
} \
88
88
\
89
89
*value = (type)data; \
98
98
\
99
99
if (!PCI_##len##_BAD) \
100
100
{ \
101
- ret = bus->ctrl->ops->write_io (bus, where, size, value); \
101
+ ret = pci_bus_write_io (bus, where, size, value); \
102
102
} \
103
103
\
104
104
return ret; \
@@ -782,6 +782,122 @@ static void pci_scan_bus(FAR struct pci_bus_s *bus)
782
782
* Public Functions
783
783
****************************************************************************/
784
784
785
+ /****************************************************************************
786
+ * Name: pci_bus_read_config
787
+ *
788
+ * Description:
789
+ * Read pci device config space
790
+ *
791
+ * Input Parameters:
792
+ * bus - The PCI device belong to
793
+ * devfn - The PCI device dev number and function number
794
+ * where - The register address
795
+ * size - The data length
796
+ * val - The data buffer
797
+ *
798
+ * Returned Value:
799
+ * Zero if success, otherwise nagative
800
+ *
801
+ ****************************************************************************/
802
+
803
+ int pci_bus_read_config (FAR struct pci_bus_s * bus ,
804
+ unsigned int devfn , int where ,
805
+ int size , FAR uint32_t * val )
806
+ {
807
+ if (size != 1 && size != 2 && size != 4 )
808
+ {
809
+ return - EINVAL ;
810
+ }
811
+
812
+ return bus -> ctrl -> ops -> read (bus , devfn , where , size , val );
813
+ }
814
+
815
+ /****************************************************************************
816
+ * Name: pci_bus_write_config
817
+ *
818
+ * Description:
819
+ * Read pci device config space
820
+ *
821
+ * Input Parameters:
822
+ * bus - The PCI device belong to
823
+ * devfn - The PCI device dev number and function number
824
+ * where - The register address
825
+ * size - The data length
826
+ * val - The data
827
+ *
828
+ * Returned Value:
829
+ * Zero if success, otherwise nagative
830
+ *
831
+ ****************************************************************************/
832
+
833
+ int pci_bus_write_config (FAR struct pci_bus_s * bus ,
834
+ unsigned int devfn , int where ,
835
+ int size , uint32_t val )
836
+ {
837
+ if (size != 1 && size != 2 && size != 4 )
838
+ {
839
+ return - EINVAL ;
840
+ }
841
+
842
+ return bus -> ctrl -> ops -> write (bus , devfn , where , size , val );
843
+ }
844
+
845
+ /****************************************************************************
846
+ * Name: pci_bus_read_io
847
+ *
848
+ * Description:
849
+ * Read pci device io space
850
+ *
851
+ * Input Parameters:
852
+ * bus - The PCI device belong to
853
+ * addr - The address to read
854
+ * size - The data length
855
+ * val - The data buffer
856
+ *
857
+ * Returned Value:
858
+ * Zero if success, otherwise nagative
859
+ *
860
+ ****************************************************************************/
861
+
862
+ int pci_bus_read_io (FAR struct pci_bus_s * bus , uintptr_t addr ,
863
+ int size , FAR uint32_t * val )
864
+ {
865
+ if (size != 1 && size != 2 && size != 4 )
866
+ {
867
+ return - EINVAL ;
868
+ }
869
+
870
+ return bus -> ctrl -> ops -> read_io (bus , addr , size , val );
871
+ }
872
+
873
+ /****************************************************************************
874
+ * Name: pci_bus_write_io
875
+ *
876
+ * Description:
877
+ * Read pci device io space
878
+ *
879
+ * Input Parameters:
880
+ * bus - The PCI device belong to
881
+ * addr - The address to write
882
+ * size - The data length
883
+ * val - The data
884
+ *
885
+ * Returned Value:
886
+ * Zero if success, otherwise nagative
887
+ *
888
+ ****************************************************************************/
889
+
890
+ int pci_bus_write_io (FAR struct pci_bus_s * bus , uintptr_t addr ,
891
+ int size , uint32_t val )
892
+ {
893
+ if (size != 1 && size != 2 && size != 4 )
894
+ {
895
+ return - EINVAL ;
896
+ }
897
+
898
+ return bus -> ctrl -> ops -> write_io (bus , addr , size , val );
899
+ }
900
+
785
901
/****************************************************************************
786
902
* Name: pci_set_master
787
903
*
@@ -1206,4 +1322,4 @@ PCI_BUS_READ_IO(word, uint16_t, 2)
1206
1322
PCI_BUS_READ_IO (dword , uint32_t , 4 )
1207
1323
PCI_BUS_WRITE_IO (byte , uint8_t , 1 )
1208
1324
PCI_BUS_WRITE_IO (word , uint16_t , 2 )
1209
- PCI_BUS_WRITE_IO (dword , uint32_t , 4 )
1325
+ PCI_BUS_WRITE_IO (dword , uint32_t , 4 )
0 commit comments