All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ati_radeon: Support PCI virtual not eq bus mapping.
@ 2010-03-31 14:54 Ed Swarthout
  2010-03-31 17:03 ` Anatolij Gustschin
  0 siblings, 1 reply; 4+ messages in thread
From: Ed Swarthout @ 2010-03-31 14:54 UTC (permalink / raw)
  To: u-boot

Use pci_bus_to_virt() to convert the bus address from the BARs to
virtual address' to eliminate the direct mapping requirement.

Rename variables to better match usage (_phys -> _bus or no-suffix)

This fixes the mpc8572ds CONFIG_PYS_64BIT mode failure: 
"videoboot: Vidoe ROM failed to map!"

Tested on mpc8572ds with and without CONFIG_PHYS_64BIT.

Signed-off-by: Ed Swarthout <Ed.Swarthout@freescale.com>
---

This patch is independent of the ati radeon return error patch,
but for ease of debug it should be applied with this one.

 drivers/bios_emulator/atibios.c |    9 ++++---
 drivers/video/ati_radeon_fb.c   |   45 ++++++++++++++++++++------------------
 drivers/video/ati_radeon_fb.h   |    4 +-
 3 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/drivers/bios_emulator/atibios.c b/drivers/bios_emulator/atibios.c
index 2881449..f488259 100644
--- a/drivers/bios_emulator/atibios.c
+++ b/drivers/bios_emulator/atibios.c
@@ -173,7 +173,7 @@ Maps a pointer to the BIOS image on the graphics card on the PCI bus.
 ****************************************************************************/
 void *PCI_mapBIOSImage(pci_dev_t pcidev)
 {
-	u32 BIOSImagePhys;
+	u32 BIOSImageBus;
 	int BIOSImageBAR;
 	u8 *BIOSImage;
 
@@ -195,16 +195,17 @@ void *PCI_mapBIOSImage(pci_dev_t pcidev)
 	 specific programming for different cards to solve this problem.
 	*/
 
-	if ((BIOSImagePhys = PCI_findBIOSAddr(pcidev, &BIOSImageBAR)) == 0) {
+	if ((BIOSImageBus = PCI_findBIOSAddr(pcidev, &BIOSImageBAR)) == 0) {
 		printf("Find bios addr error\n");
 		return NULL;
 	}
 
-	BIOSImage = (u8 *) BIOSImagePhys;
+	BIOSImage = pci_bus_to_virt(pcidev, BIOSImageBus,
+				    PCI_REGION_MEM, 0, MAP_NOCACHE);
 
 	/*Change the PCI BAR registers to map it onto the bus.*/
 	pci_write_config_dword(pcidev, BIOSImageBAR, 0);
-	pci_write_config_dword(pcidev, PCI_ROM_ADDRESS, BIOSImagePhys | 0x1);
+	pci_write_config_dword(pcidev, PCI_ROM_ADDRESS, BIOSImageBus | 0x1);
 
 	udelay(1);
 
diff --git a/drivers/video/ati_radeon_fb.c b/drivers/video/ati_radeon_fb.c
index 529ddae..a74f724 100644
--- a/drivers/video/ati_radeon_fb.c
+++ b/drivers/video/ati_radeon_fb.c
@@ -210,7 +210,7 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
 	 * ToDo: identify these cases
 	 */
 
-	DPRINT("radeonfb: Found %ldk of %s %d bits wide videoram\n",
+	DPRINT("radeonfb: Found %dk of %s %d bits wide videoram\n",
 	       rinfo->video_ram / 1024,
 	       rinfo->vram_ddr ? "DDR" : "SDRAM",
 	       rinfo->vram_width);
@@ -586,14 +586,16 @@ int radeon_probe(struct radeonfb_info *rinfo)
 		rinfo->pdev.device = did;
 		rinfo->family = get_radeon_id_family(rinfo->pdev.device);
 		pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0,
-				&rinfo->fb_base_phys);
+				&rinfo->fb_base_bus);
 		pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2,
-				&rinfo->mmio_base_phys);
-		rinfo->fb_base_phys &= 0xfffff000;
-		rinfo->mmio_base_phys &= ~0x04;
-
-		rinfo->mmio_base = (void *)rinfo->mmio_base_phys;
-		DPRINT("rinfo->mmio_base = 0x%x\n",rinfo->mmio_base);
+				&rinfo->mmio_base_bus);
+		rinfo->fb_base_bus &= 0xfffff000;
+		rinfo->mmio_base_bus &= ~0x04;
+
+		rinfo->mmio_base = pci_bus_to_virt(pdev, rinfo->mmio_base_bus,
+					PCI_REGION_MEM, 0, MAP_NOCACHE);
+		DPRINT("rinfo->mmio_base = 0x%x bus=0x%x\n",
+		       rinfo->mmio_base, rinfo->mmio_base_bus);
 		rinfo->fb_local_base = INREG(MC_FB_LOCATION) << 16;
 		DPRINT("rinfo->fb_local_base = 0x%x\n",rinfo->fb_local_base);
 		/* PostBIOS with x86 emulater */
@@ -611,14 +613,15 @@ int radeon_probe(struct radeonfb_info *rinfo)
 
 		rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM,
 				rinfo->video_ram);
-		rinfo->fb_base = (void *)rinfo->fb_base_phys;
-
-		DPRINT("Radeon: framebuffer base phy address 0x%08x," \
-		      "MMIO base phy address 0x%08x," \
-		      "framebuffer local base 0x%08x.\n ",
-		      rinfo->fb_base_phys, rinfo->mmio_base_phys,
-		      rinfo->fb_local_base);
-
+		rinfo->fb_base = pci_bus_to_virt(pdev, rinfo->fb_base_bus,
+					PCI_REGION_MEM, 0, MAP_NOCACHE);
+		DPRINT("Radeon: framebuffer base address 0x%08x, "
+		       "bus address 0x%08x\n"
+		       "MMIO base address 0x%08x, bus address 0x%08x, "
+		       "framebuffer local base 0x%08x.\n ",
+		       (u32)rinfo->fb_base, rinfo->fb_base_bus,
+		       (u32)rinfo->mmio_base, rinfo->mmio_base_bus,
+		       rinfo->fb_local_base);
 		return 0;
 	}
 	return -1;
@@ -734,13 +737,13 @@ void *video_hw_init(void)
 	}
 
 	pGD->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
-	pGD->pciBase = rinfo->fb_base_phys;
-	pGD->frameAdrs = rinfo->fb_base_phys;
+	pGD->pciBase = rinfo->fb_base;
+	pGD->frameAdrs = rinfo->fb_base;
 	pGD->memSize = 64 * 1024 * 1024;
 
 	/* Cursor Start Address */
 	pGD->dprBase =
-	    (pGD->winSizeX * pGD->winSizeY * pGD->gdfBytesPP) + rinfo->fb_base_phys;
+	    (pGD->winSizeX * pGD->winSizeY * pGD->gdfBytesPP) + rinfo->fb_base;
 	if ((pGD->dprBase & 0x0fff) != 0) {
 		/* allign it */
 		pGD->dprBase &= 0xfffff000;
@@ -748,8 +751,8 @@ void *video_hw_init(void)
 	}
 	DPRINT ("Cursor Start %x Pattern Start %x\n", pGD->dprBase,
 		PATTERN_ADR);
-	pGD->vprBase = rinfo->fb_base_phys;	/* Dummy */
-	pGD->cprBase = rinfo->fb_base_phys;	/* Dummy */
+	pGD->vprBase = rinfo->fb_base;	/* Dummy */
+	pGD->cprBase = rinfo->fb_base;	/* Dummy */
 	/* set up Hardware */
 
 	/* Clear video memory (only visible screen area) */
diff --git a/drivers/video/ati_radeon_fb.h b/drivers/video/ati_radeon_fb.h
index e981f95..0659045 100644
--- a/drivers/video/ati_radeon_fb.h
+++ b/drivers/video/ati_radeon_fb.h
@@ -49,8 +49,8 @@ struct radeonfb_info {
 	struct pci_device_id	pdev;
 	u16			family;
 
-	u32			fb_base_phys;
-	u32			mmio_base_phys;
+	u32			fb_base_bus;
+	u32			mmio_base_bus;
 
 	void			*mmio_base;
 	void			*fb_base;
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] ati_radeon: Support PCI virtual not eq bus mapping.
  2010-03-31 14:54 [U-Boot] [PATCH] ati_radeon: Support PCI virtual not eq bus mapping Ed Swarthout
@ 2010-03-31 17:03 ` Anatolij Gustschin
  2010-03-31 20:52   ` [U-Boot] [PATCH V2] " Ed Swarthout
  0 siblings, 1 reply; 4+ messages in thread
From: Anatolij Gustschin @ 2010-03-31 17:03 UTC (permalink / raw)
  To: u-boot

On Wed, 31 Mar 2010 09:54:57 -0500
Ed Swarthout <Ed.Swarthout@freescale.com> wrote:

> Use pci_bus_to_virt() to convert the bus address from the BARs to
> virtual address' to eliminate the direct mapping requirement.
> 
> Rename variables to better match usage (_phys -> _bus or no-suffix)
> 
> This fixes the mpc8572ds CONFIG_PYS_64BIT mode failure: 
> "videoboot: Vidoe ROM failed to map!"

s/CONFIG_PYS_64BIT/CONFIG_PHYS_64BIT
s/Vidoe/Video

> Tested on mpc8572ds with and without CONFIG_PHYS_64BIT.
> 
> Signed-off-by: Ed Swarthout <Ed.Swarthout@freescale.com>
> ---
> 
> This patch is independent of the ati radeon return error patch,
> but for ease of debug it should be applied with this one.
> 
>  drivers/bios_emulator/atibios.c |    9 ++++---
>  drivers/video/ati_radeon_fb.c   |   45 ++++++++++++++++++++------------------
>  drivers/video/ati_radeon_fb.h   |    4 +-
>  3 files changed, 31 insertions(+), 27 deletions(-)

With this patch applied following warnings appear:

ati_radeon_fb.c: In function 'video_hw_init':
ati_radeon_fb.c:740: warning: assignment makes integer from pointer without a cast
ati_radeon_fb.c:741: warning: assignment makes integer from pointer without a cast
ati_radeon_fb.c:746: warning: assignment makes integer from pointer without a cast
ati_radeon_fb.c:754: warning: assignment makes integer from pointer without a cast
ati_radeon_fb.c:755: warning: assignment makes integer from pointer without a cast

Please include inlined patch below to fix them. Thanks.

Other than this, I tested this patch on PPC440EPx based sequoia board
with ATI Radeon 9250 PCI card, it works.

Anatolij


diff --git a/drivers/video/ati_radeon_fb.c b/drivers/video/ati_radeon_fb.c
index a74f724..c2c2096 100644
--- a/drivers/video/ati_radeon_fb.c
+++ b/drivers/video/ati_radeon_fb.c
@@ -737,13 +737,13 @@ void *video_hw_init(void)
 	}
 
 	pGD->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
-	pGD->pciBase = rinfo->fb_base;
-	pGD->frameAdrs = rinfo->fb_base;
+	pGD->pciBase = (unsigned int)rinfo->fb_base;
+	pGD->frameAdrs = (unsigned int)rinfo->fb_base;
 	pGD->memSize = 64 * 1024 * 1024;
 
 	/* Cursor Start Address */
-	pGD->dprBase =
-	    (pGD->winSizeX * pGD->winSizeY * pGD->gdfBytesPP) + rinfo->fb_base;
+	pGD->dprBase = (pGD->winSizeX * pGD->winSizeY * pGD->gdfBytesPP) +
+		       (unsigned int)rinfo->fb_base;
 	if ((pGD->dprBase & 0x0fff) != 0) {
 		/* allign it */
 		pGD->dprBase &= 0xfffff000;
@@ -751,8 +751,8 @@ void *video_hw_init(void)
 	}
 	DPRINT ("Cursor Start %x Pattern Start %x\n", pGD->dprBase,
 		PATTERN_ADR);
-	pGD->vprBase = rinfo->fb_base;	/* Dummy */
-	pGD->cprBase = rinfo->fb_base;	/* Dummy */
+	pGD->vprBase = (unsigned int)rinfo->fb_base;	/* Dummy */
+	pGD->cprBase = (unsigned int)rinfo->fb_base;	/* Dummy */
 	/* set up Hardware */
 
 	/* Clear video memory (only visible screen area) */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH V2] ati_radeon: Support PCI virtual not eq bus mapping.
  2010-03-31 17:03 ` Anatolij Gustschin
