Skip to contentSkip to conversation

arm/tegra: pinmux: ioremap registers

PATCH Superseded Stephen Warren 2 participants 2 messages Oct 11, 2011 – Oct 12, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm/tegra: pinmux: ioremap registers

Use ioremap to obtain access to registers instead of using static mappings. This reduces the number of users of the static mappings, which will eventually allow them to be removed.

Note that on Tegra30, the number of register "spaces" will decrease to 2, and the packing of specific bits into registers will change significantly. That's why this change adds the "*_space" fields to the pingroup tables, rather than implementing some more hard-coded scheme.

Also, completely remove the implementation of suspend/resume; Tegra doesn't yet support suspend/resume, and the implementation is complex for the general pinmux driver:

* Not all registers are used within each space, so we probably shouldn't just iterate over every register in the space, and save/restore it, since that would mean touching undefined registers.

* Registers are shared between pingroups, so we can't simply iterate over each pingroup, and save/restore the registers it uses.

It'd probably be best have probe() calculate a bitmask of actually-used registers for each space, and have suspend/resume iterate over those bitmaps.

Oh, and Real Soon Now, I should be looking into converting this driver to the new pinmux/pinctrl subsystem, so I didn't want to put too much work into the current incarnation.

---
 arch/arm/mach-tegra/include/mach/pinmux.h |    4 +
 arch/arm/mach-tegra/pinmux-t2-tables.c    |   76 +++-------------
 arch/arm/mach-tegra/pinmux.c              |  137 ++++++++++++++++++++++-------
 3 files changed, 123 insertions(+), 94 deletions(-)
arch/arm/mach-tegra/include/mach/pinmux.h +4 -0
index defd877..741147f 100644
@@ -199,6 +199,7 @@ struct tegra_drive_pingroup_config {
 
 struct tegra_drive_pingroup_desc {
 	const char *name;
+	s16 reg_space;
 	s16 reg;
 };
 
@@ -207,6 +208,9 @@ struct tegra_pingroup_desc {
 	int funcs[4];
 	int func_safe;
 	int vddio;
+	s16 tri_space;	/* Register space the tri_reg exists within */
+	s16 mux_space;	/* Register space the mux_reg exists within */
+	s16 pupd_space;	/* Register space the pupd_reg exists within */
 	s16 tri_reg; 	/* offset into the TRISTATE_REG_* register bank */
 	s16 mux_reg;	/* offset into the PIN_MUX_CTL_* register bank */
 	s16 pupd_reg;	/* offset into the PULL_UPDOWN_REG_* register bank */
arch/arm/mach-tegra/pinmux-t2-tables.c +13 -63

96 lines not on this page · raw message

arch/arm/mach-tegra/pinmux.c +106 -31

269 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 arm/tegra: pinmux: ioremap registers

Hi,

Overall this looks pretty good, with a couple of nits below.

I'm not super-happy with all the opencoding of the reg / access passing into pg_readl/writel, but adding new helpers for all 4 kinds is also kind of verbose.

Quoted 13 lines · Stephen Warren
arch/arm/mach-tegra/include/mach/pinmux.h +1 -0
index defd877..741147f 100644
@@ -199,6 +199,7 @@ struct tegra_drive_pingroup_config {
 
 struct tegra_drive_pingroup_desc {
 	const char *name;
+	s16 reg_space;
 	s16 reg;
 };
 

arch/arm/mach-tegra/include/mach/pinmux.h struct tegra_pingroup_desc { · line 216

Quoted 9 lines
arch/arm/mach-tegra/include/mach/pinmux.h +3 -0
@@ -207,6 +208,9 @@ struct tegra_pingroup_desc {
 	int funcs[4];
 	int func_safe;
 	int vddio;
+	s16 tri_space;	/* Register space the tri_reg exists within */
+	s16 mux_space;	/* Register space the mux_reg exists within */
+	s16 pupd_space;	/* Register space the pupd_reg exists within */
 	s16 tri_reg; 	/* offset into the TRISTATE_REG_* register bank */
 	s16 mux_reg;	/* offset into the PIN_MUX_CTL_* register bank */
 	s16 pupd_reg;	/* offset into the PULL_UPDOWN_REG_* register bank */

'space' is really 'bank number' here, with *_reg is the offset into that bank, right? Calling it a register bank seems to go with the pre-existing language in the driver a bit more.

[...]

Quoted 14 lines
arch/arm/mach-tegra/pinmux.c +3 -1
index 46b9d87..99c2751 100644
@@ -170,15 +170,17 @@ static const char *pupd_name(unsigned long val)
 	}
 }
 
+static int nspaces;
+static void __iomem **regs;
 
-static inline unsigned long pg_readl(unsigned long offset)
+static inline u32 pg_readl(u32 reg, u32 space)
 {

arch/arm/mach-tegra/pinmux.c static const char *pupd_name(unsigned long val) · line 184

Quoted 10 lines
arch/arm/mach-tegra/pinmux.c +3 -3
-	return readl(IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset));
+	return readl(regs[space] + reg);
 }
 
-static inline void pg_writel(unsigned long value, unsigned long offset)
+static inline void pg_writel(u32 val, u32 reg, u32 space)
 {
-	writel(value, IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset));
+	writel(val, regs[space] + reg);
 }

For both of these, having the space (bank) before the offset into the bank seems a bit more logical, imho.

-Olof