From bd7b0120579a914a0bc0f8360ce6c146689d68b1 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Thu, 7 Jun 2018 21:55:50 +0200 Subject: MIPS: ath79: provide driver for Atheros ART partition 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 Signed-off-by: Sascha Hauer --- arch/mips/mach-ath79/Makefile | 1 + arch/mips/mach-ath79/art.c | 112 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 arch/mips/mach-ath79/art.c (limited to 'arch/mips') diff --git a/arch/mips/mach-ath79/Makefile b/arch/mips/mach-ath79/Makefile index 3772daebad..b827b363cf 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 0000000000..984d087363 --- /dev/null +++ b/arch/mips/mach-ath79/art.c @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2. +/* + * Copyright (c) 2018 Oleksij Rempel + */ + +#include +#include +#include +#include +#include +#include + +#define AR93000_EPPROM_OFFSET 0x1000 + +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, AR93000_EPPROM_OFFSET); + if (fd < 0) { + dev_err(dev, "Failed to open eeprom path %s %d\n", + file, fd); + return fd; + } + + rbytes = read_full(fd, &eeprom, sizeof(eeprom)); + close(fd); + if (rbytes < sizeof(eeprom)) { + dev_err(dev, "Failed to read %s\n", file); + return rbytes < 0 ? rbytes : -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); -- cgit v1.2.3 From db9a5e6bc13962d814b86d332fab99a4f351f238 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Thu, 7 Jun 2018 21:55:51 +0200 Subject: MIPS: dts: tl_wdr4300: add Atheros ART partition and define it as source of MAC address for ag71xx driver Signed-off-by: Oleksij Rempel Signed-off-by: Sascha Hauer --- arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'arch/mips') diff --git a/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts b/arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts index 5216cdc1e2..c9ce120588 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-ar9344", "qca,art"; + device-path = &spiflash_art; + barebox,provide-mac-address = <&mac0>; + }; }; }; @@ -63,6 +69,11 @@ label = "barebox-environment"; reg = <0x80000 0x10000>; }; + + spiflash_art: partition@7f0000 { + label = "art"; + reg = <0x7f0000 0x10000>; + }; }; }; -- cgit v1.2.3 From 2ed31f027be3473cf11fe6674480b81282d66888 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Thu, 7 Jun 2018 21:55:52 +0200 Subject: MIPS: dts: dpt-module: add Atheros ART partition and define it as source of MAC address for ag71xx driver Signed-off-by: Oleksij Rempel Signed-off-by: Sascha Hauer --- arch/mips/dts/ar9331-dptechnics-dpt-module.dts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'arch/mips') diff --git a/arch/mips/dts/ar9331-dptechnics-dpt-module.dts b/arch/mips/dts/ar9331-dptechnics-dpt-module.dts index 2c38bbc090..59bb0dd40e 100644 --- a/arch/mips/dts/ar9331-dptechnics-dpt-module.dts +++ b/arch/mips/dts/ar9331-dptechnics-dpt-module.dts @@ -11,6 +11,12 @@ compatible = "barebox,environment"; device-path = &spiflash, "partname:barebox-environment"; }; + + art@0 { + compatible = "qca,art-ar9331", "qca,art"; + device-path = &spiflash_art; + barebox,provide-mac-address = <&mac0>; + }; }; leds { @@ -30,6 +36,11 @@ label = "barebox-environment"; reg = <0x80000 0x10000>; }; + + spiflash_art: partition@7f0000 { + label = "art"; + reg = <0x7f0000 0x10000>; + }; }; &mac0 { -- cgit v1.2.3 From c871d35eea9e85304c48279ad23758c417d30a99 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Thu, 21 Jun 2018 14:21:19 +0300 Subject: MIPS: dts: drop skeleton.dtsi Based on feedback from Sascha: http://lists.infradead.org/pipermail/barebox/2018-April/032694.html " skeleton.dtsi should no longer be used " Several reasons to remove skeleton.dtsi are explained in the linux commit 3ebee5a2e141 ("arm64: dts: kill skeleton.dtsi"). Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/mips/dts/dlink-dir-320.dts | 6 ++++-- arch/mips/dts/jz4755.dtsi | 5 +++-- arch/mips/dts/jz4780.dtsi | 5 +++-- arch/mips/dts/loongson-ls1b.dts | 1 + arch/mips/dts/ls1b.dtsi | 5 +++-- arch/mips/dts/qemu-malta.dts | 6 ++++-- arch/mips/dts/rzx50.dts | 1 + arch/mips/dts/skeleton.dtsi | 13 ------------- 8 files changed, 19 insertions(+), 23 deletions(-) delete mode 100644 arch/mips/dts/skeleton.dtsi (limited to 'arch/mips') diff --git a/arch/mips/dts/dlink-dir-320.dts b/arch/mips/dts/dlink-dir-320.dts index b961c9dca3..966c9b362d 100644 --- a/arch/mips/dts/dlink-dir-320.dts +++ b/arch/mips/dts/dlink-dir-320.dts @@ -1,12 +1,14 @@ /dts-v1/; -#include "skeleton.dtsi" - / { model = "D-Link DIR-320"; compatible = "dlink,dir320"; + #address-cells = <1>; + #size-cells = <1>; + memory { + device_type = "memory"; reg = <0x00000000 0x2000000>; }; diff --git a/arch/mips/dts/jz4755.dtsi b/arch/mips/dts/jz4755.dtsi index 137156df7e..5d929c5d83 100644 --- a/arch/mips/dts/jz4755.dtsi +++ b/arch/mips/dts/jz4755.dtsi @@ -1,6 +1,7 @@ -#include "skeleton.dtsi" - / { + #address-cells = <1>; + #size-cells = <1>; + soc { compatible = "simple-bus"; model = "Ingenic JZ4755"; diff --git a/arch/mips/dts/jz4780.dtsi b/arch/mips/dts/jz4780.dtsi index 9f0de5d1ae..fbffe814bb 100644 --- a/arch/mips/dts/jz4780.dtsi +++ b/arch/mips/dts/jz4780.dtsi @@ -1,6 +1,7 @@ -#include "skeleton.dtsi" - / { + #address-cells = <1>; + #size-cells = <1>; + soc { model = "Ingenic JZ4780"; #address-cells = <1>; diff --git a/arch/mips/dts/loongson-ls1b.dts b/arch/mips/dts/loongson-ls1b.dts index b81a951dc7..61e9a2d2aa 100644 --- a/arch/mips/dts/loongson-ls1b.dts +++ b/arch/mips/dts/loongson-ls1b.dts @@ -7,6 +7,7 @@ compatible = "loongson,ls1b"; memory { + device_type = "memory"; reg = <0x00000000 0x4000000>; }; }; diff --git a/arch/mips/dts/ls1b.dtsi b/arch/mips/dts/ls1b.dtsi index af7119f1d0..cb85814af4 100644 --- a/arch/mips/dts/ls1b.dtsi +++ b/arch/mips/dts/ls1b.dtsi @@ -1,6 +1,7 @@ -#include "skeleton.dtsi" - / { + #address-cells = <1>; + #size-cells = <1>; + soc { #address-cells = <1>; #size-cells = <1>; diff --git a/arch/mips/dts/qemu-malta.dts b/arch/mips/dts/qemu-malta.dts index 9b0c594e87..546b129f85 100644 --- a/arch/mips/dts/qemu-malta.dts +++ b/arch/mips/dts/qemu-malta.dts @@ -1,11 +1,12 @@ /dts-v1/; -/include/ "skeleton.dtsi" - / { model = "qemu malta"; compatible = "qemu,malta"; + #address-cells = <1>; + #size-cells = <1>; + chosen { environment@0 { compatible = "barebox,environment"; @@ -14,6 +15,7 @@ }; memory { + device_type = "memory"; reg = <0x00000000 0x10000000>; }; diff --git a/arch/mips/dts/rzx50.dts b/arch/mips/dts/rzx50.dts index 7ec3352666..2896cbae82 100644 --- a/arch/mips/dts/rzx50.dts +++ b/arch/mips/dts/rzx50.dts @@ -7,6 +7,7 @@ compatible = "ritmix,rzx50"; memory { + device_type = "memory"; reg = <0x00000000 0x4000000>; }; diff --git a/arch/mips/dts/skeleton.dtsi b/arch/mips/dts/skeleton.dtsi deleted file mode 100644 index b41d241de2..0000000000 --- a/arch/mips/dts/skeleton.dtsi +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Skeleton device tree; the bare minimum needed to boot; just include and - * add a compatible value. The bootloader will typically populate the memory - * node. - */ - -/ { - #address-cells = <1>; - #size-cells = <1>; - chosen { }; - aliases { }; - memory { device_type = "memory"; reg = <0 0>; }; -}; -- cgit v1.2.3 From 136a74455005ff5ffc3cdc5186893514d4a1f8e0 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Thu, 21 Jun 2018 14:21:20 +0300 Subject: MIPS: dts: fix dtc unit_address_vs_reg warning Unit number is added to the /memory nodes to fix this dtc warning: Warning (unit_address_vs_reg): /memory: node has a reg or ranges property, but no unit name Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/mips/dts/dlink-dir-320.dts | 2 +- arch/mips/dts/img-ci20.dts | 2 +- arch/mips/dts/loongson-ls1b.dts | 2 +- arch/mips/dts/qemu-malta.dts | 2 +- arch/mips/dts/rzx50.dts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'arch/mips') diff --git a/arch/mips/dts/dlink-dir-320.dts b/arch/mips/dts/dlink-dir-320.dts index 966c9b362d..d19c3087d0 100644 --- a/arch/mips/dts/dlink-dir-320.dts +++ b/arch/mips/dts/dlink-dir-320.dts @@ -7,7 +7,7 @@ #address-cells = <1>; #size-cells = <1>; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x2000000>; }; diff --git a/arch/mips/dts/img-ci20.dts b/arch/mips/dts/img-ci20.dts index da2a5bf625..d985666020 100644 --- a/arch/mips/dts/img-ci20.dts +++ b/arch/mips/dts/img-ci20.dts @@ -24,7 +24,7 @@ model = "MIPS Creator CI20"; compatible = "img,ci20"; - memory { + memory@0 { device_type = "memory"; reg = <0x0 0x10000000>; }; diff --git a/arch/mips/dts/loongson-ls1b.dts b/arch/mips/dts/loongson-ls1b.dts index 61e9a2d2aa..6b53311982 100644 --- a/arch/mips/dts/loongson-ls1b.dts +++ b/arch/mips/dts/loongson-ls1b.dts @@ -6,7 +6,7 @@ model = "Loongson Tech LS1B Demo Board"; compatible = "loongson,ls1b"; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x4000000>; }; diff --git a/arch/mips/dts/qemu-malta.dts b/arch/mips/dts/qemu-malta.dts index 546b129f85..9772d49eb3 100644 --- a/arch/mips/dts/qemu-malta.dts +++ b/arch/mips/dts/qemu-malta.dts @@ -14,7 +14,7 @@ }; }; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x10000000>; }; diff --git a/arch/mips/dts/rzx50.dts b/arch/mips/dts/rzx50.dts index 2896cbae82..bd3631f7c4 100644 --- a/arch/mips/dts/rzx50.dts +++ b/arch/mips/dts/rzx50.dts @@ -6,7 +6,7 @@ model = "Ritmix RZX-50"; compatible = "ritmix,rzx50"; - memory { + memory@0 { device_type = "memory"; reg = <0x00000000 0x4000000>; }; -- cgit v1.2.3 From 5500987a54b2f01ffcb94d96335453388314566e Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Fri, 29 Jun 2018 13:58:23 +0300 Subject: MIPS: don't include generated header files into MIPS asm files This patch came out of discussions in the 'MIPS parallel build breakage' e-mail thread: http://lists.infradead.org/pipermail/barebox/2018-March/032251.html Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/mips/include/asm/pbl_macros.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'arch/mips') diff --git a/arch/mips/include/asm/pbl_macros.h b/arch/mips/include/asm/pbl_macros.h index 18115c8489..bb3182cda9 100644 --- a/arch/mips/include/asm/pbl_macros.h +++ b/arch/mips/include/asm/pbl_macros.h @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include #include @@ -174,7 +172,7 @@ copy_loop_exit: nop .org 0x10 - .ascii "barebox " UTS_RELEASE " " UTS_VERSION + .ascii "barebox" .byte 0 .align 4 -- cgit v1.2.3