forked from Minki/linux
pinctrl/nomadik: break out single GPIO debug function
Break out the code displaying the status of a single pin so we can use the same code in the pinctrl debug function. Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
e98ea774c8
commit
6f4350a6da
@ -943,14 +943,16 @@ static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
|
|||||||
|
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
|
|
||||||
static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
static void nmk_gpio_dbg_show_one(struct seq_file *s, struct gpio_chip *chip,
|
||||||
|
unsigned offset, unsigned gpio)
|
||||||
{
|
{
|
||||||
int mode;
|
const char *label = gpiochip_is_requested(chip, offset);
|
||||||
unsigned i;
|
|
||||||
unsigned gpio = chip->base;
|
|
||||||
int is_out;
|
|
||||||
struct nmk_gpio_chip *nmk_chip =
|
struct nmk_gpio_chip *nmk_chip =
|
||||||
container_of(chip, struct nmk_gpio_chip, chip);
|
container_of(chip, struct nmk_gpio_chip, chip);
|
||||||
|
int mode;
|
||||||
|
bool is_out;
|
||||||
|
bool pull;
|
||||||
|
u32 bit = 1 << offset;
|
||||||
const char *modes[] = {
|
const char *modes[] = {
|
||||||
[NMK_GPIO_ALT_GPIO] = "gpio",
|
[NMK_GPIO_ALT_GPIO] = "gpio",
|
||||||
[NMK_GPIO_ALT_A] = "altA",
|
[NMK_GPIO_ALT_A] = "altA",
|
||||||
@ -959,56 +961,63 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
|||||||
};
|
};
|
||||||
|
|
||||||
clk_enable(nmk_chip->clk);
|
clk_enable(nmk_chip->clk);
|
||||||
|
is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & bit);
|
||||||
|
pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit);
|
||||||
|
mode = nmk_gpio_get_mode(gpio);
|
||||||
|
|
||||||
for (i = 0; i < chip->ngpio; i++, gpio++) {
|
seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s",
|
||||||
const char *label = gpiochip_is_requested(chip, i);
|
gpio, label ?: "(none)",
|
||||||
bool pull;
|
is_out ? "out" : "in ",
|
||||||
u32 bit = 1 << i;
|
chip->get
|
||||||
|
? (chip->get(chip, offset) ? "hi" : "lo")
|
||||||
|
: "? ",
|
||||||
|
(mode < 0) ? "unknown" : modes[mode],
|
||||||
|
pull ? "pull" : "none");
|
||||||
|
|
||||||
is_out = readl(nmk_chip->addr + NMK_GPIO_DIR) & bit;
|
if (label && !is_out) {
|
||||||
pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit);
|
int irq = gpio_to_irq(gpio);
|
||||||
mode = nmk_gpio_get_mode(gpio);
|
struct irq_desc *desc = irq_to_desc(irq);
|
||||||
seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s",
|
|
||||||
gpio, label ?: "(none)",
|
|
||||||
is_out ? "out" : "in ",
|
|
||||||
chip->get
|
|
||||||
? (chip->get(chip, i) ? "hi" : "lo")
|
|
||||||
: "? ",
|
|
||||||
(mode < 0) ? "unknown" : modes[mode],
|
|
||||||
pull ? "pull" : "none");
|
|
||||||
|
|
||||||
if (label && !is_out) {
|
/* This races with request_irq(), set_irq_type(),
|
||||||
int irq = gpio_to_irq(gpio);
|
* and set_irq_wake() ... but those are "rare".
|
||||||
struct irq_desc *desc = irq_to_desc(irq);
|
*/
|
||||||
|
if (irq >= 0 && desc->action) {
|
||||||
|
char *trigger;
|
||||||
|
u32 bitmask = nmk_gpio_get_bitmask(gpio);
|
||||||
|
|
||||||
/* This races with request_irq(), set_irq_type(),
|
if (nmk_chip->edge_rising & bitmask)
|
||||||
* and set_irq_wake() ... but those are "rare".
|
trigger = "edge-rising";
|
||||||
*/
|
else if (nmk_chip->edge_falling & bitmask)
|
||||||
if (irq >= 0 && desc->action) {
|
trigger = "edge-falling";
|
||||||
char *trigger;
|
else
|
||||||
u32 bitmask = nmk_gpio_get_bitmask(gpio);
|
trigger = "edge-undefined";
|
||||||
|
|
||||||
if (nmk_chip->edge_rising & bitmask)
|
seq_printf(s, " irq-%d %s%s",
|
||||||
trigger = "edge-rising";
|
irq, trigger,
|
||||||
else if (nmk_chip->edge_falling & bitmask)
|
irqd_is_wakeup_set(&desc->irq_data)
|
||||||
trigger = "edge-falling";
|
? " wakeup" : "");
|
||||||
else
|
|
||||||
trigger = "edge-undefined";
|
|
||||||
|
|
||||||
seq_printf(s, " irq-%d %s%s",
|
|
||||||
irq, trigger,
|
|
||||||
irqd_is_wakeup_set(&desc->irq_data)
|
|
||||||
? " wakeup" : "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
seq_printf(s, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clk_disable(nmk_chip->clk);
|
clk_disable(nmk_chip->clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
unsigned gpio = chip->base;
|
||||||
|
|
||||||
|
for (i = 0; i < chip->ngpio; i++, gpio++) {
|
||||||
|
nmk_gpio_dbg_show_one(s, chip, i, gpio);
|
||||||
|
seq_printf(s, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
static inline void nmk_gpio_dbg_show_one(struct seq_file *s,
|
||||||
|
struct gpio_chip *chip,
|
||||||
|
unsigned offset, unsigned gpio)
|
||||||
|
{
|
||||||
|
}
|
||||||
#define nmk_gpio_dbg_show NULL
|
#define nmk_gpio_dbg_show NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user