Skip to content

Commit 336cdba

Browse files
author
Linus Walleij
committed
pinctrl: documentation update
Update the docs removing an obsolete __refdata tag and document the mysterious return value of pin_free(). And fixes up some various confusions in the pinctrl documentation. Reported-by: Rajendra Nayak <rnayak@ti.com> Reported-by: Randy Dunlap <rdunlap@xenotime.net> Reported-by: Thomas Abraham <thomas.abraham@linaro.org> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 3712a3c commit 336cdba

2 files changed

Lines changed: 31 additions & 27 deletions

File tree

‎Documentation/pinctrl.txt‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Definition of PIN:
3232
be sparse - i.e. there may be gaps in the space with numbers where no
3333
pin exists.
3434

35-
When a PIN CONTROLLER is instatiated, it will register a descriptor to the
35+
When a PIN CONTROLLER is instantiated, it will register a descriptor to the
3636
pin control framework, and this descriptor contains an array of pin descriptors
3737
describing the pins handled by this specific pin controller.
3838

@@ -61,14 +61,14 @@ this in our driver:
6161

6262
#include <linux/pinctrl/pinctrl.h>
6363

64-
const struct pinctrl_pin_desc __refdata foo_pins[] = {
65-
PINCTRL_PIN(0, "A1"),
66-
PINCTRL_PIN(1, "A2"),
67-
PINCTRL_PIN(2, "A3"),
64+
const struct pinctrl_pin_desc foo_pins[] = {
65+
PINCTRL_PIN(0, "A8"),
66+
PINCTRL_PIN(1, "B8"),
67+
PINCTRL_PIN(2, "C8"),
6868
...
69-
PINCTRL_PIN(61, "H6"),
70-
PINCTRL_PIN(62, "H7"),
71-
PINCTRL_PIN(63, "H8"),
69+
PINCTRL_PIN(61, "F1"),
70+
PINCTRL_PIN(62, "G1"),
71+
PINCTRL_PIN(63, "H1"),
7272
};
7373

7474
static struct pinctrl_desc foo_desc = {
@@ -91,8 +91,8 @@ int __init foo_probe(void)
9191
Pins usually have fancier names than this. You can find these in the dataheet
9292
for your chip. Notice that the core pinctrl.h file provides a fancy macro
9393
called PINCTRL_PIN() to create the struct entries. As you can see I enumerated
94-
the pins from 0 in the upper left corner to 63 in the lower right corner,
95-
this enumeration was arbitrarily chosen, in practice you need to think
94+
the pins from 0 in the upper left corner to 63 in the lower right corner.
95+
This enumeration was arbitrarily chosen, in practice you need to think
9696
through your numbering system so that it matches the layout of registers
9797
and such things in your driver, or the code may become complicated. You must
9898
also consider matching of offsets to the GPIO ranges that may be handled by
@@ -133,8 +133,8 @@ struct foo_group {
133133
const unsigned num_pins;
134134
};
135135

136-
static unsigned int spi0_pins[] = { 0, 8, 16, 24 };
137-
static unsigned int i2c0_pins[] = { 24, 25 };
136+
static const unsigned int spi0_pins[] = { 0, 8, 16, 24 };
137+
static const unsigned int i2c0_pins[] = { 24, 25 };
138138

139139
static const struct foo_group foo_groups[] = {
140140
{
@@ -242,7 +242,7 @@ chip a: [32 .. 47]
242242
chip b: [48 .. 55]
243243

244244
When GPIO-specific functions in the pin control subsystem are called, these
245-
ranges will be used to look up the apropriate pin controller by inspecting
245+
ranges will be used to look up the appropriate pin controller by inspecting
246246
and matching the pin to the pin ranges across all controllers. When a
247247
pin controller handling the matching range is found, GPIO-specific functions
248248
will be called on that specific pin controller.
@@ -438,7 +438,7 @@ you. Define enumerators only for the pins you can control if that makes sense.
438438

439439
Assumptions:
440440

441-
We assume that the number possible function maps to pin groups is limited by
441+
We assume that the number of possible function maps to pin groups is limited by
442442
the hardware. I.e. we assume that there is no system where any function can be
443443
mapped to any pin, like in a phone exchange. So the available pins groups for
444444
a certain function will be limited to a few choices (say up to eight or so),
@@ -585,7 +585,7 @@ int foo_list_funcs(struct pinctrl_dev *pctldev, unsigned selector)
585585

586586
const char *foo_get_fname(struct pinctrl_dev *pctldev, unsigned selector)
587587
{
588-
return myfuncs[selector].name;
588+
return foo_functions[selector].name;
589589
}
590590

591591
static int foo_get_groups(struct pinctrl_dev *pctldev, unsigned selector,
@@ -600,16 +600,16 @@ static int foo_get_groups(struct pinctrl_dev *pctldev, unsigned selector,
600600
int foo_enable(struct pinctrl_dev *pctldev, unsigned selector,
601601
unsigned group)
602602
{
603-
u8 regbit = (1 << group);
603+
u8 regbit = (1 << selector + group);
604604

605605
writeb((readb(MUX)|regbit), MUX)
606606
return 0;
607607
}
608608

609-
int foo_disable(struct pinctrl_dev *pctldev, unsigned selector,
609+
void foo_disable(struct pinctrl_dev *pctldev, unsigned selector,
610610
unsigned group)
611611
{
612-
u8 regbit = (1 << group);
612+
u8 regbit = (1 << selector + group);
613613

614614
writeb((readb(MUX) & ~(regbit)), MUX)
615615
return 0;
@@ -683,7 +683,7 @@ spi on the second function mapping:
683683

684684
#include <linux/pinctrl/machine.h>
685685

686-
static struct pinmux_map pmx_mapping[] = {
686+
static const struct pinmux_map pmx_mapping[] = {
687687
{
688688
.ctrl_dev_name = "pinctrl.0",
689689
.function = "spi0",
@@ -714,7 +714,7 @@ for example if they are not yet instantiated or cumbersome to obtain.
714714

715715
You register this pinmux mapping to the pinmux subsystem by simply:
716716

717-
ret = pinmux_register_mappings(&pmx_mapping, ARRAY_SIZE(pmx_mapping));
717+
ret = pinmux_register_mappings(pmx_mapping, ARRAY_SIZE(pmx_mapping));
718718

719719
Since the above construct is pretty common there is a helper macro to make
720720
it even more compact which assumes you want to use pinctrl.0 and position
@@ -762,42 +762,42 @@ case), we define a mapping like this:
762762
.name "2bit"
763763
.ctrl_dev_name = "pinctrl.0",
764764
.function = "mmc0",
765-
.group = "mmc0_0_grp",
765+
.group = "mmc0_1_grp",
766766
.dev_name = "foo-mmc.0",
767767
},
768768
{
769769
.name "4bit"
770770
.ctrl_dev_name = "pinctrl.0",
771771
.function = "mmc0",
772-
.group = "mmc0_0_grp",
772+
.group = "mmc0_1_grp",
773773
.dev_name = "foo-mmc.0",
774774
},
775775
{
776776
.name "4bit"
777777
.ctrl_dev_name = "pinctrl.0",
778778
.function = "mmc0",
779-
.group = "mmc0_1_grp",
779+
.group = "mmc0_2_grp",
780780
.dev_name = "foo-mmc.0",
781781
},
782782
{
783783
.name "8bit"
784784
.ctrl_dev_name = "pinctrl.0",
785785
.function = "mmc0",
786-
.group = "mmc0_0_grp",
786+
.group = "mmc0_1_grp",
787787
.dev_name = "foo-mmc.0",
788788
},
789789
{
790790
.name "8bit"
791791
.ctrl_dev_name = "pinctrl.0",
792792
.function = "mmc0",
793-
.group = "mmc0_1_grp",
793+
.group = "mmc0_2_grp",
794794
.dev_name = "foo-mmc.0",
795795
},
796796
{
797797
.name "8bit"
798798
.ctrl_dev_name = "pinctrl.0",
799799
.function = "mmc0",
800-
.group = "mmc0_2_grp",
800+
.group = "mmc0_3_grp",
801801
.dev_name = "foo-mmc.0",
802802
},
803803
...

‎drivers/pinctrl/pinmux.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ static int pin_request(struct pinctrl_dev *pctldev,
174174
* @pin: the pin to free
175175
* @gpio_range: the range matching the GPIO pin if this is a request for a
176176
* single GPIO pin
177+
*
178+
* This function returns a pointer to the function name in use. This is used
179+
* for callers that dynamically allocate a function name so it can be freed
180+
* once the pin is free. This is done for GPIO request functions.
177181
*/
178182
static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
179183
struct pinctrl_gpio_range *gpio_range)
@@ -919,7 +923,7 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
919923
}
920924

921925
/**
922-
* pinmux_hog_maps() - unhog specific map entries on controller device
926+
* pinmux_unhog_maps() - unhog specific map entries on controller device
923927
* @pctldev: the pin control device to unhog entries on
924928
*/
925929
void pinmux_unhog_maps(struct pinctrl_dev *pctldev)

0 commit comments

Comments
 (0)