From: yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
To: linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
jean-michel.hautbois-B+Q8N6RmIDZBDgjK7y7TUQ@public.gmane.org,
andrej.skvortzov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
hs-ynQEQJNshbs@public.gmane.org,
Anton Glukhov
<anton.a.glukhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Yegor Yefremov
<yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
Subject: [PATCH v2 3/3] can: ti_hecc: Add DT support for TI HECC module
Date: Wed, 11 Jan 2017 15:05:21 +0100 [thread overview]
Message-ID: <1484143521-4898-4-git-send-email-yegorslists@googlemail.com> (raw)
In-Reply-To: <1484143521-4898-1-git-send-email-yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
From: Anton Glukhov <anton.a.glukhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
These patch set adds device tree support for TI HECC module.
Signed-off-by: Anton Glukhov <anton.a.glukhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Yegor Yefremov <yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
---
Changes v1 -> v2:
- change compatible to "ti,am3505"
- remove CONFIG_OF
- don't set int_line to 0 explicitly
drivers/net/can/ti_hecc.c | 54 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 50 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 680d1ff..fd3d9fc 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -46,6 +46,8 @@
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
@@ -872,19 +874,62 @@ static const struct net_device_ops ti_hecc_netdev_ops = {
.ndo_change_mtu = can_change_mtu,
};
+static const struct of_device_id ti_hecc_dt_ids[] = {
+ {
+ .compatible = "ti,am3505",
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ti_hecc_dt_ids);
+
+static struct ti_hecc_platform_data *hecc_parse_dt(struct device *dev)
+{
+ struct ti_hecc_platform_data *pdata;
+ struct device_node *np = dev->of_node;
+
+ pdata = devm_kzalloc(dev, sizeof(struct ti_hecc_platform_data), GFP_KERNEL);
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ if (of_property_read_u32(np, "ti,scc-ram-offset", &pdata->scc_ram_offset)) {
+ dev_err(dev, "Missing scc-ram-offset property in the DT.\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (of_property_read_u32(np, "ti,hecc-ram-offset", &pdata->hecc_ram_offset)) {
+ dev_err(dev, "Missing hecc-ram-offset property in the DT.\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (of_property_read_u32(np, "ti,mbx-offset", &pdata->mbx_offset)) {
+ dev_err(dev, "Missing mbx-offset property in the DT.\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ of_property_read_u32(dev->of_node, "ti,int-line", &pdata->int_line);
+
+ return pdata;
+}
+
static int ti_hecc_probe(struct platform_device *pdev)
{
struct net_device *ndev = (struct net_device *)0;
struct ti_hecc_priv *priv;
- struct ti_hecc_platform_data *pdata;
+ struct ti_hecc_platform_data *pdata = dev_get_platdata(&pdev->dev);
+ struct device_node *np = pdev->dev.of_node;
struct resource *mem, *irq;
void __iomem *addr;
int err = -ENODEV;
- pdata = dev_get_platdata(&pdev->dev);
+ if (!pdata && np) {
+ pdata = hecc_parse_dt(&pdev->dev);
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
+ }
+
if (!pdata) {
- dev_err(&pdev->dev, "No platform data\n");
- goto probe_exit;
+ dev_err(&pdev->dev, "Platform data missing\n");
+ return -EINVAL;
}
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1037,6 +1082,7 @@ static int ti_hecc_resume(struct platform_device *pdev)
static struct platform_driver ti_hecc_driver = {
.driver = {
.name = DRV_NAME,
+ .of_match_table = ti_hecc_dt_ids,
},
.probe = ti_hecc_probe,
.remove = ti_hecc_remove,
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-01-11 14:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 14:05 [PATCH v2 0/3] Adding DT support for TI HECC module yegorslists-gM/Ye1E23mwN+BqQ9rBEUg
2017-01-11 14:05 ` [PATCH v2 1/3] ARM: dts: AM35x: Add hecc node yegorslists
2017-01-11 14:05 ` [PATCH v2 2/3] can: ti_hecc: Add TI HECC DT binding documentation yegorslists
[not found] ` <1484143521-4898-3-git-send-email-yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-01-13 19:56 ` Rob Herring
2017-01-16 10:59 ` Yegor Yefremov
[not found] ` <1484143521-4898-1-git-send-email-yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-01-11 14:05 ` yegorslists-gM/Ye1E23mwN+BqQ9rBEUg [this message]
[not found] ` <1484143521-4898-4-git-send-email-yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-01-11 14:24 ` [PATCH v2 3/3] can: ti_hecc: Add DT support for TI HECC module Yegor Yefremov
2017-01-17 15:31 ` Yegor Yefremov
2017-01-11 21:50 ` [PATCH v2 0/3] Adding " Yegor Yefremov
[not found] ` <CAGm1_kvWXfZ_f3PPL1VJj8AhBf59Pax_GFHDVdejuMBRDu9y6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-12 0:47 ` Tony Lindgren
[not found] ` <20170112004757.GZ2630-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-01-12 7:59 ` Yegor Yefremov
[not found] ` <CAGm1_kvNcmpayN-=mMmkCn1=wXaykhENUrHK2-MVmZLC+Cca0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-12 15:32 ` Yegor Yefremov
[not found] ` <CAGm1_ksOZ591TQHVo5u0MHP_H5fzPX3ip5Jf3eunfT2OOW7fZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-12 15:44 ` Tony Lindgren
2017-01-12 15:41 ` Tony Lindgren
2017-01-16 9:34 ` Yegor Yefremov
2017-01-16 17:38 ` Tony Lindgren
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=1484143521-4898-4-git-send-email-yegorslists@googlemail.com \
--to=yegorslists-gm/ye1e23mwn+bqq9rbeug@public.gmane.org \
--cc=andrej.skvortzov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=anton.a.glukhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hs-ynQEQJNshbs@public.gmane.org \
--cc=jean-michel.hautbois-B+Q8N6RmIDZBDgjK7y7TUQ@public.gmane.org \
--cc=linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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).