[U-Boot] [PATCH 10/25] dm: pci: video: Convert video and pci_rom to use DM PCI API

Simon Glass sjg at chromium.org
Tue Nov 17 04:53:48 CET 2015


Adjust these files to use the driver-model PCI API instead of the legacy
functions.

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

 arch/x86/cpu/ivybridge/gma.c |  2 +-
 drivers/pci/pci_rom.c        | 31 ++++++++++++++++---------------
 drivers/video/vesa_fb.c      |  6 +++---
 include/pci_rom.h            |  2 +-
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/arch/x86/cpu/ivybridge/gma.c b/arch/x86/cpu/ivybridge/gma.c
index b76c81c..122ff68 100644
--- a/arch/x86/cpu/ivybridge/gma.c
+++ b/arch/x86/cpu/ivybridge/gma.c
@@ -756,7 +756,7 @@ int gma_func0_init(struct udevice *dev, const void *blob, int node)
 
 #ifdef CONFIG_VIDEO
 	start = get_timer(0);
-	ret = pci_run_vga_bios(pci_get_bdf(dev), int15_handler,
+	ret = pci_run_vga_bios(dev, int15_handler,
 			       PCI_ROM_USE_NATIVE | PCI_ROM_ALLOW_FALLBACK);
 	debug("BIOS ran in %lums\n", get_timer(start));
 #endif
diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index d244543..6e3adf6 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -37,12 +37,12 @@
 #include <asm/acpi.h>
 #endif
 
-__weak bool board_should_run_oprom(pci_dev_t dev)
+__weak bool board_should_run_oprom(struct udevice *dev)
 {
 	return true;
 }
 
-static bool should_load_oprom(pci_dev_t dev)
+static bool should_load_oprom(struct udevice *dev)
 {
 #ifdef CONFIG_HAVE_ACPI_RESUME
 	if (acpi_get_slp_type() == 3)
@@ -61,7 +61,7 @@ __weak uint32_t board_map_oprom_vendev(uint32_t vendev)
 	return vendev;
 }
 
-static int pci_rom_probe(pci_dev_t dev, uint class,
+static int pci_rom_probe(struct udevice *dev, uint class,
 			 struct pci_rom_header **hdrp)
 {
 	struct pci_rom_header *rom_header;
@@ -73,8 +73,8 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 	u32 mapped_vendev;
 	u32 rom_address;
 
-	pci_read_config_word(dev, PCI_VENDOR_ID, &vendor);
-	pci_read_config_word(dev, PCI_DEVICE_ID, &device);
+	dm_pci_read_config16(dev, PCI_VENDOR_ID, &vendor);
+	dm_pci_read_config16(dev, PCI_DEVICE_ID, &device);
 	vendev = vendor << 16 | device;
 	mapped_vendev = board_map_oprom_vendev(vendev);
 	if (vendev != mapped_vendev)
@@ -84,15 +84,15 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 	rom_address = CONFIG_VGA_BIOS_ADDR;
 #else
 
-	pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_address);
+	dm_pci_read_config32(dev, PCI_ROM_ADDRESS, &rom_address);
 	if (rom_address == 0x00000000 || rom_address == 0xffffffff) {
 		debug("%s: rom_address=%x\n", __func__, rom_address);
 		return -ENOENT;
 	}
 
 	/* Enable expansion ROM address decoding. */
-	pci_write_config_dword(dev, PCI_ROM_ADDRESS,
-			       rom_address | PCI_ROM_ADDRESS_ENABLE);
+	dm_pci_write_config32(dev, PCI_ROM_ADDRESS,
+			      rom_address | PCI_ROM_ADDRESS_ENABLE);
 #endif
 	debug("Option ROM address %x\n", rom_address);
 	rom_header = (struct pci_rom_header *)(unsigned long)rom_address;
@@ -106,7 +106,7 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 		       le16_to_cpu(rom_header->signature));
 #ifndef CONFIG_VGA_BIOS_ADDR
 		/* Disable expansion ROM address decoding */
-		pci_write_config_dword(dev, PCI_ROM_ADDRESS, rom_address);
+		dm_pci_write_config32(dev, PCI_ROM_ADDRESS, rom_address);
 #endif
 		return -EINVAL;
 	}
@@ -259,7 +259,8 @@ void setup_video(struct screen_info *screen_info)
 	screen_info->rsvd_pos = vesa->reserved_mask_pos;
 }
 
-int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), int exec_method)
+int pci_run_vga_bios(struct udevice *dev, int (*int15_handler)(void),
+		     int exec_method)
 {
 	struct pci_rom_header *rom, *ram;
 	int vesa_mode = -1;
@@ -268,7 +269,7 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), int exec_method)
 	int ret;
 
 	/* Only execute VGA ROMs */
-	pci_read_config_dword(dev, PCI_REVISION_ID, &class);
+	dm_pci_read_config32(dev, PCI_REVISION_ID, &class);
 	if (((class >> 16) ^ PCI_CLASS_DISPLAY_VGA) & 0xff00) {
 		debug("%s: Class %#x, should be %#x\n", __func__, class,
 		      PCI_CLASS_DISPLAY_VGA);
@@ -322,12 +323,12 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), int exec_method)
 #ifdef CONFIG_BIOSEMU
 		BE_VGAInfo *info;
 
-		ret = biosemu_setup(dev, &info);
+		ret = biosemu_setup(pci_get_bdf(dev), &info);
 		if (ret)
 			return ret;
 		biosemu_set_interrupt_handler(0x15, int15_handler);
-		ret = biosemu_run(dev, (uchar *)ram, 1 << 16, info, true,
-				  vesa_mode, &mode_info);
+		ret = biosemu_run(pci_get_bdf(dev), (uchar *)ram, 1 << 16, info,
+				  true, vesa_mode, &mode_info);
 		if (ret)
 			return ret;
 #endif
@@ -335,7 +336,7 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), int exec_method)
 #ifdef CONFIG_X86
 		bios_set_interrupt_handler(0x15, int15_handler);
 
-		bios_run_on_x86(dev, (unsigned long)ram, vesa_mode,
+		bios_run_on_x86(pci_get_bdf(dev), (unsigned long)ram, vesa_mode,
 				&mode_info);
 #endif
 	}
diff --git a/drivers/video/vesa_fb.c b/drivers/video/vesa_fb.c
index a19651f..e1ee0a4 100644
--- a/drivers/video/vesa_fb.c
+++ b/drivers/video/vesa_fb.c
@@ -19,8 +19,8 @@ GraphicDevice ctfb;
 void *video_hw_init(void)
 {
 	GraphicDevice *gdev = &ctfb;
+	struct udevice *dev;
 	int bits_per_pixel;
-	pci_dev_t dev;
 	int ret;
 
 	printf("Video: ");
@@ -33,8 +33,8 @@ void *video_hw_init(void)
 		return NULL;
 	}
 	if (vbe_get_video_info(gdev)) {
-		dev = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, 0);
-		if (dev < 0) {
+		ret = dm_pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, 0, &dev);
+		if (ret) {
 			printf("no card detected\n");
 			return NULL;
 		}
diff --git a/include/pci_rom.h b/include/pci_rom.h
index 2f1665d..b4898e2 100644
--- a/include/pci_rom.h
+++ b/include/pci_rom.h
@@ -50,7 +50,7 @@ enum pci_rom_emul {
  * @int15_handler:	Function to call to handle int 0x15
  * @exec_method:	flags from enum pci_rom_emul
  */
-int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void),
+int pci_run_vga_bios(struct udevice *dev, int (*int15_handler)(void),
 		     int exec_method);
 
 /**
-- 
2.6.0.rc2.230.g3dd15c0



More information about the U-Boot mailing list