forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/pci/cobalt/cobalt-driver.c
....@@ -186,20 +186,16 @@
186186 {
187187 struct pci_dev *pci_dev = cobalt->pci_dev;
188188 struct pci_dev *pci_bus_dev = cobalt->pci_dev->bus->self;
189
- int offset;
190
- int bus_offset;
191189 u32 capa;
192190 u16 stat, ctrl;
193191
194
- offset = pci_find_capability(pci_dev, PCI_CAP_ID_EXP);
195
- bus_offset = pci_find_capability(pci_bus_dev, PCI_CAP_ID_EXP);
196
- if (!offset || !bus_offset)
192
+ if (!pci_is_pcie(pci_dev) || !pci_is_pcie(pci_bus_dev))
197193 return;
198194
199195 /* Device */
200
- pci_read_config_dword(pci_dev, offset + PCI_EXP_DEVCAP, &capa);
201
- pci_read_config_word(pci_dev, offset + PCI_EXP_DEVCTL, &ctrl);
202
- pci_read_config_word(pci_dev, offset + PCI_EXP_DEVSTA, &stat);
196
+ pcie_capability_read_dword(pci_dev, PCI_EXP_DEVCAP, &capa);
197
+ pcie_capability_read_word(pci_dev, PCI_EXP_DEVCTL, &ctrl);
198
+ pcie_capability_read_word(pci_dev, PCI_EXP_DEVSTA, &stat);
203199 cobalt_info("PCIe device capability 0x%08x: Max payload %d\n",
204200 capa, get_payload_size(capa & PCI_EXP_DEVCAP_PAYLOAD));
205201 cobalt_info("PCIe device control 0x%04x: Max payload %d. Max read request %d\n",
....@@ -209,9 +205,9 @@
209205 cobalt_info("PCIe device status 0x%04x\n", stat);
210206
211207 /* Link */
212
- pci_read_config_dword(pci_dev, offset + PCI_EXP_LNKCAP, &capa);
213
- pci_read_config_word(pci_dev, offset + PCI_EXP_LNKCTL, &ctrl);
214
- pci_read_config_word(pci_dev, offset + PCI_EXP_LNKSTA, &stat);
208
+ pcie_capability_read_dword(pci_dev, PCI_EXP_LNKCAP, &capa);
209
+ pcie_capability_read_word(pci_dev, PCI_EXP_LNKCTL, &ctrl);
210
+ pcie_capability_read_word(pci_dev, PCI_EXP_LNKSTA, &stat);
215211 cobalt_info("PCIe link capability 0x%08x: %s per lane and %u lanes\n",
216212 capa, get_link_speed(capa),
217213 (capa & PCI_EXP_LNKCAP_MLW) >> 4);
....@@ -221,15 +217,15 @@
221217 (stat & PCI_EXP_LNKSTA_NLW) >> 4);
222218
223219 /* Bus */
224
- pci_read_config_dword(pci_bus_dev, bus_offset + PCI_EXP_LNKCAP, &capa);
220
+ pcie_capability_read_dword(pci_bus_dev, PCI_EXP_LNKCAP, &capa);
225221 cobalt_info("PCIe bus link capability 0x%08x: %s per lane and %u lanes\n",
226222 capa, get_link_speed(capa),
227223 (capa & PCI_EXP_LNKCAP_MLW) >> 4);
228224
229225 /* Slot */
230
- pci_read_config_dword(pci_dev, offset + PCI_EXP_SLTCAP, &capa);
231
- pci_read_config_word(pci_dev, offset + PCI_EXP_SLTCTL, &ctrl);
232
- pci_read_config_word(pci_dev, offset + PCI_EXP_SLTSTA, &stat);
226
+ pcie_capability_read_dword(pci_dev, PCI_EXP_SLTCAP, &capa);
227
+ pcie_capability_read_word(pci_dev, PCI_EXP_SLTCTL, &ctrl);
228
+ pcie_capability_read_word(pci_dev, PCI_EXP_SLTSTA, &stat);
233229 cobalt_info("PCIe slot capability 0x%08x\n", capa);
234230 cobalt_info("PCIe slot control 0x%04x\n", ctrl);
235231 cobalt_info("PCIe slot status 0x%04x\n", stat);
....@@ -238,26 +234,22 @@
238234 static unsigned pcie_link_get_lanes(struct cobalt *cobalt)
239235 {
240236 struct pci_dev *pci_dev = cobalt->pci_dev;
241
- unsigned offset;
242237 u16 link;
243238
244
- offset = pci_find_capability(pci_dev, PCI_CAP_ID_EXP);
245
- if (!offset)
239
+ if (!pci_is_pcie(pci_dev))
246240 return 0;
247
- pci_read_config_word(pci_dev, offset + PCI_EXP_LNKSTA, &link);
241
+ pcie_capability_read_word(pci_dev, PCI_EXP_LNKSTA, &link);
248242 return (link & PCI_EXP_LNKSTA_NLW) >> 4;
249243 }
250244
251245 static unsigned pcie_bus_link_get_lanes(struct cobalt *cobalt)
252246 {
253247 struct pci_dev *pci_dev = cobalt->pci_dev->bus->self;
254
- unsigned offset;
255248 u32 link;
256249
257
- offset = pci_find_capability(pci_dev, PCI_CAP_ID_EXP);
258
- if (!offset)
250
+ if (!pci_is_pcie(pci_dev))
259251 return 0;
260
- pci_read_config_dword(pci_dev, offset + PCI_EXP_LNKCAP, &link);
252
+ pcie_capability_read_dword(pci_dev, PCI_EXP_LNKCAP, &link);
261253 return (link & PCI_EXP_LNKCAP_MLW) >> 4;
262254 }
263255
....@@ -592,7 +584,7 @@
592584 .cec_clk = 12000000,
593585 };
594586 static struct i2c_board_info adv7511_info = {
595
- .type = "adv7511",
587
+ .type = "adv7511-v4l2",
596588 .addr = 0x39, /* 0x39 or 0x3d */
597589 .platform_data = &adv7511_pdata,
598590 };