2 * linux/arch/arm/mach-tegra/pinmux.c
4 * Copyright (C) 2010 Google, Inc.
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <linux/init.h>
18 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/spinlock.h>
23 #include <linux/platform_device.h>
25 #include <mach/iomap.h>
26 #include <mach/pinmux.h>
28 #define HSM_EN(reg) (((reg) >> 2) & 0x1)
29 #define SCHMT_EN(reg) (((reg) >> 3) & 0x1)
30 #define LPMD(reg) (((reg) >> 4) & 0x3)
31 #define DRVDN(reg) (((reg) >> 12) & 0x1f)
32 #define DRVUP(reg) (((reg) >> 20) & 0x1f)
33 #define SLWR(reg) (((reg) >> 28) & 0x3)
34 #define SLWF(reg) (((reg) >> 30) & 0x3)
36 static const struct tegra_pingroup_desc
*const pingroups
= tegra_soc_pingroups
;
37 static const struct tegra_drive_pingroup_desc
*const drive_pingroups
= tegra_soc_drive_pingroups
;
39 static char *tegra_mux_names
[TEGRA_MAX_MUX
] = {
40 [TEGRA_MUX_AHB_CLK
] = "AHB_CLK",
41 [TEGRA_MUX_APB_CLK
] = "APB_CLK",
42 [TEGRA_MUX_AUDIO_SYNC
] = "AUDIO_SYNC",
43 [TEGRA_MUX_CRT
] = "CRT",
44 [TEGRA_MUX_DAP1
] = "DAP1",
45 [TEGRA_MUX_DAP2
] = "DAP2",
46 [TEGRA_MUX_DAP3
] = "DAP3",
47 [TEGRA_MUX_DAP4
] = "DAP4",
48 [TEGRA_MUX_DAP5
] = "DAP5",
49 [TEGRA_MUX_DISPLAYA
] = "DISPLAYA",
50 [TEGRA_MUX_DISPLAYB
] = "DISPLAYB",
51 [TEGRA_MUX_EMC_TEST0_DLL
] = "EMC_TEST0_DLL",
52 [TEGRA_MUX_EMC_TEST1_DLL
] = "EMC_TEST1_DLL",
53 [TEGRA_MUX_GMI
] = "GMI",
54 [TEGRA_MUX_GMI_INT
] = "GMI_INT",
55 [TEGRA_MUX_HDMI
] = "HDMI",
56 [TEGRA_MUX_I2C
] = "I2C",
57 [TEGRA_MUX_I2C2
] = "I2C2",
58 [TEGRA_MUX_I2C3
] = "I2C3",
59 [TEGRA_MUX_IDE
] = "IDE",
60 [TEGRA_MUX_IRDA
] = "IRDA",
61 [TEGRA_MUX_KBC
] = "KBC",
62 [TEGRA_MUX_MIO
] = "MIO",
63 [TEGRA_MUX_MIPI_HS
] = "MIPI_HS",
64 [TEGRA_MUX_NAND
] = "NAND",
65 [TEGRA_MUX_OSC
] = "OSC",
66 [TEGRA_MUX_OWR
] = "OWR",
67 [TEGRA_MUX_PCIE
] = "PCIE",
68 [TEGRA_MUX_PLLA_OUT
] = "PLLA_OUT",
69 [TEGRA_MUX_PLLC_OUT1
] = "PLLC_OUT1",
70 [TEGRA_MUX_PLLM_OUT1
] = "PLLM_OUT1",
71 [TEGRA_MUX_PLLP_OUT2
] = "PLLP_OUT2",
72 [TEGRA_MUX_PLLP_OUT3
] = "PLLP_OUT3",
73 [TEGRA_MUX_PLLP_OUT4
] = "PLLP_OUT4",
74 [TEGRA_MUX_PWM
] = "PWM",
75 [TEGRA_MUX_PWR_INTR
] = "PWR_INTR",
76 [TEGRA_MUX_PWR_ON
] = "PWR_ON",
77 [TEGRA_MUX_RTCK
] = "RTCK",
78 [TEGRA_MUX_SDIO1
] = "SDIO1",
79 [TEGRA_MUX_SDIO2
] = "SDIO2",
80 [TEGRA_MUX_SDIO3
] = "SDIO3",
81 [TEGRA_MUX_SDIO4
] = "SDIO4",
82 [TEGRA_MUX_SFLASH
] = "SFLASH",
83 [TEGRA_MUX_SPDIF
] = "SPDIF",
84 [TEGRA_MUX_SPI1
] = "SPI1",
85 [TEGRA_MUX_SPI2
] = "SPI2",
86 [TEGRA_MUX_SPI2_ALT
] = "SPI2_ALT",
87 [TEGRA_MUX_SPI3
] = "SPI3",
88 [TEGRA_MUX_SPI4
] = "SPI4",
89 [TEGRA_MUX_TRACE
] = "TRACE",
90 [TEGRA_MUX_TWC
] = "TWC",
91 [TEGRA_MUX_UARTA
] = "UARTA",
92 [TEGRA_MUX_UARTB
] = "UARTB",
93 [TEGRA_MUX_UARTC
] = "UARTC",
94 [TEGRA_MUX_UARTD
] = "UARTD",
95 [TEGRA_MUX_UARTE
] = "UARTE",
96 [TEGRA_MUX_ULPI
] = "ULPI",
97 [TEGRA_MUX_VI
] = "VI",
98 [TEGRA_MUX_VI_SENSOR_CLK
] = "VI_SENSOR_CLK",
99 [TEGRA_MUX_XIO
] = "XIO",
100 [TEGRA_MUX_SAFE
] = "<safe>",
103 static const char *tegra_drive_names
[TEGRA_MAX_DRIVE
] = {
104 [TEGRA_DRIVE_DIV_8
] = "DIV_8",
105 [TEGRA_DRIVE_DIV_4
] = "DIV_4",
106 [TEGRA_DRIVE_DIV_2
] = "DIV_2",
107 [TEGRA_DRIVE_DIV_1
] = "DIV_1",
110 static const char *tegra_slew_names
[TEGRA_MAX_SLEW
] = {
111 [TEGRA_SLEW_FASTEST
] = "FASTEST",
112 [TEGRA_SLEW_FAST
] = "FAST",
113 [TEGRA_SLEW_SLOW
] = "SLOW",
114 [TEGRA_SLEW_SLOWEST
] = "SLOWEST",
117 static DEFINE_SPINLOCK(mux_lock
);
119 static const char *pingroup_name(enum tegra_pingroup pg
)
121 if (pg
< 0 || pg
>= TEGRA_MAX_PINGROUP
)
124 return pingroups
[pg
].name
;
127 static const char *func_name(enum tegra_mux_func func
)
129 if (func
== TEGRA_MUX_RSVD1
)
132 if (func
== TEGRA_MUX_RSVD2
)
135 if (func
== TEGRA_MUX_RSVD3
)
138 if (func
== TEGRA_MUX_RSVD4
)
141 if (func
== TEGRA_MUX_NONE
)
144 if (func
< 0 || func
>= TEGRA_MAX_MUX
)
147 return tegra_mux_names
[func
];
151 static const char *tri_name(unsigned long val
)
153 return val
? "TRISTATE" : "NORMAL";
156 static const char *pupd_name(unsigned long val
)
174 static inline unsigned long pg_readl(unsigned long offset
)
176 return readl(IO_TO_VIRT(TEGRA_APB_MISC_BASE
+ offset
));
179 static inline void pg_writel(unsigned long value
, unsigned long offset
)
181 writel(value
, IO_TO_VIRT(TEGRA_APB_MISC_BASE
+ offset
));
184 static int tegra_pinmux_set_func(const struct tegra_pingroup_config
*config
)
190 enum tegra_pingroup pg
= config
->pingroup
;
191 enum tegra_mux_func func
= config
->func
;
193 if (pg
< 0 || pg
>= TEGRA_MAX_PINGROUP
)
196 if (pingroups
[pg
].mux_reg
< 0)
202 if (func
== TEGRA_MUX_SAFE
)
203 func
= pingroups
[pg
].func_safe
;
205 if (func
& TEGRA_MUX_RSVD
) {
208 for (i
= 0; i
< 4; i
++) {
209 if (pingroups
[pg
].funcs
[i
] == func
) {
219 spin_lock_irqsave(&mux_lock
, flags
);
221 reg
= pg_readl(pingroups
[pg
].mux_reg
);
222 reg
&= ~(0x3 << pingroups
[pg
].mux_bit
);
223 reg
|= mux
<< pingroups
[pg
].mux_bit
;
224 pg_writel(reg
, pingroups
[pg
].mux_reg
);
226 spin_unlock_irqrestore(&mux_lock
, flags
);
231 int tegra_pinmux_set_tristate(enum tegra_pingroup pg
,
232 enum tegra_tristate tristate
)
237 if (pg
< 0 || pg
>= TEGRA_MAX_PINGROUP
)
240 if (pingroups
[pg
].tri_reg
< 0)
243 spin_lock_irqsave(&mux_lock
, flags
);
245 reg
= pg_readl(pingroups
[pg
].tri_reg
);
246 reg
&= ~(0x1 << pingroups
[pg
].tri_bit
);
248 reg
|= 1 << pingroups
[pg
].tri_bit
;
249 pg_writel(reg
, pingroups
[pg
].tri_reg
);
251 spin_unlock_irqrestore(&mux_lock
, flags
);
256 int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg
,
257 enum tegra_pullupdown pupd
)
262 if (pg
< 0 || pg
>= TEGRA_MAX_PINGROUP
)
265 if (pingroups
[pg
].pupd_reg
< 0)
268 if (pupd
!= TEGRA_PUPD_NORMAL
&&
269 pupd
!= TEGRA_PUPD_PULL_DOWN
&&
270 pupd
!= TEGRA_PUPD_PULL_UP
)
274 spin_lock_irqsave(&mux_lock
, flags
);
276 reg
= pg_readl(pingroups
[pg
].pupd_reg
);
277 reg
&= ~(0x3 << pingroups
[pg
].pupd_bit
);
278 reg
|= pupd
<< pingroups
[pg
].pupd_bit
;
279 pg_writel(reg
, pingroups
[pg
].pupd_reg
);
281 spin_unlock_irqrestore(&mux_lock
, flags
);
286 static void tegra_pinmux_config_pingroup(const struct tegra_pingroup_config
*config
)
288 enum tegra_pingroup pingroup
= config
->pingroup
;
289 enum tegra_mux_func func
= config
->func
;
290 enum tegra_pullupdown pupd
= config
->pupd
;
291 enum tegra_tristate tristate
= config
->tristate
;
294 if (pingroups
[pingroup
].mux_reg
>= 0) {
295 err
= tegra_pinmux_set_func(config
);
297 pr_err("pinmux: can't set pingroup %s func to %s: %d\n",
298 pingroup_name(pingroup
), func_name(func
), err
);
301 if (pingroups
[pingroup
].pupd_reg
>= 0) {
302 err
= tegra_pinmux_set_pullupdown(pingroup
, pupd
);
304 pr_err("pinmux: can't set pingroup %s pullupdown to %s: %d\n",
305 pingroup_name(pingroup
), pupd_name(pupd
), err
);
308 if (pingroups
[pingroup
].tri_reg
>= 0) {
309 err
= tegra_pinmux_set_tristate(pingroup
, tristate
);
311 pr_err("pinmux: can't set pingroup %s tristate to %s: %d\n",
312 pingroup_name(pingroup
), tri_name(func
), err
);
316 void tegra_pinmux_config_table(const struct tegra_pingroup_config
*config
, int len
)
320 for (i
= 0; i
< len
; i
++)
321 tegra_pinmux_config_pingroup(&config
[i
]);
324 static const char *drive_pinmux_name(enum tegra_drive_pingroup pg
)
326 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
329 return drive_pingroups
[pg
].name
;
332 static const char *enable_name(unsigned long val
)
334 return val
? "ENABLE" : "DISABLE";
337 static const char *drive_name(unsigned long val
)
339 if (val
>= TEGRA_MAX_DRIVE
)
342 return tegra_drive_names
[val
];
345 static const char *slew_name(unsigned long val
)
347 if (val
>= TEGRA_MAX_SLEW
)
350 return tegra_slew_names
[val
];
353 static int tegra_drive_pinmux_set_hsm(enum tegra_drive_pingroup pg
,
358 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
361 if (hsm
!= TEGRA_HSM_ENABLE
&& hsm
!= TEGRA_HSM_DISABLE
)
364 spin_lock_irqsave(&mux_lock
, flags
);
366 reg
= pg_readl(drive_pingroups
[pg
].reg
);
367 if (hsm
== TEGRA_HSM_ENABLE
)
371 pg_writel(reg
, drive_pingroups
[pg
].reg
);
373 spin_unlock_irqrestore(&mux_lock
, flags
);
378 static int tegra_drive_pinmux_set_schmitt(enum tegra_drive_pingroup pg
,
379 enum tegra_schmitt schmitt
)
383 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
386 if (schmitt
!= TEGRA_SCHMITT_ENABLE
&& schmitt
!= TEGRA_SCHMITT_DISABLE
)
389 spin_lock_irqsave(&mux_lock
, flags
);
391 reg
= pg_readl(drive_pingroups
[pg
].reg
);
392 if (schmitt
== TEGRA_SCHMITT_ENABLE
)
396 pg_writel(reg
, drive_pingroups
[pg
].reg
);
398 spin_unlock_irqrestore(&mux_lock
, flags
);
403 static int tegra_drive_pinmux_set_drive(enum tegra_drive_pingroup pg
,
404 enum tegra_drive drive
)
408 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
411 if (drive
< 0 || drive
>= TEGRA_MAX_DRIVE
)
414 spin_lock_irqsave(&mux_lock
, flags
);
416 reg
= pg_readl(drive_pingroups
[pg
].reg
);
419 pg_writel(reg
, drive_pingroups
[pg
].reg
);
421 spin_unlock_irqrestore(&mux_lock
, flags
);
426 static int tegra_drive_pinmux_set_pull_down(enum tegra_drive_pingroup pg
,
427 enum tegra_pull_strength pull_down
)
431 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
434 if (pull_down
< 0 || pull_down
>= TEGRA_MAX_PULL
)
437 spin_lock_irqsave(&mux_lock
, flags
);
439 reg
= pg_readl(drive_pingroups
[pg
].reg
);
440 reg
&= ~(0x1f << 12);
441 reg
|= pull_down
<< 12;
442 pg_writel(reg
, drive_pingroups
[pg
].reg
);
444 spin_unlock_irqrestore(&mux_lock
, flags
);
449 static int tegra_drive_pinmux_set_pull_up(enum tegra_drive_pingroup pg
,
450 enum tegra_pull_strength pull_up
)
454 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
457 if (pull_up
< 0 || pull_up
>= TEGRA_MAX_PULL
)
460 spin_lock_irqsave(&mux_lock
, flags
);
462 reg
= pg_readl(drive_pingroups
[pg
].reg
);
463 reg
&= ~(0x1f << 12);
464 reg
|= pull_up
<< 12;
465 pg_writel(reg
, drive_pingroups
[pg
].reg
);
467 spin_unlock_irqrestore(&mux_lock
, flags
);
472 static int tegra_drive_pinmux_set_slew_rising(enum tegra_drive_pingroup pg
,
473 enum tegra_slew slew_rising
)
477 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
480 if (slew_rising
< 0 || slew_rising
>= TEGRA_MAX_SLEW
)
483 spin_lock_irqsave(&mux_lock
, flags
);
485 reg
= pg_readl(drive_pingroups
[pg
].reg
);
487 reg
|= slew_rising
<< 28;
488 pg_writel(reg
, drive_pingroups
[pg
].reg
);
490 spin_unlock_irqrestore(&mux_lock
, flags
);
495 static int tegra_drive_pinmux_set_slew_falling(enum tegra_drive_pingroup pg
,
496 enum tegra_slew slew_falling
)
500 if (pg
< 0 || pg
>= TEGRA_MAX_DRIVE_PINGROUP
)
503 if (slew_falling
< 0 || slew_falling
>= TEGRA_MAX_SLEW
)
506 spin_lock_irqsave(&mux_lock
, flags
);
508 reg
= pg_readl(drive_pingroups
[pg
].reg
);
510 reg
|= slew_falling
<< 30;
511 pg_writel(reg
, drive_pingroups
[pg
].reg
);
513 spin_unlock_irqrestore(&mux_lock
, flags
);
518 static void tegra_drive_pinmux_config_pingroup(enum tegra_drive_pingroup pingroup
,
520 enum tegra_schmitt schmitt
,
521 enum tegra_drive drive
,
522 enum tegra_pull_strength pull_down
,
523 enum tegra_pull_strength pull_up
,
524 enum tegra_slew slew_rising
,
525 enum tegra_slew slew_falling
)
529 err
= tegra_drive_pinmux_set_hsm(pingroup
, hsm
);
531 pr_err("pinmux: can't set pingroup %s hsm to %s: %d\n",
532 drive_pinmux_name(pingroup
),
533 enable_name(hsm
), err
);
535 err
= tegra_drive_pinmux_set_schmitt(pingroup
, schmitt
);
537 pr_err("pinmux: can't set pingroup %s schmitt to %s: %d\n",
538 drive_pinmux_name(pingroup
),
539 enable_name(schmitt
), err
);
541 err
= tegra_drive_pinmux_set_drive(pingroup
, drive
);
543 pr_err("pinmux: can't set pingroup %s drive to %s: %d\n",
544 drive_pinmux_name(pingroup
),
545 drive_name(drive
), err
);
547 err
= tegra_drive_pinmux_set_pull_down(pingroup
, pull_down
);
549 pr_err("pinmux: can't set pingroup %s pull down to %d: %d\n",
550 drive_pinmux_name(pingroup
),
553 err
= tegra_drive_pinmux_set_pull_up(pingroup
, pull_up
);
555 pr_err("pinmux: can't set pingroup %s pull up to %d: %d\n",
556 drive_pinmux_name(pingroup
),
559 err
= tegra_drive_pinmux_set_slew_rising(pingroup
, slew_rising
);
561 pr_err("pinmux: can't set pingroup %s rising slew to %s: %d\n",
562 drive_pinmux_name(pingroup
),
563 slew_name(slew_rising
), err
);
565 err
= tegra_drive_pinmux_set_slew_falling(pingroup
, slew_falling
);
567 pr_err("pinmux: can't set pingroup %s falling slew to %s: %d\n",
568 drive_pinmux_name(pingroup
),
569 slew_name(slew_falling
), err
);
572 void tegra_drive_pinmux_config_table(struct tegra_drive_pingroup_config
*config
,
577 for (i
= 0; i
< len
; i
++)
578 tegra_drive_pinmux_config_pingroup(config
[i
].pingroup
,
584 config
[i
].slew_rising
,
585 config
[i
].slew_falling
);
588 void tegra_pinmux_set_safe_pinmux_table(const struct tegra_pingroup_config
*config
,
592 struct tegra_pingroup_config c
;
594 for (i
= 0; i
< len
; i
++) {
597 if (c
.pingroup
< 0 || c
.pingroup
>= TEGRA_MAX_PINGROUP
) {
601 c
.func
= pingroups
[c
.pingroup
].func_safe
;
602 err
= tegra_pinmux_set_func(&c
);
604 pr_err("%s: tegra_pinmux_set_func returned %d setting "
605 "%s to %s\n", __func__
, err
,
606 pingroup_name(c
.pingroup
), func_name(c
.func
));
610 void tegra_pinmux_config_pinmux_table(const struct tegra_pingroup_config
*config
,
615 for (i
= 0; i
< len
; i
++) {
617 if (config
[i
].pingroup
< 0 ||
618 config
[i
].pingroup
>= TEGRA_MAX_PINGROUP
) {
622 err
= tegra_pinmux_set_func(&config
[i
]);
624 pr_err("%s: tegra_pinmux_set_func returned %d setting "
625 "%s to %s\n", __func__
, err
,
626 pingroup_name(config
[i
].pingroup
),
627 func_name(config
[i
].func
));
631 void tegra_pinmux_config_tristate_table(const struct tegra_pingroup_config
*config
,
632 int len
, enum tegra_tristate tristate
)
636 enum tegra_pingroup pingroup
;
638 for (i
= 0; i
< len
; i
++) {
639 pingroup
= config
[i
].pingroup
;
640 if (pingroups
[pingroup
].tri_reg
>= 0) {
641 err
= tegra_pinmux_set_tristate(pingroup
, tristate
);
643 pr_err("pinmux: can't set pingroup %s tristate"
644 " to %s: %d\n", pingroup_name(pingroup
),
645 tri_name(tristate
), err
);
650 void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config
*config
,
651 int len
, enum tegra_pullupdown pupd
)
655 enum tegra_pingroup pingroup
;
657 for (i
= 0; i
< len
; i
++) {
658 pingroup
= config
[i
].pingroup
;
659 if (pingroups
[pingroup
].pupd_reg
>= 0) {
660 err
= tegra_pinmux_set_pullupdown(pingroup
, pupd
);
662 pr_err("pinmux: can't set pingroup %s pullupdown"
663 " to %s: %d\n", pingroup_name(pingroup
),
664 pupd_name(pupd
), err
);
669 static int __devinit
tegra_pinmux_probe(struct platform_device
*pdev
)
674 static struct of_device_id tegra_pinmux_of_match
[] __devinitdata
= {
675 { .compatible
= "nvidia,tegra20-pinmux", },
679 static struct platform_driver tegra_pinmux_driver
= {
681 .name
= "tegra-pinmux",
682 .owner
= THIS_MODULE
,
683 .of_match_table
= tegra_pinmux_of_match
,
685 .probe
= tegra_pinmux_probe
,
688 static int __init
tegra_pinmux_init(void)
690 return platform_driver_register(&tegra_pinmux_driver
);
692 postcore_initcall(tegra_pinmux_init
);
694 #ifdef CONFIG_DEBUG_FS
696 #include <linux/debugfs.h>
697 #include <linux/seq_file.h>
699 static void dbg_pad_field(struct seq_file
*s
, int len
)
707 static int dbg_pinmux_show(struct seq_file
*s
, void *unused
)
712 for (i
= 0; i
< TEGRA_MAX_PINGROUP
; i
++) {
717 seq_printf(s
, "\t{TEGRA_PINGROUP_%s", pingroups
[i
].name
);
718 len
= strlen(pingroups
[i
].name
);
719 dbg_pad_field(s
, 5 - len
);
721 if (pingroups
[i
].mux_reg
< 0) {
722 seq_printf(s
, "TEGRA_MUX_NONE");
723 len
= strlen("NONE");
725 mux
= (pg_readl(pingroups
[i
].mux_reg
) >>
726 pingroups
[i
].mux_bit
) & 0x3;
727 if (pingroups
[i
].funcs
[mux
] == TEGRA_MUX_RSVD
) {
728 seq_printf(s
, "TEGRA_MUX_RSVD%1lu", mux
+1);
731 seq_printf(s
, "TEGRA_MUX_%s",
732 tegra_mux_names
[pingroups
[i
].funcs
[mux
]]);
733 len
= strlen(tegra_mux_names
[pingroups
[i
].funcs
[mux
]]);
736 dbg_pad_field(s
, 13-len
);
738 if (pingroups
[i
].pupd_reg
< 0) {
739 seq_printf(s
, "TEGRA_PUPD_NORMAL");
740 len
= strlen("NORMAL");
742 pupd
= (pg_readl(pingroups
[i
].pupd_reg
) >>
743 pingroups
[i
].pupd_bit
) & 0x3;
744 seq_printf(s
, "TEGRA_PUPD_%s", pupd_name(pupd
));
745 len
= strlen(pupd_name(pupd
));
747 dbg_pad_field(s
, 9 - len
);
749 if (pingroups
[i
].tri_reg
< 0) {
750 seq_printf(s
, "TEGRA_TRI_NORMAL");
752 tri
= (pg_readl(pingroups
[i
].tri_reg
) >>
753 pingroups
[i
].tri_bit
) & 0x1;
755 seq_printf(s
, "TEGRA_TRI_%s", tri_name(tri
));
757 seq_printf(s
, "},\n");
762 static int dbg_pinmux_open(struct inode
*inode
, struct file
*file
)
764 return single_open(file
, dbg_pinmux_show
, &inode
->i_private
);
767 static const struct file_operations debug_fops
= {
768 .open
= dbg_pinmux_open
,
771 .release
= single_release
,
774 static int dbg_drive_pinmux_show(struct seq_file
*s
, void *unused
)
779 for (i
= 0; i
< TEGRA_MAX_DRIVE_PINGROUP
; i
++) {
782 seq_printf(s
, "\t{TEGRA_DRIVE_PINGROUP_%s",
783 drive_pingroups
[i
].name
);
784 len
= strlen(drive_pingroups
[i
].name
);
785 dbg_pad_field(s
, 7 - len
);
788 reg
= pg_readl(drive_pingroups
[i
].reg
);
790 seq_printf(s
, "TEGRA_HSM_ENABLE");
793 seq_printf(s
, "TEGRA_HSM_DISABLE");
796 dbg_pad_field(s
, 17 - len
);
799 seq_printf(s
, "TEGRA_SCHMITT_ENABLE");
802 seq_printf(s
, "TEGRA_SCHMITT_DISABLE");
805 dbg_pad_field(s
, 22 - len
);
807 seq_printf(s
, "TEGRA_DRIVE_%s", drive_name(LPMD(reg
)));
808 len
= strlen(drive_name(LPMD(reg
)));
809 dbg_pad_field(s
, 5 - len
);
811 seq_printf(s
, "TEGRA_PULL_%d", DRVDN(reg
));
812 len
= DRVDN(reg
) < 10 ? 1 : 2;
813 dbg_pad_field(s
, 2 - len
);
815 seq_printf(s
, "TEGRA_PULL_%d", DRVUP(reg
));
816 len
= DRVUP(reg
) < 10 ? 1 : 2;
817 dbg_pad_field(s
, 2 - len
);
819 seq_printf(s
, "TEGRA_SLEW_%s", slew_name(SLWR(reg
)));
820 len
= strlen(slew_name(SLWR(reg
)));
821 dbg_pad_field(s
, 7 - len
);
823 seq_printf(s
, "TEGRA_SLEW_%s", slew_name(SLWF(reg
)));
825 seq_printf(s
, "},\n");
830 static int dbg_drive_pinmux_open(struct inode
*inode
, struct file
*file
)
832 return single_open(file
, dbg_drive_pinmux_show
, &inode
->i_private
);
835 static const struct file_operations debug_drive_fops
= {
836 .open
= dbg_drive_pinmux_open
,
839 .release
= single_release
,
842 static int __init
tegra_pinmux_debuginit(void)
844 (void) debugfs_create_file("tegra_pinmux", S_IRUGO
,
845 NULL
, NULL
, &debug_fops
);
846 (void) debugfs_create_file("tegra_pinmux_drive", S_IRUGO
,
847 NULL
, NULL
, &debug_drive_fops
);
850 late_initcall(tegra_pinmux_debuginit
);