Skip to content

Commit ce7a10b

Browse files
Paul WalmsleyRussell King
authored andcommitted
ARM: 8334/1: amba: tegra-ahb: detect and correct bogus base address
amba: tegra-ahb: detect and correct bogus base address From a hardware SoC integration point of view, the starting address of this IP block in the existing Tegra SoC DT files is off by 4 bytes from the actual base address. Since we attempt to make old DT files forward-compatible with newer kernels, we cannot fix the IP block base address in old DT data. This patch works around the problem by detecting the four byte base address offset in the driver code, and correcting it if it's detected. (In general, IP block base addresses almost always have a null low byte.) Future SoC DT data for Tegra AHB should use the correct Tegra AHB base address, in cases where there is no DT data backward compatibility requirement. This patch is a revision of the patch originally titled "amba: tegra-ahb: use correct base address for future chip support". This revision implements changes requested by Russell King: http://marc.info/?l=linux-tegra&m=142658851825062&w=2 http://marc.info/?l=linux-tegra&m=142658873925178&w=2 Signed-off-by: Paul Walmsley <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Alexandre Courbot <[email protected]> Cc: Hiroshi DOYU <[email protected]> Cc: Stephen Warren <[email protected]> Cc: Thierry Reding <[email protected]> Cc: [email protected] Acked-by: Stephen Warren <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 049e4b3 commit ce7a10b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/amba/tegra-ahb.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@
8282

8383
#define AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE BIT(17)
8484

85+
/*
86+
* INCORRECT_BASE_ADDR_LOW_BYTE: Legacy kernel DT files for Tegra SoCs
87+
* prior to Tegra124 generally use a physical base address ending in
88+
* 0x4 for the AHB IP block. According to the TRM, the low byte
89+
* should be 0x0. During device probing, this macro is used to detect
90+
* whether the passed-in physical address is incorrect, and if so, to
91+
* correct it.
92+
*/
93+
#define INCORRECT_BASE_ADDR_LOW_BYTE 0x4
94+
8595
static struct platform_driver tegra_ahb_driver;
8696

8797
static const u32 tegra_ahb_gizmo[] = {
@@ -124,12 +134,12 @@ struct tegra_ahb {
124134

125135
static inline u32 gizmo_readl(struct tegra_ahb *ahb, u32 offset)
126136
{
127-
return readl(ahb->regs - 4 + offset);
137+
return readl(ahb->regs + offset);
128138
}
129139

130140
static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset)
131141
{
132-
writel(value, ahb->regs - 4 + offset);
142+
writel(value, ahb->regs + offset);
133143
}
134144

135145
#ifdef CONFIG_TEGRA_IOMMU_SMMU
@@ -258,6 +268,15 @@ static int tegra_ahb_probe(struct platform_device *pdev)
258268
return -ENOMEM;
259269

260270
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
271+
272+
/* Correct the IP block base address if necessary */
273+
if (res &&
274+
(res->start & INCORRECT_BASE_ADDR_LOW_BYTE) ==
275+
INCORRECT_BASE_ADDR_LOW_BYTE) {
276+
dev_warn(&pdev->dev, "incorrect AHB base address in DT data - enabling workaround\n");
277+
res->start -= INCORRECT_BASE_ADDR_LOW_BYTE;
278+
}
279+
261280
ahb->regs = devm_ioremap_resource(&pdev->dev, res);
262281
if (IS_ERR(ahb->regs))
263282
return PTR_ERR(ahb->regs);

0 commit comments

Comments
 (0)