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 30FF3C433EF for ; Thu, 26 May 2022 14:39:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 17B858438F; Thu, 26 May 2022 16:38:55 +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="JnusL34v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1C82E84338; Thu, 26 May 2022 16:38:40 +0200 (CEST) Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) (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 9B3CF8436C for ; Thu, 26 May 2022 16:38:32 +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-lf1-x12c.google.com with SMTP id j10so2594847lfe.12 for ; Thu, 26 May 2022 07:38:32 -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=2XruWYslJyMKI3MJY5tTW2mdmkjRFt/SdzId/sbXE6Q=; b=JnusL34veg1aoEXCa/NnxFqgOgxhzuY/f+AfAowyPT/s0oOMUtC3MvhLOnbCXmwtE8 gXn/8smEzrMT/BzFKB0oEryRtfXZRWZffkVAkDWClwl5UlrIbgnH3mXU8k99rhSc4SrG /sVscdpdoSwl0MDolqjv4o3EZ6uuSD8w9Gr1oa7KC93SoPjA6YUFAuOzVHMMQ8lDECiR OMh4qw3INSwFP3SVyt1noWZmlO5q4h6pH18Nfk/ypiP1/tqaKxjgdAQWKlk8lAMw1bPh XGwm4kq3+vwHAeBrt2q7Z48uXO7uRBID+hXMtLJXz0E7NnAa50/6MFfRMA0ppTCCFscR elHQ== 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=2XruWYslJyMKI3MJY5tTW2mdmkjRFt/SdzId/sbXE6Q=; b=wPCmq2hQjjMATUAtPkbWv4wOfJFi7NcX/B7pNqll6U9O/SSTYCdRlrKbMgrCQRjlO2 rDA5wO+XQLW3rhsYJmJCDBF0WibtPhRWtb1iLsKiD1HoyGvbhN5CpKblB1Y+QNWCvA/0 GVYbIKbI7Qy2Z/kddk0T6irdh9jD7A/r2AdHW6oLw+RC6X+WR6w+Yl0mkqRBjSzwpsb9 BEw/wMqT9PSMTMxYeep9dQdBgurIWivSoxB+PiergQGw6+KIP0E9QuEo/NX6/lwHAVee eXNJOvgktZzirroURD1tIUVPDO2jQO1nyThNTVb9Vzy8SqcJfrhdVOEK5vUCLPbwJjfS 9Ogg== X-Gm-Message-State: AOAM533RwzObddf/9kvsAKXyzKtdeyOvTIthRkTjIRIbMgC9uqhjJxGZ koR6+lKuhMLwL4bCP4TzZSI5fA== X-Google-Smtp-Source: ABdhPJypbR36eUfpY7+DvNksjgFBV+B+yC/hdhH3qyo8moTIyP69oqVoYBnyWVAYNYW7AMeDHw+Dbg== X-Received: by 2002:a05:6512:2807:b0:477:b906:81af with SMTP id cf7-20020a056512280700b00477b90681afmr27553636lfb.299.1653575875693; Thu, 26 May 2022 07:37:55 -0700 (PDT) Received: from panikiel.wifi.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id s28-20020a05651c049c00b0024f3d1daea2sm464194ljc.42.2022.05.26.07.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 07:37:55 -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, mw@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH v2 04/11] board: Add Chameleonv3 board dir Date: Thu, 26 May 2022 16:37:08 +0200 Message-Id: <20220526143715.277342-5-pan@semihalf.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220526143715.277342-1-pan@semihalf.com> References: <20220526143715.277342-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 --- 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.124.g0e6072fb45-goog