summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-11-27 14:40:05 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-11-27 14:40:05 +0100
commit5c8ffe5ff4140bc09e0be717702e6a55ddc443ac (patch)
tree9efa48f42152d67d1f951aaa4de2b65cfbaff600
parent49fd45a074bd1c4e44d5a9c7c2d2a9a7117bdfb4 (diff)
parent3510166cffd25670ab0ca7cd53c2096b88333c38 (diff)
downloadbarebox-5c8ffe5ff4140bc09e0be717702e6a55ddc443ac.tar.gz
Merge branch 'for-next/layerscape' into next
-rw-r--r--arch/arm/boards/ls1046ardb/board.c107
-rw-r--r--arch/arm/dts/fsl-ls1046a-rdb.dts46
-rw-r--r--arch/arm/dts/fsl-tqmls1046a-mbls10xxa.dts2
3 files changed, 152 insertions, 3 deletions
diff --git a/arch/arm/boards/ls1046ardb/board.c b/arch/arm/boards/ls1046ardb/board.c
index 0846df9..d744737 100644
--- a/arch/arm/boards/ls1046ardb/board.c
+++ b/arch/arm/boards/ls1046ardb/board.c
@@ -2,13 +2,117 @@
#include <common.h>
#include <init.h>
+#include <bbu.h>
+#include <net.h>
+#include <crc.h>
+#include <fs.h>
#include <envfs.h>
+#include <libfile.h>
#include <asm/memory.h>
#include <linux/sizes.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <asm/system.h>
#include <mach/layerscape.h>
+#include <mach/bbu.h>
+
+#define MAX_NUM_PORTS 16
+struct nxid {
+ u8 id[4]; /* 0x00 - 0x03 EEPROM Tag 'NXID' */
+ u8 sn[12]; /* 0x04 - 0x0F Serial Number */
+ u8 errata[5]; /* 0x10 - 0x14 Errata Level */
+ u8 date[6]; /* 0x15 - 0x1a Build Date */
+ u8 res_0; /* 0x1b Reserved */
+ u32 version; /* 0x1c - 0x1f NXID Version */
+ u8 tempcal[8]; /* 0x20 - 0x27 Temperature Calibration Factors */
+ u8 tempcalsys[2]; /* 0x28 - 0x29 System Temperature Calibration Factors */
+ u8 tempcalflags; /* 0x2a Temperature Calibration Flags */
+ u8 res_1[21]; /* 0x2b - 0x3f Reserved */
+ u8 mac_count; /* 0x40 Number of MAC addresses */
+ u8 mac_flag; /* 0x41 MAC table flags */
+ u8 mac[MAX_NUM_PORTS][6]; /* 0x42 - 0xa1 MAC addresses */
+ u8 res_2[90]; /* 0xa2 - 0xfb Reserved */
+ u32 crc; /* 0xfc - 0xff CRC32 checksum */
+} __packed;
+
+static int nxid_is_valid(struct nxid *nxid)
+{
+ unsigned char id[] = { 'N', 'X', 'I', 'D' };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(id); i++)
+ if (nxid->id[i] != id[i])
+ return false;
+ return true;
+}
+
+static struct nxid *nxp_nxid_read(const char *filename, unsigned int offset)
+{
+ struct nxid *nxid;
+ int fd, ret, i;
+ struct device_node *root;
+ u32 crc, crc_expected;
+
+ nxid = xzalloc(sizeof(*nxid));
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ ret = -errno;
+ goto out;
+ }
+
+ ret = pread(fd, nxid, sizeof(*nxid), offset);
+ if (ret < 0) {
+ close(fd);
+ goto out;
+ }
+
+ if (!nxid_is_valid(nxid)) {
+ ret = -ENODEV;
+ goto out;
+ }
+
+ crc = crc32(0, nxid, 256 - 4);
+ crc_expected = be32_to_cpu(nxid->crc);
+ if (crc != crc_expected) {
+ pr_err("CRC mismatch (%08x != %08x)\n", crc, crc_expected);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ root = of_get_root_node();
+
+ for (i = 0; i < nxid->mac_count; i++) {
+ struct device_node *np;
+ char alias[sizeof("ethernetxxx")];
+ const char *ethaddr = nxid->mac[i];
+
+ sprintf(alias, "ethernet%d", i);
+
+ np = of_find_node_by_alias(root, alias);
+ if (!np)
+ continue;
+
+ of_eth_register_ethaddr(np, ethaddr);
+ }
+
+ ret = 0;
+out:
+ if (ret) {
+ free(nxid);
+ nxid = ERR_PTR(ret);
+ }
+
+ return nxid;
+}
+
+static int rdb_late_init(void)
+{
+ nxp_nxid_read("/dev/eeprom", 256);
+
+ return 0;
+}
+late_initcall(rdb_late_init);
static int rdb_mem_init(void)
{
@@ -35,6 +139,9 @@ static int rdb_postcore_init(void)
defaultenv_append_directory(defaultenv_ls1046ardb);
+ ls1046a_bbu_mmc_register_handler("sd", "/dev/mmc0.barebox",
+ BBU_HANDLER_FLAG_DEFAULT);
+
return 0;
}
diff --git a/arch/arm/dts/fsl-ls1046a-rdb.dts b/arch/arm/dts/fsl-ls1046a-rdb.dts
index 842d684..32b3f40 100644
--- a/arch/arm/dts/fsl-ls1046a-rdb.dts
+++ b/arch/arm/dts/fsl-ls1046a-rdb.dts
@@ -5,6 +5,10 @@
#include <arm64/freescale/fsl-ls1046a-rdb.dts>
/ {
+ aliases {
+ eeprom = &eeprom;
+ };
+
chosen {
stdout-path = &duart0;
@@ -23,9 +27,14 @@
#address-cells = <1>;
#size-cells = <1>;
- environment_sd: partition@200000 {
+ partition@1000 {
+ label = "barebox";
+ reg = <0x1000 0xdf000>;
+ };
+
+ environment_sd: partition@e0000 {
label = "barebox-environment";
- reg = <0x200000 0x20000>;
+ reg = <0xe0000 0x20000>;
};
};
@@ -41,6 +50,17 @@
status = "okay";
};
+&i2c0 {
+ eeprom: eeprom@52 {
+ compatible = "atmel,24c04";
+ };
+
+ non_existent_eeprom: eeprom@53 {
+ };
+};
+
+/delete-node/ &non_existent_eeprom;
+
&fman0 {
ethernet@e0000 {
status = "disabled";
@@ -109,6 +129,14 @@
};
};
+&qflash0 {
+ compatible = "jedec,spi-nor";
+};
+
+&qflash1 {
+ compatible = "jedec,spi-nor";
+};
+
&usb0 {
dr_mode = "host";
};
@@ -122,3 +150,17 @@
&usb2 {
dr_mode = "host";
};
+
+&soc {
+ pcie1: pcie@3400000 {
+ status = "okay";
+ };
+
+ pcie2: pcie@3500000 {
+ status = "okay";
+ };
+
+ pcie3: pcie@3600000 {
+ status = "okay";
+ };
+};
diff --git a/arch/arm/dts/fsl-tqmls1046a-mbls10xxa.dts b/arch/arm/dts/fsl-tqmls1046a-mbls10xxa.dts
index a4e3f6b..7b17fe2 100644
--- a/arch/arm/dts/fsl-tqmls1046a-mbls10xxa.dts
+++ b/arch/arm/dts/fsl-tqmls1046a-mbls10xxa.dts
@@ -84,7 +84,7 @@
compatible = "fixed-partitions";
- partition@0 {
+ partition@1000 {
label = "barebox";
reg = <0x1000 0xdf000>;
};