mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-28 01:51:33 +00:00
dm: pinctrl: migrate pinctrl-generic to livetree
Migrate pinctrl-generic to livetree: - dev_for_each_property - dev_read_prop_by_prop - dev_read_string_count - dev_read_string_index and get rid of DECLARE_GLOBAL_DATA_PTR. This patch solves the parsing issue during sandbox tests for pin configuration (OF_LIVE is activated in sandbox_defconfig and sub node are not correctly parsed in pinctrl_generic_set_state_subnode with fdt lib API). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
This commit is contained in:
parent
ce891fcada
commit
e93f39213a
1 changed files with 11 additions and 19 deletions
|
@ -9,8 +9,6 @@
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
#include <dm/pinctrl.h>
|
#include <dm/pinctrl.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinctrl_pin_name_to_selector() - return the pin selector for a pin
|
* pinctrl_pin_name_to_selector() - return the pin selector for a pin
|
||||||
*
|
*
|
||||||
|
@ -244,18 +242,14 @@ static int pinctrl_generic_set_state_one(struct udevice *dev,
|
||||||
struct udevice *config,
|
struct udevice *config,
|
||||||
bool is_group, unsigned selector)
|
bool is_group, unsigned selector)
|
||||||
{
|
{
|
||||||
const void *fdt = gd->fdt_blob;
|
|
||||||
int node_offset = dev_of_offset(config);
|
|
||||||
const char *propname;
|
const char *propname;
|
||||||
const void *value;
|
const void *value;
|
||||||
int prop_offset, len, func_selector, param, ret;
|
struct ofprop property;
|
||||||
|
int len, func_selector, param, ret;
|
||||||
u32 arg, default_val;
|
u32 arg, default_val;
|
||||||
|
|
||||||
for (prop_offset = fdt_first_property_offset(fdt, node_offset);
|
dev_for_each_property(property, config) {
|
||||||
prop_offset > 0;
|
value = dev_read_prop_by_prop(&property, &propname, &len);
|
||||||
prop_offset = fdt_next_property_offset(fdt, prop_offset)) {
|
|
||||||
value = fdt_getprop_by_offset(fdt, prop_offset,
|
|
||||||
&propname, &len);
|
|
||||||
if (!value)
|
if (!value)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -299,18 +293,16 @@ static int pinctrl_generic_set_state_one(struct udevice *dev,
|
||||||
static int pinctrl_generic_set_state_subnode(struct udevice *dev,
|
static int pinctrl_generic_set_state_subnode(struct udevice *dev,
|
||||||
struct udevice *config)
|
struct udevice *config)
|
||||||
{
|
{
|
||||||
const void *fdt = gd->fdt_blob;
|
|
||||||
int node = dev_of_offset(config);
|
|
||||||
const char *subnode_target_type = "pins";
|
const char *subnode_target_type = "pins";
|
||||||
bool is_group = false;
|
bool is_group = false;
|
||||||
const char *name;
|
const char *name;
|
||||||
int strings_count, selector, i, ret;
|
int strings_count, selector, i, ret;
|
||||||
|
|
||||||
strings_count = fdt_stringlist_count(fdt, node, subnode_target_type);
|
strings_count = dev_read_string_count(config, subnode_target_type);
|
||||||
if (strings_count < 0) {
|
if (strings_count < 0) {
|
||||||
subnode_target_type = "groups";
|
subnode_target_type = "groups";
|
||||||
is_group = true;
|
is_group = true;
|
||||||
strings_count = fdt_stringlist_count(fdt, node,
|
strings_count = dev_read_string_count(config,
|
||||||
subnode_target_type);
|
subnode_target_type);
|
||||||
if (strings_count < 0) {
|
if (strings_count < 0) {
|
||||||
/* skip this node; may contain config child nodes */
|
/* skip this node; may contain config child nodes */
|
||||||
|
@ -319,10 +311,10 @@ static int pinctrl_generic_set_state_subnode(struct udevice *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < strings_count; i++) {
|
for (i = 0; i < strings_count; i++) {
|
||||||
name = fdt_stringlist_get(fdt, node, subnode_target_type, i,
|
ret = dev_read_string_index(config, subnode_target_type, i,
|
||||||
NULL);
|
&name);
|
||||||
if (!name)
|
if (ret)
|
||||||
return -EINVAL;
|
return ret;
|
||||||
|
|
||||||
if (is_group)
|
if (is_group)
|
||||||
selector = pinctrl_group_name_to_selector(dev, name);
|
selector = pinctrl_group_name_to_selector(dev, name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue