* [PATCH v1 1/3] net: ag71xx: define parent devices @ 2017-09-20 18:05 Oleksij Rempel 2017-09-20 18:05 ` [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add Atheros ART partition Oleksij Rempel 2017-09-20 18:05 ` [PATCH v1 3/3] MIPS: ath79: provide driver for " Oleksij Rempel 0 siblings, 2 replies; 5+ messages in thread From: Oleksij Rempel @ 2017-09-20 18:05 UTC (permalink / raw) To: barebox; +Cc: Oleksij Rempel without it we are not able to set mac address from other driver. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> --- drivers/net/ag71xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ag71xx.c b/drivers/net/ag71xx.c index 1cec26360..a422aacdd 100644 --- a/drivers/net/ag71xx.c +++ b/drivers/net/ag71xx.c @@ -580,6 +580,7 @@ static int ag71xx_probe(struct device_d *dev) miibus = &priv->miibus; dev->priv = edev; edev->priv = priv; + edev->parent = dev; edev->init = ag71xx_ether_init; edev->open = ag71xx_ether_open; @@ -597,6 +598,7 @@ static int ag71xx_probe(struct device_d *dev) miibus->read = ag71xx_ether_mii_read; miibus->write = ag71xx_ether_mii_write; miibus->priv = priv; + miibus->parent = dev; /* enable switch core */ rd = ar7240_reg_rd(AR71XX_PLL_BASE + AR933X_ETHSW_CLOCK_CONTROL_REG); -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add Atheros ART partition 2017-09-20 18:05 [PATCH v1 1/3] net: ag71xx: define parent devices Oleksij Rempel @ 2017-09-20 18:05 ` Oleksij Rempel 2017-09-26 7:09 ` Sascha Hauer 2017-09-20 18:05 ` [PATCH v1 3/3] MIPS: ath79: provide driver for " Oleksij Rempel 1 sibling, 1 reply; 5+ messages in thread From: Oleksij Rempel @ 2017-09-20 18:05 UTC (permalink / raw) To: barebox; +Cc: Oleksij Rempel and define it as source of MAC address for ag71xx driver Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> --- arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts b/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts index d16cab005..3733ad5b7 100644 --- a/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts +++ b/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts @@ -26,6 +26,12 @@ compatible = "barebox,environment"; device-path = &spiflash, "partname:barebox-environment"; }; + + art@0 { + compatible = "qca,art", "qca,art-ar9344"; + device-path = &spiflash, "partname:art"; + barebox,provide-mac-address = <&mac0>; + }; }; }; @@ -59,6 +65,11 @@ label = "barebox-environment"; reg = <0x80000 0x10000>; }; + + partition@7f0000 { + label = "art"; + reg = <0x7f0000 0x10000>; + }; }; }; -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add Atheros ART partition 2017-09-20 18:05 ` [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add Atheros ART partition Oleksij Rempel @ 2017-09-26 7:09 ` Sascha Hauer 2017-09-29 22:03 ` Oleksij Rempel 0 siblings, 1 reply; 5+ messages in thread From: Sascha Hauer @ 2017-09-26 7:09 UTC (permalink / raw) To: Oleksij Rempel; +Cc: barebox Hi Oleksij, On Wed, Sep 20, 2017 at 08:05:56PM +0200, Oleksij Rempel wrote: > and define it as source of MAC address for ag71xx driver > > Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> > --- > arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts b/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts > index d16cab005..3733ad5b7 100644 > --- a/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts > +++ b/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts > @@ -26,6 +26,12 @@ > compatible = "barebox,environment"; > device-path = &spiflash, "partname:barebox-environment"; > }; > + > + art@0 { > + compatible = "qca,art", "qca,art-ar9344"; > + device-path = &spiflash, "partname:art"; > + barebox,provide-mac-address = <&mac0>; > + }; > }; > }; > > @@ -59,6 +65,11 @@ > label = "barebox-environment"; > reg = <0x80000 0x10000>; > }; > + > + partition@7f0000 { > + label = "art"; > + reg = <0x7f0000 0x10000>; > + }; > }; > }; There once was a proposal to add nvmem support to mtd (https://lkml.org/lkml/2017/3/7/131). Apparently this didn't make it mainline, although the comments to this series haven't been very negative. Could you have a look if it's worth to pick this work up or at least adopt it for barebox? I have the feeling that nvmem support for mtd is something that we haven't come across for the last time. Sascha -- 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] 5+ messages in thread
* Re: [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add Atheros ART partition 2017-09-26 7:09 ` Sascha Hauer @ 2017-09-29 22:03 ` Oleksij Rempel 0 siblings, 0 replies; 5+ messages in thread From: Oleksij Rempel @ 2017-09-29 22:03 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox [-- Attachment #1.1.1: Type: text/plain, Size: 1734 bytes --] Am 26.09.2017 um 09:09 schrieb Sascha Hauer: > Hi Oleksij, > > On Wed, Sep 20, 2017 at 08:05:56PM +0200, Oleksij Rempel wrote: >> and define it as source of MAC address for ag71xx driver >> >> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> >> --- >> arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts | 11 +++++++++++ >> 1 file changed, 11 insertions(+) >> >> diff --git a/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts b/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts >> index d16cab005..3733ad5b7 100644 >> --- a/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts >> +++ b/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts >> @@ -26,6 +26,12 @@ >> compatible = "barebox,environment"; >> device-path = &spiflash, "partname:barebox-environment"; >> }; >> + >> + art@0 { >> + compatible = "qca,art", "qca,art-ar9344"; >> + device-path = &spiflash, "partname:art"; >> + barebox,provide-mac-address = <&mac0>; >> + }; >> }; >> }; >> >> @@ -59,6 +65,11 @@ >> label = "barebox-environment"; >> reg = <0x80000 0x10000>; >> }; >> + >> + partition@7f0000 { >> + label = "art"; >> + reg = <0x7f0000 0x10000>; >> + }; >> }; >> }; > > There once was a proposal to add nvmem support to mtd > (https://lkml.org/lkml/2017/3/7/131). Apparently this didn't make it > mainline, although the comments to this series haven't been very > negative. Could you have a look if it's worth to pick this work up > or at least adopt it for barebox? I have the feeling that nvmem support > for mtd is something that we haven't come across for the last time. Ok, i'll take a look on it. Since this will take some time, i'll resend some patches from this set, separately -- Regards, Oleksij [-- Attachment #1.2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 149 bytes --] _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 3/3] MIPS: ath79: provide driver for Atheros ART partition 2017-09-20 18:05 [PATCH v1 1/3] net: ag71xx: define parent devices Oleksij Rempel 2017-09-20 18:05 ` [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add Atheros ART partition Oleksij Rempel @ 2017-09-20 18:05 ` Oleksij Rempel 1 sibling, 0 replies; 5+ messages in thread From: Oleksij Rempel @ 2017-09-20 18:05 UTC (permalink / raw) To: barebox; +Cc: Oleksij Rempel this partition contains calibration data for WiFi and some board specific data, like MAC address. For now we care only about MAC. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> --- arch/mips/mach-ath79/Makefile | 1 + arch/mips/mach-ath79/art.c | 126 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 arch/mips/mach-ath79/art.c diff --git a/arch/mips/mach-ath79/Makefile b/arch/mips/mach-ath79/Makefile index 3772daeba..b827b363c 100644 --- a/arch/mips/mach-ath79/Makefile +++ b/arch/mips/mach-ath79/Makefile @@ -1,2 +1,3 @@ obj-y += reset.o obj-y += bbu.o +obj-y += art.o diff --git a/arch/mips/mach-ath79/art.c b/arch/mips/mach-ath79/art.c new file mode 100644 index 000000000..78f9f1382 --- /dev/null +++ b/arch/mips/mach-ath79/art.c @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2017 Oleksij Rempel <linux@rempel-privat.de> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <common.h> +#include <init.h> +#include <io.h> +#include <of.h> +#include <malloc.h> +#include <partition.h> +#include <libfile.h> +#include <fcntl.h> +#include <unistd.h> +#include <net.h> + +struct ar9300_eeprom { + u8 eeprom_version; + u8 template_version; + u8 mac_addr[6]; +}; + +static int art_set_mac(struct device_d *dev, struct ar9300_eeprom *eeprom) +{ + struct device_node *node = dev->device_node; + struct device_node *rnode; + + if (!node) + return -ENOENT; + + rnode = of_parse_phandle_from(node, NULL, + "barebox,provide-mac-address", 0); + if (!rnode) + return -ENOENT; + + of_eth_register_ethaddr(rnode, &eeprom->mac_addr[0]); + + return 0; +} + +static int art_read_mac(struct device_d *dev, const char *file) +{ + int fd, rbytes; + struct ar9300_eeprom eeprom; + + fd = open_and_lseek(file, O_RDONLY, 0x1000); + if (fd < 0) { + dev_err(dev, "Failed to open eeprom path %s %d\n", + file, -errno); + return -errno; + } + + rbytes = read_full(fd, &eeprom, sizeof(eeprom)); + close(fd); + if (rbytes <= 0 || rbytes < sizeof(eeprom)) { + dev_err(dev, "Failed to read %s\n", file); + return -EIO; + } + + dev_dbg(dev, "ART version: %x.%x\n", + eeprom.eeprom_version, eeprom.template_version); + dev_dbg(dev, "mac: %02x:%02x:%02x:%02x:%02x:%02x\n", + eeprom.mac_addr[0], + eeprom.mac_addr[1], + eeprom.mac_addr[2], + eeprom.mac_addr[3], + eeprom.mac_addr[4], + eeprom.mac_addr[5]); + + if (!is_valid_ether_addr(&eeprom.mac_addr[0])) { + dev_err(dev, "bad MAC addr\n"); + return -EILSEQ; + } + + return art_set_mac(dev, &eeprom); +} + +static int art_probe(struct device_d *dev) +{ + char *path; + int ret; + + dev_dbg(dev, "found ART partition\n"); + + ret = of_find_path(dev->device_node, "device-path", &path, 0); + if (ret) { + dev_err(dev, "can't find path\n"); + return ret; + } + + return art_read_mac(dev, path); +} + +static struct of_device_id art_dt_ids[] = { + { + .compatible = "qca,art", + }, { + /* sentinel */ + } +}; + +static struct driver_d art_driver = { + .name = "qca-art", + .probe = art_probe, + .of_compatible = art_dt_ids, +}; + +static int art_of_driver_init(void) +{ + platform_driver_register(&art_driver); + + return 0; +} +late_initcall(art_of_driver_init); -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-29 22:04 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-09-20 18:05 [PATCH v1 1/3] net: ag71xx: define parent devices Oleksij Rempel 2017-09-20 18:05 ` [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add Atheros ART partition Oleksij Rempel 2017-09-26 7:09 ` Sascha Hauer 2017-09-29 22:03 ` Oleksij Rempel 2017-09-20 18:05 ` [PATCH v1 3/3] MIPS: ath79: provide driver for " Oleksij Rempel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox