blob: 400f1926b2347babde12e9dc0768805116125b65 [file] [log] [blame]
Linus Walleij2744e8a2011-05-02 20:50:54 +02001/*
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 Walleije93bcee2012-02-09 07:23:28 +010012#ifndef __LINUX_PINCTRL_MACHINE_H
13#define __LINUX_PINCTRL_MACHINE_H
Linus Walleij2744e8a2011-05-02 20:50:54 +020014
15/**
Linus Walleije93bcee2012-02-09 07:23:28 +010016 * struct pinctrl_map - boards/machines shall provide this map for devices
Linus Walleij2744e8a2011-05-02 20:50:54 +020017 * @name: the name of this specific map entry for the particular machine.
18 * This is the second parameter passed to pinmux_get() when you want
19 * to have several mappings to the same device
Linus Walleij2744e8a2011-05-02 20:50:54 +020020 * @ctrl_dev_name: the name of the device controlling this specific mapping,
Linus Walleij9dfac4f2012-02-01 18:02:47 +010021 * the name must be the same as in your struct device*
Linus Walleij2744e8a2011-05-02 20:50:54 +020022 * @function: a function in the driver to use for this mapping, the driver
23 * will lookup the function referenced by this ID on the specified
24 * pin control device
25 * @group: sometimes a function can map to different pin groups, so this
26 * selects a certain specific pin group to activate for the function, if
27 * left as NULL, the first applicable group will be used
Linus Walleij2744e8a2011-05-02 20:50:54 +020028 * @dev_name: the name of the device using this specific mapping, the name
Linus Walleij77a59882012-02-10 01:34:12 +010029 * must be the same as in your struct device*. If this name is set to the
30 * same name as the pin controllers own dev_name(), the map entry will be
31 * hogged by the driver itself upon registration
Linus Walleij2744e8a2011-05-02 20:50:54 +020032 */
Linus Walleije93bcee2012-02-09 07:23:28 +010033struct pinctrl_map {
Linus Walleij2744e8a2011-05-02 20:50:54 +020034 const char *name;
Linus Walleij2744e8a2011-05-02 20:50:54 +020035 const char *ctrl_dev_name;
36 const char *function;
37 const char *group;
Linus Walleij2744e8a2011-05-02 20:50:54 +020038 const char *dev_name;
Linus Walleij2744e8a2011-05-02 20:50:54 +020039};
40
41/*
42 * Convenience macro to set a simple map from a certain pin controller and a
43 * certain function to a named device
44 */
Linus Walleije93bcee2012-02-09 07:23:28 +010045#define PIN_MAP(a, b, c, d) \
Linus Walleij2744e8a2011-05-02 20:50:54 +020046 { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
47
48/*
Stephen Warren1ddb6ff2011-12-09 16:59:03 -070049 * Convenience macro to map a system function onto a certain pinctrl device,
Linus Walleije93bcee2012-02-09 07:23:28 +010050 * to be hogged by the pin control core until the system shuts down.
Stephen Warren1ddb6ff2011-12-09 16:59:03 -070051 */
Linus Walleije93bcee2012-02-09 07:23:28 +010052#define PIN_MAP_SYS_HOG(a, b, c) \
Linus Walleij77a59882012-02-10 01:34:12 +010053 { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, }
Stephen Warren1ddb6ff2011-12-09 16:59:03 -070054
Linus Walleij23750192011-12-14 09:30:08 +010055/*
56 * Convenience macro to map a system function onto a certain pinctrl device
Linus Walleije93bcee2012-02-09 07:23:28 +010057 * using a specified group, to be hogged by the pin control core until the
58 * system shuts down.
Linus Walleij23750192011-12-14 09:30:08 +010059 */
Linus Walleije93bcee2012-02-09 07:23:28 +010060#define PIN_MAP_SYS_HOG_GROUP(a, b, c, d) \
Linus Walleij77a59882012-02-10 01:34:12 +010061 { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, \
62 .group = d, }
Linus Walleij23750192011-12-14 09:30:08 +010063
Linus Walleij2744e8a2011-05-02 20:50:54 +020064#ifdef CONFIG_PINMUX
65
Linus Walleije93bcee2012-02-09 07:23:28 +010066extern int pinctrl_register_mappings(struct pinctrl_map const *map,
Linus Walleij2744e8a2011-05-02 20:50:54 +020067 unsigned num_maps);
68
69#else
70
Linus Walleije93bcee2012-02-09 07:23:28 +010071static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
Linus Walleij2744e8a2011-05-02 20:50:54 +020072 unsigned num_maps)
73{
74 return 0;
75}
76
77#endif /* !CONFIG_PINMUX */
78#endif