drm/msm: use componentised device support
Subsystems (3)
RFC 1/1 drm/msm: use componentised device support
Hey Russell,
Here is a early/rough pass at conversion to componentized device support. I was hoping you could have a quick look at this to make sure I'm on the right track, since there were no non-DT examples for me to look at ;-)
I still haven't gotten rid of the global hdmi_pdev and a3xx_pdev ptrs. I am not entirely sure how to find those subordinate device pointers again without DT/phandle stuff. I think I might need something like:
struct device *component_find(struct device *dev, const char *name)
{
struct master *master;
struct component *c;
struct device *component = NULL; mutex_lock(&component_mutex);
master = __master_find(dev, NULL);
if (master) {
list_for_each_entry(c, &master->components, master_node) {
if (!strcmp(name, dev_name(c->dev))) {
/* maybe take a ref to the device? */
component = c->dev;
break;
}
}
}
mutex_unlock(&component_mutex);
return component;}
or I could probably hack around it somehow in msm.. I suppose I'm the only one who still has to care for a bit longer about componentized + !DT.
Also still need to remove the extra MODULE_DEVICE_TABLE()'s for DT case and few other little things.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 34 ++++++--- drivers/gpu/drm/msm/hdmi/hdmi.c | 38 +++++++--- drivers/gpu/drm/msm/msm_drv.c | 128 +++++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/msm_drv.h | 1 + 4 files changed, 179 insertions(+), 22 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +25 -9
@@ -556,17 +556,17 @@ fail:# include <mach/kgsl.h> #endif -static int a3xx_probe (struct platform_device *pdev) +static int a3xx_bind (struct device *dev,struct device *master,void *data) {static struct adreno_platform_config config = {};#ifdef CONFIG_OF -struct device_node *child, *node = pdev->dev.of_node; +struct device_node *child, *node = dev->of_node;u32 val;int ret; ret =of_property_read_u32 (node,"qcom,chipid" , &val);if (ret) { -dev_err (&pdev->dev,"could not find chipid: %d\n" , ret); +dev_err (dev,"could not find chipid: %d\n" , ret);return ret; }
@@ -582,7 +582,7 @@ static int a3xx_probe(struct platform_device *pdev)for_each_child_of_node (child, pwrlvl) { ret =of_property_read_u32 (pwrlvl,"qcom,gpu-freq" , &val);if (ret) { -dev_err (&pdev->dev,"could not find gpu-freq: %d\n" , ret); +dev_err (dev,"could not find gpu-freq: %d\n" , ret);return ret; } config.fast_rate =max (config.fast_rate, val);
@@ -592,12 +592,12 @@ static int a3xx_probe(struct platform_device *pdev) }if (!config.fast_rate) { -dev_err (&pdev->dev,"could not find clk rates\n" ); +dev_err (dev,"could not find clk rates\n" );return -ENXIO ; }#else -struct kgsl_device_platform_data *pdata = pdev->dev.platform_data; +struct kgsl_device_platform_data *pdata = dev->platform_data;uint32_t version =socinfo_get_version ();if (cpu_is_apq8064ab ()) { config.fast_rate =450000000 ;
@@ -643,14 +643,30 @@ static int a3xx_probe(struct platform_device *pdev) config.bus_scale_table = pdata->bus_scale_table;# endif #endif - pdev->dev.platform_data = &config; - a3xx_pdev = pdev; + dev->platform_data = &config; + a3xx_pdev =to_platform_device (dev);return 0 ; } -static int a3xx_remove (struct platform_device *pdev) +static void a3xx_unbind (struct device *dev,struct device *master, +void *data) { a3xx_pdev =NULL ; +} + +static const struct component_ops a3xx_ops = { + .bind = a3xx_bind, + .unbind = a3xx_unbind, +}; + +static int a3xx_probe (struct platform_device *pdev) +{ +return component_add (&pdev->dev, &a3xx_ops); +} + +static int a3xx_remove (struct platform_device *pdev) +{ +component_del (&pdev->dev, &a3xx_ops);return 0 ; }
drivers/gpu/drm/msm/hdmi/hdmi.c +27 -11
@@ -255,17 +255,17 @@ fail:#include <linux/of_gpio.h> -static int hdmi_dev_probe (struct platform_device *pdev) +static int hdmi_bind (struct device *dev,struct device *master,void *data) {static struct hdmi_platform_config config = {};#ifdef CONFIG_OF -struct device_node *of_node = pdev->dev.of_node; +struct device_node *of_node = dev->of_node;int get_gpio (const char *name) {int gpio =of_get_named_gpio (of_node, name,0 );if (gpio <0 ) { -dev_err (&pdev->dev,"failed to get gpio: %s (%d)\n" , +dev_err (dev,"failed to get gpio: %s (%d)\n" , name, gpio); gpio =-1 ; }
@@ -342,8 +342,30 @@ static int hdmi_dev_probe(struct platform_device *pdev) config.mux_sel_gpio = -1; }#endif - pdev->dev.platform_data = &config; - hdmi_pdev = pdev; + dev->platform_data = &config; + hdmi_pdev =to_platform_device (dev); +return 0 ; +} + +static void hdmi_unbind (struct device *dev,struct device *master, +void *data) +{ + hdmi_pdev =NULL ; +} + +static const struct component_ops hdmi_ops = { + .bind = hdmi_bind, + .unbind = hdmi_unbind, +}; + +static int hdmi_dev_probe (struct platform_device *pdev) +{ +return component_add (&pdev->dev, &hdmi_ops); +} + +static int hdmi_dev_remove (struct platform_device *pdev) +{ +component_del (&pdev->dev, &hdmi_ops);return 0 ; }
@@ -361,12 +383,6 @@ void hdmi_msm_audio_sample_rate_reset(int rate) }EXPORT_SYMBOL (hdmi_msm_audio_sample_rate_reset); -static int hdmi_dev_remove (struct platform_device *pdev) -{ - hdmi_pdev =NULL ; -return 0 ; -} -static const struct of_device_id dt_match[] = { { .compatible ="qcom,hdmi-tx" }, {}
drivers/gpu/drm/msm/msm_drv.c +126 -2
162 lines not on this page · raw message
drivers/gpu/drm/msm/msm_drv.h +1 -0
@@ -22,6 +22,7 @@#include <linux/clk.h> #include <linux/cpufreq.h> #include <linux/module.h> +#include <linux/component.h> #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/pm_runtime.h>
Signature · 1 line
1.8.5.3