All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 09/10] x86: Access the VGA ROM when needed
Date: Mon, 29 Dec 2014 19:32:30 -0700	[thread overview]
Message-ID: <1419906751-29776-10-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1419906751-29776-1-git-send-email-sjg@chromium.org>

Add code to the generic pci_rom file to access the VGA ROM in PCI space
when needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/pci/pci_auto.c | 28 +++++++++++++++++++++++++++-
 drivers/pci/pci_rom.c  |  7 ++++++-
 include/pci.h          |  9 +++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci_auto.c b/drivers/pci/pci_auto.c
index 44470fa..61bf6b4 100644
--- a/drivers/pci/pci_auto.c
+++ b/drivers/pci/pci_auto.c
@@ -11,7 +11,7 @@
  */
 
 #include <common.h>
-
+#include <errno.h>
 #include <pci.h>
 
 #undef DEBUG
@@ -191,6 +191,32 @@ void pciauto_setup_device(struct pci_controller *hose,
 	pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80);
 }
 
+int pciauto_setup_rom(struct pci_controller *hose, pci_dev_t dev)
+{
+	pci_addr_t bar_value;
+	pci_size_t bar_size;
+	u32 bar_response;
+	u16 cmdstat = 0;
+
+	pci_hose_write_config_dword(hose, dev, PCI_ROM_ADDRESS, -2);
+	pci_hose_read_config_dword(hose, dev, PCI_ROM_ADDRESS, &bar_response);
+	if (!bar_response)
+		return -ENOENT;
+
+	bar_size = -(bar_response & ~1);
+	DEBUGF("PCI Autoconfig: ROM, size=%#x, ", bar_size);
+	if (pciauto_region_allocate(hose->pci_mem, bar_size, &bar_value) == 0) {
+		pci_hose_write_config_dword(hose, dev, PCI_ROM_ADDRESS,
+					    bar_value);
+	}
+	DEBUGF("\n");
+	pci_hose_read_config_word(hose, dev, PCI_COMMAND, &cmdstat);
+	cmdstat |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
+	pci_hose_write_config_word(hose, dev, PCI_COMMAND, cmdstat);
+
+	return 0;
+}
+
 void pciauto_prescan_setup_bridge(struct pci_controller *hose,
 					 pci_dev_t dev, int sub_bus)
 {
diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index a16e99f..eb76591 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -81,7 +81,12 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 #ifdef CONFIG_X86_OPTION_ROM_ADDR
 	rom_address = CONFIG_X86_OPTION_ROM_ADDR;
 #else
-	pci_write_config_dword(dev, PCI_ROM_ADDRESS, (u32)PCI_ROM_ADDRESS_MASK);
+
+	if (pciauto_setup_rom(pci_bus_to_hose(PCI_BUS(dev)), dev)) {
+		debug("Cannot find option ROM\n");
+		return -ENOENT;
+	}
+
 	pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_address);
 	if (rom_address == 0x00000000 || rom_address == 0xffffffff) {
 		debug("%s: rom_address=%x\n", __func__, rom_address);
diff --git a/include/pci.h b/include/pci.h
index 216f448..f135ba8 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -701,5 +701,14 @@ void pci_write_bar32(struct pci_controller *hose, pci_dev_t dev, int barnum,
  * */
 u32 pci_read_bar32(struct pci_controller *hose, pci_dev_t dev, int barnum);
 
+/**
+ * pciauto_setup_rom() - Set up access to a device ROM
+ *
+ * @hose:	PCI hose to use
+ * @dev:	PCI device to adjust
+ * @return 0 if done, -ve on error
+ */
+int pciauto_setup_rom(struct pci_controller *hose, pci_dev_t dev);
+
 #endif /* __ASSEMBLY__ */
 #endif /* _PCI_H */
-- 
2.2.0.rc0.207.ga3a616c

  parent reply	other threads:[~2014-12-30  2:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-30  2:32 [U-Boot] [PATCH 0/10] x86: Add generic VESA video driver Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 01/10] bios_emulator: Fix an #ifdef typo in the header file Simon Glass
2015-01-04  5:10   ` Bin Meng
2015-01-15  4:23     ` Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 02/10] x86: Correct endianness isues in pci_rom Simon Glass
2015-01-04  5:43   ` Bin Meng
2015-01-15  4:23     ` Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 03/10] x86: Support ROMs on other archs Simon Glass
2015-01-04  5:43   ` Bin Meng
2015-01-15  4:23     ` Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 04/10] bios_emulator: Don't display error when emulator terminates Simon Glass
2015-01-15  4:23   ` Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 05/10] bios_emulator: Add some VESA interface debugging Simon Glass
2015-01-15  4:24   ` Simon Glass
2019-07-30 20:52   ` Heinrich Schuchardt
2019-08-01 16:51     ` Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 06/10] x86: pci: Don't stop when we get a vendor/device mismatch Simon Glass
2015-01-04  5:51   ` Bin Meng
2015-01-15  4:24     ` Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 07/10] x86: Add a VESA video driver Simon Glass
2015-01-15  4:24   ` Simon Glass
2014-12-30  2:32 ` [U-Boot] [PATCH 08/10] x86: Drop the x86_fb driver Simon Glass
2015-01-15  4:25   ` Simon Glass
2014-12-30  2:32 ` Simon Glass [this message]
2015-01-04  5:54   ` [U-Boot] [PATCH 09/10] x86: Access the VGA ROM when needed Bin Meng
2015-01-05  1:45     ` Simon Glass
2015-01-05 13:49       ` Bin Meng
2015-01-14 19:36         ` Simon Glass
2015-01-15  2:17           ` Bin Meng
2014-12-30  2:32 ` [U-Boot] [PATCH 10/10] RFC: Test code for glacier PCI video support Simon Glass
2015-01-08  4:46   ` Bin Meng
2015-01-08  6:18   ` Bin Meng
2015-01-08 15:06     ` Simon Glass
2015-01-09  1:34       ` Bin Meng
2015-01-09  3:35         ` Simon Glass
2015-01-09  5:23           ` Bin Meng
2015-01-09 19:02             ` Simon Glass
2015-01-10  3:52               ` Bin Meng
2015-01-10 16:08                 ` Simon Glass
2015-01-11  3:04                   ` Bin Meng
2015-01-11  3:42                     ` Simon Glass
2015-01-11  4:20                       ` Bin Meng
2015-01-13  1:11                         ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419906751-29776-10-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.