@ 2010-03-31 20:52   ` Ed Swarthout
  2010-04-08 14:37     ` Anatolij Gustschin
  0 siblings, 1 reply; 4+ messages in thread
From: Ed Swarthout @ 2010-03-31 20:52 UTC (permalink / raw)
  To: u-boot

Use pci_bus_to_virt() to convert the bus address from the BARs to
virtual address' to eliminate the direct mapping requirement.

Rename variables to better match usage (_phys -> _bus or no-suffix)

This fixes the mpc8572ds CONFIG_PHYS_64BIT mode failure:
"videoboot: Video ROM failed to map!"

Tested on mpc8572ds with and without CONFIG_PHYS_64BIT.

Signed-off-by: Ed Swarthout <Ed.Swarthout@freescale.com>
---

V2: 

 Fix typos and warnings as pointed out by Anatolij Gustschin. -thanks

 Fixed checkpatch error:

 ERROR: do not use assignment in if condition
 #41: FILE: drivers/bios_emulator/atibios.c:198:
 +	if ((BIOSImageBus = PCI_findBIOSAddr(pcidev, &BIOSImageBAR)) == 0) {

 drivers/bios_emulator/atibios.c |   10 +++++---
 drivers/video/ati_radeon_fb.c   |   47 ++++++++++++++++++++------------------
 drivers/video/ati_radeon_fb.h   |    4 +-
 3 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/drivers/bios_emulator/atibios.c b/drivers/bios_emulator/atibios.c
index 2881449..dbb5e8c 100644
--- a/drivers/bios_emulator/atibios.c
+++ b/drivers/bios_emulator/atibios.c
@@ -173,7 +173,7 @@ Maps a pointer to the BIOS image on the graphics card on the PCI bus.
 ****************************************************************************/
 void *PCI_mapBIOSImage(pci_dev_t pcidev)
 {
-	u32 BIOSImagePhys;
+	u32 BIOSImageBus;
 	int BIOSImageBAR;
 	u8 *BIOSImage;
 
@@ -195,16 +195,18 @@ void *PCI_mapBIOSImage(pci_dev_t pcidev)
 	 specific programming for different cards to solve this problem.
 	*/
 
-	if ((BIOSImagePhys = PCI_findBIOSAddr(pcidev, &BIOSImageBAR)) == 0) {
+	BIOSImageBus = PCI_findBIOSAddr(pcidev, &BIOSImageBAR);
+	if (BIOSImageBus == 0) {
 		printf("Find bios addr error\n");
 		return NULL;
 	}
 
-	BIOSImage = (u8 *) BIOSImagePhys;
+	BIOSImage = pci_bus_to_virt(pcidev, BIOSImageBus,
+				    PCI_REGION_MEM, 0, MAP_NOCACHE);
 
 	/*Change the PCI BAR registers to map it onto the bus.*/
 	pci_write_config_dword(pcidev, BIOSImageBAR, 0);
-	pci_write_config_dword(pcidev, PCI_ROM_ADDRESS, BIOSImagePhys | 0x1);
+	pci_write_config_dword(pcidev, PCI_ROM_ADDRESS, BIOSImageBus | 0x1);
 
 	udelay(1);
 
diff --git a/drivers/video/ati_radeon_fb.c b/drivers/video/ati_radeon_fb.c
index 529ddae..f797104 100644
--- a/drivers/video/ati_radeon_fb.c
+++ b/drivers/video/ati_radeon_fb.c
@@ -210,7 +210,7 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
 	 * ToDo: identify these cases
 	 */
 
-	DPRINT("radeonfb: Found %ldk of %s %d bits wide videoram\n",
+	DPRINT("radeonfb: Found %dk of %s %d bits wide videoram\n",
 	       rinfo->video_ram / 1024,
 	       rinfo->vram_ddr ? "DDR" : "SDRAM",
 	       rinfo->vram_width);
@@ -586,14 +586,16 @@ int radeon_probe(struct radeonfb_info *rinfo)
 		rinfo->pdev.device = did;
 		rinfo->family = get_radeon_id_family(rinfo->pdev.device);
 		pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0,
-				&rinfo->fb_base_phys);
+				&rinfo->fb_base_bus);
 		pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2,
-				&rinfo->mmio_base_phys);
-		rinfo->fb_base_phys &= 0xfffff000;
-		rinfo->mmio_base_phys &= ~0x04;
-
-		rinfo->mmio_base = (void *)rinfo->mmio_base_phys;
-		DPRINT("rinfo->mmio_base = 0x%x\n",rinfo->mmio_base);
+				&rinfo->mmio_base_bus);
+		rinfo->fb_base_bus &= 0xfffff000;
+		rinfo->mmio_base_bus &= ~0x04;
+
+		rinfo->mmio_base = pci_bus_to_virt(pdev, rinfo->mmio_base_bus,
+					PCI_REGION_MEM, 0, MAP_NOCACHE);
+		DPRINT("rinfo->mmio_base = 0x%x bus=0x%x\n",
+		       rinfo->mmio_base, rinfo->mmio_base_bus);
 		rinfo->fb_local_base = INREG(MC_FB_LOCATION) << 16;
 		DPRINT("rinfo->fb_local_base = 0x%x\n",rinfo->fb_local_base);
 		/* PostBIOS with x86 emulater */
