public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Paweł Anikiel" <pan@semihalf.com>
To: marex@denx.de, simon.k.r.goldschmidt@gmail.com,
	tien.fong.chee@intel.com, michal.simek@xilinx.com
Cc: u-boot@lists.denx.de, sjg@chromium.org, festevam@denx.de,
	jagan@amarulasolutions.com, andre.przywara@arm.com,
	narmstrong@baylibre.com, pbrobinson@gmail.com,
	tharvey@gateworks.com, paul.liu@linaro.org,
	christianshewitt@gmail.com, adrian.fiergolski@fastree3d.com,
	marek.behun@nic.cz, wd@denx.de, elly.siew.chin.lim@intel.com,
	mw@semihalf.com, "Paweł Anikiel" <pan@semihalf.com>
Subject: [PATCH 04/11] board: Add Chameleonv3 board dir
Date: Fri,  1 Apr 2022 14:43:18 +0200	[thread overview]
Message-ID: <20220401124325.1810108-5-pan@semihalf.com> (raw)
In-Reply-To: <20220401124325.1810108-1-pan@semihalf.com>

Add board directory for Google Chameleon V3 board

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
---
 board/google/chameleonv3/Makefile          |  5 +++
 board/google/chameleonv3/board.c           | 27 ++++++++++++++
 board/google/chameleonv3/fpga.its          | 28 ++++++++++++++
 board/google/chameleonv3/fpga_early_io.its | 35 ++++++++++++++++++
 board/google/chameleonv3/mercury_aa1.c     | 43 ++++++++++++++++++++++
 board/google/chameleonv3/mercury_aa1.h     | 12 ++++++
 6 files changed, 150 insertions(+)
 create mode 100644 board/google/chameleonv3/Makefile
 create mode 100644 board/google/chameleonv3/board.c
 create mode 100644 board/google/chameleonv3/fpga.its
 create mode 100644 board/google/chameleonv3/fpga_early_io.its
 create mode 100644 board/google/chameleonv3/mercury_aa1.c
 create mode 100644 board/google/chameleonv3/mercury_aa1.h

