diff options
| -rw-r--r-- | arch/arm/mach-tegra/board-harmony-pcie.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-tegra/board-harmony-pinmux.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-tegra/board-paz00-pinmux.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-tegra/board-trimslice-pinmux.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-tegra/include/mach/pinmux.h | 25 | ||||
| -rw-r--r-- | arch/arm/mach-tegra/pinmux-tegra20-tables.c | 15 | ||||
| -rw-r--r-- | arch/arm/mach-tegra/pinmux.c | 105 |
7 files changed, 86 insertions, 63 deletions
diff --git a/arch/arm/mach-tegra/board-harmony-pcie.c b/arch/arm/mach-tegra/board-harmony-pcie.c index 6db7d699ef1c..bd402d0d5d06 100644 --- a/arch/arm/mach-tegra/board-harmony-pcie.c +++ b/arch/arm/mach-tegra/board-harmony-pcie.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <asm/mach-types.h> | 23 | #include <asm/mach-types.h> |
| 24 | 24 | ||
| 25 | #include <mach/pinmux.h> | 25 | #include <mach/pinmux.h> |
| 26 | #include <mach/pinmux-tegra20.h> | ||
| 26 | #include "board.h" | 27 | #include "board.h" |
| 27 | #include "board-harmony.h" | 28 | #include "board-harmony.h" |
| 28 | 29 | ||
diff --git a/arch/arm/mach-tegra/board-harmony-pinmux.c b/arch/arm/mach-tegra/board-harmony-pinmux.c index 7a4a26d5174c..b8a2485e3cb9 100644 --- a/arch/arm/mach-tegra/board-harmony-pinmux.c +++ b/arch/arm/mach-tegra/board-harmony-pinmux.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
| 20 | 20 | ||
| 21 | #include <mach/pinmux.h> | 21 | #include <mach/pinmux.h> |
| 22 | #include <mach/pinmux-tegra20.h> | ||
| 22 | 23 | ||
| 23 | #include "gpio-names.h" | 24 | #include "gpio-names.h" |
| 24 | #include "board-harmony.h" | 25 | #include "board-harmony.h" |
diff --git a/arch/arm/mach-tegra/board-paz00-pinmux.c b/arch/arm/mach-tegra/board-paz00-pinmux.c index be30e215f4b7..bc1fe58c26fb 100644 --- a/arch/arm/mach-tegra/board-paz00-pinmux.c +++ b/arch/arm/mach-tegra/board-paz00-pinmux.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
| 20 | 20 | ||
| 21 | #include <mach/pinmux.h> | 21 | #include <mach/pinmux.h> |
| 22 | #include <mach/pinmux-tegra20.h> | ||
| 22 | 23 | ||
| 23 | #include "gpio-names.h" | 24 | #include "gpio-names.h" |
| 24 | #include "board-paz00.h" | 25 | #include "board-paz00.h" |
diff --git a/arch/arm/mach-tegra/board-trimslice-pinmux.c b/arch/arm/mach-tegra/board-trimslice-pinmux.c index 7ab719d46da0..7331e15b73cc 100644 --- a/arch/arm/mach-tegra/board-trimslice-pinmux.c +++ b/arch/arm/mach-tegra/board-trimslice-pinmux.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
| 20 | 20 | ||
| 21 | #include <mach/pinmux.h> | 21 | #include <mach/pinmux.h> |
| 22 | #include <mach/pinmux-tegra20.h> | ||
| 22 | 23 | ||
| 23 | #include "gpio-names.h" | 24 | #include "gpio-names.h" |
| 24 | #include "board-trimslice.h" | 25 | #include "board-trimslice.h" |
diff --git a/arch/arm/mach-tegra/include/mach/pinmux.h b/arch/arm/mach-tegra/include/mach/pinmux.h index b93df9e31349..35999ce7c9b2 100644 --- a/arch/arm/mach-tegra/include/mach/pinmux.h +++ b/arch/arm/mach-tegra/include/mach/pinmux.h | |||
| @@ -17,12 +17,6 @@ | |||
| 17 | #ifndef __MACH_TEGRA_PINMUX_H | 17 | #ifndef __MACH_TEGRA_PINMUX_H |
| 18 | #define __MACH_TEGRA_PINMUX_H | 18 | #define __MACH_TEGRA_PINMUX_H |
| 19 | 19 | ||
| 20 | #if defined(CONFIG_ARCH_TEGRA_2x_SOC) | ||
| 21 | #include "pinmux-tegra20.h" | ||
| 22 | #else | ||
| 23 | #error "Undefined Tegra architecture" | ||
| 24 | #endif | ||
| 25 | |||
| 26 | enum tegra_mux_func { | 20 | enum tegra_mux_func { |
| 27 | TEGRA_MUX_RSVD = 0x8000, | 21 | TEGRA_MUX_RSVD = 0x8000, |
| 28 | TEGRA_MUX_RSVD1 = 0x8000, | 22 | TEGRA_MUX_RSVD1 = 0x8000, |
| @@ -118,7 +112,7 @@ enum tegra_vddio { | |||
| 118 | }; | 112 | }; |
| 119 | 113 | ||
| 120 | struct tegra_pingroup_config { | 114 | struct tegra_pingroup_config { |
| 121 | enum tegra_pingroup pingroup; | 115 | int pingroup; |
| 122 | enum tegra_mux_func func; | 116 | enum tegra_mux_func func; |
| 123 | enum tegra_pullupdown pupd; | 117 | enum tegra_pullupdown pupd; |
| 124 | enum tegra_tristate tristate; | 118 | enum tegra_tristate tristate; |
| @@ -187,7 +181,7 @@ enum tegra_schmitt { | |||
| 187 | }; | 181 | }; |
| 188 | 182 | ||
| 189 | struct tegra_drive_pingroup_config { | 183 | struct tegra_drive_pingroup_config { |
| 190 | enum tegra_drive_pingroup pingroup; | 184 | int pingroup; |
| 191 | enum tegra_hsm hsm; | 185 | enum tegra_hsm hsm; |
| 192 | enum tegra_schmitt schmitt; | 186 | enum tegra_schmitt schmitt; |
| 193 | enum tegra_drive drive; | 187 | enum tegra_drive drive; |
| @@ -219,13 +213,15 @@ struct tegra_pingroup_desc { | |||
| 219 | s8 pupd_bit; /* offset into the PULL_UPDOWN_REG_* register bit */ | 213 | s8 pupd_bit; /* offset into the PULL_UPDOWN_REG_* register bit */ |
| 220 | }; | 214 | }; |
| 221 | 215 | ||
| 222 | extern const struct tegra_pingroup_desc tegra_soc_pingroups[]; | 216 | typedef void (*pinmux_init) (const struct tegra_pingroup_desc **pg, |
| 223 | extern const struct tegra_drive_pingroup_desc tegra_soc_drive_pingroups[]; | 217 | int *pg_max, const struct tegra_drive_pingroup_desc **pgdrive, |
| 218 | int *pgdrive_max); | ||
| 224 | 219 | ||
| 225 | int tegra_pinmux_set_tristate(enum tegra_pingroup pg, | 220 | void tegra20_pinmux_init(const struct tegra_pingroup_desc **pg, int *pg_max, |
| 226 | enum tegra_tristate tristate); | 221 | const struct tegra_drive_pingroup_desc **pgdrive, int *pgdrive_max); |
| 227 | int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg, | 222 | |
| 228 | enum tegra_pullupdown pupd); | 223 | int tegra_pinmux_set_tristate(int pg, enum tegra_tristate tristate); |
| 224 | int tegra_pinmux_set_pullupdown(int pg, enum tegra_pullupdown pupd); | ||
| 229 | 225 | ||
| 230 | void tegra_pinmux_config_table(const struct tegra_pingroup_config *config, | 226 | void tegra_pinmux_config_table(const struct tegra_pingroup_config *config, |
| 231 | int len); | 227 | int len); |
| @@ -241,4 +237,3 @@ void tegra_pinmux_config_tristate_table(const struct tegra_pingroup_config *conf | |||
| 241 | void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *config, | 237 | void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *config, |
| 242 | int len, enum tegra_pullupdown pupd); | 238 | int len, enum tegra_pullupdown pupd); |
| 243 | #endif | 239 | #endif |
| 244 | |||
diff --git a/arch/arm/mach-tegra/pinmux-tegra20-tables.c b/arch/arm/mach-tegra/pinmux-tegra20-tables.c index 88642a54e3aa..efe6aeeea474 100644 --- a/arch/arm/mach-tegra/pinmux-tegra20-tables.c +++ b/arch/arm/mach-tegra/pinmux-tegra20-tables.c | |||
| @@ -44,7 +44,7 @@ | |||
| 44 | .reg = ((r) - PINGROUP_REG_A) \ | 44 | .reg = ((r) - PINGROUP_REG_A) \ |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | const struct tegra_drive_pingroup_desc tegra_soc_drive_pingroups[TEGRA_MAX_DRIVE_PINGROUP] = { | 47 | static const struct tegra_drive_pingroup_desc tegra_soc_drive_pingroups[TEGRA_MAX_DRIVE_PINGROUP] = { |
| 48 | DRIVE_PINGROUP(AO1, 0x868), | 48 | DRIVE_PINGROUP(AO1, 0x868), |
| 49 | DRIVE_PINGROUP(AO2, 0x86c), | 49 | DRIVE_PINGROUP(AO2, 0x86c), |
| 50 | DRIVE_PINGROUP(AT1, 0x870), | 50 | DRIVE_PINGROUP(AT1, 0x870), |
| @@ -108,7 +108,7 @@ const struct tegra_drive_pingroup_desc tegra_soc_drive_pingroups[TEGRA_MAX_DRIVE | |||
| 108 | .pupd_bit = pupd_b, \ | 108 | .pupd_bit = pupd_b, \ |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | const struct tegra_pingroup_desc tegra_soc_pingroups[TEGRA_MAX_PINGROUP] = { | 111 | static const struct tegra_pingroup_desc tegra_soc_pingroups[TEGRA_MAX_PINGROUP] = { |
| 112 | PINGROUP(ATA, NAND, IDE, NAND, GMI, RSVD, IDE, 0x14, 0, 0x80, 24, 0xA0, 0), | 112 | PINGROUP(ATA, NAND, IDE, NAND, GMI, RSVD, IDE, 0x14, 0, 0x80, 24, 0xA0, 0), |
| 113 | PINGROUP(ATB, NAND, IDE, NAND, GMI, SDIO4, IDE, 0x14, 1, 0x80, 16, 0xA0, 2), | 113 | PINGROUP(ATB, NAND, IDE, NAND, GMI, SDIO4, IDE, 0x14, 1, 0x80, 16, 0xA0, 2), |
| 114 | PINGROUP(ATC, NAND, IDE, NAND, GMI, SDIO4, IDE, 0x14, 2, 0x80, 22, 0xA0, 4), | 114 | PINGROUP(ATC, NAND, IDE, NAND, GMI, SDIO4, IDE, 0x14, 2, 0x80, 22, 0xA0, 4), |
| @@ -227,3 +227,14 @@ const struct tegra_pingroup_desc tegra_soc_pingroups[TEGRA_MAX_PINGROUP] = { | |||
| 227 | PINGROUP(XM2C, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xA8, 30), | 227 | PINGROUP(XM2C, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xA8, 30), |
| 228 | PINGROUP(XM2D, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xA8, 28), | 228 | PINGROUP(XM2D, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xA8, 28), |
| 229 | }; | 229 | }; |
| 230 | |||
| 231 | void __init tegra20_pinmux_init(const struct tegra_pingroup_desc **pg, | ||
| 232 | int *pg_max, const struct tegra_drive_pingroup_desc **pgdrive, | ||
| 233 | int *pgdrive_max) | ||
| 234 | { | ||
| 235 | *pg = tegra_soc_pingroups; | ||
| 236 | *pg_max = TEGRA_MAX_PINGROUP; | ||
| 237 | *pgdrive = tegra_soc_drive_pingroups; | ||
| 238 | *pgdrive_max = TEGRA_MAX_DRIVE_PINGROUP; | ||
| 239 | } | ||
| 240 | |||
diff --git a/arch/arm/mach-tegra/pinmux.c b/arch/arm/mach-tegra/pinmux.c index 1d201650d7a4..45ebd8ceccca 100644 --- a/arch/arm/mach-tegra/pinmux.c +++ b/arch/arm/mach-tegra/pinmux.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/spinlock.h> | 21 | #include <linux/spinlock.h> |
| 22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
| 23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/of_device.h> | ||
| 24 | 25 | ||
| 25 | #include <mach/iomap.h> | 26 | #include <mach/iomap.h> |
| 26 | #include <mach/pinmux.h> | 27 | #include <mach/pinmux.h> |
| @@ -33,8 +34,10 @@ | |||
| 33 | #define SLWR(reg) (((reg) >> 28) & 0x3) | 34 | #define SLWR(reg) (((reg) >> 28) & 0x3) |
| 34 | #define SLWF(reg) (((reg) >> 30) & 0x3) | 35 | #define SLWF(reg) (((reg) >> 30) & 0x3) |
| 35 | 36 | ||
| 36 | static const struct tegra_pingroup_desc *const pingroups = tegra_soc_pingroups; | 37 | static const struct tegra_pingroup_desc *pingroups; |
| 37 | static const struct tegra_drive_pingroup_desc *const drive_pingroups = tegra_soc_drive_pingroups; | 38 | static const struct tegra_drive_pingroup_desc *drive_pingroups; |
| 39 | static int pingroup_max; | ||
| 40 | static int drive_max; | ||
| 38 | 41 | ||
| 39 | static char *tegra_mux_names[TEGRA_MAX_MUX] = { | 42 | static char *tegra_mux_names[TEGRA_MAX_MUX] = { |
| 40 | [TEGRA_MUX_AHB_CLK] = "AHB_CLK", | 43 | [TEGRA_MUX_AHB_CLK] = "AHB_CLK", |
| @@ -116,9 +119,9 @@ static const char *tegra_slew_names[TEGRA_MAX_SLEW] = { | |||
| 116 | 119 | ||
| 117 | static DEFINE_SPINLOCK(mux_lock); | 120 | static DEFINE_SPINLOCK(mux_lock); |
| 118 | 121 | ||
| 119 | static const char *pingroup_name(enum tegra_pingroup pg) | 122 | static const char *pingroup_name(int pg) |
| 120 | { | 123 | { |
| 121 | if (pg < 0 || pg >= TEGRA_MAX_PINGROUP) | 124 | if (pg < 0 || pg >= pingroup_max) |
| 122 | return "<UNKNOWN>"; | 125 | return "<UNKNOWN>"; |
| 123 | 126 | ||
| 124 | return pingroups[pg].name; | 127 | return pingroups[pg].name; |
| @@ -189,10 +192,10 @@ static int tegra_pinmux_set_func(const struct tegra_pingroup_config *config) | |||
| 189 | int i; | 192 | int i; |
| 190 | unsigned long reg; | 193 | unsigned long reg; |
| 191 | unsigned long flags; | 194 | unsigned long flags; |
| 192 | enum tegra_pingroup pg = config->pingroup; | 195 | int pg = config->pingroup; |
| 193 | enum tegra_mux_func func = config->func; | 196 | enum tegra_mux_func func = config->func; |
| 194 | 197 | ||
| 195 | if (pg < 0 || pg >= TEGRA_MAX_PINGROUP) | 198 | if (pg < 0 || pg >= pingroup_max) |
| 196 | return -ERANGE; | 199 | return -ERANGE; |
| 197 | 200 | ||
| 198 | if (pingroups[pg].mux_reg < 0) | 201 | if (pingroups[pg].mux_reg < 0) |
| @@ -230,13 +233,12 @@ static int tegra_pinmux_set_func(const struct tegra_pingroup_config *config) | |||
| 230 | return 0; | 233 | return 0; |
| 231 | } | 234 | } |
| 232 | 235 | ||
| 233 | int tegra_pinmux_set_tristate(enum tegra_pingroup pg, | 236 | int tegra_pinmux_set_tristate(int pg, enum tegra_tristate tristate) |
| 234 | enum tegra_tristate tristate) | ||
| 235 | { | 237 | { |
| 236 | unsigned long reg; | 238 | unsigned long reg; |
| 237 | unsigned long flags; | 239 | unsigned long flags; |
| 238 | 240 | ||
| 239 | if (pg < 0 || pg >= TEGRA_MAX_PINGROUP) | 241 | if (pg < 0 || pg >= pingroup_max) |
| 240 | return -ERANGE; | 242 | return -ERANGE; |
| 241 | 243 | ||
| 242 | if (pingroups[pg].tri_reg < 0) | 244 | if (pingroups[pg].tri_reg < 0) |
| @@ -255,13 +257,12 @@ int tegra_pinmux_set_tristate(enum tegra_pingroup pg, | |||
| 255 | return 0; | 257 | return 0; |
| 256 | } | 258 | } |
| 257 | 259 | ||
| 258 | int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg, | 260 | int tegra_pinmux_set_pullupdown(int pg, enum tegra_pullupdown pupd) |
| 259 | enum tegra_pullupdown pupd) | ||
| 260 | { | 261 | { |
| 261 | unsigned long reg; | 262 | unsigned long reg; |
| 262 | unsigned long flags; | 263 | unsigned long flags; |
| 263 | 264 | ||
| 264 | if (pg < 0 || pg >= TEGRA_MAX_PINGROUP) | 265 | if (pg < 0 || pg >= pingroup_max) |
| 265 | return -ERANGE; | 266 | return -ERANGE; |
| 266 | 267 | ||
| 267 | if (pingroups[pg].pupd_reg < 0) | 268 | if (pingroups[pg].pupd_reg < 0) |
| @@ -287,7 +288,7 @@ int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg, | |||
| 287 | 288 | ||
| 288 | static void tegra_pinmux_config_pingroup(const struct tegra_pingroup_config *config) | 289 | static void tegra_pinmux_config_pingroup(const struct tegra_pingroup_config *config) |
| 289 | { | 290 | { |
| 290 | enum tegra_pingroup pingroup = config->pingroup; | 291 | int pingroup = config->pingroup; |
| 291 | enum tegra_mux_func func = config->func; | 292 | enum tegra_mux_func func = config->func; |
| 292 | enum tegra_pullupdown pupd = config->pupd; | 293 | enum tegra_pullupdown pupd = config->pupd; |
| 293 | enum tegra_tristate tristate = config->tristate; | 294 | enum tegra_tristate tristate = config->tristate; |
| @@ -323,9 +324,9 @@ void tegra_pinmux_config_table(const struct tegra_pingroup_config *config, int l | |||
| 323 | tegra_pinmux_config_pingroup(&config[i]); | 324 | tegra_pinmux_config_pingroup(&config[i]); |
| 324 | } | 325 | } |
| 325 | 326 | ||
| 326 | static const char *drive_pinmux_name(enum tegra_drive_pingroup pg) | 327 | static const char *drive_pinmux_name(int pg) |
| 327 | { | 328 | { |
| 328 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 329 | if (pg < 0 || pg >= drive_max) |
| 329 | return "<UNKNOWN>"; | 330 | return "<UNKNOWN>"; |
| 330 | 331 | ||
| 331 | return drive_pingroups[pg].name; | 332 | return drive_pingroups[pg].name; |
| @@ -352,12 +353,11 @@ static const char *slew_name(unsigned long val) | |||
| 352 | return tegra_slew_names[val]; | 353 | return tegra_slew_names[val]; |
| 353 | } | 354 | } |
| 354 | 355 | ||
| 355 | static int tegra_drive_pinmux_set_hsm(enum tegra_drive_pingroup pg, | 356 | static int tegra_drive_pinmux_set_hsm(int pg, enum tegra_hsm hsm) |
| 356 | enum tegra_hsm hsm) | ||
| 357 | { | 357 | { |
| 358 | unsigned long flags; | 358 | unsigned long flags; |
| 359 | u32 reg; | 359 | u32 reg; |
| 360 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 360 | if (pg < 0 || pg >= drive_max) |
| 361 | return -ERANGE; | 361 | return -ERANGE; |
| 362 | 362 | ||
| 363 | if (hsm != TEGRA_HSM_ENABLE && hsm != TEGRA_HSM_DISABLE) | 363 | if (hsm != TEGRA_HSM_ENABLE && hsm != TEGRA_HSM_DISABLE) |
| @@ -377,12 +377,11 @@ static int tegra_drive_pinmux_set_hsm(enum tegra_drive_pingroup pg, | |||
| 377 | return 0; | 377 | return 0; |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | static int tegra_drive_pinmux_set_schmitt(enum tegra_drive_pingroup pg, | 380 | static int tegra_drive_pinmux_set_schmitt(int pg, enum tegra_schmitt schmitt) |
| 381 | enum tegra_schmitt schmitt) | ||
| 382 | { | 381 | { |
| 383 | unsigned long flags; | 382 | unsigned long flags; |
| 384 | u32 reg; | 383 | u32 reg; |
| 385 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 384 | if (pg < 0 || pg >= drive_max) |
| 386 | return -ERANGE; | 385 | return -ERANGE; |
| 387 | 386 | ||
| 388 | if (schmitt != TEGRA_SCHMITT_ENABLE && schmitt != TEGRA_SCHMITT_DISABLE) | 387 | if (schmitt != TEGRA_SCHMITT_ENABLE && schmitt != TEGRA_SCHMITT_DISABLE) |
| @@ -402,12 +401,11 @@ static int tegra_drive_pinmux_set_schmitt(enum tegra_drive_pingroup pg, | |||
| 402 | return 0; | 401 | return 0; |
| 403 | } | 402 | } |
| 404 | 403 | ||
| 405 | static int tegra_drive_pinmux_set_drive(enum tegra_drive_pingroup pg, | 404 | static int tegra_drive_pinmux_set_drive(int pg, enum tegra_drive drive) |
| 406 | enum tegra_drive drive) | ||
| 407 | { | 405 | { |
| 408 | unsigned long flags; | 406 | unsigned long flags; |
| 409 | u32 reg; | 407 | u32 reg; |
| 410 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 408 | if (pg < 0 || pg >= drive_max) |
| 411 | return -ERANGE; | 409 | return -ERANGE; |
| 412 | 410 | ||
| 413 | if (drive < 0 || drive >= TEGRA_MAX_DRIVE) | 411 | if (drive < 0 || drive >= TEGRA_MAX_DRIVE) |
| @@ -425,12 +423,12 @@ static int tegra_drive_pinmux_set_drive(enum tegra_drive_pingroup pg, | |||
| 425 | return 0; | 423 | return 0; |
| 426 | } | 424 | } |
| 427 | 425 | ||
| 428 | static int tegra_drive_pinmux_set_pull_down(enum tegra_drive_pingroup pg, | 426 | static int tegra_drive_pinmux_set_pull_down(int pg, |
| 429 | enum tegra_pull_strength pull_down) | 427 | enum tegra_pull_strength pull_down) |
| 430 | { | 428 | { |
| 431 | unsigned long flags; | 429 | unsigned long flags; |
| 432 | u32 reg; | 430 | u32 reg; |
| 433 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 431 | if (pg < 0 || pg >= drive_max) |
| 434 | return -ERANGE; | 432 | return -ERANGE; |
| 435 | 433 | ||
| 436 | if (pull_down < 0 || pull_down >= TEGRA_MAX_PULL) | 434 | if (pull_down < 0 || pull_down >= TEGRA_MAX_PULL) |
| @@ -448,12 +446,12 @@ static int tegra_drive_pinmux_set_pull_down(enum tegra_drive_pingroup pg, | |||
| 448 | return 0; | 446 | return 0; |
| 449 | } | 447 | } |
| 450 | 448 | ||
| 451 | static int tegra_drive_pinmux_set_pull_up(enum tegra_drive_pingroup pg, | 449 | static int tegra_drive_pinmux_set_pull_up(int pg, |
| 452 | enum tegra_pull_strength pull_up) | 450 | enum tegra_pull_strength pull_up) |
| 453 | { | 451 | { |
| 454 | unsigned long flags; | 452 | unsigned long flags; |
| 455 | u32 reg; | 453 | u32 reg; |
| 456 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 454 | if (pg < 0 || pg >= drive_max) |
| 457 | return -ERANGE; | 455 | return -ERANGE; |
| 458 | 456 | ||
| 459 | if (pull_up < 0 || pull_up >= TEGRA_MAX_PULL) | 457 | if (pull_up < 0 || pull_up >= TEGRA_MAX_PULL) |
| @@ -471,12 +469,12 @@ static int tegra_drive_pinmux_set_pull_up(enum tegra_drive_pingroup pg, | |||
| 471 | return 0; | 469 | return 0; |
| 472 | } | 470 | } |
| 473 | 471 | ||
| 474 | static int tegra_drive_pinmux_set_slew_rising(enum tegra_drive_pingroup pg, | 472 | static int tegra_drive_pinmux_set_slew_rising(int pg, |
| 475 | enum tegra_slew slew_rising) | 473 | enum tegra_slew slew_rising) |
| 476 | { | 474 | { |
| 477 | unsigned long flags; | 475 | unsigned long flags; |
| 478 | u32 reg; | 476 | u32 reg; |
| 479 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 477 | if (pg < 0 || pg >= drive_max) |
| 480 | return -ERANGE; | 478 | return -ERANGE; |
| 481 | 479 | ||
| 482 | if (slew_rising < 0 || slew_rising >= TEGRA_MAX_SLEW) | 480 | if (slew_rising < 0 || slew_rising >= TEGRA_MAX_SLEW) |
| @@ -494,12 +492,12 @@ static int tegra_drive_pinmux_set_slew_rising(enum tegra_drive_pingroup pg, | |||
| 494 | return 0; | 492 | return 0; |
| 495 | } | 493 | } |
| 496 | 494 | ||
| 497 | static int tegra_drive_pinmux_set_slew_falling(enum tegra_drive_pingroup pg, | 495 | static int tegra_drive_pinmux_set_slew_falling(int pg, |
| 498 | enum tegra_slew slew_falling) | 496 | enum tegra_slew slew_falling) |
| 499 | { | 497 | { |
| 500 | unsigned long flags; | 498 | unsigned long flags; |
| 501 | u32 reg; | 499 | u32 reg; |
| 502 | if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP) | 500 | if (pg < 0 || pg >= drive_max) |
| 503 | return -ERANGE; | 501 | return -ERANGE; |
| 504 | 502 | ||
| 505 | if (slew_falling < 0 || slew_falling >= TEGRA_MAX_SLEW) | 503 | if (slew_falling < 0 || slew_falling >= TEGRA_MAX_SLEW) |
| @@ -517,7 +515,7 @@ static int tegra_drive_pinmux_set_slew_falling(enum tegra_drive_pingroup pg, | |||
| 517 | return 0; | 515 | return 0; |
| 518 | } | 516 | } |
| 519 | 517 | ||
| 520 | static void tegra_drive_pinmux_config_pingroup(enum tegra_drive_pingroup pingroup, | 518 | static void tegra_drive_pinmux_config_pingroup(int pingroup, |
| 521 | enum tegra_hsm hsm, | 519 | enum tegra_hsm hsm, |
| 522 | enum tegra_schmitt schmitt, | 520 | enum tegra_schmitt schmitt, |
| 523 | enum tegra_drive drive, | 521 | enum tegra_drive drive, |
| @@ -596,7 +594,7 @@ void tegra_pinmux_set_safe_pinmux_table(const struct tegra_pingroup_config *conf | |||
| 596 | for (i = 0; i < len; i++) { | 594 | for (i = 0; i < len; i++) { |
| 597 | int err; | 595 | int err; |
| 598 | c = config[i]; | 596 | c = config[i]; |
| 599 | if (c.pingroup < 0 || c.pingroup >= TEGRA_MAX_PINGROUP) { | 597 | if (c.pingroup < 0 || c.pingroup >= pingroup_max) { |
| 600 | WARN_ON(1); | 598 | WARN_ON(1); |
| 601 | continue; | 599 | continue; |
| 602 | } | 600 | } |
| @@ -617,7 +615,7 @@ void tegra_pinmux_config_pinmux_table(const struct tegra_pingroup_config *config | |||
| 617 | for (i = 0; i < len; i++) { | 615 | for (i = 0; i < len; i++) { |
| 618 | int err; | 616 | int err; |
| 619 | if (config[i].pingroup < 0 || | 617 | if (config[i].pingroup < 0 || |
| 620 | config[i].pingroup >= TEGRA_MAX_PINGROUP) { | 618 | config[i].pingroup >= pingroup_max) { |
| 621 | WARN_ON(1); | 619 | WARN_ON(1); |
| 622 | continue; | 620 | continue; |
| 623 | } | 621 | } |
| @@ -635,7 +633,7 @@ void tegra_pinmux_config_tristate_table(const struct tegra_pingroup_config *conf | |||
| 635 | { | 633 | { |
| 636 | int i; | 634 | int i; |
| 637 | int err; | 635 | int err; |
| 638 | enum tegra_pingroup pingroup; | 636 | int pingroup; |
| 639 | 637 | ||
| 640 | for (i = 0; i < len; i++) { | 638 | for (i = 0; i < len; i++) { |
| 641 | pingroup = config[i].pingroup; | 639 | pingroup = config[i].pingroup; |
| @@ -654,7 +652,7 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co | |||
| 654 | { | 652 | { |
| 655 | int i; | 653 | int i; |
| 656 | int err; | 654 | int err; |
| 657 | enum tegra_pingroup pingroup; | 655 | int pingroup; |
| 658 | 656 | ||
| 659 | for (i = 0; i < len; i++) { | 657 | for (i = 0; i < len; i++) { |
| 660 | pingroup = config[i].pingroup; | 658 | pingroup = config[i].pingroup; |
| @@ -668,11 +666,31 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co | |||
| 668 | } | 666 | } |
| 669 | } | 667 | } |
| 670 | 668 | ||
| 669 | static struct of_device_id tegra_pinmux_of_match[] __devinitdata = { | ||
| 670 | { .compatible = "nvidia,tegra20-pinmux", tegra20_pinmux_init }, | ||
| 671 | { }, | ||
| 672 | }; | ||
| 673 | |||
| 671 | static int __devinit tegra_pinmux_probe(struct platform_device *pdev) | 674 | static int __devinit tegra_pinmux_probe(struct platform_device *pdev) |
| 672 | { | 675 | { |
| 673 | struct resource *res; | 676 | struct resource *res; |
| 674 | int i; | 677 | int i; |
| 675 | int config_bad = 0; | 678 | int config_bad = 0; |
| 679 | const struct of_device_id *match; | ||
| 680 | |||
| 681 | match = of_match_device(tegra_pinmux_of_match, &pdev->dev); | ||
| 682 | |||
| 683 | if (match) | ||
| 684 | ((pinmux_init)(match->data))(&pingroups, &pingroup_max, | ||
| 685 | &drive_pingroups, &drive_max); | ||
| 686 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC | ||
| 687 | else | ||
| 688 | /* no device tree available, so we must be on tegra20 */ | ||
| 689 | tegra20_pinmux_init(&pingroups, &pingroup_max, | ||
| 690 | &drive_pingroups, &drive_max); | ||
| 691 | #else | ||
| 692 | pr_warn("non Tegra20 platform requires pinmux devicetree node\n"); | ||
| 693 | #endif | ||
| 676 | 694 | ||
| 677 | for (i = 0; ; i++) { | 695 | for (i = 0; ; i++) { |
| 678 | res = platform_get_resource(pdev, IORESOURCE_MEM, i); | 696 | res = platform_get_resource(pdev, IORESOURCE_MEM, i); |
| @@ -681,7 +699,7 @@ static int __devinit tegra_pinmux_probe(struct platform_device *pdev) | |||
| 681 | } | 699 | } |
| 682 | nbanks = i; | 700 | nbanks = i; |
| 683 | 701 | ||
| 684 | for (i = 0; i < TEGRA_MAX_PINGROUP; i++) { | 702 | for (i = 0; i < pingroup_max; i++) { |
| 685 | if (pingroups[i].tri_bank >= nbanks) { | 703 | if (pingroups[i].tri_bank >= nbanks) { |
| 686 | dev_err(&pdev->dev, "pingroup %d: bad tri_bank\n", i); | 704 | dev_err(&pdev->dev, "pingroup %d: bad tri_bank\n", i); |
| 687 | config_bad = 1; | 705 | config_bad = 1; |
| @@ -698,7 +716,7 @@ static int __devinit tegra_pinmux_probe(struct platform_device *pdev) | |||
| 698 | } | 716 | } |
| 699 | } | 717 | } |
| 700 | 718 | ||
| 701 | for (i = 0; i < TEGRA_MAX_DRIVE_PINGROUP; i++) { | 719 | for (i = 0; i < drive_max; i++) { |
| 702 | if (drive_pingroups[i].reg_bank >= nbanks) { | 720 | if (drive_pingroups[i].reg_bank >= nbanks) { |
| 703 | dev_err(&pdev->dev, | 721 | dev_err(&pdev->dev, |
| 704 | "drive pingroup %d: bad reg_bank\n", i); | 722 | "drive pingroup %d: bad reg_bank\n", i); |
| @@ -741,11 +759,6 @@ static int __devinit tegra_pinmux_probe(struct platform_device *pdev) | |||
| 741 | return 0; | 759 | return 0; |
| 742 | } | 760 | } |
| 743 | 761 | ||
| 744 | static struct of_device_id tegra_pinmux_of_match[] __devinitdata = { | ||
| 745 | { .compatible = "nvidia,tegra20-pinmux", }, | ||
| 746 | { }, | ||
| 747 | }; | ||
| 748 | |||
| 749 | static struct platform_driver tegra_pinmux_driver = { | 762 | static struct platform_driver tegra_pinmux_driver = { |
| 750 | .driver = { | 763 | .driver = { |
| 751 | .name = "tegra-pinmux", | 764 | .name = "tegra-pinmux", |
| @@ -779,7 +792,7 @@ static int dbg_pinmux_show(struct seq_file *s, void *unused) | |||
| 779 | int i; | 792 | int i; |
| 780 | int len; | 793 | int len; |
| 781 | 794 | ||
| 782 | for (i = 0; i < TEGRA_MAX_PINGROUP; i++) { | 795 | for (i = 0; i < pingroup_max; i++) { |
| 783 | unsigned long reg; | 796 | unsigned long reg; |
| 784 | unsigned long tri; | 797 | unsigned long tri; |
| 785 | unsigned long mux; | 798 | unsigned long mux; |
| @@ -850,7 +863,7 @@ static int dbg_drive_pinmux_show(struct seq_file *s, void *unused) | |||
| 850 | int i; | 863 | int i; |
| 851 | int len; | 864 | int len; |
| 852 | 865 | ||
| 853 | for (i = 0; i < TEGRA_MAX_DRIVE_PINGROUP; i++) { | 866 | for (i = 0; i < drive_max; i++) { |
| 854 | u32 reg; | 867 | u32 reg; |
| 855 | 868 | ||
| 856 | seq_printf(s, "\t{TEGRA_DRIVE_PINGROUP_%s", | 869 | seq_printf(s, "\t{TEGRA_DRIVE_PINGROUP_%s", |
