Commit 47433b63 authored by Laurentiu Tudor's avatar Laurentiu Tudor Committed by Greg Kroah-Hartman

staging: fsl-mc: add support for device type

The MC bus has different types of devices and this is supported by
device model. This patch adds initial support for device types
(defines them, adds helpers and sets the device type).
Signed-off-by: default avatarLaurentiu Tudor <laurentiu.tudor@nxp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a385dd7b
...@@ -156,6 +156,68 @@ struct bus_type fsl_mc_bus_type = { ...@@ -156,6 +156,68 @@ struct bus_type fsl_mc_bus_type = {
}; };
EXPORT_SYMBOL_GPL(fsl_mc_bus_type); EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
struct device_type fsl_mc_bus_dprc_type = {
.name = "fsl_mc_bus_dprc"
};
struct device_type fsl_mc_bus_dpni_type = {
.name = "fsl_mc_bus_dpni"
};
struct device_type fsl_mc_bus_dpio_type = {
.name = "fsl_mc_bus_dpio"
};
struct device_type fsl_mc_bus_dpsw_type = {
.name = "fsl_mc_bus_dpsw"
};
struct device_type fsl_mc_bus_dpbp_type = {
.name = "fsl_mc_bus_dpbp"
};
struct device_type fsl_mc_bus_dpcon_type = {
.name = "fsl_mc_bus_dpcon"
};
struct device_type fsl_mc_bus_dpmcp_type = {
.name = "fsl_mc_bus_dpmcp"
};
struct device_type fsl_mc_bus_dpmac_type = {
.name = "fsl_mc_bus_dpmac"
};
struct device_type fsl_mc_bus_dprtc_type = {
.name = "fsl_mc_bus_dprtc"
};
static struct device_type *fsl_mc_get_device_type(const char *type)
{
static const struct {
struct device_type *dev_type;
const char *type;
} dev_types[] = {
{ &fsl_mc_bus_dprc_type, "dprc" },
{ &fsl_mc_bus_dpni_type, "dpni" },
{ &fsl_mc_bus_dpio_type, "dpio" },
{ &fsl_mc_bus_dpsw_type, "dpsw" },
{ &fsl_mc_bus_dpbp_type, "dpbp" },
{ &fsl_mc_bus_dpcon_type, "dpcon" },
{ &fsl_mc_bus_dpmcp_type, "dpmcp" },
{ &fsl_mc_bus_dpmac_type, "dpmac" },
{ &fsl_mc_bus_dprtc_type, "dprtc" },
{ NULL, NULL }
};
int i;
for (i = 0; dev_types[i].dev_type; i++)
if (!strcmp(dev_types[i].type, type))
return dev_types[i].dev_type;
return NULL;
}
static int fsl_mc_driver_probe(struct device *dev) static int fsl_mc_driver_probe(struct device *dev)
{ {
struct fsl_mc_driver *mc_drv; struct fsl_mc_driver *mc_drv;
...@@ -506,6 +568,11 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc, ...@@ -506,6 +568,11 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
mc_dev->dev.parent = parent_dev; mc_dev->dev.parent = parent_dev;
mc_dev->dev.bus = &fsl_mc_bus_type; mc_dev->dev.bus = &fsl_mc_bus_type;
mc_dev->dev.release = fsl_mc_device_release; mc_dev->dev.release = fsl_mc_device_release;
mc_dev->dev.type = fsl_mc_get_device_type(obj_desc->type);
if (!mc_dev->dev.type) {
dev_err(parent_dev, "unknown device type %s\n", obj_desc->type);
goto error_cleanup_dev;
}
dev_set_name(&mc_dev->dev, "%s.%d", obj_desc->type, obj_desc->id); dev_set_name(&mc_dev->dev, "%s.%d", obj_desc->type, obj_desc->id);
if (strcmp(obj_desc->type, "dprc") == 0) { if (strcmp(obj_desc->type, "dprc") == 0) {
......
...@@ -398,4 +398,59 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev); ...@@ -398,4 +398,59 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
extern struct bus_type fsl_mc_bus_type; extern struct bus_type fsl_mc_bus_type;
extern struct device_type fsl_mc_bus_dprc_type;
extern struct device_type fsl_mc_bus_dpni_type;
extern struct device_type fsl_mc_bus_dpio_type;
extern struct device_type fsl_mc_bus_dpsw_type;
extern struct device_type fsl_mc_bus_dpbp_type;
extern struct device_type fsl_mc_bus_dpcon_type;
extern struct device_type fsl_mc_bus_dpmcp_type;
extern struct device_type fsl_mc_bus_dpmac_type;
extern struct device_type fsl_mc_bus_dprtc_type;
static inline bool is_fsl_mc_bus_dprc(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dprc_type;
}
static inline bool is_fsl_mc_bus_dpni(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dpni_type;
}
static inline bool is_fsl_mc_bus_dpio(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dpio_type;
}
static inline bool is_fsl_mc_bus_dpsw(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dpsw_type;
}
static inline bool is_fsl_mc_bus_dpbp(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dpbp_type;
}
static inline bool is_fsl_mc_bus_dpcon(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dpcon_type;
}
static inline bool is_fsl_mc_bus_dpmcp(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dpmcp_type;
}
static inline bool is_fsl_mc_bus_dpmac(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dpmac_type;
}
static inline bool is_fsl_mc_bus_dprtc(const struct fsl_mc_device *mc_dev)
{
return mc_dev->dev.type == &fsl_mc_bus_dprtc_type;
}
#endif /* _FSL_MC_H_ */ #endif /* _FSL_MC_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment