@@ -26,6 +26,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <soc/tegra/ahb.h>
@@ -120,16 +121,17 @@ struct tegra_ahb {
void __iomem *regs;
struct device *dev;
u32 ctx[0];
+ short offset;
};
static inline u32 gizmo_readl(struct tegra_ahb *ahb, u32 offset)
{
- return readl(ahb->regs - 4 + offset);
+ return readl(ahb->regs + ahb->offset + offset);
}
static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset)
{
- writel(value, ahb->regs - 4 + offset);
+ writel(value, ahb->regs + ahb->offset + offset);
}
#ifdef CONFIG_TEGRA_IOMMU_SMMU
@@ -246,11 +248,30 @@ static void tegra_ahb_gizmo_init(struct tegra_ahb *ahb)
gizmo_writel(ahb, val, AHB_MEM_PREFETCH_CFG4);
}
+struct ahb_data {
+ short offset;
+};
+
+static const struct ahb_data correct_offset;
+static const struct ahb_data broken_offset = {
+ .offset = -4,
+};
+
+static const struct of_device_id tegra_ahb_of_match[] = {
+ { .compatible = "nvidia,tegra132-ahb", .data = &correct_offset },
+ { .compatible = "nvidia,tegra30-ahb", .data = &broken_offset },
+ { .compatible = "nvidia,tegra20-ahb", .data = &broken_offset },
+ {},
+};
+
static int tegra_ahb_probe(struct platform_device *pdev)
{
struct resource *res;
struct tegra_ahb *ahb;
size_t bytes;
+ const struct of_device_id *of_id =
+ of_match_device(tegra_ahb_of_match, &pdev->dev);
+ const struct ahb_data *ad;
bytes = sizeof(*ahb) + sizeof(u32) * ARRAY_SIZE(tegra_ahb_gizmo);
ahb = devm_kzalloc(&pdev->dev, bytes, GFP_KERNEL);
@@ -262,18 +283,15 @@ static int tegra_ahb_probe(struct platform_device *pdev)
if (IS_ERR(ahb->regs))
return PTR_ERR(ahb->regs);
+ ad = of_id->data;
ahb->dev = &pdev->dev;
+ ahb->offset = ad->offset;
+
platform_set_drvdata(pdev, ahb);
tegra_ahb_gizmo_init(ahb);
return 0;
}
-static const struct of_device_id tegra_ahb_of_match[] = {
- { .compatible = "nvidia,tegra30-ahb", },
- { .compatible = "nvidia,tegra20-ahb", },
- {},
-};
-
static struct platform_driver tegra_ahb_driver = {
.probe = tegra_ahb_probe,
.driver = {