Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59921C433EF for ; Fri, 17 Jun 2022 10:48:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 143C5843DD; Fri, 17 Jun 2022 12:48:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=semihalf.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=semihalf.com header.i=@semihalf.com header.b="UFyGqhGm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5936F84435; Fri, 17 Jun 2022 12:47:55 +0200 (CEST) Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DD48D843E3 for ; Fri, 17 Jun 2022 12:47:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=semihalf.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pan@semihalf.com Received: by mail-lj1-x22d.google.com with SMTP id v8so4306744ljj.8 for ; Fri, 17 Jun 2022 03:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XP7CM0rLkCwtV5DIh5IMWNGsnrsD7dk/7JazTWFD9Vc=; b=UFyGqhGmFFbDh8i+GDq4TZB1T3ZC2YnYTkekxTov6DupkMiqd3ZhGLL3ZfAiFMp36P bmm72uj1J7P+ufen3rtes6p8dEJzsXLip2X8NR0DiXVddkt1G7tYeD56MuRgKmoAfb98 +8KHmJWEgf8wAo4yTk0MDXQr4ZCCvTXtlMVt8KgCSibAZHT9XZNt6Yqh8n/MGFx7IhQP uvfyllZcdwQE+cdPI6zQRrvfEdJrMOzUWCKu6knnBWG23J19rrYlWEx/WlapS2nNDUJB tqQbNeTADQNO9w6y4BR8vJgzRr4X0F3Epzz4TuvK5eftj5oCbRXm7h+fFTFAycFYu7x8 SXgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XP7CM0rLkCwtV5DIh5IMWNGsnrsD7dk/7JazTWFD9Vc=; b=ikk5c2b/sWWYo6Xo7bx1wCxn2TbcmckSO91IXgCeyxjCOkcjpIRdPxa6gJ200Pw/Tb nZzu8I+jscAVi+ZI6HrkGGIsnymArJO2rPEYEXAOH5RU4qqABsC6fW2SvvterMlWZgRy V9ZL8QCt7/T11Rx6775VvnsfvKU1ef51U4uOzkcumAiB7OPdy5QYFzf1J4HP/qJAeucn UbNk6gDVG8Hb0DedXIasis7o49jJF2o12DOVpkzCLd7YURZ656bQUVd5CBkoL7PHllEs 0qrjD5bnNM5vB0NmOK9qPXazo/DP62fbXGpFXjWmp+P026y5+PH8oxO3gQzWLvcTeKXA 1y7Q== X-Gm-Message-State: AJIora/LXZqCQXmwl+DlftoArV3Lz74tWrdnf8lW9cwQjbhZIzwkFegM Qz55eqVnysda6q2/s5Iyq1s/cw== X-Google-Smtp-Source: AGRyM1t0YrDWcGNnVH0jASvjOwkc9st72lrlWWgkgkn1y2CBgGNecjV8F3AEGoUb20QtAYtDteJR/g== X-Received: by 2002:a2e:bc28:0:b0:255:8c76:3d22 with SMTP id b40-20020a2ebc28000000b002558c763d22mr4810859ljf.308.1655462869131; Fri, 17 Jun 2022 03:47:49 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-204-250.toya.net.pl. [31.182.204.250]) by smtp.gmail.com with ESMTPSA id a17-20020ac25e71000000b00479342519e5sm592379lfr.210.2022.06.17.03.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 03:47:48 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= 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, upstream@semihalf.com, amstan@chromium.org, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH v3 04/11] board: Add Chameleonv3 board dir Date: Fri, 17 Jun 2022 12:47:19 +0200 Message-Id: <20220617104726.158688-5-pan@semihalf.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617104726.158688-1-pan@semihalf.com> References: <20220617104726.158688-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Add board directory for Google Chameleon V3 board Signed-off-by: Paweł Anikiel Reviewed-by: Simon Glass --- 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 +#include +#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 +#include +#include +#include +#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.36.1.476.g0c4daa206d-goog