blob: f8593fdc6466bc5190ac3d9572ac5dd1b14c6d2e [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 */
12#ifndef __LINUX_PINMUX_MACHINE_H
13#define __LINUX_PINMUX_MACHINE_H
14
15/**
16 * struct pinmux_map - boards/machines shall provide this map for devices
17 * @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 Walleij9dfac4f2012-02-01 18:02:47 +010029 * must be the same as in your struct device*
Linus Walleij2744e8a2011-05-02 20:50:54 +020030 * @hog_on_boot: if this is set to true, the pin control subsystem will itself
31 * hog the mappings as the pinmux device drivers are attached, so this is
32 * typically used with system maps (mux mappings without an assigned
33 * device) that you want to get hogged and enabled by default as soon as
34 * a pinmux device supporting it is registered. These maps will not be
35 * disabled and put until the system shuts down.
36 */
37struct pinmux_map {
38 const char *name;
Linus Walleij2744e8a2011-05-02 20:50:54 +020039 const char *ctrl_dev_name;
40 const char *function;
41 const char *group;
Linus Walleij2744e8a2011-05-02 20:50:54 +020042 const char *dev_name;
Linus Walleij97607d12011-11-29 12:52:39 +010043 bool hog_on_boot;
Linus Walleij2744e8a2011-05-02 20:50:54 +020044};
45
46/*
47 * Convenience macro to set a simple map from a certain pin controller and a
48 * certain function to a named device
49 */
50#define PINMUX_MAP(a, b, c, d) \
51 { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
52
53/*
54 * Convenience macro to map a system function onto a certain pinctrl device.
55 * System functions are not assigned to a particular device.
56 */
57#define PINMUX_MAP_SYS(a, b, c) \
58 { .name = a, .ctrl_dev_name = b, .function = c }
59
60/*
Stephen Warren1ddb6ff2011-12-09 16:59:03 -070061 * Convenience macro to map a system function onto a certain pinctrl device,
62 * to be hogged by the pinmux core until the system shuts down.
63 */
64#define PINMUX_MAP_SYS_HOG(a, b, c) \
65 { .name = a, .ctrl_dev_name = b, .function = c, \
66 .hog_on_boot = true }
67
Linus Walleij23750192011-12-14 09:30:08 +010068/*
69 * Convenience macro to map a system function onto a certain pinctrl device
70 * using a specified group, to be hogged by the pinmux core until the system
71 * shuts down.
72 */
73#define PINMUX_MAP_SYS_HOG_GROUP(a, b, c, d) \
74 { .name = a, .ctrl_dev_name = b, .function = c, .group = d, \
75 .hog_on_boot = true }
76
Linus Walleij2744e8a2011-05-02 20:50:54 +020077#ifdef CONFIG_PINMUX
78
79extern int pinmux_register_mappings(struct pinmux_map const *map,
80 unsigned num_maps);
81
82#else
83
84static inline int pinmux_register_mappings(struct pinmux_map const *map,
85 unsigned num_maps)
86{
87 return 0;
88}
89
90#endif /* !CONFIG_PINMUX */
91#endif