[U-Boot-Users] [PATCH] pci: Move PCI device configuration check into a separate weak function

This patch moves the check, if a device should be skipped in PCI PNP configuration into the function pci_skip_dev(). This function is defined as weak so that it can be overwritten by a platform specific one if needed. The check if the device should get printed in the PCI summary upon bootup (when CONFIG_PCI_SCAN_SHOW is defined) is moved to the function pci_print_dev() which is also defined as weak too.
Signed-off-by: Stefan Roese sr@denx.de --- drivers/pci/pci.c | 70 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 46 insertions(+), 24 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b3ae3b1..16180cb 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -411,6 +411,40 @@ void pci_cfgfunc_do_nothing(struct pci_controller *hose, extern int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev); extern void pciauto_config_init(struct pci_controller *hose);
+int __pci_skip_dev(struct pci_controller *hose, pci_dev_t dev) +{ + /* + * Check if pci device should be skipped in configuration + */ + if (dev == PCI_BDF(hose->first_busno, 0, 0)) { +#if defined(CONFIG_PCI_CONFIG_HOST_BRIDGE) /* don't skip host bridge */ + /* + * Only skip configuration if "pciconfighost" is not set + */ + if (getenv("pciconfighost") == NULL) + return 1; +#else + return 1; +#endif + } + + return 0; +} +int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev) + __attribute__((weak, alias("__pci_skip_dev"))); + +#ifdef CONFIG_PCI_SCAN_SHOW +int __pci_print_dev(struct pci_controller *hose, pci_dev_t dev) +{ + if (dev == PCI_BDF(hose->first_busno, 0, 0)) + return 0; + + return 1; +} +int pci_print_dev(struct pci_controller *hose, pci_dev_t dev) + __attribute__((weak, alias("__pci_print_dev"))); +#endif /* CONFIG_PCI_SCAN_SHOW */ + int pci_hose_scan_bus(struct pci_controller *hose, int bus) { unsigned int sub_bus, found_multi=0; @@ -423,21 +457,10 @@ int pci_hose_scan_bus(struct pci_controller *hose, int bus)
for (dev = PCI_BDF(bus,0,0); dev < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1); - dev += PCI_BDF(0,0,1)) - { - /* Skip our host bridge */ - if ( dev == PCI_BDF(hose->first_busno,0,0) ) { -#if defined(CONFIG_PCI_CONFIG_HOST_BRIDGE) /* don't skip host bridge */ - /* - * Only skip hostbridge configuration if "pciconfighost" is not set - */ - if (getenv("pciconfighost") == NULL) { - continue; /* Skip our host bridge */ - } -#else - continue; /* Skip our host bridge */ -#endif - } + dev += PCI_BDF(0,0,1)) { + + if (pci_skip_dev(hose, dev)) + continue;
if (PCI_FUNC(dev) && !found_multi) continue; @@ -473,15 +496,14 @@ int pci_hose_scan_bus(struct pci_controller *hose, int bus) hose->fixup_irq(hose, dev);
#ifdef CONFIG_PCI_SCAN_SHOW - /* Skip our host bridge */ - if ( dev != PCI_BDF(hose->first_busno,0,0) ) { - unsigned char int_line; - - pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_LINE, - &int_line); - printf(" %02x %02x %04x %04x %04x %02x\n", - PCI_BUS(dev), PCI_DEV(dev), vendor, device, class, - int_line); + if (pci_print_dev(hose, dev)) { + unsigned char int_line; + + pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_LINE, + &int_line); + printf(" %02x %02x %04x %04x %04x %02x\n", + PCI_BUS(dev), PCI_DEV(dev), vendor, device, class, + int_line); } #endif }

Hi, Stefan.
2008/7/8 Stefan Roese sr@denx.de:
This patch moves the check, if a device should be skipped in PCI PNP configuration into the function pci_skip_dev(). This function is defined as weak so that it can be overwritten by a platform specific one if needed. The check if the device should get printed in the PCI summary upon bootup (when CONFIG_PCI_SCAN_SHOW is defined) is moved to the function pci_print_dev() which is also defined as weak too.
Signed-off-by: Stefan Roese sr@denx.de
drivers/pci/pci.c | 70 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 46 insertions(+), 24 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b3ae3b1..16180cb 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -411,6 +411,40 @@ void pci_cfgfunc_do_nothing(struct pci_controller *hose, extern int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev); extern void pciauto_config_init(struct pci_controller *hose);
+int __pci_skip_dev(struct pci_controller *hose, pci_dev_t dev) +{
/*
* Check if pci device should be skipped in configuration
*/
if (dev == PCI_BDF(hose->first_busno, 0, 0)) {
+#if defined(CONFIG_PCI_CONFIG_HOST_BRIDGE) /* don't skip host bridge */
/*
* Only skip configuration if "pciconfighost" is not set
*/
if (getenv("pciconfighost") == NULL)
return 1;
+#else
return 1;
+#endif
}
return 0;
+} +int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev)
__attribute__((weak, alias("__pci_skip_dev")));
+#ifdef CONFIG_PCI_SCAN_SHOW +int __pci_print_dev(struct pci_controller *hose, pci_dev_t dev) +{
if (dev == PCI_BDF(hose->first_busno, 0, 0))
return 0;
return 1;
+} +int pci_print_dev(struct pci_controller *hose, pci_dev_t dev)
__attribute__((weak, alias("__pci_print_dev")));
+#endif /* CONFIG_PCI_SCAN_SHOW */
When PCI_BDF was 0,0,0, does the board of PPC have the device which do not want to initialize?
Best regards, Nobuhiro

Hi Nobuhiro,
On Wednesday 09 July 2008, Nobuhiro Iwamatsu wrote:
When PCI_BDF was 0,0,0, does the board of PPC have the device which do not want to initialize?
This is the current situation, yes. At least on PPC4xx. With this new patch all platforms can overwrite this default behavior without breaking backward compatibility.
Does it work for you?
Best regards, Stefan
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de =====================================================================

Hi, Stefan.
2008/7/9 Stefan Roese sr@denx.de:
Hi Nobuhiro,
On Wednesday 09 July 2008, Nobuhiro Iwamatsu wrote:
When PCI_BDF was 0,0,0, does the board of PPC have the device which do not want to initialize?
This is the current situation, yes. At least on PPC4xx. With this new patch all platforms can overwrite this default behavior without breaking backward compatibility.
OK, I see.
Does it work for you?
Work fine. Thank you. But I have suggestion.
If these cords depend on PPC4xx and other PPC platform, I think that move these code to PPC platform. Do you think this suggestion?
Best regards, Nobuhiro

On Wednesday 09 July 2008, Nobuhiro Iwamatsu wrote:
When PCI_BDF was 0,0,0, does the board of PPC have the device which do not want to initialize?
This is the current situation, yes. At least on PPC4xx. With this new patch all platforms can overwrite this default behavior without breaking backward compatibility.
OK, I see.
Does it work for you?
Work fine. Thank you.
OK.
But I have suggestion.
If these cords depend on PPC4xx and other PPC platform, I think that move these code to PPC platform. Do you think this suggestion?
I don't know if this current implementation only works for PPC. Its used on all platforms using this PCI code right now. So I think we should keep this version in this file as default behavior.
Best regards, Stefan
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de =====================================================================

Hi, Stefan.
2008/7/9 Stefan Roese sr@denx.de:
On Wednesday 09 July 2008, Nobuhiro Iwamatsu wrote:
When PCI_BDF was 0,0,0, does the board of PPC have the device which do not want to initialize?
This is the current situation, yes. At least on PPC4xx. With this new patch all platforms can overwrite this default behavior without breaking backward compatibility.
OK, I see.
Does it work for you?
Work fine. Thank you.
OK.
But I have suggestion.
If these cords depend on PPC4xx and other PPC platform, I think that move these code to PPC platform. Do you think this suggestion?
I don't know if this current implementation only works for PPC. Its used on all platforms using this PCI code right now. So I think we should keep this version in this file as default behavior.
OK, I understand. Acked-By: Nobuhiro Iwamatsu iwamatsu@nigauri.org
Are you going to put this patch in 1.3.4?
Best regatds, Nobuhiro

Hi Nobuhiro,
On Wednesday 09 July 2008, Nobuhiro Iwamatsu wrote:
But I have suggestion.
If these cords depend on PPC4xx and other PPC platform, I think that move these code to PPC platform. Do you think this suggestion?
I don't know if this current implementation only works for PPC. Its used on all platforms using this PCI code right now. So I think we should keep this version in this file as default behavior.
OK, I understand. Acked-By: Nobuhiro Iwamatsu iwamatsu@nigauri.org
Are you going to put this patch in 1.3.4?
Yes, I think we should put it into the repo now.
Wolfgang, can you please pick my patch up directly?
Thanks.
Best regards, Stefan
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de =====================================================================

In message 200807100859.07778.sr@denx.de you wrote:
Yes, I think we should put it into the repo now.
Wolfgang, can you please pick my patch up directly?
I can, if you tell me which one exactly.
Best regards,
Wolfgang Denk

On Thursday 10 July 2008, Wolfgang Denk wrote:
In message 200807100859.07778.sr@denx.de you wrote:
Yes, I think we should put it into the repo now.
Wolfgang, can you please pick my patch up directly?
I can, if you tell me which one exactly.
The one from this email thread:
[PATCH] pci: Move PCI device configuration check into a separate weak function
From 08.07.2008
Thanks.
Best regards, Stefan
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de =====================================================================

In message 1215511307-25645-1-git-send-email-sr@denx.de you wrote:
This patch moves the check, if a device should be skipped in PCI PNP configuration into the function pci_skip_dev(). This function is defined as weak so that it can be overwritten by a platform specific one if needed. The check if the device should get printed in the PCI summary upon bootup (when CONFIG_PCI_SCAN_SHOW is defined) is moved to the function pci_print_dev() which is also defined as weak too.
Signed-off-by: Stefan Roese sr@denx.de
drivers/pci/pci.c | 70 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 46 insertions(+), 24 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
participants (4)
-
Nobuhiro Iwamatsu
-
Nobuhiro Iwamatsu
-
Stefan Roese
-
Wolfgang Denk