blob: 05d25c8adbafb17f5e5551be557e2e423518a6f2 [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
Stephen Warren46919ae2012-03-01 18:48:32 -070015#include "pinctrl.h"
16
Linus Walleij2744e8a2011-05-02 20:50:54 +020017/**
Linus Walleije93bcee2012-02-09 07:23:28 +010018 * struct pinctrl_map - boards/machines shall provide this map for devices
Stephen Warren806d3142012-02-23 17:04:39 -070019 * @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 Walleij2744e8a2011-05-02 20:50:54 +020023 * @name: the name of this specific map entry for the particular machine.
Stephen Warren6e5e9592012-03-02 13:05:47 -070024 * This is the parameter passed to pinmux_lookup_state()
Linus Walleij2744e8a2011-05-02 20:50:54 +020025 * @ctrl_dev_name: the name of the device controlling this specific mapping,
Linus Walleij9dfac4f2012-02-01 18:02:47 +010026 * the name must be the same as in your struct device*
Linus Walleij2744e8a2011-05-02 20:50:54 +020027 * @group: sometimes a function can map to different pin groups, so this
28 * selects a certain specific pin group to activate for the function, if
29 * left as NULL, the first applicable group will be used
Stephen Warren6e5e9592012-03-02 13:05:47 -070030 * @function: a function in the driver to use for this mapping, the driver
31 * will lookup the function referenced by this ID on the specified
32 * pin control device
Linus Walleij2744e8a2011-05-02 20:50:54 +020033 */
Linus Walleije93bcee2012-02-09 07:23:28 +010034struct pinctrl_map {
Stephen Warren806d3142012-02-23 17:04:39 -070035 const char *dev_name;
Linus Walleij2744e8a2011-05-02 20:50:54 +020036 const char *name;
Linus Walleij2744e8a2011-05-02 20:50:54 +020037 const char *ctrl_dev_name;
Linus Walleij2744e8a2011-05-02 20:50:54 +020038 const char *group;
Stephen Warren6e5e9592012-03-02 13:05:47 -070039 const char *function;
Linus Walleij2744e8a2011-05-02 20:50:54 +020040};
41
42/*
43 * Convenience macro to set a simple map from a certain pin controller and a
44 * certain function to a named device
45 */
Linus Walleije93bcee2012-02-09 07:23:28 +010046#define PIN_MAP(a, b, c, d) \
Linus Walleij2744e8a2011-05-02 20:50:54 +020047 { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
48
49/*
Stephen Warren1ddb6ff2011-12-09 16:59:03 -070050 * Convenience macro to map a system function onto a certain pinctrl device,
Linus Walleije93bcee2012-02-09 07:23:28 +010051 * to be hogged by the pin control core until the system shuts down.
Stephen Warren1ddb6ff2011-12-09 16:59:03 -070052 */
Stephen Warren46919ae2012-03-01 18:48:32 -070053#define PIN_MAP_SYS_HOG(a, b) \
54 { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \
55 .function = b, }
Stephen Warren1ddb6ff2011-12-09 16:59:03 -070056
Linus Walleij23750192011-12-14 09:30:08 +010057/*
58 * Convenience macro to map a system function onto a certain pinctrl device
Linus Walleije93bcee2012-02-09 07:23:28 +010059 * using a specified group, to be hogged by the pin control core until the
60 * system shuts down.
Linus Walleij23750192011-12-14 09:30:08 +010061 */
Stephen Warren46919ae2012-03-01 18:48:32 -070062#define PIN_MAP_SYS_HOG_GROUP(a, b, c) \
63 { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \
64 .function = b, .group = c, }
Linus Walleij23750192011-12-14 09:30:08 +010065
Linus Walleij2744e8a2011-05-02 20:50:54 +020066#ifdef CONFIG_PINMUX
67
Linus Walleije93bcee2012-02-09 07:23:28 +010068extern int pinctrl_register_mappings(struct pinctrl_map const *map,
Linus Walleij2744e8a2011-05-02 20:50:54 +020069 unsigned num_maps);
70
71#else
72
Linus Walleije93bcee2012-02-09 07:23:28 +010073static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
Linus Walleij2744e8a2011-05-02 20:50:54 +020074 unsigned num_maps)
75{
76 return 0;
77}
78
79#endif /* !CONFIG_PINMUX */
80#endif