From: Sylvain Munaut <tnt@246tNt•com>
To: Andrew Morton <akpm@osdl•org>
Cc: Tom Rini <trini@kernel•crashing.org>,
Sylvain Munaut <tnt@246tNt•com>,
Linux PPC Embedded <linuxppc-embedded@ozlabs•org>
Subject: [PATCH 7/9] ppc32: Fix MPC52xx configuration space access
Date: Tue, 20 Dec 2005 21:43:33 +0100 (CET) [thread overview]
Message-ID: <7.20051220_213752_1ebc_tnt@patchsend.246tNt.com> (raw)
In-Reply-To: <0.20051220_213752_1ebc_tnt@patchsend.246tNt.com>
ppc32: Fix MPC52xx configuration space access
This patch takes care of an errata of the MPC5200 by avoiding 32 bits
access in type 1 configuration accesses. All others accesses are still
32 bits wide. It also adds some mb() since the simple out_be(...) are
not sufficient in this case.
Signed-off-by: Sylvain Munaut <tnt@246tNt•com>
---
commit 20734ce8dc6fafd40c421bd275712d7bb6124d20
tree e53eeedbe423ecf718313dd2173031d456b4f3e8
parent 7834134483a1ae663b805714fcd741c1caf41171
author Sylvain Munaut <tnt@246tNt•com> Sun, 18 Dec 2005 14:52:51 +0100
committer Sylvain Munaut <tnt@246tNt•com> Sun, 18 Dec 2005 14:52:51 +0100
arch/ppc/syslib/mpc52xx_pci.c | 81 ++++++++++++++++++++++++++++++++++-------
1 files changed, 68 insertions(+), 13 deletions(-)
diff --git a/arch/ppc/syslib/mpc52xx_pci.c b/arch/ppc/syslib/mpc52xx_pci.c
index e6cb3e2..2c5e6dd 100644
--- a/arch/ppc/syslib/mpc52xx_pci.c
+++ b/arch/ppc/syslib/mpc52xx_pci.c
@@ -24,6 +24,12 @@
#include <asm/machdep.h>
+/* This macro is defined to activate the workaround for the bug
+ 435 of the MPC5200 (L25R). With it activated, we don't do any
+ 32 bits configuration access during type-1 cycles */
+#define MPC5200_BUG_435_WORKAROUND
+
+
static int
mpc52xx_pci_read_config(struct pci_bus *bus, unsigned int devfn,
int offset, int len, u32 *val)
@@ -40,17 +46,39 @@ mpc52xx_pci_read_config(struct pci_bus *
((bus->number - hose->bus_offset) << 16) |
(devfn << 8) |
(offset & 0xfc));
+ mb();
- value = in_le32(hose->cfg_data);
+#ifdef MPC5200_BUG_435_WORKAROUND
+ if (bus->number != hose->bus_offset) {
+ switch (len) {
+ case 1:
+ value = in_8(((u8 __iomem *)hose->cfg_data) + (offset & 3));
+ break;
+ case 2:
+ value = in_le16(((u16 __iomem *)hose->cfg_data) + ((offset>>1) & 1));
+ break;
+
+ default:
+ value = in_le16((u16 __iomem *)hose->cfg_data) |
+ (in_le16(((u16 __iomem *)hose->cfg_data) + 1) << 16);
+ break;
+ }
+ }
+ else
+#endif
+ {
+ value = in_le32(hose->cfg_data);
- if (len != 4) {
- value >>= ((offset & 0x3) << 3);
- value &= 0xffffffff >> (32 - (len << 3));
+ if (len != 4) {
+ value >>= ((offset & 0x3) << 3);
+ value &= 0xffffffff >> (32 - (len << 3));
+ }
}
*val = value;
out_be32(hose->cfg_addr, 0);
+ mb();
return PCIBIOS_SUCCESSFUL;
}
@@ -71,21 +99,48 @@ mpc52xx_pci_write_config(struct pci_bus
((bus->number - hose->bus_offset) << 16) |
(devfn << 8) |
(offset & 0xfc));
+ mb();
- if (len != 4) {
- value = in_le32(hose->cfg_data);
+#ifdef MPC5200_BUG_435_WORKAROUND
+ if (bus->number != hose->bus_offset) {
+ switch (len) {
+ case 1:
+ out_8(((u8 __iomem *)hose->cfg_data) +
+ (offset & 3), val);
+ break;
+ case 2:
+ out_le16(((u16 __iomem *)hose->cfg_data) +
+ ((offset>>1) & 1), val);
+ break;
+
+ default:
+ out_le16((u16 __iomem *)hose->cfg_data,
+ (u16)val);
+ out_le16(((u16 __iomem *)hose->cfg_data) + 1,
+ (u16)(val>>16));
+ break;
+ }
+ }
+ else
+#endif
+ {
+ if (len != 4) {
+ value = in_le32(hose->cfg_data);
+
+ offset = (offset & 0x3) << 3;
+ mask = (0xffffffff >> (32 - (len << 3)));
+ mask <<= offset;
- offset = (offset & 0x3) << 3;
- mask = (0xffffffff >> (32 - (len << 3)));
- mask <<= offset;
+ value &= ~mask;
+ val = value | ((val << offset) & mask);
+ }
- value &= ~mask;
- val = value | ((val << offset) & mask);
+ out_le32(hose->cfg_data, val);
}
-
- out_le32(hose->cfg_data, val);
+ mb();
out_be32(hose->cfg_addr, 0);
+ mb();
return PCIBIOS_SUCCESSFUL;
}
next prev parent reply other threads:[~2005-12-20 20:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-20 20:40 [PATCH 0/9] Some Freescale MPC52xx related updates Sylvain Munaut
2005-12-20 20:40 ` [PATCH 1/9] ppc32: Remove useless file arch/ppc/platforms/mpc5200.c Sylvain Munaut
2005-12-20 20:41 ` [PATCH 2/9] ppc32/serial: Fix compiler errors with GCC 4.x in mpc52xx_uart.c Sylvain Munaut
2005-12-20 20:41 ` [PATCH 3/9] ppc32/serial: Change mpc52xx_uart.c to use the Low Density Serial port major Sylvain Munaut
2005-12-20 20:42 ` [PATCH 4/9] ppc32: Fix static IO mapping for Freescale MPC52xx Sylvain Munaut
2005-12-20 20:42 ` [PATCH 5/9] ppc32: Modify Freescale MPC52xx IRQ mapping to _not_ use irq 0 Sylvain Munaut
2005-12-20 20:43 ` [PATCH 6/9] ppc32: Remove __init qualifier from mpc52xx pci resources fixups Sylvain Munaut
2005-12-20 20:43 ` Sylvain Munaut [this message]
2005-12-20 20:44 ` [PATCH 8/9] ppc32: Fix MPC52xx PCI init in cas the bootloader didn't do it Sylvain Munaut
2005-12-20 20:44 ` [PATCH 9/9] ppc32: Allows compilation of a MPC52xx kernel without PCI Sylvain Munaut
2005-12-20 20:54 ` [PATCH 0/9] Some Freescale MPC52xx related updates Kumar Gala
2005-12-20 21:36 ` Sylvain Munaut
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=7.20051220_213752_1ebc_tnt@patchsend.246tNt.com \
--to=tnt@246tnt$(echo .)com \
--cc=akpm@osdl$(echo .)org \
--cc=linuxppc-embedded@ozlabs$(echo .)org \
--cc=trini@kernel$(echo .)crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox