Skip to content

Commit

Permalink
board: mt7621: enable set unused pins to gpio input mode
Browse files Browse the repository at this point in the history
Signed-off-by: Shiji Yang <[email protected]>
  • Loading branch information
DragonBluep committed May 2, 2023
1 parent 113bda4 commit ae2062c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions board/ralink/mt7621_nand_rfb/mt7621_nand_rfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,35 @@ static inline int gpio_input_init(unsigned gpio, const char *label)
return 0;
}

/* Set unused pins to gpio input mode */
static int pins_unused_init(const int *pinlist, unsigned listsize)
{
int cnt;
char label[10] = "";

for (cnt = 0; cnt < listsize; cnt ++) {
if (cnt < 0 || cnt > 48) {
printf("unsupported GPIO: gpio#%d", pinlist[cnt]);
return -1;
}

strcpy(label, "gpio#");
strcat(label, simple_itoa(pinlist[cnt]));
gpio_input_init(pinlist[cnt], label);
}

return 0;
}

#ifdef CONFIG_LAST_STAGE_INIT
int last_stage_init(void)
{
#define MT7621_UNUSED_PIN_LIST {}

int pinlist[] = MT7621_UNUSED_PIN_LIST;

pins_unused_init(pinlist, sizeof(pinlist)/sizeof(int));

return 0;
}
#endif // CONFIG_LAST_STAGE_INIT
Expand Down
26 changes: 26 additions & 0 deletions board/ralink/mt7621_rfb/mt7621_rfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,35 @@ static inline int gpio_input_init(unsigned gpio, const char *label)
return 0;
}

/* Set unused pins to gpio input mode */
static int pins_unused_init(const int *pinlist, unsigned listsize)
{
int cnt;
char label[10] = "";

for (cnt = 0; cnt < listsize; cnt ++) {
if (cnt < 0 || cnt > 48) {
printf("unsupported GPIO: gpio#%d", pinlist[cnt]);
return -1;
}

strcpy(label, "gpio#");
strcat(label, simple_itoa(pinlist[cnt]));
gpio_input_init(pinlist[cnt], label);
}

return 0;
}

#ifdef CONFIG_LAST_STAGE_INIT
int last_stage_init(void)
{
#define MT7621_UNUSED_PIN_LIST {}

int pinlist[] = MT7621_UNUSED_PIN_LIST;

pins_unused_init(pinlist, sizeof(pinlist)/sizeof(int));

return 0;
}
#endif // CONFIG_LAST_STAGE_INIT
Expand Down

0 comments on commit ae2062c

Please sign in to comment.