summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-12-10 05:41:24 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-12-10 05:41:24 +0100
commite0b4ef8fcd5ca31e7a7dc13caf915aad921cf94f (patch)
treea81c63ca568d86f519aa3f9432fe8cebd51ba15b /arch
parent1a94fdfb850624f7736afe695151bf273b760ba8 (diff)
parent3885852d87f49f6c32f5deb0fb4577e450ce23a7 (diff)
downloadbarebox-e0b4ef8fcd5ca31e7a7dc13caf915aad921cf94f.tar.gz
barebox-e0b4ef8fcd5ca31e7a7dc13caf915aad921cf94f.tar.xz
Merge branch 'for-next/layerscape'
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/ls1046ardb/board.c122
-rw-r--r--arch/arm/dts/fsl-ls1046a-rdb.dts46
-rw-r--r--arch/arm/dts/fsl-tqmls1046a-mbls10xxa.dts2
-rw-r--r--arch/arm/mach-layerscape/ppa.c19
4 files changed, 186 insertions, 3 deletions
diff --git a/arch/arm/boards/ls1046ardb/board.c b/arch/arm/boards/ls1046ardb/board.c
index 0846df9fad..ef68e9c7f9 100644
--- a/arch/arm/boards/ls1046ardb/board.c
+++ b/arch/arm/boards/ls1046ardb/board.c
@@ -2,13 +2,132 @@
#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, n;
+ 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();
+
+ i = n = 0;
+
+ /*
+ * The MAC addresses in the nxid structure are in the order of enabled
+ * network interfaces. We have to find the network interfaces by their
+ * aliases and skip assigning MAC addresses to disabled devices.
+ */
+ while (1) {
+ struct device_node *np;
+ char alias[sizeof("ethernetxxx")];
+
+ sprintf(alias, "ethernet%d", n);
+
+ np = of_find_node_by_alias(root, alias);
+ if (!np)
+ goto out;
+
+ n++;
+ if (!of_device_is_available(np))
+ continue;
+
+ of_eth_register_ethaddr(np, (char *)nxid->mac[i]);
+
+ i++;
+
+ if (i == nxid->mac_count)
+ break;
+ }
+
+ 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 +154,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 842d684588..32b3f40769 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 a4e3f6b589..7b17fe2210 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>;
};
diff --git a/arch/arm/mach-layerscape/ppa.c b/arch/arm/mach-layerscape/ppa.c
index 6070451020..c5eba35b33 100644
--- a/arch/arm/mach-layerscape/ppa.c
+++ b/arch/arm/mach-layerscape/ppa.c
@@ -18,14 +18,33 @@
int ppa_entry(const void *, u32 *, u32 *);
void dma_flush_range(void *ptr, size_t size);
+#define SEC_JR3_OFFSET 0x40000
+
static int of_psci_do_fixup(struct device_node *root, void *unused)
{
unsigned long psci_version;
+ struct device_node *np;
struct arm_smccc_res res = {};
arm_smccc_smc(ARM_PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &res);
psci_version = res.a0;
+ for_each_compatible_node_from(np, root, NULL, "fsl,sec-v4.0-job-ring") {
+ const void *reg;
+ int na = of_n_addr_cells(np);
+ u64 offset;
+
+ reg = of_get_property(np, "reg", NULL);
+ if (!reg)
+ continue;
+
+ offset = of_read_number(reg, na);
+ if (offset != SEC_JR3_OFFSET)
+ continue;
+
+ of_delete_node(np);
+ }
+
return of_psci_fixup(root, psci_version);
}