@@ -611,14 +613,15 @@ int radeon_probe(struct radeonfb_info *rinfo)
 
 		rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM,
 				rinfo->video_ram);
-		rinfo->fb_base = (void *)rinfo->fb_base_phys;
-
-		DPRINT("Radeon: framebuffer base phy address 0x%08x," \
-		      "MMIO base phy address 0x%08x," \
-		      "framebuffer local base 0x%08x.\n ",
-		      rinfo->fb_base_phys, rinfo->mmio_base_phys,
-		      rinfo->fb_local_base);
-
+		rinfo->fb_base = pci_bus_to_virt(pdev, rinfo->fb_base_bus,
+					PCI_REGION_MEM, 0, MAP_NOCACHE);
+		DPRINT("Radeon: framebuffer base address 0x%08x, "
+		       "bus address 0x%08x\n"
+		       "MMIO base address 0x%08x, bus address 0x%08x, "
+		       "framebuffer local base 0x%08x.\n ",
+		       (u32)rinfo->fb_base, rinfo->fb_base_bus,
+		       (u32)rinfo->mmio_base, rinfo->mmio_base_bus,
+		       rinfo->fb_local_base);
 		return 0;
 	}
 	return -1;
@@ -734,13 +737,13 @@ void *video_hw_init(void)
 	}
 
 	pGD->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
