ARM: tegra: Add emc files for Tegra12x
Mark Stadler [Wed, 1 Aug 2012 01:23:52 +0000 (18:23 -0700)]
Change-Id: Iee70053fff3a63fe56c76363289834c0e5d7165b
Reviewed-by: Mark Stadler <mastadler@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
Reviewed-by: Jeff Smith <jsmith@nvidia.com>
Tested-by: Ken Adams <kadams@nvidia.com>
Signed-off-by: Jin Qian <jqian@nvidia.com>
Reviewed-on: http://git-master/r/82934
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Signed-off-by: Mark Stadler <mastadler@nvidia.com>

arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/tegra12_emc.c [new file with mode: 0644]
arch/arm/mach-tegra/tegra12_emc.h [new file with mode: 0644]

index f649d7a..5924e2e 100644 (file)
@@ -115,6 +115,7 @@ obj-$(CONFIG_ARCH_TEGRA_14x_SOC)        += tegra3_actmon.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += tegra2_emc.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)         += tegra3_emc.o
 obj-$(CONFIG_ARCH_TEGRA_11x_SOC)        += tegra11_emc.o
+obj-$(CONFIG_ARCH_TEGRA_12x_SOC)        += tegra12_emc.o
 obj-$(CONFIG_ARCH_TEGRA_14x_SOC)        += tegra14_emc.o
 obj-y                                  += tegra_emc.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += pinmux-tegra20-tables.o
diff --git a/arch/arm/mach-tegra/tegra12_emc.c b/arch/arm/mach-tegra/tegra12_emc.c
new file mode 100644 (file)
index 0000000..6c0f364
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * arch/arm/mach-tegra/tegra12_emc.c
+ *
+ * Copyright (C) 2011 NVIDIA Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/io.h>
+
+#include "clock.h"
+#include "iomap.h"
+#include "tegra12_emc.h"
+
+static u32 dram_type = -1;
+
+static struct clk *emc;
+
+struct tegra_emc_table;
+
+static void __iomem *emc_base = IO_ADDRESS(TEGRA_EMC_BASE);
+static void __iomem *mc_base = IO_ADDRESS(TEGRA_MC_BASE);
+
+static inline void emc_writel(u32 val, unsigned long addr)
+{
+       writel(val, (u32)emc_base + addr);
+       barrier();
+}
+static inline u32 emc_readl(unsigned long addr)
+{
+       return readl((u32)emc_base + addr);
+}
+static inline void mc_writel(u32 val, unsigned long addr)
+{
+       writel(val, (u32)mc_base + addr);
+       barrier();
+}
+static inline u32 mc_readl(unsigned long addr)
+{
+       return readl((u32)mc_base + addr);
+}
+
+int tegra_emc_set_rate(unsigned long rate)
+{
+       /* FIXME: This is just a stub */
+       return 0;
+}
+
+long tegra_emc_round_rate(unsigned long rate)
+{
+       /* FIXME: This is just a stub */
+       return -EINVAL;
+}
+
+struct clk *tegra_emc_predict_parent(unsigned long rate, u32 *div_value)
+{
+       /* FIXME: This is just a stub */
+       return NULL;
+}
+
+void tegra_init_emc(const struct tegra_emc_table *table, int table_size)
+{
+       /* FIXME: This is just a stub */
+}
+
+void tegra_emc_timing_invalidate(void)
+{
+       /* FIXME: This is just a stub */
+}
+
+void tegra_emc_dram_type_init(struct clk *c)
+{
+       emc = c;
+
+       dram_type = (emc_readl(EMC_FBIO_CFG5) &
+                    EMC_CFG5_TYPE_MASK) >> EMC_CFG5_TYPE_SHIFT;
+}
+
+int tegra_emc_get_dram_type(void)
+{
+       return dram_type;
+}
diff --git a/arch/arm/mach-tegra/tegra12_emc.h b/arch/arm/mach-tegra/tegra12_emc.h
new file mode 100644 (file)
index 0000000..ede0027
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * arch/arm/mach-tegra/tegra12_emc.h
+ *
+ * Copyright (C) 2011-2012 NVIDIA Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef _MACH_TEGRA_TEGRA11_EMC_H
+#define _MACH_TEGRA_TEGRA11_EMC_H
+
+/* !!!FIXME!!! Need actual Tegra11x values */
+#define TEGRA_EMC_NUM_REGS             110
+
+#define TEGRA_EMC_BRIDGE_RATE_MIN      300000000
+#define TEGRA_EMC_BRIDGE_MVOLTS_MIN    1200
+
+struct tegra_emc_table {
+       u8 rev;
+       unsigned long rate;
+
+       /* unconditionally updated in one burst shot */
+       u32 burst_regs[TEGRA_EMC_NUM_REGS];
+
+       /* updated separately under some conditions */
+       u32 emc_zcal_cnt_long;
+       u32 emc_acal_interval;
+       u32 emc_periodic_qrst;
+       u32 emc_mode_reset;
+       u32 emc_mode_1;
+       u32 emc_mode_2;
+       u32 emc_dsr;
+       int emc_min_mv;
+};
+
+struct clk;
+
+void tegra_init_emc(const struct tegra_emc_table *table, int table_size);
+
+void tegra_emc_dram_type_init(struct clk *c);
+int tegra_emc_get_dram_type(void);
+
+#ifdef CONFIG_PM_SLEEP
+void tegra_mc_timing_restore(void);
+#else
+static inline void tegra_mc_timing_restore(void)
+{ }
+#endif
+
+#define EMC_FBIO_CFG5                          0x104
+#define EMC_CFG5_TYPE_SHIFT                    0x0
+#define EMC_CFG5_TYPE_MASK                     (0x3 << EMC_CFG5_TYPE_SHIFT)
+enum {
+       DRAM_TYPE_DDR3   = 0,
+       DRAM_TYPE_LPDDR2 = 2,
+};
+
+#endif