imx233: add pinctrl debug code to track pin uses

Past development has proved that one can mistakely use
the same pin for two uses without noticing. Since this
causes extremely hard to find bugs, the infrastructure
will allow to register pin uses and panic when a conflict
is detected. The pinctrl debug now shows the pin uses
when its support is compiled in.

Change-Id: Idb2d5235ce09207d77aa474d6f158e72b933761a
This commit is contained in:
Amaury Pouly 2012-05-10 00:08:03 +02:00
parent d29a11b7a8
commit 645680d62b
13 changed files with 122 additions and 6 deletions

View file

@ -399,13 +399,25 @@ bool dbg_hw_info_pinctrl(void)
{
lcd_setfont(FONT_SYSFIXED);
#ifdef IMX233_PINCTRL_DEBUG
unsigned top_user = 0;
#endif
while(1)
{
int button = get_action(CONTEXT_STD, HZ / 10);
switch(button)
{
case ACTION_STD_NEXT:
#ifdef IMX233_PINCTRL_DEBUG
top_user++;
break;
#endif
case ACTION_STD_PREV:
#ifdef IMX233_PINCTRL_DEBUG
if(top_user > 0)
top_user--;
break;
#endif
case ACTION_STD_OK:
case ACTION_STD_MENU:
lcd_setfont(FONT_UI);
@ -418,6 +430,23 @@ bool dbg_hw_info_pinctrl(void)
lcd_clear_display();
for(int i = 0; i < 4; i++)
lcd_putsf(0, i, "DIN%d = 0x%08x", i, imx233_get_gpio_input_mask(i, 0xffffffff));
#ifdef IMX233_PINCTRL_DEBUG
unsigned cur_line = 6;
unsigned last_line = lcd_getheight() / font_get(lcd_getfont())->height;
unsigned cur_idx = 0;
for(int bank = 0; bank < 4; bank++)
for(int pin = 0; pin < 32; pin++)
{
const char *owner = imx233_pinctrl_get_pin_use(bank, pin);
if(owner == NULL)
continue;
if(cur_idx++ >= top_user && cur_line < last_line)
lcd_putsf(0, cur_line++, "B%dP%02d %s", bank, pin, owner);
}
if(cur_idx < top_user)
top_user = cur_idx - 1;
#endif
lcd_update();
yield();
}