aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/pinctrl.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/pinctrl.txt')
-rw-r--r--Documentation/pinctrl.txt52
1 files changed, 26 insertions, 26 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt
index b04cb7d45a16..0a8b2250062a 100644
--- a/Documentation/pinctrl.txt
+++ b/Documentation/pinctrl.txt
@@ -32,7 +32,7 @@ Definition of PIN:
32 be sparse - i.e. there may be gaps in the space with numbers where no 32 be sparse - i.e. there may be gaps in the space with numbers where no
33 pin exists. 33 pin exists.
34 34
35When a PIN CONTROLLER is instatiated, it will register a descriptor to the 35When a PIN CONTROLLER is instantiated, it will register a descriptor to the
36pin control framework, and this descriptor contains an array of pin descriptors 36pin control framework, and this descriptor contains an array of pin descriptors
37describing the pins handled by this specific pin controller. 37describing the pins handled by this specific pin controller.
38 38
@@ -61,14 +61,14 @@ this in our driver:
61 61
62#include <linux/pinctrl/pinctrl.h> 62#include <linux/pinctrl/pinctrl.h>
63 63
64const struct pinctrl_pin_desc __refdata foo_pins[] = { 64const struct pinctrl_pin_desc foo_pins[] = {
65 PINCTRL_PIN(0, "A1"), 65 PINCTRL_PIN(0, "A8"),
66 PINCTRL_PIN(1, "A2"), 66 PINCTRL_PIN(1, "B8"),
67 PINCTRL_PIN(2, "A3"), 67 PINCTRL_PIN(2, "C8"),
68 ... 68 ...
69 PINCTRL_PIN(61, "H6"), 69 PINCTRL_PIN(61, "F1"),
70 PINCTRL_PIN(62, "H7"), 70 PINCTRL_PIN(62, "G1"),
71 PINCTRL_PIN(63, "H8"), 71 PINCTRL_PIN(63, "H1"),
72}; 72};
73 73
74static struct pinctrl_desc foo_desc = { 74static struct pinctrl_desc foo_desc = {
@@ -91,8 +91,8 @@ int __init foo_probe(void)
91Pins usually have fancier names than this. You can find these in the dataheet 91Pins usually have fancier names than this. You can find these in the dataheet
92for your chip. Notice that the core pinctrl.h file provides a fancy macro 92for your chip. Notice that the core pinctrl.h file provides a fancy macro
93called PINCTRL_PIN() to create the struct entries. As you can see I enumerated 93called PINCTRL_PIN() to create the struct entries. As you can see I enumerated
94the pins from 0 in the upper left corner to 63 in the lower right corner, 94the pins from 0 in the upper left corner to 63 in the lower right corner.
95this enumeration was arbitrarily chosen, in practice you need to think 95This enumeration was arbitrarily chosen, in practice you need to think
96through your numbering system so that it matches the layout of registers 96through your numbering system so that it matches the layout of registers
97and such things in your driver, or the code may become complicated. You must 97and such things in your driver, or the code may become complicated. You must
98also consider matching of offsets to the GPIO ranges that may be handled by 98also consider matching of offsets to the GPIO ranges that may be handled by
@@ -133,8 +133,8 @@ struct foo_group {
133 const unsigned num_pins; 133 const unsigned num_pins;
134}; 134};
135 135
136static unsigned int spi0_pins[] = { 0, 8, 16, 24 }; 136static const unsigned int spi0_pins[] = { 0, 8, 16, 24 };
137static unsigned int i2c0_pins[] = { 24, 25 }; 137static const unsigned int i2c0_pins[] = { 24, 25 };
138 138
139static const struct foo_group foo_groups[] = { 139static const struct foo_group foo_groups[] = {
140 { 140 {
@@ -242,7 +242,7 @@ chip a: [32 .. 47]
242chip b: [48 .. 55] 242chip b: [48 .. 55]
243 243
244When GPIO-specific functions in the pin control subsystem are called, these 244When GPIO-specific functions in the pin control subsystem are called, these
245ranges will be used to look up the apropriate pin controller by inspecting 245ranges will be used to look up the appropriate pin controller by inspecting
246and matching the pin to the pin ranges across all controllers. When a 246and matching the pin to the pin ranges across all controllers. When a
247pin controller handling the matching range is found, GPIO-specific functions 247pin controller handling the matching range is found, GPIO-specific functions
248will be called on that specific pin controller. 248will 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.
438 438
439Assumptions: 439Assumptions:
440 440
441We assume that the number possible function maps to pin groups is limited by 441We assume that the number of possible function maps to pin groups is limited by
442the hardware. I.e. we assume that there is no system where any function can be 442the hardware. I.e. we assume that there is no system where any function can be
443mapped to any pin, like in a phone exchange. So the available pins groups for 443mapped to any pin, like in a phone exchange. So the available pins groups for
444a certain function will be limited to a few choices (say up to eight or so), 444a 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)
585 585
586const char *foo_get_fname(struct pinctrl_dev *pctldev, unsigned selector) 586const char *foo_get_fname(struct pinctrl_dev *pctldev, unsigned selector)
587{ 587{
588 return myfuncs[selector].name; 588 return foo_functions[selector].name;
589} 589}
590 590
591static int foo_get_groups(struct pinctrl_dev *pctldev, unsigned selector, 591static 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,
600int foo_enable(struct pinctrl_dev *pctldev, unsigned selector, 600int foo_enable(struct pinctrl_dev *pctldev, unsigned selector,
601 unsigned group) 601 unsigned group)
602{ 602{
603 u8 regbit = (1 << group); 603 u8 regbit = (1 << selector + group);
604 604
605 writeb((readb(MUX)|regbit), MUX) 605 writeb((readb(MUX)|regbit), MUX)
606 return 0; 606 return 0;
607} 607}
608 608
609int foo_disable(struct pinctrl_dev *pctldev, unsigned selector, 609void foo_disable(struct pinctrl_dev *pctldev, unsigned selector,
610 unsigned group) 610 unsigned group)
611{ 611{
612 u8 regbit = (1 << group); 612 u8 regbit = (1 << selector + group);
613 613
614 writeb((readb(MUX) & ~(regbit)), MUX) 614 writeb((readb(MUX) & ~(regbit)), MUX)
615 return 0; 615 return 0;
@@ -683,7 +683,7 @@ spi on the second function mapping:
683 683
684#include <linux/pinctrl/machine.h> 684#include <linux/pinctrl/machine.h>
685 685
686static struct pinmux_map pmx_mapping[] = { 686static const struct pinmux_map pmx_mapping[] = {
687 { 687 {
688 .ctrl_dev_name = "pinctrl.0", 688 .ctrl_dev_name = "pinctrl.0",
689 .function = "spi0", 689 .function = "spi0",
@@ -714,7 +714,7 @@ for example if they are not yet instantiated or cumbersome to obtain.
714 714
715You register this pinmux mapping to the pinmux subsystem by simply: 715You register this pinmux mapping to the pinmux subsystem by simply:
716 716
717 ret = pinmux_register_mappings(&pmx_mapping, ARRAY_SIZE(pmx_mapping)); 717 ret = pinmux_register_mappings(pmx_mapping, ARRAY_SIZE(pmx_mapping));
718 718
719Since the above construct is pretty common there is a helper macro to make 719Since the above construct is pretty common there is a helper macro to make
720it even more compact which assumes you want to use pinctrl.0 and position 720it even more compact which assumes you want to use pinctrl.0 and position
@@ -762,42 +762,42 @@ case), we define a mapping like this:
762 .name "2bit" 762 .name "2bit"
763 .ctrl_dev_name = "pinctrl.0", 763 .ctrl_dev_name = "pinctrl.0",
764 .function = "mmc0", 764 .function = "mmc0",
765 .group = "mmc0_0_grp", 765 .group = "mmc0_1_grp",
766 .dev_name = "foo-mmc.0", 766 .dev_name = "foo-mmc.0",
767}, 767},
768{ 768{
769 .name "4bit" 769 .name "4bit"
770 .ctrl_dev_name = "pinctrl.0", 770 .ctrl_dev_name = "pinctrl.0",
771 .function = "mmc0", 771 .function = "mmc0",
772 .group = "mmc0_0_grp", 772 .group = "mmc0_1_grp",
773 .dev_name = "foo-mmc.0", 773 .dev_name = "foo-mmc.0",
774}, 774},
775{ 775{
776 .name "4bit" 776 .name "4bit"
777 .ctrl_dev_name = "pinctrl.0", 777 .ctrl_dev_name = "pinctrl.0",
778 .function = "mmc0", 778 .function = "mmc0",
779 .group = "mmc0_1_grp", 779 .group = "mmc0_2_grp",
780 .dev_name = "foo-mmc.0", 780 .dev_name = "foo-mmc.0",
781}, 781},
782{ 782{
783 .name "8bit" 783 .name "8bit"
784 .ctrl_dev_name = "pinctrl.0", 784 .ctrl_dev_name = "pinctrl.0",
785 .function = "mmc0", 785 .function = "mmc0",
786 .group = "mmc0_0_grp", 786 .group = "mmc0_1_grp",
787 .dev_name = "foo-mmc.0", 787 .dev_name = "foo-mmc.0",
788}, 788},
789{ 789{
790 .name "8bit" 790 .name "8bit"
791 .ctrl_dev_name = "pinctrl.0", 791 .ctrl_dev_name = "pinctrl.0",
792 .function = "mmc0", 792 .function = "mmc0",
793 .group = "mmc0_1_grp", 793 .group = "mmc0_2_grp",
794 .dev_name = "foo-mmc.0", 794 .dev_name = "foo-mmc.0",
795}, 795},
796{ 796{
797 .name "8bit" 797 .name "8bit"
798 .ctrl_dev_name = "pinctrl.0", 798 .ctrl_dev_name = "pinctrl.0",
799 .function = "mmc0", 799 .function = "mmc0",
800 .group = "mmc0_2_grp", 800 .group = "mmc0_3_grp",
801 .dev_name = "foo-mmc.0", 801 .dev_name = "foo-mmc.0",
802}, 802},
803... 803...