spmi: Add spmi_resource for non spmi-dev-container cases
The devnode array is currently being used for non spmi-dev-container devices as a special case where the number of devnodes is 1. This obfuscates the code and also removes the ability to store the dev-container's device resource information, since in that special case the devnode array is dedicated for the child devices. Add a new spmi_resource entry used for typical spmi_devices, and treat the devnode array as the special case for spmi-dev-container. Also add a new API spmi_get_primary_dev_name() to return the name of the device assigned with the 'label' binding if it exists. Change-Id: Ibe7b12285e37bb0529024558550a96d71393bc10 Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
This commit is contained in:
committed by
Stephen Boyd
parent
d2f455c4e2
commit
a22d6fb262
@@ -116,7 +116,8 @@ struct spmi_resource {
|
||||
* @dev: Driver model representation of the device.
|
||||
* @name: Name of driver to use with this device.
|
||||
* @ctrl: SPMI controller managing the bus hosting this device.
|
||||
* @dev_node: array of SPMI resources - one entry per device_node.
|
||||
* @res: SPMI resource for the primary node
|
||||
* @dev_node: array of SPMI resources when used with spmi-dev-container.
|
||||
* @num_dev_node: number of device_node structures.
|
||||
* @sid: Slave Identifier.
|
||||
*/
|
||||
@@ -124,6 +125,7 @@ struct spmi_device {
|
||||
struct device dev;
|
||||
const char *name;
|
||||
struct spmi_controller *ctrl;
|
||||
struct spmi_resource res;
|
||||
struct spmi_resource *dev_node;
|
||||
u32 num_dev_node;
|
||||
u8 sid;
|
||||
@@ -132,10 +134,12 @@ struct spmi_device {
|
||||
|
||||
/**
|
||||
* struct spmi_boardinfo: Declare board info for SPMI device bringup.
|
||||
* @name: Name of driver to use with this device.
|
||||
* @slave_id: slave identifier.
|
||||
* @spmi_device: device to be registered with the SPMI framework.
|
||||
* @of_node: pointer to the OpenFirmware device node.
|
||||
* @dev_node: one spmi_resource for each device_node.
|
||||
* @res: SPMI resource for the primary node
|
||||
* @dev_node: array of SPMI resources when used with spmi-dev-container.
|
||||
* @num_dev_node: number of device_node structures.
|
||||
* @platform_data: goes to spmi_device.dev.platform_data
|
||||
*/
|
||||
@@ -143,6 +147,7 @@ struct spmi_boardinfo {
|
||||
char name[SPMI_NAME_SIZE];
|
||||
uint8_t slave_id;
|
||||
struct device_node *of_node;
|
||||
struct spmi_resource res;
|
||||
struct spmi_resource *dev_node;
|
||||
u32 num_dev_node;
|
||||
const void *platform_data;
|
||||
@@ -452,6 +457,22 @@ extern int spmi_get_irq(struct spmi_device *dev, struct spmi_resource *node,
|
||||
extern int spmi_get_irq_byname(struct spmi_device *dev,
|
||||
struct spmi_resource *node, const char *name);
|
||||
|
||||
/**
|
||||
* spmi_get_node_name - return device name for spmi node
|
||||
* @dev: spmi device handle
|
||||
*
|
||||
* Get the primary node name of a spmi_device coresponding with
|
||||
* with the 'label' binding.
|
||||
*
|
||||
* Returns NULL if no primary dev name has been assigned to this spmi_device.
|
||||
*/
|
||||
static inline const char *spmi_get_primary_dev_name(struct spmi_device *dev)
|
||||
{
|
||||
if (dev->res.label)
|
||||
return dev->res.label;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct spmi_resource *spmi_get_dev_container_byname(struct spmi_device *dev,
|
||||
const char *label);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user