Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Machine interface for the pinctrl subsystem. |
| 3 | * |
| 4 | * Copyright (C) 2011 ST-Ericsson SA |
| 5 | * Written on behalf of Linaro for ST-Ericsson |
| 6 | * Based on bits of regulator core, gpio core and clk core |
| 7 | * |
| 8 | * Author: Linus Walleij <linus.walleij@linaro.org> |
| 9 | * |
| 10 | * License terms: GNU General Public License (GPL) version 2 |
| 11 | */ |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 12 | #ifndef __LINUX_PINCTRL_MACHINE_H |
| 13 | #define __LINUX_PINCTRL_MACHINE_H |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 14 | |
Stephen Warren | 46919ae | 2012-03-01 18:48:32 -0700 | [diff] [blame^] | 15 | #include "pinctrl.h" |
| 16 | |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 17 | /** |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 18 | * struct pinctrl_map - boards/machines shall provide this map for devices |
Stephen Warren | 806d314 | 2012-02-23 17:04:39 -0700 | [diff] [blame] | 19 | * @dev_name: the name of the device using this specific mapping, the name |
| 20 | * must be the same as in your struct device*. If this name is set to the |
| 21 | * same name as the pin controllers own dev_name(), the map entry will be |
| 22 | * hogged by the driver itself upon registration |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 23 | * @name: the name of this specific map entry for the particular machine. |
| 24 | * This is the second parameter passed to pinmux_get() when you want |
| 25 | * to have several mappings to the same device |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 26 | * @ctrl_dev_name: the name of the device controlling this specific mapping, |
Linus Walleij | 9dfac4f | 2012-02-01 18:02:47 +0100 | [diff] [blame] | 27 | * the name must be the same as in your struct device* |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 28 | * @function: a function in the driver to use for this mapping, the driver |
| 29 | * will lookup the function referenced by this ID on the specified |
| 30 | * pin control device |
| 31 | * @group: sometimes a function can map to different pin groups, so this |
| 32 | * selects a certain specific pin group to activate for the function, if |
| 33 | * left as NULL, the first applicable group will be used |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 34 | */ |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 35 | struct pinctrl_map { |
Stephen Warren | 806d314 | 2012-02-23 17:04:39 -0700 | [diff] [blame] | 36 | const char *dev_name; |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 37 | const char *name; |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 38 | const char *ctrl_dev_name; |
| 39 | const char *function; |
| 40 | const char *group; |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /* |
| 44 | * Convenience macro to set a simple map from a certain pin controller and a |
| 45 | * certain function to a named device |
| 46 | */ |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 47 | #define PIN_MAP(a, b, c, d) \ |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 48 | { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d } |
| 49 | |
| 50 | /* |
Stephen Warren | 1ddb6ff | 2011-12-09 16:59:03 -0700 | [diff] [blame] | 51 | * Convenience macro to map a system function onto a certain pinctrl device, |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 52 | * to be hogged by the pin control core until the system shuts down. |
Stephen Warren | 1ddb6ff | 2011-12-09 16:59:03 -0700 | [diff] [blame] | 53 | */ |
Stephen Warren | 46919ae | 2012-03-01 18:48:32 -0700 | [diff] [blame^] | 54 | #define PIN_MAP_SYS_HOG(a, b) \ |
| 55 | { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ |
| 56 | .function = b, } |
Stephen Warren | 1ddb6ff | 2011-12-09 16:59:03 -0700 | [diff] [blame] | 57 | |
Linus Walleij | 2375019 | 2011-12-14 09:30:08 +0100 | [diff] [blame] | 58 | /* |
| 59 | * Convenience macro to map a system function onto a certain pinctrl device |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 60 | * using a specified group, to be hogged by the pin control core until the |
| 61 | * system shuts down. |
Linus Walleij | 2375019 | 2011-12-14 09:30:08 +0100 | [diff] [blame] | 62 | */ |
Stephen Warren | 46919ae | 2012-03-01 18:48:32 -0700 | [diff] [blame^] | 63 | #define PIN_MAP_SYS_HOG_GROUP(a, b, c) \ |
| 64 | { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ |
| 65 | .function = b, .group = c, } |
Linus Walleij | 2375019 | 2011-12-14 09:30:08 +0100 | [diff] [blame] | 66 | |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 67 | #ifdef CONFIG_PINMUX |
| 68 | |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 69 | extern int pinctrl_register_mappings(struct pinctrl_map const *map, |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 70 | unsigned num_maps); |
| 71 | |
| 72 | #else |
| 73 | |
Linus Walleij | e93bcee | 2012-02-09 07:23:28 +0100 | [diff] [blame] | 74 | static inline int pinctrl_register_mappings(struct pinctrl_map const *map, |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 75 | unsigned num_maps) |
| 76 | { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | #endif /* !CONFIG_PINMUX */ |
| 81 | #endif |