2017-11-07 16:30:07 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
/*
|
|
|
|
* Componentized device handling.
|
|
|
|
*/
|
|
|
|
#include <linux/component.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/slab.h>
|
2017-12-01 13:23:16 +00:00
|
|
|
#include <linux/debugfs.h>
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2019-02-07 23:27:56 +00:00
|
|
|
/**
|
|
|
|
* DOC: overview
|
|
|
|
*
|
|
|
|
* The component helper allows drivers to collect a pile of sub-devices,
|
|
|
|
* including their bound drivers, into an aggregate driver. Various subsystems
|
|
|
|
* already provide functions to get hold of such components, e.g.
|
|
|
|
* of_clk_get_by_name(). The component helper can be used when such a
|
|
|
|
* subsystem-specific way to find a device is not available: The component
|
|
|
|
* helper fills the niche of aggregate drivers for specific hardware, where
|
|
|
|
* further standardization into a subsystem would not be practical. The common
|
|
|
|
* example is when a logical device (e.g. a DRM display driver) is spread around
|
2019-02-18 16:36:48 +00:00
|
|
|
* the SoC on various components (scanout engines, blending blocks, transcoders
|
2019-02-07 23:27:56 +00:00
|
|
|
* for various outputs and so on).
|
|
|
|
*
|
|
|
|
* The component helper also doesn't solve runtime dependencies, e.g. for system
|
|
|
|
* suspend and resume operations. See also :ref:`device links<device_link>`.
|
|
|
|
*
|
|
|
|
* Components are registered using component_add() and unregistered with
|
|
|
|
* component_del(), usually from the driver's probe and disconnect functions.
|
|
|
|
*
|
|
|
|
* Aggregate drivers first assemble a component match list of what they need
|
|
|
|
* using component_match_add(). This is then registered as an aggregate driver
|
|
|
|
* using component_master_add_with_match(), and unregistered using
|
|
|
|
* component_master_del().
|
|
|
|
*/
|
|
|
|
|
2014-04-18 22:05:53 +00:00
|
|
|
struct component;
|
|
|
|
|
2015-11-17 12:08:01 +00:00
|
|
|
struct component_match_array {
|
|
|
|
void *data;
|
|
|
|
int (*compare)(struct device *, void *);
|
2019-02-07 23:27:57 +00:00
|
|
|
int (*compare_typed)(struct device *, int, void *);
|
2015-11-17 12:08:01 +00:00
|
|
|
void (*release)(struct device *, void *);
|
|
|
|
struct component *component;
|
|
|
|
bool duplicate;
|
|
|
|
};
|
|
|
|
|
2014-04-19 10:18:01 +00:00
|
|
|
struct component_match {
|
|
|
|
size_t alloc;
|
|
|
|
size_t num;
|
2015-11-17 12:08:01 +00:00
|
|
|
struct component_match_array *compare;
|
2014-04-19 10:18:01 +00:00
|
|
|
};
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device {
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
struct list_head node;
|
|
|
|
bool bound;
|
|
|
|
|
|
|
|
const struct component_master_ops *ops;
|
2021-05-20 00:25:14 +00:00
|
|
|
struct device *parent;
|
2014-04-19 10:18:01 +00:00
|
|
|
struct component_match *match;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct component {
|
|
|
|
struct list_head node;
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *adev;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
bool bound;
|
|
|
|
|
|
|
|
const struct component_ops *ops;
|
2019-02-07 23:27:57 +00:00
|
|
|
int subcomponent;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
struct device *dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DEFINE_MUTEX(component_mutex);
|
|
|
|
static LIST_HEAD(component_list);
|
2022-01-27 20:01:07 +00:00
|
|
|
static LIST_HEAD(aggregate_devices);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2017-12-01 13:23:16 +00:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
|
|
|
|
static struct dentry *component_debugfs_dir;
|
|
|
|
|
|
|
|
static int component_devices_show(struct seq_file *s, void *data)
|
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *m = s->private;
|
2017-12-01 13:23:16 +00:00
|
|
|
struct component_match *match = m->match;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
mutex_lock(&component_mutex);
|
2022-01-27 20:01:07 +00:00
|
|
|
seq_printf(s, "%-40s %20s\n", "aggregate_device name", "status");
|
2017-12-01 13:23:16 +00:00
|
|
|
seq_puts(s, "-------------------------------------------------------------\n");
|
|
|
|
seq_printf(s, "%-40s %20s\n\n",
|
2021-05-20 00:25:14 +00:00
|
|
|
dev_name(m->parent), m->bound ? "bound" : "not bound");
|
2017-12-01 13:23:16 +00:00
|
|
|
|
|
|
|
seq_printf(s, "%-40s %20s\n", "device name", "status");
|
|
|
|
seq_puts(s, "-------------------------------------------------------------\n");
|
|
|
|
for (i = 0; i < match->num; i++) {
|
2019-11-18 11:54:31 +00:00
|
|
|
struct component *component = match->compare[i].component;
|
2017-12-01 13:23:16 +00:00
|
|
|
|
2019-11-18 11:54:31 +00:00
|
|
|
seq_printf(s, "%-40s %20s\n",
|
|
|
|
component ? dev_name(component->dev) : "(unknown)",
|
|
|
|
component ? (component->bound ? "bound" : "not bound") : "not registered");
|
2017-12-01 13:23:16 +00:00
|
|
|
}
|
|
|
|
mutex_unlock(&component_mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-15 08:36:36 +00:00
|
|
|
DEFINE_SHOW_ATTRIBUTE(component_devices);
|
2017-12-01 13:23:16 +00:00
|
|
|
|
|
|
|
static int __init component_debug_init(void)
|
|
|
|
{
|
|
|
|
component_debugfs_dir = debugfs_create_dir("device_component", NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
core_initcall(component_debug_init);
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static void component_debugfs_add(struct aggregate_device *m)
|
2017-12-01 13:23:16 +00:00
|
|
|
{
|
2021-05-20 00:25:14 +00:00
|
|
|
debugfs_create_file(dev_name(m->parent), 0444, component_debugfs_dir, m,
|
2021-02-16 14:23:59 +00:00
|
|
|
&component_devices_fops);
|
2017-12-01 13:23:16 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static void component_debugfs_del(struct aggregate_device *m)
|
2017-12-01 13:23:16 +00:00
|
|
|
{
|
2021-05-20 00:25:14 +00:00
|
|
|
debugfs_remove(debugfs_lookup(dev_name(m->parent), component_debugfs_dir));
|
2017-12-01 13:23:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static void component_debugfs_add(struct aggregate_device *m)
|
2017-12-01 13:23:16 +00:00
|
|
|
{ }
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static void component_debugfs_del(struct aggregate_device *m)
|
2017-12-01 13:23:16 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static struct aggregate_device *__aggregate_find(struct device *parent,
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
const struct component_master_ops *ops)
|
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *m;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
list_for_each_entry(m, &aggregate_devices, node)
|
2021-05-20 00:25:14 +00:00
|
|
|
if (m->parent == parent && (!ops || m->ops == ops))
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
return m;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static struct component *find_component(struct aggregate_device *adev,
|
2019-02-07 23:27:57 +00:00
|
|
|
struct component_match_array *mc)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
|
|
|
struct component *c;
|
|
|
|
|
|
|
|
list_for_each_entry(c, &component_list, node) {
|
2022-01-27 20:01:07 +00:00
|
|
|
if (c->adev && c->adev != adev)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
continue;
|
|
|
|
|
2019-02-07 23:27:57 +00:00
|
|
|
if (mc->compare && mc->compare(c->dev, mc->data))
|
|
|
|
return c;
|
|
|
|
|
|
|
|
if (mc->compare_typed &&
|
|
|
|
mc->compare_typed(c->dev, c->subcomponent, mc->data))
|
2014-04-18 22:05:53 +00:00
|
|
|
return c;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
2014-04-18 22:05:53 +00:00
|
|
|
return NULL;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static int find_components(struct aggregate_device *adev)
|
2014-04-19 10:18:01 +00:00
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct component_match *match = adev->match;
|
2014-04-19 10:18:01 +00:00
|
|
|
size_t i;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan the array of match functions and attach
|
2022-01-27 20:01:07 +00:00
|
|
|
* any components which are found to this adev.
|
2014-04-19 10:18:01 +00:00
|
|
|
*/
|
|
|
|
for (i = 0; i < match->num; i++) {
|
2015-11-17 12:08:01 +00:00
|
|
|
struct component_match_array *mc = &match->compare[i];
|
2014-04-18 22:05:53 +00:00
|
|
|
struct component *c;
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
dev_dbg(adev->parent, "Looking for component %zu\n", i);
|
2014-04-18 22:05:53 +00:00
|
|
|
|
|
|
|
if (match->compare[i].component)
|
|
|
|
continue;
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
c = find_component(adev, mc);
|
2014-04-18 22:05:53 +00:00
|
|
|
if (!c) {
|
|
|
|
ret = -ENXIO;
|
2014-04-19 10:18:01 +00:00
|
|
|
break;
|
2014-04-18 22:05:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
dev_dbg(adev->parent, "found component %s, duplicate %u\n",
|
|
|
|
dev_name(c->dev), !!c->adev);
|
2014-04-18 22:05:53 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
/* Attach this component to the adev */
|
|
|
|
match->compare[i].duplicate = !!c->adev;
|
2014-04-18 22:05:53 +00:00
|
|
|
match->compare[i].component = c;
|
2022-01-27 20:01:07 +00:00
|
|
|
c->adev = adev;
|
2014-04-19 10:18:01 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
/* Detach component from associated aggregate_device */
|
|
|
|
static void remove_component(struct aggregate_device *adev, struct component *c)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
2014-04-18 22:05:53 +00:00
|
|
|
size_t i;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
/* Detach the component from this adev. */
|
|
|
|
for (i = 0; i < adev->match->num; i++)
|
|
|
|
if (adev->match->compare[i].component == c)
|
|
|
|
adev->match->compare[i].component = NULL;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2022-01-27 20:01:07 +00:00
|
|
|
* Try to bring up an aggregate device. If component is NULL, we're interested
|
|
|
|
* in this aggregate device, otherwise it's a component which must be present
|
|
|
|
* to try and bring up the aggregate device.
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
*
|
|
|
|
* Returns 1 for successful bringup, 0 if not ready, or -ve errno.
|
|
|
|
*/
|
2022-01-27 20:01:07 +00:00
|
|
|
static int try_to_bring_up_aggregate_device(struct aggregate_device *adev,
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
struct component *component)
|
|
|
|
{
|
2014-04-23 09:52:17 +00:00
|
|
|
int ret;
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
dev_dbg(adev->parent, "trying to bring up adev\n");
|
2014-04-18 22:05:53 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
if (find_components(adev)) {
|
|
|
|
dev_dbg(adev->parent, "master has incomplete components\n");
|
2014-04-18 22:05:53 +00:00
|
|
|
return 0;
|
2014-04-23 09:52:17 +00:00
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
if (component && component->adev != adev) {
|
|
|
|
dev_dbg(adev->parent, "master is not for this component (%s)\n",
|
2014-04-18 22:05:53 +00:00
|
|
|
dev_name(component->dev));
|
|
|
|
return 0;
|
2014-04-23 09:52:17 +00:00
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
if (!devres_open_group(adev->parent, adev, GFP_KERNEL))
|
2014-04-18 22:05:53 +00:00
|
|
|
return -ENOMEM;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2014-04-23 09:52:17 +00:00
|
|
|
/* Found all components */
|
2022-01-27 20:01:07 +00:00
|
|
|
ret = adev->ops->bind(adev->parent);
|
2014-04-23 09:52:17 +00:00
|
|
|
if (ret < 0) {
|
2022-01-27 20:01:07 +00:00
|
|
|
devres_release_group(adev->parent, NULL);
|
2020-04-11 19:02:41 +00:00
|
|
|
if (ret != -EPROBE_DEFER)
|
2022-01-27 20:01:07 +00:00
|
|
|
dev_info(adev->parent, "adev bind failed: %d\n", ret);
|
2014-04-18 22:05:53 +00:00
|
|
|
return ret;
|
2014-04-23 09:52:17 +00:00
|
|
|
}
|
2014-02-07 20:09:27 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
devres_close_group(adev->parent, NULL);
|
|
|
|
adev->bound = true;
|
2014-04-23 09:52:17 +00:00
|
|
|
return 1;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int try_to_bring_up_masters(struct component *component)
|
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *adev;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
list_for_each_entry(adev, &aggregate_devices, node) {
|
|
|
|
if (!adev->bound) {
|
|
|
|
ret = try_to_bring_up_aggregate_device(adev, component);
|
2014-04-23 09:46:11 +00:00
|
|
|
if (ret != 0)
|
|
|
|
break;
|
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static void take_down_aggregate_device(struct aggregate_device *adev)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
if (adev->bound) {
|
|
|
|
adev->ops->unbind(adev->parent);
|
|
|
|
devres_release_group(adev->parent, adev);
|
|
|
|
adev->bound = false;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 00:25:14 +00:00
|
|
|
static void devm_component_match_release(struct device *parent, void *res)
|
2014-04-19 10:18:01 +00:00
|
|
|
{
|
2021-05-20 00:25:14 +00:00
|
|
|
struct component_match *match = res;
|
2015-11-17 12:08:01 +00:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < match->num; i++) {
|
|
|
|
struct component_match_array *mc = &match->compare[i];
|
|
|
|
|
|
|
|
if (mc->release)
|
2021-05-20 00:25:14 +00:00
|
|
|
mc->release(parent, mc->data);
|
2015-11-17 12:08:01 +00:00
|
|
|
}
|
2016-01-26 14:49:22 +00:00
|
|
|
|
|
|
|
kfree(match->compare);
|
2014-04-19 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 00:25:13 +00:00
|
|
|
static int component_match_realloc(struct component_match *match, size_t num)
|
2014-04-19 10:18:01 +00:00
|
|
|
{
|
2015-11-17 12:08:01 +00:00
|
|
|
struct component_match_array *new;
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2015-11-17 12:08:01 +00:00
|
|
|
if (match->alloc == num)
|
|
|
|
return 0;
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2016-01-26 14:49:22 +00:00
|
|
|
new = kmalloc_array(num, sizeof(*new), GFP_KERNEL);
|
2014-04-19 10:18:01 +00:00
|
|
|
if (!new)
|
2015-11-17 12:08:01 +00:00
|
|
|
return -ENOMEM;
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2015-11-17 12:08:01 +00:00
|
|
|
if (match->compare) {
|
|
|
|
memcpy(new, match->compare, sizeof(*new) *
|
|
|
|
min(match->num, num));
|
2016-01-26 14:49:22 +00:00
|
|
|
kfree(match->compare);
|
2014-04-19 10:18:01 +00:00
|
|
|
}
|
2015-11-17 12:08:01 +00:00
|
|
|
match->compare = new;
|
|
|
|
match->alloc = num;
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2015-11-17 12:08:01 +00:00
|
|
|
return 0;
|
2014-04-19 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static void __component_match_add(struct device *parent,
|
2015-11-17 12:08:01 +00:00
|
|
|
struct component_match **matchptr,
|
|
|
|
void (*release)(struct device *, void *),
|
2019-02-07 23:27:57 +00:00
|
|
|
int (*compare)(struct device *, void *),
|
|
|
|
int (*compare_typed)(struct device *, int, void *),
|
|
|
|
void *compare_data)
|
2014-04-19 10:18:01 +00:00
|
|
|
{
|
|
|
|
struct component_match *match = *matchptr;
|
|
|
|
|
|
|
|
if (IS_ERR(match))
|
|
|
|
return;
|
|
|
|
|
2015-11-17 12:08:01 +00:00
|
|
|
if (!match) {
|
|
|
|
match = devres_alloc(devm_component_match_release,
|
|
|
|
sizeof(*match), GFP_KERNEL);
|
|
|
|
if (!match) {
|
|
|
|
*matchptr = ERR_PTR(-ENOMEM);
|
|
|
|
return;
|
|
|
|
}
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
devres_add(parent, match);
|
2014-04-19 10:18:01 +00:00
|
|
|
|
|
|
|
*matchptr = match;
|
2015-11-17 12:08:01 +00:00
|
|
|
}
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2015-11-17 12:08:01 +00:00
|
|
|
if (match->num == match->alloc) {
|
2016-02-02 07:27:53 +00:00
|
|
|
size_t new_size = match->alloc + 16;
|
2015-11-17 12:08:01 +00:00
|
|
|
int ret;
|
|
|
|
|
2021-05-20 00:25:13 +00:00
|
|
|
ret = component_match_realloc(match, new_size);
|
2015-11-17 12:08:01 +00:00
|
|
|
if (ret) {
|
|
|
|
*matchptr = ERR_PTR(ret);
|
2014-04-19 10:18:01 +00:00
|
|
|
return;
|
2015-11-17 12:08:01 +00:00
|
|
|
}
|
2014-04-19 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:08:01 +00:00
|
|
|
match->compare[match->num].compare = compare;
|
2019-02-07 23:27:57 +00:00
|
|
|
match->compare[match->num].compare_typed = compare_typed;
|
2015-11-17 12:08:01 +00:00
|
|
|
match->compare[match->num].release = release;
|
2014-04-19 10:18:01 +00:00
|
|
|
match->compare[match->num].data = compare_data;
|
2014-04-18 22:05:53 +00:00
|
|
|
match->compare[match->num].component = NULL;
|
2014-04-19 10:18:01 +00:00
|
|
|
match->num++;
|
|
|
|
}
|
2019-02-07 23:27:57 +00:00
|
|
|
|
|
|
|
/**
|
2019-02-18 16:36:48 +00:00
|
|
|
* component_match_add_release - add a component match entry with release callback
|
2022-01-27 20:01:07 +00:00
|
|
|
* @parent: parent device of the aggregate driver
|
2019-02-07 23:27:57 +00:00
|
|
|
* @matchptr: pointer to the list of component matches
|
|
|
|
* @release: release function for @compare_data
|
|
|
|
* @compare: compare function to match against all components
|
|
|
|
* @compare_data: opaque pointer passed to the @compare function
|
|
|
|
*
|
2022-01-27 20:01:07 +00:00
|
|
|
* Adds a new component match to the list stored in @matchptr, which the
|
2019-02-07 23:27:57 +00:00
|
|
|
* aggregate driver needs to function. The list of component matches pointed to
|
|
|
|
* by @matchptr must be initialized to NULL before adding the first match. This
|
|
|
|
* only matches against components added with component_add().
|
|
|
|
*
|
|
|
|
* The allocated match list in @matchptr is automatically released using devm
|
|
|
|
* actions, where upon @release will be called to free any references held by
|
|
|
|
* @compare_data, e.g. when @compare_data is a &device_node that must be
|
|
|
|
* released with of_node_put().
|
|
|
|
*
|
|
|
|
* See also component_match_add() and component_match_add_typed().
|
|
|
|
*/
|
2022-01-27 20:01:07 +00:00
|
|
|
void component_match_add_release(struct device *parent,
|
2019-02-07 23:27:57 +00:00
|
|
|
struct component_match **matchptr,
|
|
|
|
void (*release)(struct device *, void *),
|
|
|
|
int (*compare)(struct device *, void *), void *compare_data)
|
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
__component_match_add(parent, matchptr, release, compare, NULL,
|
2019-02-07 23:27:57 +00:00
|
|
|
compare_data);
|
|
|
|
}
|
2015-11-17 12:08:01 +00:00
|
|
|
EXPORT_SYMBOL(component_match_add_release);
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2019-02-07 23:27:57 +00:00
|
|
|
/**
|
2019-02-18 16:36:48 +00:00
|
|
|
* component_match_add_typed - add a component match entry for a typed component
|
2022-01-27 20:01:07 +00:00
|
|
|
* @parent: parent device of the aggregate driver
|
2019-02-07 23:27:57 +00:00
|
|
|
* @matchptr: pointer to the list of component matches
|
|
|
|
* @compare_typed: compare function to match against all typed components
|
|
|
|
* @compare_data: opaque pointer passed to the @compare function
|
|
|
|
*
|
2022-01-27 20:01:07 +00:00
|
|
|
* Adds a new component match to the list stored in @matchptr, which the
|
2019-02-07 23:27:57 +00:00
|
|
|
* aggregate driver needs to function. The list of component matches pointed to
|
|
|
|
* by @matchptr must be initialized to NULL before adding the first match. This
|
|
|
|
* only matches against components added with component_add_typed().
|
|
|
|
*
|
|
|
|
* The allocated match list in @matchptr is automatically released using devm
|
|
|
|
* actions.
|
|
|
|
*
|
|
|
|
* See also component_match_add_release() and component_match_add_typed().
|
|
|
|
*/
|
2022-01-27 20:01:07 +00:00
|
|
|
void component_match_add_typed(struct device *parent,
|
2019-02-07 23:27:57 +00:00
|
|
|
struct component_match **matchptr,
|
|
|
|
int (*compare_typed)(struct device *, int, void *), void *compare_data)
|
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
__component_match_add(parent, matchptr, NULL, NULL, compare_typed,
|
2019-02-07 23:27:57 +00:00
|
|
|
compare_data);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(component_match_add_typed);
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static void free_aggregate_device(struct aggregate_device *adev)
|
2016-01-26 17:59:13 +00:00
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct component_match *match = adev->match;
|
2016-01-26 17:59:13 +00:00
|
|
|
int i;
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
component_debugfs_del(adev);
|
|
|
|
list_del(&adev->node);
|
2016-01-26 17:59:13 +00:00
|
|
|
|
|
|
|
if (match) {
|
|
|
|
for (i = 0; i < match->num; i++) {
|
|
|
|
struct component *c = match->compare[i].component;
|
|
|
|
if (c)
|
2022-01-27 20:01:07 +00:00
|
|
|
c->adev = NULL;
|
2016-01-26 17:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
kfree(adev);
|
2016-01-26 17:59:13 +00:00
|
|
|
}
|
|
|
|
|
2019-02-07 23:27:56 +00:00
|
|
|
/**
|
|
|
|
* component_master_add_with_match - register an aggregate driver
|
2021-05-20 00:25:14 +00:00
|
|
|
* @parent: parent device of the aggregate driver
|
2019-02-07 23:27:56 +00:00
|
|
|
* @ops: callbacks for the aggregate driver
|
|
|
|
* @match: component match list for the aggregate driver
|
|
|
|
*
|
|
|
|
* Registers a new aggregate driver consisting of the components added to @match
|
|
|
|
* by calling one of the component_match_add() functions. Once all components in
|
|
|
|
* @match are available, it will be assembled by calling
|
|
|
|
* &component_master_ops.bind from @ops. Must be unregistered by calling
|
|
|
|
* component_master_del().
|
|
|
|
*/
|
2021-05-20 00:25:14 +00:00
|
|
|
int component_master_add_with_match(struct device *parent,
|
2014-04-19 10:18:01 +00:00
|
|
|
const struct component_master_ops *ops,
|
|
|
|
struct component_match *match)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *adev;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
int ret;
|
|
|
|
|
2014-04-18 21:10:32 +00:00
|
|
|
/* Reallocate the match array for its true size */
|
2021-05-20 00:25:13 +00:00
|
|
|
ret = component_match_realloc(match, match->num);
|
2015-11-17 12:08:01 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2014-04-19 10:18:01 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
|
|
|
|
if (!adev)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
adev->parent = parent;
|
|
|
|
adev->ops = ops;
|
|
|
|
adev->match = match;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
component_debugfs_add(adev);
|
|
|
|
/* Add to the list of available aggregate devices. */
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
mutex_lock(&component_mutex);
|
2022-01-27 20:01:07 +00:00
|
|
|
list_add(&adev->node, &aggregate_devices);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
ret = try_to_bring_up_aggregate_device(adev, NULL);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2016-01-26 17:59:13 +00:00
|
|
|
if (ret < 0)
|
2022-01-27 20:01:07 +00:00
|
|
|
free_aggregate_device(adev);
|
2016-01-26 17:59:13 +00:00
|
|
|
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
mutex_unlock(&component_mutex);
|
|
|
|
|
|
|
|
return ret < 0 ? ret : 0;
|
|
|
|
}
|
2014-04-19 10:18:01 +00:00
|
|
|
EXPORT_SYMBOL_GPL(component_master_add_with_match);
|
|
|
|
|
2019-02-07 23:27:56 +00:00
|
|
|
/**
|
|
|
|
* component_master_del - unregister an aggregate driver
|
2021-05-20 00:25:14 +00:00
|
|
|
* @parent: parent device of the aggregate driver
|
2019-02-07 23:27:56 +00:00
|
|
|
* @ops: callbacks for the aggregate driver
|
|
|
|
*
|
|
|
|
* Unregisters an aggregate driver registered with
|
|
|
|
* component_master_add_with_match(). If necessary the aggregate driver is first
|
|
|
|
* disassembled by calling &component_master_ops.unbind from @ops.
|
|
|
|
*/
|
2021-05-20 00:25:14 +00:00
|
|
|
void component_master_del(struct device *parent,
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
const struct component_master_ops *ops)
|
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *adev;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
|
|
|
mutex_lock(&component_mutex);
|
2022-01-27 20:01:07 +00:00
|
|
|
adev = __aggregate_find(parent, ops);
|
|
|
|
if (adev) {
|
|
|
|
take_down_aggregate_device(adev);
|
|
|
|
free_aggregate_device(adev);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
mutex_unlock(&component_mutex);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(component_master_del);
|
|
|
|
|
|
|
|
static void component_unbind(struct component *component,
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *adev, void *data)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
|
|
|
WARN_ON(!component->bound);
|
|
|
|
|
2020-02-27 10:45:47 +00:00
|
|
|
if (component->ops && component->ops->unbind)
|
2022-01-27 20:01:07 +00:00
|
|
|
component->ops->unbind(component->dev, adev->parent, data);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
component->bound = false;
|
|
|
|
|
|
|
|
/* Release all resources claimed in the binding of this component */
|
|
|
|
devres_release_group(component->dev, component);
|
|
|
|
}
|
|
|
|
|
2019-02-07 23:27:56 +00:00
|
|
|
/**
|
2019-02-18 16:36:48 +00:00
|
|
|
* component_unbind_all - unbind all components of an aggregate driver
|
2021-05-20 00:25:14 +00:00
|
|
|
* @parent: parent device of the aggregate driver
|
2019-02-07 23:27:56 +00:00
|
|
|
* @data: opaque pointer, passed to all components
|
|
|
|
*
|
2021-05-20 00:25:14 +00:00
|
|
|
* Unbinds all components of the aggregate device by passing @data to their
|
2019-02-07 23:27:56 +00:00
|
|
|
* &component_ops.unbind functions. Should be called from
|
|
|
|
* &component_master_ops.unbind.
|
|
|
|
*/
|
2021-05-20 00:25:14 +00:00
|
|
|
void component_unbind_all(struct device *parent, void *data)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *adev;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
struct component *c;
|
2014-04-18 22:05:53 +00:00
|
|
|
size_t i;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
|
|
|
WARN_ON(!mutex_is_locked(&component_mutex));
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
adev = __aggregate_find(parent, NULL);
|
|
|
|
if (!adev)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
return;
|
|
|
|
|
2014-04-18 22:05:53 +00:00
|
|
|
/* Unbind components in reverse order */
|
2022-01-27 20:01:07 +00:00
|
|
|
for (i = adev->match->num; i--; )
|
|
|
|
if (!adev->match->compare[i].duplicate) {
|
|
|
|
c = adev->match->compare[i].component;
|
|
|
|
component_unbind(c, adev, data);
|
2014-04-18 22:05:53 +00:00
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(component_unbind_all);
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
static int component_bind(struct component *component, struct aggregate_device *adev,
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Each component initialises inside its own devres group.
|
|
|
|
* This allows us to roll-back a failed component without
|
|
|
|
* affecting anything else.
|
|
|
|
*/
|
2022-01-27 20:01:07 +00:00
|
|
|
if (!devres_open_group(adev->parent, NULL, GFP_KERNEL))
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Also open a group for the device itself: this allows us
|
|
|
|
* to release the resources claimed against the sub-device
|
|
|
|
* at the appropriate moment.
|
|
|
|
*/
|
|
|
|
if (!devres_open_group(component->dev, component, GFP_KERNEL)) {
|
2022-01-27 20:01:07 +00:00
|
|
|
devres_release_group(adev->parent, NULL);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
dev_dbg(adev->parent, "binding %s (ops %ps)\n",
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
dev_name(component->dev), component->ops);
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
ret = component->ops->bind(component->dev, adev->parent, data);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
if (!ret) {
|
|
|
|
component->bound = true;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close the component device's group so that resources
|
|
|
|
* allocated in the binding are encapsulated for removal
|
|
|
|
* at unbind. Remove the group on the DRM device as we
|
|
|
|
* can clean those resources up independently.
|
|
|
|
*/
|
|
|
|
devres_close_group(component->dev, NULL);
|
2022-01-27 20:01:07 +00:00
|
|
|
devres_remove_group(adev->parent, NULL);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
dev_info(adev->parent, "bound %s (ops %ps)\n",
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
dev_name(component->dev), component->ops);
|
|
|
|
} else {
|
|
|
|
devres_release_group(component->dev, NULL);
|
2022-01-27 20:01:07 +00:00
|
|
|
devres_release_group(adev->parent, NULL);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
2020-04-11 19:02:41 +00:00
|
|
|
if (ret != -EPROBE_DEFER)
|
2022-01-27 20:01:07 +00:00
|
|
|
dev_err(adev->parent, "failed to bind %s (ops %ps): %d\n",
|
2020-04-11 19:02:41 +00:00
|
|
|
dev_name(component->dev), component->ops, ret);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-02-07 23:27:56 +00:00
|
|
|
/**
|
2019-02-18 16:36:48 +00:00
|
|
|
* component_bind_all - bind all components of an aggregate driver
|
2021-05-20 00:25:14 +00:00
|
|
|
* @parent: parent device of the aggregate driver
|
2019-02-07 23:27:56 +00:00
|
|
|
* @data: opaque pointer, passed to all components
|
|
|
|
*
|
2019-02-18 16:36:48 +00:00
|
|
|
* Binds all components of the aggregate @dev by passing @data to their
|
2019-02-07 23:27:56 +00:00
|
|
|
* &component_ops.bind functions. Should be called from
|
|
|
|
* &component_master_ops.bind.
|
|
|
|
*/
|
2021-05-20 00:25:14 +00:00
|
|
|
int component_bind_all(struct device *parent, void *data)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
2022-01-27 20:01:07 +00:00
|
|
|
struct aggregate_device *adev;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
struct component *c;
|
2014-04-18 22:05:53 +00:00
|
|
|
size_t i;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
WARN_ON(!mutex_is_locked(&component_mutex));
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
adev = __aggregate_find(parent, NULL);
|
|
|
|
if (!adev)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-04-18 22:05:53 +00:00
|
|
|
/* Bind components in match order */
|
2022-01-27 20:01:07 +00:00
|
|
|
for (i = 0; i < adev->match->num; i++)
|
|
|
|
if (!adev->match->compare[i].duplicate) {
|
|
|
|
c = adev->match->compare[i].component;
|
|
|
|
ret = component_bind(c, adev, data);
|
2014-04-18 22:05:53 +00:00
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
|
|
|
if (ret != 0) {
|
2018-08-28 04:15:39 +00:00
|
|
|
for (; i > 0; i--)
|
2022-01-27 20:01:07 +00:00
|
|
|
if (!adev->match->compare[i - 1].duplicate) {
|
|
|
|
c = adev->match->compare[i - 1].component;
|
|
|
|
component_unbind(c, adev, data);
|
2014-04-18 22:05:53 +00:00
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(component_bind_all);
|
|
|
|
|
2019-02-07 23:27:57 +00:00
|
|
|
static int __component_add(struct device *dev, const struct component_ops *ops,
|
|
|
|
int subcomponent)
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
{
|
|
|
|
struct component *component;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
component = kzalloc(sizeof(*component), GFP_KERNEL);
|
|
|
|
if (!component)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
component->ops = ops;
|
|
|
|
component->dev = dev;
|
2019-02-07 23:27:57 +00:00
|
|
|
component->subcomponent = subcomponent;
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
|
|
|
dev_dbg(dev, "adding component (ops %ps)\n", ops);
|
|
|
|
|
|
|
|
mutex_lock(&component_mutex);
|
|
|
|
list_add_tail(&component->node, &component_list);
|
|
|
|
|
|
|
|
ret = try_to_bring_up_masters(component);
|
|
|
|
if (ret < 0) {
|
2022-01-27 20:01:07 +00:00
|
|
|
if (component->adev)
|
|
|
|
remove_component(component->adev, component);
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
list_del(&component->node);
|
|
|
|
|
|
|
|
kfree(component);
|
|
|
|
}
|
|
|
|
mutex_unlock(&component_mutex);
|
|
|
|
|
|
|
|
return ret < 0 ? ret : 0;
|
|
|
|
}
|
2019-02-07 23:27:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* component_add_typed - register a component
|
|
|
|
* @dev: component device
|
|
|
|
* @ops: component callbacks
|
|
|
|
* @subcomponent: nonzero identifier for subcomponents
|
|
|
|
*
|
|
|
|
* Register a new component for @dev. Functions in @ops will be call when the
|
|
|
|
* aggregate driver is ready to bind the overall driver by calling
|
|
|
|
* component_bind_all(). See also &struct component_ops.
|
|
|
|
*
|
|
|
|
* @subcomponent must be nonzero and is used to differentiate between multiple
|
|
|
|
* components registerd on the same device @dev. These components are match
|
|
|
|
* using component_match_add_typed().
|
|
|
|
*
|
|
|
|
* The component needs to be unregistered at driver unload/disconnect by
|
|
|
|
* calling component_del().
|
|
|
|
*
|
|
|
|
* See also component_add().
|
|
|
|
*/
|
|
|
|
int component_add_typed(struct device *dev, const struct component_ops *ops,
|
|
|
|
int subcomponent)
|
|
|
|
{
|
|
|
|
if (WARN_ON(subcomponent == 0))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return __component_add(dev, ops, subcomponent);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(component_add_typed);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* component_add - register a component
|
|
|
|
* @dev: component device
|
|
|
|
* @ops: component callbacks
|
|
|
|
*
|
|
|
|
* Register a new component for @dev. Functions in @ops will be called when the
|
|
|
|
* aggregate driver is ready to bind the overall driver by calling
|
|
|
|
* component_bind_all(). See also &struct component_ops.
|
|
|
|
*
|
|
|
|
* The component needs to be unregistered at driver unload/disconnect by
|
|
|
|
* calling component_del().
|
|
|
|
*
|
|
|
|
* See also component_add_typed() for a variant that allows multipled different
|
|
|
|
* components on the same device.
|
|
|
|
*/
|
|
|
|
int component_add(struct device *dev, const struct component_ops *ops)
|
|
|
|
{
|
|
|
|
return __component_add(dev, ops, 0);
|
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
EXPORT_SYMBOL_GPL(component_add);
|
|
|
|
|
2019-02-07 23:27:56 +00:00
|
|
|
/**
|
|
|
|
* component_del - unregister a component
|
|
|
|
* @dev: component device
|
|
|
|
* @ops: component callbacks
|
|
|
|
*
|
|
|
|
* Unregister a component added with component_add(). If the component is bound
|
|
|
|
* into an aggregate driver, this will force the entire aggregate driver, including
|
|
|
|
* all its components, to be unbound.
|
|
|
|
*/
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
void component_del(struct device *dev, const struct component_ops *ops)
|
|
|
|
{
|
|
|
|
struct component *c, *component = NULL;
|
|
|
|
|
|
|
|
mutex_lock(&component_mutex);
|
|
|
|
list_for_each_entry(c, &component_list, node)
|
|
|
|
if (c->dev == dev && c->ops == ops) {
|
|
|
|
list_del(&c->node);
|
|
|
|
component = c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-01-27 20:01:07 +00:00
|
|
|
if (component && component->adev) {
|
|
|
|
take_down_aggregate_device(component->adev);
|
|
|
|
remove_component(component->adev, component);
|
2014-04-18 22:05:53 +00:00
|
|
|
}
|
drivers/base: provide an infrastructure for componentised subsystems
Subsystems such as ALSA, DRM and others require a single card-level
device structure to represent a subsystem. However, firmware tends to
describe the individual devices and the connections between them.
Therefore, we need a way to gather up the individual component devices
together, and indicate when we have all the component devices.
We do this in DT by providing a "superdevice" node which specifies
the components, eg:
imx-drm {
compatible = "fsl,drm";
crtcs = <&ipu1>;
connectors = <&hdmi>;
};
The superdevice is declared into the component support, along with the
subcomponents. The superdevice receives callbacks to locate the
subcomponents, and identify when all components are present. At this
point, we bind the superdevice, which causes the appropriate subsystem
to be initialised in the conventional way.
When any of the components or superdevice are removed from the system,
we unbind the superdevice, thereby taking the subsystem down.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-10 23:23:37 +00:00
|
|
|
|
|
|
|
mutex_unlock(&component_mutex);
|
|
|
|
|
|
|
|
WARN_ON(!component);
|
|
|
|
kfree(component);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(component_del);
|