@@ -82,6 +82,8 @@ static void usage(void)
8282 printf (" %s [-p] [-v] lev [GPIO]\n" , name );
8383 printf ("OR\n" );
8484 printf (" %s -c <chip> [funcs] [GPIO]\n" , name );
85+ printf ("OR\n" );
86+ printf (" %s -l\n" , name );
8587 printf ("\n" );
8688 printf ("GPIO is a comma-separated list of GPIO names, numbers or ranges (without\n" );
8789 printf ("spaces), e.g. 4 or 18-21 or BT_ON,9-11\n" );
@@ -94,6 +96,7 @@ static void usage(void)
9496 printf ("or if [GPIO] is specified the alternate funcs just for that specific GPIO.\n" );
9597 printf ("The -c option allows the alt functions (and only the alt function) for a named\n" );
9698 printf ("chip to be displayed, even if that chip is not present in the current system.\n" );
99+ printf ("The -l option lists the discovered chips.\n" );
97100 printf ("\n" );
98101 printf ("Valid [options] for %s set are:\n" , name );
99102 printf (" ip set GPIO as input\n" );
@@ -119,6 +122,7 @@ static void usage(void)
119122 printf (" %s set 20 op pn dh Set GPIO20 to output with no pull and driving high\n" , name );
120123 printf (" %s lev 4 Prints the level (1 or 0) of GPIO4\n" , name );
121124 printf (" %s -c bcm2835 9-11 Display the alt functions for GPIOs 9-11 on bcm2835\n" , name );
125+ printf (" %s -l List the compatible detected GPIO chips\n" , name );
122126}
123127
124128static int do_gpio_get (unsigned int gpio )
@@ -338,6 +342,7 @@ int main(int argc, char *argv[])
338342 int poll = 0 ;
339343 int funcs = 0 ;
340344 int echo = 0 ;
345+ int list = 0 ;
341346 int pull = PULL_MAX ;
342347 int infer_cmd = 0 ;
343348 int fsparam = GPIO_FSEL_MAX ;
@@ -355,33 +360,38 @@ int main(int argc, char *argv[])
355360 const char * arg = * (argv ++ );
356361 argc -- ;
357362
358- if (strcmp (arg , "-h" ) == 0 )
363+ if (strcmp (arg , "-c" ) == 0 )
364+ {
365+ if (!argc )
366+ {
367+ printf ("* chip name expected - use 'pinctrl -h' for help\n" );
368+ return -1 ;
369+ }
370+ named_chip = * (argv ++ );
371+ argc -- ;
372+ }
373+ else if (strcmp (arg , "-e" ) == 0 )
374+ {
375+ echo = 1 ;
376+ }
377+ else if (strcmp (arg , "-h" ) == 0 )
359378 {
360379 usage ();
361380 return 0 ;
362381 }
363- else if (strcmp (arg , "-p " ) == 0 )
382+ else if (strcmp (arg , "-l " ) == 0 )
364383 {
365- pin_mode = 1 ;
384+ list = 1 ;
385+ verbose_mode = 1 ;
366386 }
367- else if (strcmp (arg , "-e " ) == 0 )
387+ else if (strcmp (arg , "-p " ) == 0 )
368388 {
369- echo = 1 ;
389+ pin_mode = 1 ;
370390 }
371391 else if (strcmp (arg , "-v" ) == 0 )
372392 {
373393 verbose_mode = 1 ;
374394 }
375- else if (strcmp (arg , "-c" ) == 0 )
376- {
377- if (!argc )
378- {
379- printf ("* chip name expected - use 'pinctrl -h' for help\n" );
380- return -1 ;
381- }
382- named_chip = * (argv ++ );
383- argc -- ;
384- }
385395 else
386396 {
387397 printf ("Unknown option '%s' - try \"%s help\"\n" ,
@@ -445,6 +455,9 @@ int main(int argc, char *argv[])
445455 get = 1 ;
446456 }
447457
458+ if (list )
459+ return 0 ;
460+
448461 if (pin_mode )
449462 {
450463 gpio_get_pin_range (& start_pin , & end_pin );
0 commit comments