2019-06-04 15:11:33 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2014-11-04 07:28:56 +07:00
|
|
|
/*
|
|
|
|
* property.h - Unified device property interface.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014, Intel Corporation
|
|
|
|
* Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
|
|
|
* Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_PROPERTY_H_
|
|
|
|
#define _LINUX_PROPERTY_H_
|
|
|
|
|
2019-04-02 17:30:37 +07:00
|
|
|
#include <linux/bits.h>
|
2015-03-17 05:49:03 +07:00
|
|
|
#include <linux/fwnode.h>
|
2014-11-04 07:28:56 +07:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
struct device;
|
|
|
|
|
|
|
|
enum dev_prop_type {
|
|
|
|
DEV_PROP_U8,
|
|
|
|
DEV_PROP_U16,
|
|
|
|
DEV_PROP_U32,
|
|
|
|
DEV_PROP_U64,
|
|
|
|
DEV_PROP_STRING,
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
DEV_PROP_REF,
|
2014-11-04 07:28:56 +07:00
|
|
|
};
|
|
|
|
|
2015-10-29 05:50:47 +07:00
|
|
|
enum dev_dma_attr {
|
|
|
|
DEV_DMA_NOT_SUPPORTED,
|
|
|
|
DEV_DMA_NON_COHERENT,
|
|
|
|
DEV_DMA_COHERENT,
|
|
|
|
};
|
|
|
|
|
2017-03-28 14:52:24 +07:00
|
|
|
struct fwnode_handle *dev_fwnode(struct device *dev);
|
|
|
|
|
2014-11-04 07:28:56 +07:00
|
|
|
bool device_property_present(struct device *dev, const char *propname);
|
|
|
|
int device_property_read_u8_array(struct device *dev, const char *propname,
|
|
|
|
u8 *val, size_t nval);
|
|
|
|
int device_property_read_u16_array(struct device *dev, const char *propname,
|
|
|
|
u16 *val, size_t nval);
|
|
|
|
int device_property_read_u32_array(struct device *dev, const char *propname,
|
|
|
|
u32 *val, size_t nval);
|
|
|
|
int device_property_read_u64_array(struct device *dev, const char *propname,
|
|
|
|
u64 *val, size_t nval);
|
|
|
|
int device_property_read_string_array(struct device *dev, const char *propname,
|
|
|
|
const char **val, size_t nval);
|
|
|
|
int device_property_read_string(struct device *dev, const char *propname,
|
|
|
|
const char **val);
|
2015-09-14 21:37:35 +07:00
|
|
|
int device_property_match_string(struct device *dev,
|
|
|
|
const char *propname, const char *string);
|
2014-11-04 07:28:56 +07:00
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
|
|
|
|
bool fwnode_property_present(const struct fwnode_handle *fwnode,
|
|
|
|
const char *propname);
|
|
|
|
int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u8 *val,
|
|
|
|
size_t nval);
|
2017-07-21 18:39:36 +07:00
|
|
|
int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u16 *val,
|
|
|
|
size_t nval);
|
2017-07-21 18:39:36 +07:00
|
|
|
int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u32 *val,
|
|
|
|
size_t nval);
|
2017-07-21 18:39:36 +07:00
|
|
|
int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u64 *val,
|
|
|
|
size_t nval);
|
2017-07-21 18:39:36 +07:00
|
|
|
int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, const char **val,
|
|
|
|
size_t nval);
|
2017-07-21 18:39:36 +07:00
|
|
|
int fwnode_property_read_string(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, const char **val);
|
2017-07-21 18:39:36 +07:00
|
|
|
int fwnode_property_match_string(const struct fwnode_handle *fwnode,
|
2015-09-14 21:37:35 +07:00
|
|
|
const char *propname, const char *string);
|
2017-07-21 19:11:49 +07:00
|
|
|
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
|
|
|
|
const char *prop, const char *nargs_prop,
|
|
|
|
unsigned int nargs, unsigned int index,
|
|
|
|
struct fwnode_reference_args *args);
|
2014-11-04 20:03:59 +07:00
|
|
|
|
2019-05-31 21:15:39 +07:00
|
|
|
struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
|
|
|
|
const char *name,
|
|
|
|
unsigned int index);
|
|
|
|
|
2019-10-03 19:32:12 +07:00
|
|
|
const char *fwnode_get_name(const struct fwnode_handle *fwnode);
|
2019-10-03 19:32:13 +07:00
|
|
|
const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode);
|
2017-07-21 18:39:36 +07:00
|
|
|
struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
|
|
|
|
struct fwnode_handle *fwnode_get_next_parent(
|
|
|
|
struct fwnode_handle *fwnode);
|
2019-10-03 19:32:11 +07:00
|
|
|
unsigned int fwnode_count_parents(const struct fwnode_handle *fwn);
|
|
|
|
struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn,
|
|
|
|
unsigned int depth);
|
2017-07-21 18:39:36 +07:00
|
|
|
struct fwnode_handle *fwnode_get_next_child_node(
|
|
|
|
const struct fwnode_handle *fwnode, struct fwnode_handle *child);
|
2018-01-18 19:31:41 +07:00
|
|
|
struct fwnode_handle *fwnode_get_next_available_child_node(
|
|
|
|
const struct fwnode_handle *fwnode, struct fwnode_handle *child);
|
2017-03-28 14:52:18 +07:00
|
|
|
|
|
|
|
#define fwnode_for_each_child_node(fwnode, child) \
|
|
|
|
for (child = fwnode_get_next_child_node(fwnode, NULL); child; \
|
|
|
|
child = fwnode_get_next_child_node(fwnode, child))
|
2017-03-28 14:52:17 +07:00
|
|
|
|
2018-01-18 19:31:41 +07:00
|
|
|
#define fwnode_for_each_available_child_node(fwnode, child) \
|
|
|
|
for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
|
|
|
|
child = fwnode_get_next_available_child_node(fwnode, child))
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
struct fwnode_handle *device_get_next_child_node(
|
|
|
|
struct device *dev, struct fwnode_handle *child);
|
2014-11-04 20:03:59 +07:00
|
|
|
|
2015-11-30 22:11:34 +07:00
|
|
|
#define device_for_each_child_node(dev, child) \
|
|
|
|
for (child = device_get_next_child_node(dev, NULL); child; \
|
2014-11-04 20:03:59 +07:00
|
|
|
child = device_get_next_child_node(dev, child))
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
struct fwnode_handle *fwnode_get_named_child_node(
|
|
|
|
const struct fwnode_handle *fwnode, const char *childname);
|
2016-06-22 00:50:20 +07:00
|
|
|
struct fwnode_handle *device_get_named_child_node(struct device *dev,
|
|
|
|
const char *childname);
|
|
|
|
|
2017-09-19 16:39:11 +07:00
|
|
|
struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
|
2014-11-04 20:03:59 +07:00
|
|
|
void fwnode_handle_put(struct fwnode_handle *fwnode);
|
|
|
|
|
2018-01-18 19:31:40 +07:00
|
|
|
int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index);
|
|
|
|
|
2014-11-04 20:03:59 +07:00
|
|
|
unsigned int device_get_child_node_count(struct device *dev);
|
|
|
|
|
2014-11-04 07:28:56 +07:00
|
|
|
static inline bool device_property_read_bool(struct device *dev,
|
|
|
|
const char *propname)
|
|
|
|
{
|
|
|
|
return device_property_present(dev, propname);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int device_property_read_u8(struct device *dev,
|
|
|
|
const char *propname, u8 *val)
|
|
|
|
{
|
|
|
|
return device_property_read_u8_array(dev, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int device_property_read_u16(struct device *dev,
|
|
|
|
const char *propname, u16 *val)
|
|
|
|
{
|
|
|
|
return device_property_read_u16_array(dev, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int device_property_read_u32(struct device *dev,
|
|
|
|
const char *propname, u32 *val)
|
|
|
|
{
|
|
|
|
return device_property_read_u32_array(dev, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int device_property_read_u64(struct device *dev,
|
|
|
|
const char *propname, u64 *val)
|
|
|
|
{
|
|
|
|
return device_property_read_u64_array(dev, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
2019-06-13 23:59:51 +07:00
|
|
|
static inline int device_property_count_u8(struct device *dev, const char *propname)
|
|
|
|
{
|
|
|
|
return device_property_read_u8_array(dev, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int device_property_count_u16(struct device *dev, const char *propname)
|
|
|
|
{
|
|
|
|
return device_property_read_u16_array(dev, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int device_property_count_u32(struct device *dev, const char *propname)
|
|
|
|
{
|
|
|
|
return device_property_read_u32_array(dev, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int device_property_count_u64(struct device *dev, const char *propname)
|
|
|
|
{
|
|
|
|
return device_property_read_u64_array(dev, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname)
|
|
|
|
{
|
|
|
|
return fwnode_property_present(fwnode, propname);
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
static inline int fwnode_property_read_u8(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u8 *val)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u8_array(fwnode, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
static inline int fwnode_property_read_u16(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u16 *val)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u16_array(fwnode, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
static inline int fwnode_property_read_u32(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u32 *val)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u32_array(fwnode, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode,
|
2014-11-04 20:03:59 +07:00
|
|
|
const char *propname, u64 *val)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u64_array(fwnode, propname, val, 1);
|
|
|
|
}
|
|
|
|
|
2019-06-13 23:59:51 +07:00
|
|
|
static inline int fwnode_property_count_u8(const struct fwnode_handle *fwnode,
|
|
|
|
const char *propname)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u8_array(fwnode, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int fwnode_property_count_u16(const struct fwnode_handle *fwnode,
|
|
|
|
const char *propname)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u16_array(fwnode, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int fwnode_property_count_u32(const struct fwnode_handle *fwnode,
|
|
|
|
const char *propname)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u32_array(fwnode, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int fwnode_property_count_u64(const struct fwnode_handle *fwnode,
|
|
|
|
const char *propname)
|
|
|
|
{
|
|
|
|
return fwnode_property_read_u64_array(fwnode, propname, NULL, 0);
|
|
|
|
}
|
|
|
|
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
struct software_node;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct software_node_ref_args - Reference property with additional arguments
|
|
|
|
* @node: Reference to a software node
|
|
|
|
* @nargs: Number of elements in @args array
|
|
|
|
* @args: Integer arguments
|
|
|
|
*/
|
|
|
|
struct software_node_ref_args {
|
|
|
|
const struct software_node *node;
|
|
|
|
unsigned int nargs;
|
|
|
|
u64 args[NR_FWNODE_REFERENCE_ARGS];
|
|
|
|
};
|
|
|
|
|
2015-04-03 21:05:11 +07:00
|
|
|
/**
|
|
|
|
* struct property_entry - "Built-in" device property representation.
|
|
|
|
* @name: Name of the property.
|
2015-11-30 22:11:31 +07:00
|
|
|
* @length: Length of data making up the value.
|
2019-11-08 11:22:20 +07:00
|
|
|
* @is_inline: True when the property value is stored inline.
|
2018-05-16 00:32:02 +07:00
|
|
|
* @type: Type of the data in unions.
|
2019-11-08 11:22:20 +07:00
|
|
|
* @pointer: Pointer to the property when it is not stored inline.
|
|
|
|
* @value: Value of the property when it is stored inline.
|
2015-04-03 21:05:11 +07:00
|
|
|
*/
|
|
|
|
struct property_entry {
|
|
|
|
const char *name;
|
2015-11-30 22:11:31 +07:00
|
|
|
size_t length;
|
2019-11-08 11:22:20 +07:00
|
|
|
bool is_inline;
|
2018-05-16 00:32:02 +07:00
|
|
|
enum dev_prop_type type;
|
2015-04-03 21:05:11 +07:00
|
|
|
union {
|
2019-10-24 03:02:24 +07:00
|
|
|
const void *pointer;
|
2015-11-30 22:11:32 +07:00
|
|
|
union {
|
2019-11-08 11:22:21 +07:00
|
|
|
u8 u8_data[sizeof(u64) / sizeof(u8)];
|
|
|
|
u16 u16_data[sizeof(u64) / sizeof(u16)];
|
|
|
|
u32 u32_data[sizeof(u64) / sizeof(u32)];
|
|
|
|
u64 u64_data[sizeof(u64) / sizeof(u64)];
|
|
|
|
const char *str[sizeof(u64) / sizeof(char *)];
|
2015-11-30 22:11:32 +07:00
|
|
|
} value;
|
|
|
|
};
|
2015-04-03 21:05:11 +07:00
|
|
|
};
|
|
|
|
|
2016-01-01 08:07:09 +07:00
|
|
|
/*
|
2019-10-24 03:02:26 +07:00
|
|
|
* Note: the below initializers for the anonymous union are carefully
|
2016-01-01 08:07:09 +07:00
|
|
|
* crafted to avoid gcc-4.4.4's problems with initialization of anon unions
|
|
|
|
* and structs.
|
|
|
|
*/
|
|
|
|
|
2019-10-24 03:02:26 +07:00
|
|
|
#define __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_) \
|
2019-11-08 11:22:21 +07:00
|
|
|
sizeof(((struct property_entry *)NULL)->value._elem_[0])
|
2019-10-24 03:02:26 +07:00
|
|
|
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
#define __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, _elsize_, _Type_, \
|
|
|
|
_val_, _len_) \
|
2018-05-16 00:32:02 +07:00
|
|
|
(struct property_entry) { \
|
|
|
|
.name = _name_, \
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
.length = (_len_) * (_elsize_), \
|
2018-05-16 00:32:02 +07:00
|
|
|
.type = DEV_PROP_##_Type_, \
|
2019-10-24 03:02:24 +07:00
|
|
|
{ .pointer = _val_ }, \
|
2015-11-30 22:11:33 +07:00
|
|
|
}
|
|
|
|
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
#define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)\
|
|
|
|
__PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, \
|
|
|
|
__PROPERTY_ENTRY_ELEMENT_SIZE(_elem_), \
|
|
|
|
_Type_, _val_, _len_)
|
|
|
|
|
2019-10-24 03:02:20 +07:00
|
|
|
#define PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, _len_) \
|
2019-10-24 03:02:26 +07:00
|
|
|
__PROPERTY_ENTRY_ARRAY_LEN(_name_, u8_data, U8, _val_, _len_)
|
2019-10-24 03:02:20 +07:00
|
|
|
#define PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, _len_) \
|
2019-10-24 03:02:26 +07:00
|
|
|
__PROPERTY_ENTRY_ARRAY_LEN(_name_, u16_data, U16, _val_, _len_)
|
2019-10-24 03:02:20 +07:00
|
|
|
#define PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, _len_) \
|
2019-10-24 03:02:26 +07:00
|
|
|
__PROPERTY_ENTRY_ARRAY_LEN(_name_, u32_data, U32, _val_, _len_)
|
2019-10-24 03:02:20 +07:00
|
|
|
#define PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, _len_) \
|
2019-10-24 03:02:26 +07:00
|
|
|
__PROPERTY_ENTRY_ARRAY_LEN(_name_, u64_data, U64, _val_, _len_)
|
2019-10-24 03:02:20 +07:00
|
|
|
#define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_) \
|
2019-10-24 03:02:26 +07:00
|
|
|
__PROPERTY_ENTRY_ARRAY_LEN(_name_, str, STRING, _val_, _len_)
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
#define PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, _len_) \
|
|
|
|
__PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, \
|
|
|
|
sizeof(struct software_node_ref_args), \
|
|
|
|
REF, _val_, _len_)
|
2015-11-30 22:11:33 +07:00
|
|
|
|
2019-10-24 03:02:20 +07:00
|
|
|
#define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_) \
|
|
|
|
PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
|
|
|
#define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_) \
|
|
|
|
PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
|
|
|
#define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_) \
|
|
|
|
PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
|
|
|
#define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_) \
|
|
|
|
PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
|
|
|
#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \
|
|
|
|
PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
#define PROPERTY_ENTRY_REF_ARRAY(_name_, _val_) \
|
|
|
|
PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
2019-10-24 03:02:20 +07:00
|
|
|
|
2019-10-24 03:02:26 +07:00
|
|
|
#define __PROPERTY_ENTRY_ELEMENT(_name_, _elem_, _Type_, _val_) \
|
|
|
|
(struct property_entry) { \
|
|
|
|
.name = _name_, \
|
|
|
|
.length = __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_), \
|
2019-11-08 11:22:20 +07:00
|
|
|
.is_inline = true, \
|
2019-10-24 03:02:26 +07:00
|
|
|
.type = DEV_PROP_##_Type_, \
|
2019-11-08 11:22:21 +07:00
|
|
|
{ .value = { ._elem_[0] = _val_ } }, \
|
2015-11-30 22:11:33 +07:00
|
|
|
}
|
|
|
|
|
2019-10-24 03:02:26 +07:00
|
|
|
#define PROPERTY_ENTRY_U8(_name_, _val_) \
|
|
|
|
__PROPERTY_ENTRY_ELEMENT(_name_, u8_data, U8, _val_)
|
|
|
|
#define PROPERTY_ENTRY_U16(_name_, _val_) \
|
|
|
|
__PROPERTY_ENTRY_ELEMENT(_name_, u16_data, U16, _val_)
|
|
|
|
#define PROPERTY_ENTRY_U32(_name_, _val_) \
|
|
|
|
__PROPERTY_ENTRY_ELEMENT(_name_, u32_data, U32, _val_)
|
|
|
|
#define PROPERTY_ENTRY_U64(_name_, _val_) \
|
|
|
|
__PROPERTY_ENTRY_ELEMENT(_name_, u64_data, U64, _val_)
|
|
|
|
#define PROPERTY_ENTRY_STRING(_name_, _val_) \
|
|
|
|
__PROPERTY_ENTRY_ELEMENT(_name_, str, STRING, _val_)
|
2015-11-30 22:11:33 +07:00
|
|
|
|
|
|
|
#define PROPERTY_ENTRY_BOOL(_name_) \
|
2018-01-22 23:01:42 +07:00
|
|
|
(struct property_entry) { \
|
2015-11-30 22:11:33 +07:00
|
|
|
.name = _name_, \
|
2019-11-08 11:22:20 +07:00
|
|
|
.is_inline = true, \
|
2015-11-30 22:11:33 +07:00
|
|
|
}
|
|
|
|
|
software node: implement reference properties
It is possible to store references to software nodes in the same fashion as
other static properties, so that users do not need to define separate
structures:
static const struct software_node gpio_bank_b_node = {
.name = "B",
};
static const struct property_entry simone_key_enter_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
PROPERTY_ENTRY_STRING("label", "enter"),
PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
{ }
};
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-08 11:22:22 +07:00
|
|
|
#define PROPERTY_ENTRY_REF(_name_, _ref_, ...) \
|
|
|
|
(struct property_entry) { \
|
|
|
|
.name = _name_, \
|
|
|
|
.length = sizeof(struct software_node_ref_args), \
|
|
|
|
.type = DEV_PROP_REF, \
|
|
|
|
{ .pointer = &(const struct software_node_ref_args) { \
|
|
|
|
.node = _ref_, \
|
|
|
|
.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1, \
|
|
|
|
.args = { __VA_ARGS__ }, \
|
|
|
|
} }, \
|
|
|
|
}
|
|
|
|
|
2017-02-03 08:41:27 +07:00
|
|
|
struct property_entry *
|
|
|
|
property_entries_dup(const struct property_entry *properties);
|
|
|
|
|
|
|
|
void property_entries_free(const struct property_entry *properties);
|
|
|
|
|
2016-03-29 18:52:23 +07:00
|
|
|
int device_add_properties(struct device *dev,
|
2017-02-03 08:41:25 +07:00
|
|
|
const struct property_entry *properties);
|
2016-03-29 18:52:23 +07:00
|
|
|
void device_remove_properties(struct device *dev);
|
2015-04-03 21:05:11 +07:00
|
|
|
|
2015-10-29 05:50:49 +07:00
|
|
|
bool device_dma_supported(struct device *dev);
|
|
|
|
|
|
|
|
enum dev_dma_attr device_get_dma_attr(struct device *dev);
|
2017-12-13 14:20:49 +07:00
|
|
|
|
2018-02-09 22:38:36 +07:00
|
|
|
const void *device_get_match_data(struct device *dev);
|
2015-10-29 05:50:49 +07:00
|
|
|
|
2015-08-13 05:06:26 +07:00
|
|
|
int device_get_phy_mode(struct device *dev);
|
|
|
|
|
|
|
|
void *device_get_mac_address(struct device *dev, char *addr, int alen);
|
|
|
|
|
2018-01-18 19:31:39 +07:00
|
|
|
int fwnode_get_phy_mode(struct fwnode_handle *fwnode);
|
2018-01-18 19:31:38 +07:00
|
|
|
void *fwnode_get_mac_address(struct fwnode_handle *fwnode,
|
|
|
|
char *addr, int alen);
|
2017-03-28 14:52:21 +07:00
|
|
|
struct fwnode_handle *fwnode_graph_get_next_endpoint(
|
2017-07-21 18:39:36 +07:00
|
|
|
const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
|
2017-06-06 16:37:41 +07:00
|
|
|
struct fwnode_handle *
|
2017-07-21 18:39:36 +07:00
|
|
|
fwnode_graph_get_port_parent(const struct fwnode_handle *fwnode);
|
2017-03-28 14:52:21 +07:00
|
|
|
struct fwnode_handle *fwnode_graph_get_remote_port_parent(
|
2017-07-21 18:39:36 +07:00
|
|
|
const struct fwnode_handle *fwnode);
|
2017-03-28 14:52:21 +07:00
|
|
|
struct fwnode_handle *fwnode_graph_get_remote_port(
|
2017-07-21 18:39:36 +07:00
|
|
|
const struct fwnode_handle *fwnode);
|
2017-03-28 14:52:21 +07:00
|
|
|
struct fwnode_handle *fwnode_graph_get_remote_endpoint(
|
2017-07-21 18:39:36 +07:00
|
|
|
const struct fwnode_handle *fwnode);
|
|
|
|
struct fwnode_handle *
|
|
|
|
fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port,
|
|
|
|
u32 endpoint);
|
2017-03-28 14:52:21 +07:00
|
|
|
|
2019-04-02 17:30:37 +07:00
|
|
|
/*
|
|
|
|
* Fwnode lookup flags
|
|
|
|
*
|
|
|
|
* @FWNODE_GRAPH_ENDPOINT_NEXT: In the case of no exact match, look for the
|
|
|
|
* closest endpoint ID greater than the specified
|
|
|
|
* one.
|
|
|
|
* @FWNODE_GRAPH_DEVICE_DISABLED: That the device to which the remote
|
|
|
|
* endpoint of the given endpoint belongs to,
|
|
|
|
* may be disabled.
|
|
|
|
*/
|
|
|
|
#define FWNODE_GRAPH_ENDPOINT_NEXT BIT(0)
|
|
|
|
#define FWNODE_GRAPH_DEVICE_DISABLED BIT(1)
|
|
|
|
|
|
|
|
struct fwnode_handle *
|
|
|
|
fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
|
|
|
|
u32 port, u32 endpoint, unsigned long flags);
|
|
|
|
|
2017-09-19 16:39:12 +07:00
|
|
|
#define fwnode_graph_for_each_endpoint(fwnode, child) \
|
|
|
|
for (child = NULL; \
|
|
|
|
(child = fwnode_graph_get_next_endpoint(fwnode, child)); )
|
|
|
|
|
2017-07-21 18:39:36 +07:00
|
|
|
int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
|
2017-03-28 14:52:25 +07:00
|
|
|
struct fwnode_endpoint *endpoint);
|
|
|
|
|
2018-11-09 21:21:36 +07:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
/* Software fwnode support - when HW description is incomplete or missing */
|
|
|
|
|
2019-05-31 21:15:34 +07:00
|
|
|
/**
|
|
|
|
* struct software_node - Software node description
|
|
|
|
* @name: Name of the software node
|
|
|
|
* @parent: Parent of the software node
|
|
|
|
* @properties: Array of device properties
|
|
|
|
*/
|
|
|
|
struct software_node {
|
|
|
|
const char *name;
|
|
|
|
const struct software_node *parent;
|
|
|
|
const struct property_entry *properties;
|
|
|
|
};
|
|
|
|
|
2018-11-09 21:21:36 +07:00
|
|
|
bool is_software_node(const struct fwnode_handle *fwnode);
|
2019-10-03 19:32:09 +07:00
|
|
|
const struct software_node *
|
|
|
|
to_software_node(const struct fwnode_handle *fwnode);
|
2019-05-31 21:15:34 +07:00
|
|
|
struct fwnode_handle *software_node_fwnode(const struct software_node *node);
|
|
|
|
|
2019-08-19 17:07:22 +07:00
|
|
|
const struct software_node *
|
|
|
|
software_node_find_by_name(const struct software_node *parent,
|
|
|
|
const char *name);
|
|
|
|
|
2019-05-31 21:15:34 +07:00
|
|
|
int software_node_register_nodes(const struct software_node *nodes);
|
|
|
|
void software_node_unregister_nodes(const struct software_node *nodes);
|
|
|
|
|
|
|
|
int software_node_register(const struct software_node *node);
|
2018-11-09 21:21:36 +07:00
|
|
|
|
|
|
|
int software_node_notify(struct device *dev, unsigned long action);
|
|
|
|
|
|
|
|
struct fwnode_handle *
|
|
|
|
fwnode_create_software_node(const struct property_entry *properties,
|
|
|
|
const struct fwnode_handle *parent);
|
|
|
|
void fwnode_remove_software_node(struct fwnode_handle *fwnode);
|
|
|
|
|
2014-11-04 07:28:56 +07:00
|
|
|
#endif /* _LINUX_PROPERTY_H_ */
|