machine.h 3.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * Machine interface for the pinctrl subsystem.
 *
 * Copyright (C) 2011 ST-Ericsson SA
 * Written on behalf of Linaro for ST-Ericsson
 * Based on bits of regulator core, gpio core and clk core
 *
 * Author: Linus Walleij <linus.walleij@linaro.org>
 *
 * License terms: GNU General Public License (GPL) version 2
 */
12 13
#ifndef __LINUX_PINCTRL_MACHINE_H
#define __LINUX_PINCTRL_MACHINE_H
14 15

/**
16
 * struct pinctrl_map - boards/machines shall provide this map for devices
17 18 19 20
 * @name: the name of this specific map entry for the particular machine.
 *	This is the second parameter passed to pinmux_get() when you want
 *	to have several mappings to the same device
 * @ctrl_dev_name: the name of the device controlling this specific mapping,
21
 *	the name must be the same as in your struct device*
22 23 24 25 26 27 28
 * @function: a function in the driver to use for this mapping, the driver
 *	will lookup the function referenced by this ID on the specified
 *	pin control device
 * @group: sometimes a function can map to different pin groups, so this
 *	selects a certain specific pin group to activate for the function, if
 *	left as NULL, the first applicable group will be used
 * @dev_name: the name of the device using this specific mapping, the name
29
 *	must be the same as in your struct device*
30 31 32 33 34 35 36
 * @hog_on_boot: if this is set to true, the pin control subsystem will itself
 *	hog the mappings as the pinmux device drivers are attached, so this is
 *	typically used with system maps (mux mappings without an assigned
 *	device) that you want to get hogged and enabled by default as soon as
 *	a pinmux device supporting it is registered. These maps will not be
 *	disabled and put until the system shuts down.
 */
37
struct pinctrl_map {
38 39 40 41 42
	const char *name;
	const char *ctrl_dev_name;
	const char *function;
	const char *group;
	const char *dev_name;
43
	bool hog_on_boot;
44 45 46 47 48 49
};

/*
 * Convenience macro to set a simple map from a certain pin controller and a
 * certain function to a named device
 */
50
#define PIN_MAP(a, b, c, d) \
51 52 53 54 55 56
	{ .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }

/*
 * Convenience macro to map a system function onto a certain pinctrl device.
 * System functions are not assigned to a particular device.
 */
57
#define PIN_MAP_SYS(a, b, c) \
58 59
	{ .name = a, .ctrl_dev_name = b, .function = c }

60 61
/*
 * Convenience macro to map a system function onto a certain pinctrl device,
62
 * to be hogged by the pin control core until the system shuts down.
63
 */
64
#define PIN_MAP_SYS_HOG(a, b, c) \
65 66 67
	{ .name = a, .ctrl_dev_name = b, .function = c, \
	  .hog_on_boot = true }

68 69
/*
 * Convenience macro to map a system function onto a certain pinctrl device
70 71
 * using a specified group, to be hogged by the pin control core until the
 * system shuts down.
72
 */
73
#define PIN_MAP_SYS_HOG_GROUP(a, b, c, d)		\
74 75 76
	{ .name = a, .ctrl_dev_name = b, .function = c, .group = d, \
	  .hog_on_boot = true }

77 78
#ifdef CONFIG_PINMUX

79
extern int pinctrl_register_mappings(struct pinctrl_map const *map,
80 81 82 83
				unsigned num_maps);

#else

84
static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
85 86 87 88 89 90 91
					   unsigned num_maps)
{
	return 0;
}

#endif /* !CONFIG_PINMUX */
#endif