From: Luis Oliveira <Luis.Oliveira@synopsys.com>
To: mchehab@kernel.org, davem@davemloft.net,
gregkh@linuxfoundation.org, Jonathan.Cameron@huawei.com,
robh@kernel.org, nicolas.ferre@microchip.com,
paulmck@linux.ibm.com, mark.rutland@arm.com, kishon@ti.com,
devicetree@vger.kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Joao.Pinto@synopsys.com, Luis Oliveira <Luis.Oliveira@synopsys.com>
Subject: [v4 6/6] media: platform: dwc: Add platform data support to D-Phy
Date: Tue, 11 Jun 2019 21:20:55 +0200 [thread overview]
Message-ID: <1560280855-18085-7-git-send-email-luis.oliveira@synopsys.com> (raw)
In-Reply-To: <1560280855-18085-1-git-send-email-luis.oliveira@synopsys.com>
This patch allows the configuration via platform data. This allows
the driver loading not devicetree dependent.
Signed-off-by: Luis Oliveira <luis.oliveira@synopsys.com>
---
Changelog
v3-v4
- This patch was not in the v3. This enables pdata to configure the driver
drivers/media/platform/dwc/dw-dphy-plat.c | 87 ++++++++++++++++++++++---------
drivers/media/platform/dwc/dw-dphy-rx.c | 19 ++++---
2 files changed, 72 insertions(+), 34 deletions(-)
diff --git a/drivers/media/platform/dwc/dw-dphy-plat.c b/drivers/media/platform/dwc/dw-dphy-plat.c
index 1f5113d..34d9caf 100644
--- a/drivers/media/platform/dwc/dw-dphy-plat.c
+++ b/drivers/media/platform/dwc/dw-dphy-plat.c
@@ -23,38 +23,50 @@ static struct phy_ops dw_dphy_ops = {
static struct phy_provider *phy_provider;
+#if IS_ENABLED(CONFIG_DWC_MIPI_TC_DPHY_GEN3)
static u8 get_config_8l(struct device *dev, struct dw_dphy_rx *dphy)
{
- dphy->config_8l = of_get_gpio(dev->of_node, 0);
- if (!gpio_is_valid(dphy->config_8l)) {
- dev_warn(dev,
- "failed to parse 8l config, default is 0\n");
- dphy->config_8l = 0;
- }
+ if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+ dphy->config_8l = of_get_gpio(dev->of_node, 0);
+ if (!gpio_is_valid(dphy->config_8l)) {
+ dev_warn(dev,
+ "failed to parse 8l config, default is 0\n");
+ dphy->config_8l = 0;
+ }
+ } else {
+ struct dw_phy_pdata *pdata = dev->platform_data;
+ dphy->config_8l = pdata->config_8l;
+ }
return dphy->config_8l;
}
-
+#endif
static int get_resources(struct device *dev, struct dw_dphy_rx *dphy)
{
int ret = 0;
- if (of_property_read_u32(dev->of_node, "snps,dphy-frequency",
- &dphy->dphy_freq)) {
- dev_err(dev, "failed to find dphy frequency\n");
- ret = -EINVAL;
- }
-
- if (of_property_read_u32(dev->of_node, "bus-width",
- &dphy->dphy_te_len)) {
- dev_err(dev, "failed to find dphy te length\n");
- ret = -EINVAL;
- }
+ if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+ if (of_property_read_u32(dev->of_node, "snps,dphy-frequency",
+ &dphy->dphy_freq)) {
+ dev_err(dev, "failed to find dphy frequency\n");
+ ret = -EINVAL;
+ }
+ if (of_property_read_u32(dev->of_node, "bus-width",
+ &dphy->dphy_te_len)) {
+ dev_err(dev, "failed to find dphy te length\n");
+ ret = -EINVAL;
+ }
+ if (of_property_read_u32(dev->of_node, "snps,phy_type",
+ &dphy->phy_type)) {
+ dev_err(dev, "failed to find dphy type\n");
+ ret = -EINVAL;
+ }
+ } else {
+ struct dw_phy_pdata *pdata = dev->platform_data;
- if (of_property_read_u32(dev->of_node, "snps,phy_type",
- &dphy->phy_type)) {
- dev_err(dev, "failed to find dphy te length\n");
- ret = -EINVAL;
+ dphy->dphy_freq = pdata->dphy_frequency;
+ dphy->dphy_te_len = pdata->dphy_te_len;
+ dphy->dphy_gen = pdata->dphy_gen;
}
dev_set_drvdata(dev, dphy);
@@ -63,20 +75,39 @@ static int get_resources(struct device *dev, struct dw_dphy_rx *dphy)
static int phy_register(struct device *dev)
{
- if (dev->of_node) {
+ int ret = 0;
+
+ if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
phy_provider = devm_of_phy_provider_register(dev,
dw_dphy_xlate);
if (IS_ERR(phy_provider)) {
dev_err(dev, "error getting phy provider\n");
- return PTR_ERR(phy_provider);
+ ret = PTR_ERR(phy_provider);
}
+ } else {
+ struct dw_phy_pdata *pdata = dev->platform_data;
+ struct dw_dphy_rx *dphy = dev_get_drvdata(dev);
+
+ ret = phy_create_lookup(dphy->phy,
+ phys[pdata->id].name,
+ csis[pdata->id].name);
+ if (ret)
+ dev_err(dev, "Failed to create dphy lookup\n");
+ else
+ dev_warn(dev,
+ "Created dphy lookup [%s] --> [%s]\n",
+ phys[pdata->id].name, csis[pdata->id].name);
}
- return 0;
+ return ret;
}
static void phy_unregister(struct device *dev)
{
- devm_of_phy_provider_unregister(dev, phy_provider);
+ if (!dev->of_node) {
+ struct dw_dphy_rx *dphy = dev_get_drvdata(dev);
+
+ phy_remove_lookup(dphy->phy, "dw-dphy", "dw-csi");
+ }
}
static int dw_dphy_rx_probe(struct platform_device *pdev)
@@ -166,18 +197,22 @@ static int dw_dphy_rx_remove(struct platform_device *pdev)
return 0;
}
+#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id dw_dphy_rx_of_match[] = {
{ .compatible = "snps,dw-dphy-rx" },
{},
};
MODULE_DEVICE_TABLE(of, dw_dphy_rx_of_match);
+#endif
static struct platform_driver dw_dphy_rx_driver = {
.probe = dw_dphy_rx_probe,
.remove = dw_dphy_rx_remove,
.driver = {
+#if IS_ENABLED(CONFIG_OF)
.of_match_table = of_match_ptr(dw_dphy_rx_of_match),
+#endif
.name = "dw-dphy",
.owner = THIS_MODULE,
}
diff --git a/drivers/media/platform/dwc/dw-dphy-rx.c b/drivers/media/platform/dwc/dw-dphy-rx.c
index f57a814..a69cb3e 100644
--- a/drivers/media/platform/dwc/dw-dphy-rx.c
+++ b/drivers/media/platform/dwc/dw-dphy-rx.c
@@ -71,15 +71,18 @@ u8 dw_dphy_setup_config(struct dw_dphy_rx *dphy)
dev_vdbg(&dphy->phy->dev, "CONFIG 4L\n");
return CTRL_4_LANES;
}
-
- ret = gpio_request(dphy->config_8l, "config");
- if (ret < 0) {
- dev_vdbg(&dphy->phy->dev,
- "could not acquire config gpio (err=%d)\n", ret);
- return ret;
+ if (IS_ENABLED(CONFIG_OF)) {
+ ret = gpio_request(dphy->config_8l, "config");
+ if (ret < 0) {
+ dev_vdbg(&dphy->phy->dev,
+ "could not acquire config (err=%d)\n", ret);
+ return ret;
+ }
+ ret = gpio_get_value(dphy->config_8l);
+ gpio_free(dphy->config_8l);
+ } else {
+ ret = dphy->config_8l;
}
- ret = gpio_get_value(dphy->config_8l);
- gpio_free(dphy->config_8l);
dev_vdbg(&dphy->phy->dev,
"Booting in [%s] mode\n",
--
2.7.4
prev parent reply other threads:[~2019-06-11 19:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-11 19:20 [v4 0/6] platform: dwc: Adding DesignWare MIPI CSI-2 Host and D-PHY Luis Oliveira
2019-06-11 19:20 ` [v4 1/6] dt-bindings: media: Document bindings for DW MIPI CSI-2 Host Luis Oliveira
2019-06-28 14:13 ` Sakari Ailus
2019-07-08 15:21 ` Luis de Oliveira
2019-07-09 18:25 ` Sakari Ailus
2019-07-10 10:20 ` Luis de Oliveira
2019-07-25 20:02 ` Sakari Ailus
2019-07-26 9:50 ` Luis de Oliveira
2019-07-26 11:13 ` Eugen.Hristev
2019-07-09 14:33 ` Eugen.Hristev
2019-07-09 17:08 ` Luis de Oliveira
2019-07-10 6:53 ` Eugen.Hristev
2019-07-10 10:23 ` Luis de Oliveira
2019-06-11 19:20 ` [v4 2/6] media: platform: dwc: Add MIPI CSI-2 controller driver Luis Oliveira
2019-07-10 8:59 ` Eugen.Hristev
2019-07-10 14:21 ` Luis de Oliveira
2019-08-09 14:10 ` Sakari Ailus
2019-08-10 13:09 ` Andy Shevchenko
2019-08-12 9:45 ` Luis de Oliveira
2019-08-12 16:50 ` Andy Shevchenko
2019-06-11 19:20 ` [v4 3/6] media: platform: dwc: Add MIPI CSI-2 platform data Luis Oliveira
2019-08-09 14:39 ` Sakari Ailus
2019-06-11 19:20 ` [v4 4/6] dt-bindings: phy: Document the Synopsys MIPI DPHY Rx bindings Luis Oliveira
2019-07-09 14:20 ` Rob Herring
2019-07-09 16:28 ` Luis de Oliveira
2019-07-10 13:50 ` Rob Herring
2019-08-09 14:42 ` Sakari Ailus
2019-08-09 14:45 ` Sakari Ailus
2019-08-09 14:47 ` Sakari Ailus
2019-06-11 19:20 ` [v4 5/6] media: platform: dwc: Add DW MIPI DPHY Rx driver Luis Oliveira
2019-06-11 19:20 ` Luis Oliveira [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1560280855-18085-7-git-send-email-luis.oliveira@synopsys.com \
--to=luis.oliveira@synopsys.com \
--cc=Joao.Pinto@synopsys.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mchehab@kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=paulmck@linux.ibm.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).