// SPDX-License-Identifier: GPL-2.0-only /* * Device tree integration for the pin control subsystem * * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. */ #include <linux/device.h> #include <linux/of.h> #include <linux/pinctrl/pinctrl.h> #include <linux/slab.h> #include "core.h" #include "devicetree.h" /** * struct pinctrl_dt_map - mapping table chunk parsed from device tree * @node: list node for struct pinctrl's @dt_maps field * @pctldev: the pin controller that allocated this struct, and will free it * @map: the mapping table entries * @num_maps: number of mapping table entries */ struct pinctrl_dt_map { … }; static void dt_free_map(struct pinctrl_dev *pctldev, struct pinctrl_map *map, unsigned int num_maps) { … } void pinctrl_dt_free_maps(struct pinctrl *p) { … } static int dt_remember_or_free_map(struct pinctrl *p, const char *statename, struct pinctrl_dev *pctldev, struct pinctrl_map *map, unsigned int num_maps) { … } struct pinctrl_dev *of_pinctrl_get(struct device_node *np) { … } EXPORT_SYMBOL_GPL(…); static int dt_to_map_one_config(struct pinctrl *p, struct pinctrl_dev *hog_pctldev, const char *statename, struct device_node *np_config) { … } static int dt_remember_dummy_state(struct pinctrl *p, const char *statename) { … } int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev) { … } /* * For pinctrl binding, typically #pinctrl-cells is for the pin controller * device, so either parent or grandparent. See pinctrl-bindings.txt. */ static int pinctrl_find_cells_size(const struct device_node *np) { … } /** * pinctrl_get_list_and_count - Gets the list and it's cell size and number * @np: pointer to device node with the property * @list_name: property that contains the list * @list: pointer for the list found * @cells_size: pointer for the cell size found * @nr_elements: pointer for the number of elements found * * Typically np is a single pinctrl entry containing the list. */ static int pinctrl_get_list_and_count(const struct device_node *np, const char *list_name, const __be32 **list, int *cells_size, int *nr_elements) { … } /** * pinctrl_count_index_with_args - Count number of elements in a pinctrl entry * @np: pointer to device node with the property * @list_name: property that contains the list * * Counts the number of elements in a pinctrl array consisting of an index * within the controller and a number of u32 entries specified for each * entry. Note that device_node is always for the parent pin controller device. */ int pinctrl_count_index_with_args(const struct device_node *np, const char *list_name) { … } EXPORT_SYMBOL_GPL(…); /** * pinctrl_copy_args - Populates of_phandle_args based on index * @np: pointer to device node with the property * @list: pointer to a list with the elements * @index: entry within the list of elements * @nr_cells: number of cells in the list * @nr_elem: number of elements for each entry in the list * @out_args: returned values * * Populates the of_phandle_args based on the index in the list. */ static int pinctrl_copy_args(const struct device_node *np, const __be32 *list, int index, int nr_cells, int nr_elem, struct of_phandle_args *out_args) { … } /** * pinctrl_parse_index_with_args - Find a node pointed by index in a list * @np: pointer to device node with the property * @list_name: property that contains the list * @index: index within the list * @out_args: entries in the list pointed by index * * Finds the selected element in a pinctrl array consisting of an index * within the controller and a number of u32 entries specified for each * entry. Note that device_node is always for the parent pin controller device. */ int pinctrl_parse_index_with_args(const struct device_node *np, const char *list_name, int index, struct of_phandle_args *out_args) { … } EXPORT_SYMBOL_GPL(…);