machine.h revision e93bcee00c43e2bd4037291262111016f4c05793
12744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij/*
22744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * Machine interface for the pinctrl subsystem.
32744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *
42744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * Copyright (C) 2011 ST-Ericsson SA
52744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * Written on behalf of Linaro for ST-Ericsson
62744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * Based on bits of regulator core, gpio core and clk core
72744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *
82744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * Author: Linus Walleij <linus.walleij@linaro.org>
92744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *
102744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * License terms: GNU General Public License (GPL) version 2
112744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij */
12e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij#ifndef __LINUX_PINCTRL_MACHINE_H
13e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij#define __LINUX_PINCTRL_MACHINE_H
142744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
152744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij/**
16e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij * struct pinctrl_map - boards/machines shall provide this map for devices
172744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * @name: the name of this specific map entry for the particular machine.
182744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	This is the second parameter passed to pinmux_get() when you want
192744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	to have several mappings to the same device
202744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * @ctrl_dev_name: the name of the device controlling this specific mapping,
219dfac4fd7f8cdcdf734dff2ccc7ca467f53f1cfdLinus Walleij *	the name must be the same as in your struct device*
222744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * @function: a function in the driver to use for this mapping, the driver
232744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	will lookup the function referenced by this ID on the specified
242744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	pin control device
252744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * @group: sometimes a function can map to different pin groups, so this
262744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	selects a certain specific pin group to activate for the function, if
272744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	left as NULL, the first applicable group will be used
282744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * @dev_name: the name of the device using this specific mapping, the name
299dfac4fd7f8cdcdf734dff2ccc7ca467f53f1cfdLinus Walleij *	must be the same as in your struct device*
302744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * @hog_on_boot: if this is set to true, the pin control subsystem will itself
312744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	hog the mappings as the pinmux device drivers are attached, so this is
322744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	typically used with system maps (mux mappings without an assigned
332744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	device) that you want to get hogged and enabled by default as soon as
342744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	a pinmux device supporting it is registered. These maps will not be
352744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij *	disabled and put until the system shuts down.
362744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij */
37e93bcee00c43e2bd4037291262111016f4c05793Linus Walleijstruct pinctrl_map {
382744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	const char *name;
392744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	const char *ctrl_dev_name;
402744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	const char *function;
412744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	const char *group;
422744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	const char *dev_name;
4397607d157c133ab18dfcd77fa836e37fa950a44aLinus Walleij	bool hog_on_boot;
442744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij};
452744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
462744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij/*
472744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * Convenience macro to set a simple map from a certain pin controller and a
482744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * certain function to a named device
492744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij */
50e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij#define PIN_MAP(a, b, c, d) \
512744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	{ .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
522744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
532744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij/*
542744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * Convenience macro to map a system function onto a certain pinctrl device.
552744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij * System functions are not assigned to a particular device.
562744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij */
57e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij#define PIN_MAP_SYS(a, b, c) \
582744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	{ .name = a, .ctrl_dev_name = b, .function = c }
592744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
602744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij/*
611ddb6ff03c0cdec58c6cfdbada95acddcce4a7b7Stephen Warren * Convenience macro to map a system function onto a certain pinctrl device,
62e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij * to be hogged by the pin control core until the system shuts down.
631ddb6ff03c0cdec58c6cfdbada95acddcce4a7b7Stephen Warren */
64e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij#define PIN_MAP_SYS_HOG(a, b, c) \
651ddb6ff03c0cdec58c6cfdbada95acddcce4a7b7Stephen Warren	{ .name = a, .ctrl_dev_name = b, .function = c, \
661ddb6ff03c0cdec58c6cfdbada95acddcce4a7b7Stephen Warren	  .hog_on_boot = true }
671ddb6ff03c0cdec58c6cfdbada95acddcce4a7b7Stephen Warren
6823750196ef472e9249958d5165b0bb292518c710Linus Walleij/*
6923750196ef472e9249958d5165b0bb292518c710Linus Walleij * Convenience macro to map a system function onto a certain pinctrl device
70e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij * using a specified group, to be hogged by the pin control core until the
71e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij * system shuts down.
7223750196ef472e9249958d5165b0bb292518c710Linus Walleij */
73e93bcee00c43e2bd4037291262111016f4c05793Linus Walleij#define PIN_MAP_SYS_HOG_GROUP(a, b, c, d)		\
7423750196ef472e9249958d5165b0bb292518c710Linus Walleij	{ .name = a, .ctrl_dev_name = b, .function = c, .group = d, \
7523750196ef472e9249958d5165b0bb292518c710Linus Walleij	  .hog_on_boot = true }
7623750196ef472e9249958d5165b0bb292518c710Linus Walleij
772744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij#ifdef CONFIG_PINMUX
782744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
79e93bcee00c43e2bd4037291262111016f4c05793Linus Walleijextern int pinctrl_register_mappings(struct pinctrl_map const *map,
802744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij				unsigned num_maps);
812744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
822744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij#else
832744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
84e93bcee00c43e2bd4037291262111016f4c05793Linus Walleijstatic inline int pinctrl_register_mappings(struct pinctrl_map const *map,
852744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij					   unsigned num_maps)
862744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij{
872744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij	return 0;
882744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij}
892744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij
902744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij#endif /* !CONFIG_PINMUX */
912744e8afb3b76343e7eb8197e8b3e085036010a5Linus Walleij#endif
92