-	pGD->pciBase = rinfo->fb_base_phys;
-	pGD->frameAdrs = rinfo->fb_base_phys;
+	pGD->pciBase = (unsigned int)rinfo->fb_base;
+	pGD->frameAdrs = (unsigned int)rinfo->fb_base;
 	pGD->memSize = 64 * 1024 * 1024;
 
 	/* Cursor Start Address */
-	pGD->dprBase =
-	    (pGD->winSizeX * pGD->winSizeY * pGD->gdfBytesPP) + rinfo->fb_base_phys;
+	pGD->dprBase = (pGD->winSizeX * pGD->winSizeY * pGD->gdfBytesPP) +
+		(unsigned int)rinfo->fb_base;
 	if ((pGD->dprBase & 0x0fff) != 0) {
 		/* allign it */
 		pGD->dprBase &= 0xfffff000;
@@ -748,8 +751,8 @@ void *video_hw_init(void)
 	}
 	DPRINT ("Cursor Start %x Pattern Start %x\n", pGD->dprBase,
 		PATTERN_ADR);
-	pGD->vprBase = rinfo->fb_base_phys;	/* Dummy */
-	pGD->cprBase = rinfo->fb_base_phys;	/* Dummy */
+	pGD->vprBase = (unsigned int)rinfo->fb_base;	/* Dummy */
+	pGD->cprBase = (unsigned int)rinfo->fb_base;	/* Dummy */
 	/* set up Hardware */
 
 	/* Clear video memory (only visible screen area) */
