From patchwork Fri Apr 1 12:43:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 1612234 X-Patchwork-Delegate: simon.k.r.goldschmidt@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20210112.gappssmtp.com header.i=@semihalf-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=FFXmPRDJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KVLyK6SnXz9sXM for ; Sat, 2 Apr 2022 00:44:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F25984301; Fri, 1 Apr 2022 15:42:43 +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.20210112.gappssmtp.com header.i=@semihalf-com.20210112.gappssmtp.com header.b="FFXmPRDJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A46E1842A9; Fri, 1 Apr 2022 14:44:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 5150F842D4 for ; Fri, 1 Apr 2022 14:44:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=semihalf.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=pan@semihalf.com Received: by mail-wr1-x431.google.com with SMTP id r13so4061300wrr.9 for ; Fri, 01 Apr 2022 05:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y13a9xWgNOsT7gtUv8xay99OvRjYBBtB/OO2Jr/nhYM=; b=FFXmPRDJYpJnnyZT8SFdCDjrcSVK4f2cu3rS3YOOV+1iq8pQ/Y6moRmIIPPLxspYXY 6oBWLL2uZ6cWwsj1QC5chuJMAqL3NHNUOejKMF4tLocYQG+BH+2RPwDhXO4fi7duZoxa TD4SK4c4sLD1snZT6gYkAhru8iHP0yo6zTKmCuHMWEM/0gLOywRH2fXcUuWvRbueFbgy 8mdwRzreDYyW3ogjOjy20gq0LgZenETOqO7QV3HmyPYKLaswxozLgdntq30ypfn9VZ5g hhvLNiY5+LJTovCOP0nPkp3p+rUC7aWZK56Yy2nPk8cf+VsViSoGjGMK6LDjOnLl1izx dsTA== 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=Y13a9xWgNOsT7gtUv8xay99OvRjYBBtB/OO2Jr/nhYM=; b=1Z15nyJUyMSSOt4Hv7GjR9NvoJV038R2qgyfKle8X/mpscNAADFzHDv0POwQCSf+KO j1NEv2WoisBZwgernyAoSkhGyLvoYZ6pi1cNf9PjdWH5li9szTb6AsatDLOnQq7oo6u3 BXie8gEuL6tGXQuSeNNXBBI50TNlcRZEQS/aTvLLHlb+e3yEHtexEXNjL3HXOyA3Q0WM 401P1JW6qn9Rd9+7IqLUeVK3wYrofw+s69tJzstfP/kHobCQw/yISBjtyLCaTV4A7AFG B7qqbPS6KHTKW22vgsn/kiSMuAxzHIy+BhFxqwolXRdp9Y7yV7X/9TuRN+BqmtU5yiSY wtYQ== X-Gm-Message-State: AOAM531tv/D3JxstZ9b0CTE7wfrpzAsZxtEykFOyFwcrqLK7lX8W7dWt 2yt3aYBdvRCFQIyeZO0305jD8g== X-Google-Smtp-Source: ABdhPJyoqRCRGFUDA1zbCzeK9x/XB3zWS6+3Yjk0WwOl5UhhQl550qNWN2yZI0oNSDek8ramO9zTXw== X-Received: by 2002:a05:6000:2ca:b0:205:9e2d:ae37 with SMTP id o10-20020a05600002ca00b002059e2dae37mr7412903wry.128.1648817047896; Fri, 01 Apr 2022 05:44:07 -0700 (PDT) Received: from localhost.localdomain ([85.191.191.191]) by smtp.gmail.com with ESMTPSA id o10-20020a5d47ca000000b00203fb25165esm2478175wrc.6.2022.04.01.05.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Apr 2022 05:44:07 -0700 (PDT) From: =?utf-8?q?Pawe=C5=82_Anikiel?= 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, =?utf-8?q?Pawe=C5=82_Anikiel?= Subject: [PATCH 04/11] board: Add Chameleonv3 board dir Date: Fri, 1 Apr 2022 14:43:18 +0200 Message-Id: <20220401124325.1810108-5-pan@semihalf.com> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog In-Reply-To: <20220401124325.1810108-1-pan@semihalf.com> References: <20220401124325.1810108-1-pan@semihalf.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 01 Apr 2022 15:42:19 +0200 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);