@@ -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
3636pin control framework, and this descriptor contains an array of pin descriptors
3737describing 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
7474static struct pinctrl_desc foo_desc = {
@@ -91,8 +91,8 @@ int __init foo_probe(void)
9191Pins usually have fancier names than this. You can find these in the dataheet
9292for your chip. Notice that the core pinctrl.h file provides a fancy macro
9393called 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
9696through your numbering system so that it matches the layout of registers
9797and such things in your driver, or the code may become complicated. You must
9898also 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
139139static const struct foo_group foo_groups[] = {
140140 {
@@ -242,7 +242,7 @@ chip a: [32 .. 47]
242242chip b: [48 .. 55]
243243
244244When 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
246246and matching the pin to the pin ranges across all controllers. When a
247247pin controller handling the matching range is found, GPIO-specific functions
248248will 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
439439Assumptions:
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
442442the hardware. I.e. we assume that there is no system where any function can be
443443mapped to any pin, like in a phone exchange. So the available pins groups for
444444a 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
586586const char *foo_get_fname(struct pinctrl_dev *pctldev, unsigned selector)
587587{
588- return myfuncs [selector].name;
588+ return foo_functions [selector].name;
589589}
590590
591591static 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,
600600int 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
715715You 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
719719Since the above construct is pretty common there is a helper macro to make
720720it 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...
0 commit comments