diff --git a/board/google/chameleonv3/Makefile b/board/google/chameleonv3/Makefile
new file mode 100644
index 0000000000..bb413fde83
--- /dev/null
+++ b/board/google/chameleonv3/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright 2022 Google LLC
+
+obj-y	:= board.o mercury_aa1.o
diff --git a/board/google/chameleonv3/board.c b/board/google/chameleonv3/board.c
new file mode 100644
index 0000000000..4d3049689d
--- /dev/null
+++ b/board/google/chameleonv3/board.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2022 Google LLC
+ */
+#include <net.h>
+#include <errno.h>
+#include "mercury_aa1.h"
+
+int misc_init_r(void)
+{
+	u8 mac[ARP_HLEN];
+	int res;
+
+	if (env_get("ethaddr"))
+		return 0;
+
+	res = mercury_aa1_read_mac(mac);
+	if (res) {
+		printf("couldn't read mac address: %s\n", errno_str(res));
+		return 0;
+	}
+
+	if (is_valid_ethaddr(mac))
+		eth_env_set_enetaddr("ethaddr", mac);
+
+	return 0;
+}
diff --git a/board/google/chameleonv3/fpga.its b/board/google/chameleonv3/fpga.its
new file mode 100644
index 0000000000..85a830002f
--- /dev/null
+++ b/board/google/chameleonv3/fpga.its
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2022 Google LLC
+ */
+/dts-v1/;
+
+/ {
+	description = "FIT image with FPGA bistream";
+	#address-cells = <1>;
+
+	images {
+		fpga-periph-1 {
+			description = "FPGA full bitstream";
+			data = /incbin/("../../../fpga.rbf");
+			type = "fpga";
+			arch = "arm";
+			compression = "none";
+		};
+	};
+
+	configurations {
+		default = "config-1";
+		config-1 {
+			description = "Boot with FPGA config";
+			fpga = "fpga-periph-1";
+		};
+	};
+};
diff --git a/board/google/chameleonv3/fpga_early_io.its b/board/google/chameleonv3/fpga_early_io.its
new file mode 100644
index 0000000000..ebc7bcbaae
--- /dev/null
+++ b/board/google/chameleonv3/fpga_early_io.its
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2022 Google LLC
+ */
+/dts-v1/;
+
+/ {
+	description = "FIT image with FPGA bistream";
+	#address-cells = <1>;
+
+	images {
+		fpga-periph-1 {
+			description = "FPGA peripheral bitstream";
+			data = /incbin/("../../../periph.rbf");
+			type = "fpga";
+			arch = "arm";
+			compression = "none";
+		};
+		fpga-core-1 {
+			description = "FPGA core bitstream";
+			data = /incbin/("../../../core.rbf");
+			type = "fpga";
+			arch = "arm";
+			compression = "none";
+		};
+	};
+
+	configurations {
+		default = "config-1";
+		config-1 {
+			description = "Boot with FPGA config";
+			fpga = "fpga-periph-1", "fpga-core-1";
+		};
+	};
+};
diff --git a/board/google/chameleonv3/mercury_aa1.c b/board/google/chameleonv3/mercury_aa1.c
new file mode 100644
index 0000000000..ed447ec37c
--- /dev/null
+++ b/board/google/chameleonv3/mercury_aa1.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2022 Google LLC
+ */
+#include <net.h>
+#include <dm/device.h>
+#include <dm/uclass.h>
+#include <atsha204a-i2c.h>
+#include "mercury_aa1.h"
+
+#define MERCURY_AA1_ATSHA204A_OTP_MAC0 4
+#define MERCURY_AA1_ATSHA204A_OTP_MAC1 5
+
+int mercury_aa1_read_mac(u8 *mac)
+{
+	struct udevice *dev;
+	u8 buf[8];
+	int ret;
+
+	ret = uclass_get_device_by_name(UCLASS_MISC, "atsha204a@64", &dev);
+	if (ret)
+		return ret;
+
+	ret = atsha204a_wakeup(dev);
+	if (ret)
+		return ret;
+
+	ret = atsha204a_read(dev, ATSHA204A_ZONE_OTP, false,
+			     MERCURY_AA1_ATSHA204A_OTP_MAC0, buf);
+	if (ret)
+		goto sleep;
+
+	ret = atsha204a_read(dev, ATSHA204A_ZONE_OTP, false,
+			     MERCURY_AA1_ATSHA204A_OTP_MAC1, buf + 4);
+	if (ret)
+		goto sleep;
+
+	memcpy(mac, buf, ARP_HLEN);
+
+sleep:
+	atsha204a_sleep(dev);
+	return ret;
+}
diff --git a/board/google/chameleonv3/mercury_aa1.h b/board/google/chameleonv3/mercury_aa1.h
new file mode 100644
index 0000000000..636b735a3b
--- /dev/null
+++ b/board/google/chameleonv3/mercury_aa1.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2022 Google LLC
+ */
+
+/**
+ * mercury_aa1_read_mac() - Read mac address from on-board OTP memory
+ *
+ * @mac: Returned mac address
+ * Return: 0 if successful, -ve on error
+ */
+int mercury_aa1_read_mac(u8 *mac);
-- 
2.35.1.1094.g7c7d902a7c-goog


  parent reply	other threads:[~2022-04-01 13:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01 12:43 [PATCH 00/11] Add Chameleon V3 support Paweł Anikiel
2022-04-01 12:43 ` [PATCH 01/11] arm: dts: Add Mercury+ AA1 devicetree Paweł Anikiel
2022-04-11 18:34   ` Simon Glass
2022-04-14 14:07     ` Paweł Anikiel
2022-04-01 12:43 ` [PATCH 02/11] arm: dts: Add Chameleonv3 handoff headers Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-14 13:58     ` Paweł Anikiel
2022-04-01 12:43 ` [PATCH 03/11] arm: dts: Add Chameleonv3 devicetree Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-14 15:57     ` Paweł Anikiel
2022-04-01 12:43 ` Paweł Anikiel [this message]
2022-04-11 18:35   ` [PATCH 04/11] board: Add Chameleonv3 board dir Simon Glass
2022-04-01 12:43 ` [PATCH 05/11] config: Add Chameleonv3 config Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-01 12:43 ` [PATCH 06/11] misc: atsha204a: Increase wake delay by tWHI Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-01 12:43 ` [PATCH 07/11] sysreset: socfpga: Use parent device for reading base address Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-14 13:33     ` Paweł Anikiel
2022-04-01 12:43 ` [PATCH 08/11] socfpga: arria10: Replace delays with busy waiting in cm_full_cfg Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-01 12:43 ` [PATCH 09/11] socfpga: arria10: Improve bitstream loading speed Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-01 12:43 ` [PATCH 10/11] socfpga: arria10: Wait for fifo empty after writing bitstream Paweł Anikiel
2022-04-11 18:35   ` Simon Glass
2022-04-01 12:43 ` [PATCH 11/11] socfpga: arria10: Allow dcache_enable before relocation Paweł Anikiel
2022-04-11 18:35   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220401124325.1810108-5-pan@semihalf.com \
    --to=pan@semihalf.com \
    --cc=adrian.fiergolski@fastree3d.com \
    --cc=andre.przywara@arm.com \
    --cc=christianshewitt@gmail.com \
    --cc=elly.siew.chin.lim@intel.com \
    --cc=festevam@denx.de \
    --cc=jagan@amarulasolutions.com \
    --cc=marek.behun@nic.cz \
    --cc=marex@denx.de \
    --cc=michal.simek@xilinx.com \
    --cc=mw@semihalf.com \
    --cc=narmstrong@baylibre.com \
    --cc=paul.liu@linaro.org \
    --cc=pbrobinson@gmail.com \
    --cc=simon.k.r.goldschmidt@gmail.com \
    --cc=sjg@chromium.org \
    --cc=tharvey@gateworks.com \
    --cc=tien.fong.chee@intel.com \
    --cc=u-boot@lists.denx.de \
    --cc=wd@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox