From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 02/10] ARM: i.MX: iim: Add devicetree probe support
Date: Tue, 21 May 2013 11:57:39 +0200 [thread overview]
Message-ID: <1369130267-8094-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1369130267-8094-1-git-send-email-s.hauer@pengutronix.de>
Only adds the dt ids.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Documentation/devicetree/bindings/README | 6 +++
.../devicetree/bindings/misc/fsl,imx-iim.txt | 20 ++++++++
arch/arm/mach-imx/iim.c | 58 ++++++++++++++++++++++
3 files changed, 84 insertions(+)
create mode 100644 Documentation/devicetree/bindings/README
create mode 100644 Documentation/devicetree/bindings/misc/fsl,imx-iim.txt
diff --git a/Documentation/devicetree/bindings/README b/Documentation/devicetree/bindings/README
new file mode 100644
index 0000000..b818ee8
--- /dev/null
+++ b/Documentation/devicetree/bindings/README
@@ -0,0 +1,6 @@
+
+barebox uses the same devicetree bindings as the kernel. For
+the bindings derived from the kernel look in the kernel sources
+for reference.
+
+barebox specific bindings are documented here.
diff --git a/Documentation/devicetree/bindings/misc/fsl,imx-iim.txt b/Documentation/devicetree/bindings/misc/fsl,imx-iim.txt
new file mode 100644
index 0000000..ed3efcc
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/fsl,imx-iim.txt
@@ -0,0 +1,20 @@
+Freescale i.MX IIM (Ic Identification Module)
+
+Required properties:
+
+- compatible: fsl,imx-iim
+- reg: physical register base and size
+
+Optional properties:
+
+- barebox,provide-mac-address: Provide MAC addresses for ethernet devices. This
+ can be multiple entries in the form <&phandle bankno fuseofs> to specify a MAC
+ address to a ethernet device.
+
+Example:
+
+iim: iim@83f98000 {
+ compatible = "fsl,imx51-iim", "fsl,imx-iim";
+ reg = <0x83f98000 0x4000>;
+ barebox,provide-mac-address = <&fec 1 9>;
+};
diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
index bb806d7..956811c 100644
--- a/arch/arm/mach-imx/iim.c
+++ b/arch/arm/mach-imx/iim.c
@@ -223,6 +223,54 @@ static int imx_iim_add_bank(struct device_d *dev, void __iomem *base, int num)
return devfs_create(cdev);
}
+#if IS_ENABLED(CONFIG_OFDEVICE)
+
+/*
+ * a single MAC address reference has the form
+ * <&phandle iim-bank-no offset>, so three cells
+ */
+#define MAC_ADDRESS_PROPLEN (3 * sizeof(__be32))
+
+static void imx_iim_init_dt(struct device_d *dev)
+{
+ char mac[6];
+ const __be32 *prop;
+ struct device_node *node = dev->device_node;
+ int len, ret;
+
+ if (!node)
+ return;
+
+ prop = of_get_property(node, "barebox,provide-mac-address", &len);
+ if (!prop)
+ return;
+
+ while (len >= MAC_ADDRESS_PROPLEN) {
+ struct device_node *rnode;
+ uint32_t phandle, bank, offset;
+
+ phandle = be32_to_cpup(prop++);
+
+ rnode = of_find_node_by_phandle(phandle);
+ bank = be32_to_cpup(prop++);
+ offset = be32_to_cpup(prop++);
+
+ ret = imx_iim_read(bank, offset, mac, 6);
+ if (ret == 6) {
+ of_eth_register_ethaddr(rnode, mac);
+ } else {
+ dev_err(dev, "cannot read: %s\n", strerror(-ret));
+ }
+
+ len -= MAC_ADDRESS_PROPLEN;
+ }
+}
+#else
+static inline void imx_iim_init_dt(struct device_d *dev)
+{
+}
+#endif
+
static int imx_iim_probe(struct device_d *dev)
{
int i;
@@ -234,6 +282,7 @@ static int imx_iim_probe(struct device_d *dev)
imx_iim_add_bank(dev, base, i);
}
+ imx_iim_init_dt(dev);
if (IS_ENABLED(CONFIG_IMX_IIM_FUSE_BLOW))
dev_add_param_bool(dev, "permanent_write_enable",
@@ -245,9 +294,18 @@ static int imx_iim_probe(struct device_d *dev)
return 0;
}
+static __maybe_unused struct of_device_id imx_iim_dt_ids[] = {
+ {
+ .compatible = "fsl,imx-iim",
+ }, {
+ /* sentinel */
+ }
+};
+
static struct driver_d imx_iim_driver = {
.name = DRIVERNAME,
.probe = imx_iim_probe,
+ .of_compatible = DRV_OF_COMPAT(imx_iim_dt_ids),
};
static int imx_iim_init(void)
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-05-21 9:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-21 9:57 [PATCH] move the first i.MX board over to devicetree Sascha Hauer
2013-05-21 9:57 ` [PATCH 01/10] ARM: i.MX: remove unused .mac_addr_base in iim Sascha Hauer
2013-05-21 9:57 ` Sascha Hauer [this message]
2013-05-21 9:57 ` [PATCH 03/10] ARM: i.MX51: Add devicetree files Sascha Hauer
2013-05-21 9:57 ` [PATCH 04/10] ARM: i.MX51: Add IIM devicetree node Sascha Hauer
2013-05-21 9:57 ` [PATCH 05/10] ARM: i.MX51: Fixup fec pads in dts Sascha Hauer
2013-05-21 9:57 ` [PATCH 06/10] ARM: i.MX51: skip devices register when devicetree is present Sascha Hauer
2013-05-21 9:57 ` [PATCH 07/10] ARM: i.MX51 babbage: Add spi-cs-high property to pmic Sascha Hauer
2013-05-21 9:57 ` [PATCH 08/10] ARM: i.MX51 babbage: provide MAC adress in devicetree Sascha Hauer
2013-05-21 15:22 ` Alexander Shiyan
2013-05-21 17:53 ` Sascha Hauer
2013-05-21 9:57 ` [PATCH 09/10] ARM: i.MX51 babbage: Add phy reset gpio to dts Sascha Hauer
2013-05-21 9:57 ` [PATCH 10/10] ARM: i.MX51 babbage: switch to devicetree Sascha Hauer
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=1369130267-8094-3-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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