Commit 5f031b47 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Tomi Valkeinen

drm/omap: dss: hdmi5: Move initialization code from bind to probe

There's no reason to delay initialization of most of the driver (such as
mapping memory I/O or enabling runtime PM) to the component bind
handler. Perform as much of the initialization as possible at probe
time, initializing at bind time only the parts that depends on the DSS.
The cleanup code is moved from unbind to remove in a similar way.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 5fc15d98
...@@ -544,53 +544,10 @@ static const struct omap_dss_device_ops hdmi_ops = { ...@@ -544,53 +544,10 @@ static const struct omap_dss_device_ops hdmi_ops = {
}, },
}; };
static void hdmi_init_output(struct omap_hdmi *hdmi) /* -----------------------------------------------------------------------------
{ * Audio Callbacks
struct omap_dss_device *out = &hdmi->output; */
out->dev = &hdmi->pdev->dev;
out->id = OMAP_DSS_OUTPUT_HDMI;
out->output_type = OMAP_DISPLAY_TYPE_HDMI;
out->name = "hdmi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
out->ops = &hdmi_ops;
out->owner = THIS_MODULE;
out->of_ports = BIT(0);
omapdss_device_register(out);
}
static void hdmi_uninit_output(struct omap_hdmi *hdmi)
{
struct omap_dss_device *out = &hdmi->output;
omapdss_device_unregister(out);
}
static int hdmi_probe_of(struct omap_hdmi *hdmi)
{
struct platform_device *pdev = hdmi->pdev;
struct device_node *node = pdev->dev.of_node;
struct device_node *ep;
int r;
ep = of_graph_get_endpoint_by_regs(node, 0, 0);
if (!ep)
return 0;
r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy);
if (r)
goto err;
of_node_put(ep);
return 0;
err:
of_node_put(ep);
return r;
}
/* Audio callbacks */
static int hdmi_audio_startup(struct device *dev, static int hdmi_audio_startup(struct device *dev,
void (*abort_cb)(struct device *dev)) void (*abort_cb)(struct device *dev))
{ {
...@@ -711,27 +668,116 @@ static int hdmi_audio_register(struct omap_hdmi *hdmi) ...@@ -711,27 +668,116 @@ static int hdmi_audio_register(struct omap_hdmi *hdmi)
return 0; return 0;
} }
/* HDMI HW IP initialisation */ /* -----------------------------------------------------------------------------
* Component Bind & Unbind
*/
static int hdmi5_bind(struct device *dev, struct device *master, void *data) static int hdmi5_bind(struct device *dev, struct device *master, void *data)
{ {
struct platform_device *pdev = to_platform_device(dev);
struct dss_device *dss = dss_get_device(master); struct dss_device *dss = dss_get_device(master);
struct omap_hdmi *hdmi; struct omap_hdmi *hdmi = dev_get_drvdata(dev);
int r; int r;
hdmi->dss = dss;
r = hdmi_pll_init(dss, hdmi->pdev, &hdmi->pll, &hdmi->wp);
if (r)
return r;
r = hdmi_audio_register(hdmi);
if (r) {
DSSERR("Registering HDMI audio failed %d\n", r);
goto err_pll_uninit;
}
hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
hdmi);
return 0;
err_pll_uninit:
hdmi_pll_uninit(&hdmi->pll);
return r;
}
static void hdmi5_unbind(struct device *dev, struct device *master, void *data)
{
struct omap_hdmi *hdmi = dev_get_drvdata(dev);
dss_debugfs_remove_file(hdmi->debugfs);
if (hdmi->audio_pdev)
platform_device_unregister(hdmi->audio_pdev);
hdmi_pll_uninit(&hdmi->pll);
}
static const struct component_ops hdmi5_component_ops = {
.bind = hdmi5_bind,
.unbind = hdmi5_unbind,
};
/* -----------------------------------------------------------------------------
* Probe & Remove, Suspend & Resume
*/
static void hdmi5_init_output(struct omap_hdmi *hdmi)
{
struct omap_dss_device *out = &hdmi->output;
out->dev = &hdmi->pdev->dev;
out->id = OMAP_DSS_OUTPUT_HDMI;
out->output_type = OMAP_DISPLAY_TYPE_HDMI;
out->name = "hdmi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
out->ops = &hdmi_ops;
out->owner = THIS_MODULE;
out->of_ports = BIT(0);
omapdss_device_register(out);
}
static void hdmi5_uninit_output(struct omap_hdmi *hdmi)
{
struct omap_dss_device *out = &hdmi->output;
omapdss_device_unregister(out);
}
static int hdmi5_probe_of(struct omap_hdmi *hdmi)
{
struct platform_device *pdev = hdmi->pdev;
struct device_node *node = pdev->dev.of_node;
struct device_node *ep;
int r;
ep = of_graph_get_endpoint_by_regs(node, 0, 0);
if (!ep)
return 0;
r = hdmi_parse_lanes_of(pdev, ep, &hdmi->phy);
of_node_put(ep);
return r;
}
static int hdmi5_probe(struct platform_device *pdev)
{
struct omap_hdmi *hdmi;
int irq; int irq;
int r;
hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
if (!hdmi) if (!hdmi)
return -ENOMEM; return -ENOMEM;
hdmi->pdev = pdev; hdmi->pdev = pdev;
hdmi->dss = dss;
dev_set_drvdata(&pdev->dev, hdmi); dev_set_drvdata(&pdev->dev, hdmi);
mutex_init(&hdmi->lock); mutex_init(&hdmi->lock);
spin_lock_init(&hdmi->audio_playing_lock); spin_lock_init(&hdmi->audio_playing_lock);
r = hdmi_probe_of(hdmi); r = hdmi5_probe_of(hdmi);
if (r) if (r)
goto err_free; goto err_free;
...@@ -739,23 +785,19 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data) ...@@ -739,23 +785,19 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
if (r) if (r)
goto err_free; goto err_free;
r = hdmi_pll_init(dss, pdev, &hdmi->pll, &hdmi->wp);
if (r)
goto err_free;
r = hdmi_phy_init(pdev, &hdmi->phy, 5); r = hdmi_phy_init(pdev, &hdmi->phy, 5);
if (r) if (r)
goto err_pll; goto err_free;
r = hdmi5_core_init(pdev, &hdmi->core); r = hdmi5_core_init(pdev, &hdmi->core);
if (r) if (r)
goto err_pll; goto err_free;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
DSSERR("platform_get_irq failed\n"); DSSERR("platform_get_irq failed\n");
r = -ENODEV; r = -ENODEV;
goto err_pll; goto err_free;
} }
r = devm_request_threaded_irq(&pdev->dev, irq, r = devm_request_threaded_irq(&pdev->dev, irq,
...@@ -763,65 +805,38 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data) ...@@ -763,65 +805,38 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
IRQF_ONESHOT, "OMAP HDMI", hdmi); IRQF_ONESHOT, "OMAP HDMI", hdmi);
if (r) { if (r) {
DSSERR("HDMI IRQ request failed\n"); DSSERR("HDMI IRQ request failed\n");
goto err_pll; goto err_free;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
hdmi_init_output(hdmi); hdmi5_init_output(hdmi);
r = hdmi_audio_register(hdmi); r = component_add(&pdev->dev, &hdmi5_component_ops);
if (r) { if (r)
DSSERR("Registering HDMI audio failed %d\n", r);
goto err_uninit_output; goto err_uninit_output;
}
hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
hdmi);
return 0; return 0;
err_uninit_output: err_uninit_output:
hdmi_uninit_output(hdmi); hdmi5_uninit_output(hdmi);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_pll:
hdmi_pll_uninit(&hdmi->pll);
err_free: err_free:
kfree(hdmi); kfree(hdmi);
return r; return r;
} }
static void hdmi5_unbind(struct device *dev, struct device *master, void *data) static int hdmi5_remove(struct platform_device *pdev)
{ {
struct omap_hdmi *hdmi = dev_get_drvdata(dev); struct omap_hdmi *hdmi = platform_get_drvdata(pdev);
dss_debugfs_remove_file(hdmi->debugfs);
if (hdmi->audio_pdev) component_del(&pdev->dev, &hdmi5_component_ops);
platform_device_unregister(hdmi->audio_pdev);
hdmi_uninit_output(hdmi);
hdmi_pll_uninit(&hdmi->pll); hdmi5_uninit_output(hdmi);
pm_runtime_disable(dev); pm_runtime_disable(&pdev->dev);
kfree(hdmi); kfree(hdmi);
}
static const struct component_ops hdmi5_component_ops = {
.bind = hdmi5_bind,
.unbind = hdmi5_unbind,
};
static int hdmi5_probe(struct platform_device *pdev)
{
return component_add(&pdev->dev, &hdmi5_component_ops);
}
static int hdmi5_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &hdmi5_component_ops);
return 0; return 0;
} }
......
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