diff --git a/drivers/video/ati_radeon_fb.h b/drivers/video/ati_radeon_fb.h
index e981f95..0659045 100644
--- a/drivers/video/ati_radeon_fb.h
+++ b/drivers/video/ati_radeon_fb.h
@@ -49,8 +49,8 @@ struct radeonfb_info {
 	struct pci_device_id	pdev;
 	u16			family;
 
-	u32			fb_base_phys;
-	u32			mmio_base_phys;
+	u32			fb_base_bus;
+	u32			mmio_base_bus;
 
 	void			*mmio_base;
 	void			*fb_base;
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH V2] ati_radeon: Support PCI virtual not eq bus mapping.
  2010-03-31 20:52   ` [U-Boot] [PATCH V2] " Ed Swarthout
@ 2010-04-08 14:37     ` Anatolij Gustschin
  0 siblings, 0 replies; 4+ messages in thread
From: Anatolij Gustschin @ 2010-04-08 14:37 UTC (permalink / raw)
  To: u-boot

On Wed, 31 Mar 2010 15:52:40 -0500
Ed Swarthout <Ed.Swarthout@freescale.com> wrote:

> Use pci_bus_to_virt() to convert the bus address from the BARs to
> virtual address' to eliminate the direct mapping requirement.
> 
> Rename variables to better match usage (_phys -> _bus or no-suffix)
> 
> This fixes the mpc8572ds CONFIG_PHYS_64BIT mode failure:
> "videoboot: Video ROM failed to map!"
> 
> Tested on mpc8572ds with and without CONFIG_PHYS_64BIT.
> 
> Signed-off-by: Ed Swarthout <Ed.Swarthout@freescale.com>
> ---
> 
> V2: 
> 
>  Fix typos and warnings as pointed out by Anatolij Gustschin. -thanks
> 
>  Fixed checkpatch error:
> 
>  ERROR: do not use assignment in if condition
>  #41: FILE: drivers/bios_emulator/atibios.c:198:
>  +	if ((BIOSImageBus = PCI_findBIOSAddr(pcidev, &BIOSImageBAR)) == 0) {
> 
>  drivers/bios_emulator/atibios.c |   10 +++++---
>  drivers/video/ati_radeon_fb.c   |   47 ++++++++++++++++++++------------------
>  drivers/video/ati_radeon_fb.h   |    4 +-
>  3 files changed, 33 insertions(+), 28 deletions(-)

Applied to u-boot-video/master. Thanks!

Anatolij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-08 14:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-31 14:54 [U-Boot] [PATCH] ati_radeon: Support PCI virtual not eq bus mapping Ed Swarthout
2010-03-31 17:03 ` Anatolij Gustschin
2010-03-31 20:52   ` [U-Boot] [PATCH V2] " Ed Swarthout
2010-04-08 14:37     ` Anatolij Gustschin

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.