* [PATCH] misc oftree patches
@ 2013-05-21 7:38 Sascha Hauer
2013-05-21 7:38 ` [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available Sascha Hauer
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-05-21 7:38 UTC (permalink / raw)
To: barebox
Some assorted devicetree related patches. This makes the SPI support
more complete, adds devicetree probing to the dataflash driver and some
more.
Sascha
----------------------------------------------------------------
Sascha Hauer (5):
pinctrl: imx-iomux-v3: only register pinctrl when device node is available
spi: improve devicetree support
mtd: dataflash: Add devicetree probing support
net: Add of_register_ethaddr
net: fec: Add imx25 compatible property
drivers/mtd/devices/mtd_dataflash.c | 11 ++++++
drivers/net/fec_imx.c | 3 ++
drivers/pinctrl/imx-iomux-v3.c | 2 +-
drivers/spi/spi.c | 15 ++++++--
include/net.h | 5 +++
net/eth.c | 68 ++++++++++++++++++++++++++++++-------
6 files changed, 89 insertions(+), 15 deletions(-)
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available
2013-05-21 7:38 [PATCH] misc oftree patches Sascha Hauer
@ 2013-05-21 7:38 ` Sascha Hauer
2013-06-05 15:18 ` Lucas Stach
2013-05-21 7:38 ` [PATCH 2/5] spi: improve devicetree support Sascha Hauer
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2013-05-21 7:38 UTC (permalink / raw)
To: barebox
The pinctrl support is devicetree only, so only register it
when we actually have a devicetree. Otherwise we crash boards
using the iomux-v3 from platform code in pinctrl_register().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pinctrl/imx-iomux-v3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c
index 3ff3c15..c867a23 100644
--- a/drivers/pinctrl/imx-iomux-v3.c
+++ b/drivers/pinctrl/imx-iomux-v3.c
@@ -177,7 +177,7 @@ static int imx_iomux_v3_probe(struct device_d *dev)
iomuxv3_base = dev_request_mem_region(dev, 0);
iomuxv3_dev = dev;
- if (IS_ENABLED(CONFIG_PINCTRL))
+ if (IS_ENABLED(CONFIG_PINCTRL) && dev->device_node)
ret = imx_pinctrl_dt(dev, iomuxv3_base);
return ret;
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/5] spi: improve devicetree support
2013-05-21 7:38 [PATCH] misc oftree patches Sascha Hauer
2013-05-21 7:38 ` [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available Sascha Hauer
@ 2013-05-21 7:38 ` Sascha Hauer
2013-05-21 7:38 ` [PATCH 3/5] mtd: dataflash: Add devicetree probing support Sascha Hauer
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-05-21 7:38 UTC (permalink / raw)
To: barebox
- zero spi_board_info structure to not accidently pass
unitilialized fields
- parse spi-max-frequency property from devicetree
- parse mode flags from devicetree
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/spi/spi.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index d58b664..f460a7a 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -108,9 +108,20 @@ void spi_of_register_slaves(struct spi_master *master, struct device_node *node)
struct property *reg;
device_node_for_nach_child(node, n) {
- chip.name = n->name;
+ memset(&chip, 0, sizeof(chip));
+ chip.name = xstrdup(n->name);
chip.bus_num = master->bus_num;
- chip.max_speed_hz = 300000; /* FIXME */
+ /* Mode (clock phase/polarity/etc.) */
+ if (of_find_property(n, "spi-cpha"))
+ chip.mode |= SPI_CPHA;
+ if (of_find_property(n, "spi-cpol"))
+ chip.mode |= SPI_CPOL;
+ if (of_find_property(n, "spi-cs-high"))
+ chip.mode |= SPI_CS_HIGH;
+ if (of_find_property(n, "spi-3wire"))
+ chip.mode |= SPI_3WIRE;
+ of_property_read_u32(n, "spi-max-frequency",
+ &chip.max_speed_hz);
reg = of_find_property(n, "reg");
if (!reg)
continue;
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/5] mtd: dataflash: Add devicetree probing support
2013-05-21 7:38 [PATCH] misc oftree patches Sascha Hauer
2013-05-21 7:38 ` [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available Sascha Hauer
2013-05-21 7:38 ` [PATCH 2/5] spi: improve devicetree support Sascha Hauer
@ 2013-05-21 7:38 ` Sascha Hauer
2013-05-21 7:38 ` [PATCH 4/5] net: Add of_register_ethaddr Sascha Hauer
2013-05-21 7:38 ` [PATCH 5/5] net: fec: Add imx25 compatible property Sascha Hauer
4 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-05-21 7:38 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/devices/mtd_dataflash.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index ddab6bb..52bd842 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -871,9 +871,20 @@ static int dataflash_probe(struct device_d *dev)
return status;
}
+static __maybe_unused struct of_device_id dataflash_dt_ids[] = {
+ {
+ .compatible = "atmel,at45",
+ }, {
+ .compatible = "atmel,dataflash",
+ }, {
+ /* sentinel */
+ }
+};
+
static struct driver_d dataflash_driver = {
.name = "mtd_dataflash",
.probe = dataflash_probe,
+ .of_compatible = DRV_OF_COMPAT(dataflash_dt_ids),
};
device_spi_driver(dataflash_driver);
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/5] net: Add of_register_ethaddr
2013-05-21 7:38 [PATCH] misc oftree patches Sascha Hauer
` (2 preceding siblings ...)
2013-05-21 7:38 ` [PATCH 3/5] mtd: dataflash: Add devicetree probing support Sascha Hauer
@ 2013-05-21 7:38 ` Sascha Hauer
2013-05-21 7:38 ` [PATCH 5/5] net: fec: Add imx25 compatible property Sascha Hauer
4 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-05-21 7:38 UTC (permalink / raw)
To: barebox
We already have a possibility to register a MAC address provider
based on a ethernet device id. This adds a similar functionality
for devices probed from devicetree. Code can register itself to
be a MAC address provider for a certain devicetree node.
This helps on i.MX to let the IIM unit provide a MAC address for
the FEC.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/net.h | 5 +++++
net/eth.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 61 insertions(+), 12 deletions(-)
diff --git a/include/net.h b/include/net.h
index bb6b8fa..610a6e6 100644
--- a/include/net.h
+++ b/include/net.h
@@ -76,8 +76,13 @@ int eth_rx(void); /* Check for received packets */
static inline void eth_register_ethaddr(int ethid, const char *ethaddr)
{
}
+static inline void of_eth_register_ethaddr(struct device_node *node,
+ const char *ethaddr)
+{
+}
#else
void eth_register_ethaddr(int ethid, const char *ethaddr);
+void of_eth_register_ethaddr(struct device_node *node, const char *ethaddr);
#endif
/*
* Ethernet header
diff --git a/net/eth.c b/net/eth.c
index 4646dd8..bea7b12 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -36,16 +36,34 @@ struct eth_ethaddr {
struct list_head list;
u8 ethaddr[6];
int ethid;
+ struct device_node *node;
};
static LIST_HEAD(ethaddr_list);
-static int eth_get_registered_ethaddr(int ethid, void *buf)
+static void register_preset_mac_address(struct eth_device *edev, const char *ethaddr)
+{
+ unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")];
+
+ ethaddr_to_string(ethaddr, ethaddr_str);
+
+ if (is_valid_ether_addr(ethaddr)) {
+ dev_info(&edev->dev, "got preset MAC address: %s\n", ethaddr_str);
+ dev_set_param(&edev->dev, "ethaddr", ethaddr_str);
+ }
+}
+
+static int eth_get_registered_ethaddr(struct eth_device *edev, void *buf)
{
struct eth_ethaddr *addr;
+ struct device_node *node = NULL;
+
+ if (edev->parent)
+ node = edev->parent->device_node;
list_for_each_entry(addr, ðaddr_list, list) {
- if (addr->ethid == ethid) {
+ if ((node && node == addr->node) ||
+ addr->ethid == edev->dev.id) {
memcpy(buf, addr->ethaddr, 6);
return 0;
}
@@ -78,6 +96,38 @@ void eth_register_ethaddr(int ethid, const char *ethaddr)
list_add_tail(&addr->list, ðaddr_list);
}
+static struct eth_device *eth_get_by_node(struct device_node *node)
+{
+ struct eth_device *edev;
+
+ list_for_each_entry(edev, &netdev_list, list) {
+ if (!edev->parent)
+ continue;
+ if (!edev->parent->device_node)
+ continue;
+ if (edev->parent->device_node == node)
+ return edev;
+ }
+ return NULL;
+}
+
+void of_eth_register_ethaddr(struct device_node *node, const char *ethaddr)
+{
+ struct eth_ethaddr *addr;
+ struct eth_device *edev;
+
+ edev = eth_get_by_node(node);
+ if (edev) {
+ register_preset_mac_address(edev, ethaddr);
+ return;
+ }
+
+ addr = xzalloc(sizeof(*addr));
+ addr->node = node;
+ memcpy(addr->ethaddr, ethaddr, 6);
+ list_add_tail(&addr->list, ðaddr_list);
+}
+
void eth_set_current(struct eth_device *eth)
{
if (eth_current && eth_current->active) {
@@ -225,8 +275,7 @@ static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const ch
int eth_register(struct eth_device *edev)
{
- struct device_d *dev = &edev->dev;
- unsigned char ethaddr_str[20];
+ struct device_d *dev = &edev->dev;
unsigned char ethaddr[6];
int ret, found = 0;
@@ -254,7 +303,7 @@ int eth_register(struct eth_device *edev)
list_add_tail(&edev->list, &netdev_list);
- ret = eth_get_registered_ethaddr(dev->id, ethaddr);
+ ret = eth_get_registered_ethaddr(edev, ethaddr);
if (!ret)
found = 1;
@@ -264,13 +313,8 @@ int eth_register(struct eth_device *edev)
found = 1;
}
- if (found) {
- ethaddr_to_string(ethaddr, ethaddr_str);
- if (is_valid_ether_addr(ethaddr)) {
- dev_info(dev, "got preset MAC address: %s\n", ethaddr_str);
- dev_set_param(dev, "ethaddr", ethaddr_str);
- }
- }
+ if (found)
+ register_preset_mac_address(edev, ethaddr);
if (!eth_current)
eth_current = edev;
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/5] net: fec: Add imx25 compatible property
2013-05-21 7:38 [PATCH] misc oftree patches Sascha Hauer
` (3 preceding siblings ...)
2013-05-21 7:38 ` [PATCH 4/5] net: Add of_register_ethaddr Sascha Hauer
@ 2013-05-21 7:38 ` Sascha Hauer
4 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-05-21 7:38 UTC (permalink / raw)
To: barebox
The i.MX53 fec claims to be compatible to i.MX25 and i.MX53. In barebox
we do not have to make differences between i.MX25 and i.MX27 though, so
just fall back to i.MX27.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/fec_imx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 1a85d15..96c4ac3 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -746,6 +746,9 @@ static void fec_remove(struct device_d *dev)
static __maybe_unused struct of_device_id imx_fec_dt_ids[] = {
{
+ .compatible = "fsl,imx25-fec",
+ .data = FEC_TYPE_IMX27,
+ }, {
.compatible = "fsl,imx27-fec",
.data = FEC_TYPE_IMX27,
}, {
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available
2013-05-21 7:38 ` [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available Sascha Hauer
@ 2013-06-05 15:18 ` Lucas Stach
2013-06-05 20:33 ` Sascha Hauer
0 siblings, 1 reply; 8+ messages in thread
From: Lucas Stach @ 2013-06-05 15:18 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
This commit isn't included in the 2013.06 release.
I hereby nominate it as a candidate for the v2013.06 stable branch.
Am Dienstag, den 21.05.2013, 09:38 +0200 schrieb Sascha Hauer:
> The pinctrl support is devicetree only, so only register it
> when we actually have a devicetree. Otherwise we crash boards
> using the iomux-v3 from platform code in pinctrl_register().
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/pinctrl/imx-iomux-v3.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c
> index 3ff3c15..c867a23 100644
> --- a/drivers/pinctrl/imx-iomux-v3.c
> +++ b/drivers/pinctrl/imx-iomux-v3.c
> @@ -177,7 +177,7 @@ static int imx_iomux_v3_probe(struct device_d *dev)
> iomuxv3_base = dev_request_mem_region(dev, 0);
> iomuxv3_dev = dev;
>
> - if (IS_ENABLED(CONFIG_PINCTRL))
> + if (IS_ENABLED(CONFIG_PINCTRL) && dev->device_node)
> ret = imx_pinctrl_dt(dev, iomuxv3_base);
>
> return ret;
--
Pengutronix e.K. | Lucas Stach |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5076 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available
2013-06-05 15:18 ` Lucas Stach
@ 2013-06-05 20:33 ` Sascha Hauer
0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-06-05 20:33 UTC (permalink / raw)
To: Lucas Stach; +Cc: barebox
On Wed, Jun 05, 2013 at 05:18:49PM +0200, Lucas Stach wrote:
> This commit isn't included in the 2013.06 release.
>
> I hereby nominate it as a candidate for the v2013.06 stable branch.
Ok, just queued it for stable.
Sascha
>
> Am Dienstag, den 21.05.2013, 09:38 +0200 schrieb Sascha Hauer:
> > The pinctrl support is devicetree only, so only register it
> > when we actually have a devicetree. Otherwise we crash boards
> > using the iomux-v3 from platform code in pinctrl_register().
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> > drivers/pinctrl/imx-iomux-v3.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c
> > index 3ff3c15..c867a23 100644
> > --- a/drivers/pinctrl/imx-iomux-v3.c
> > +++ b/drivers/pinctrl/imx-iomux-v3.c
> > @@ -177,7 +177,7 @@ static int imx_iomux_v3_probe(struct device_d *dev)
> > iomuxv3_base = dev_request_mem_region(dev, 0);
> > iomuxv3_dev = dev;
> >
> > - if (IS_ENABLED(CONFIG_PINCTRL))
> > + if (IS_ENABLED(CONFIG_PINCTRL) && dev->device_node)
> > ret = imx_pinctrl_dt(dev, iomuxv3_base);
> >
> > return ret;
>
> --
> Pengutronix e.K. | Lucas Stach |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5076 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-06-05 20:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 7:38 [PATCH] misc oftree patches Sascha Hauer
2013-05-21 7:38 ` [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available Sascha Hauer
2013-06-05 15:18 ` Lucas Stach
2013-06-05 20:33 ` Sascha Hauer
2013-05-21 7:38 ` [PATCH 2/5] spi: improve devicetree support Sascha Hauer
2013-05-21 7:38 ` [PATCH 3/5] mtd: dataflash: Add devicetree probing support Sascha Hauer
2013-05-21 7:38 ` [PATCH 4/5] net: Add of_register_ethaddr Sascha Hauer
2013-05-21 7:38 ` [PATCH 5/5] net: fec: Add imx25 compatible property Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox