From nobody Mon Nov 25 09:37:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716062754; cv=none; d=zohomail.com; s=zohoarc; b=I7hk7bGkC1CVlRl2+jfHk9icj0hiFycrKqefrv4jN4sQA91vGnMQOuPMxPjURqxYaTeepXrcdsIJMUr4ccCAWuG6CURhPB+iWdWmO3/uLuvc1S+HN/L9EaDHQaPUQgYAI3AbmJ0y2PKiwtABdkKBcLTMonwmEm3QoLBPgtR6e34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716062754; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ysgP+yPDGO8uiEFIfsYLuz5Skf20J+l+VBft06aJ5hI=; b=DMhrhuqfW0ONXBpkAgECSo0BPp8ZKydfYQtn+5So6ISbgLuKmFozv4b33mO4PcDRXkUsWAw/BDBcj0kDYuslZH6JEJNGHNcQcj730XwMxNnohMbmN1woB43ssvCSoN2Lh/63BOL3BL+Xk+8W9yvShgaJmMcnA8hBm1k9BRkPXFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716062754303487.80983857417107; Sat, 18 May 2024 13:05:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8QIT-0003do-GN; Sat, 18 May 2024 16:04:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8QIS-0003dV-EY; Sat, 18 May 2024 16:04:48 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8QIQ-00062N-91; Sat, 18 May 2024 16:04:48 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1ee5235f5c9so40413375ad.2; Sat, 18 May 2024 13:04:45 -0700 (PDT) Received: from localhost.localdomain ([49.47.193.102]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2ae0de0sm16637481b3a.116.2024.05.18.13.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 13:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716062684; x=1716667484; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ysgP+yPDGO8uiEFIfsYLuz5Skf20J+l+VBft06aJ5hI=; b=OlYnC3f8Sy/WCpcFUt0sCZ1KTyU5rqYYBKVSgJhcsrrNHS2l13gN3TS6SuUx4LbTdI JDRF/zp/DrkIDyTnIa+n2qRbgHBxryWht2Nc3SNixh6V8x8tsGNlHFKF0zwiGwWL6IUy 8IuWYfQcsNc8x/ALJ04KgDV/oYEgpCcS0/u1/Lk6g6u+7E8TgESgWnPz+S7+MnY4zxEb xl5rPjI+x3yeIDQHku9Jw/sRY0aqnmAptRzeHhmrkYBsPZ09VreFxirsmJOZp4coZ6Li ovVGpDKLkFMii0+FkPsTcxGnXn+9u8PJFEhXXhLiZvGRrDeGO9boRXsZe55Tx9QqJE+k Lbsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716062684; x=1716667484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ysgP+yPDGO8uiEFIfsYLuz5Skf20J+l+VBft06aJ5hI=; b=s1kbiqYJR2wS/60pTNsXtXkr4TdeKeU2JehYfYg/Ez9Ba/Y07TQQqyGQ8cNk5AWM2u gTXnqDXL86TNQ+t4g8ZFuX/n81ti/+1jXDe3zXocqhEppqPqlkLtoWfZIgMjN7VZK8nL flzKQkVPBsP3lkitdLTjO5BP/FGkm+pL2i64DRk+SiCdauT/hzsRAmCDXKi0Bxt3GqnC 6HaYme8XxKGGP5N91yGwXQv+MBQlumZmjU9j9R91IAKea/Tu+W8fns0LUgut5/b32eZu qLQYRcQDVG/Ewr+D/ECz12dORdXH/GVgQU8u5vlIZ6x3axoksNhXkCRGh1d/n9Mb+SW/ nMKA== X-Forwarded-Encrypted: i=1; AJvYcCW9NOiB5TIXCZgs9V6LczgJhShQ7uQ/aUTZo/VDwgM1xZ1KHeCEXVCYoO+MFCV594XmE+7CDUZAcKjcasZGCAjc4SaQ X-Gm-Message-State: AOJu0YwrzhMFVJn8Z2PD33Vrz2Hpl+YEBS0Nrwl6MzRBWHmyh7xpRXrv YataKOPBmGqBskkvRvlD7XRQyEaMNUZxZnXBG/zQnlZXlidaCsqQ6srY/A== X-Google-Smtp-Source: AGHT+IFcJ7MSpeUTXFdnakT8D39Dhf4dRHuMMTyVB5ODGEhWXq+IhD3mvIjZ+RAgmOVbDeTKN7a3pw== X-Received: by 2002:a05:6a00:995:b0:6ed:4f0e:76a8 with SMTP id d2e1a72fcca58-6f4e029c2a6mr31165997b3a.6.1716062684163; Sat, 18 May 2024 13:04:44 -0700 (PDT) From: Rayhan Faizel To: qemu-devel@nongnu.org Cc: philmd@linaro.org, peter.maydell@linaro.org, qemu-arm@nongnu.org, Rayhan Faizel Subject: [PATCH v2 1/3] hw/nvram: Add BCM2835 OTP device Date: Sun, 19 May 2024 01:31:34 +0530 Message-Id: <20240518200136.1448672-2-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240518200136.1448672-1-rayhan.faizel@gmail.com> References: <20240518200136.1448672-1-rayhan.faizel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=rayhan.faizel@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716062755708100007 Content-Type: text/plain; charset="utf-8" The OTP device registers are currently stubbed. For now, the device houses the OTP rows which will be accessed directly by other peripherals. Signed-off-by: Rayhan Faizel --- hw/nvram/bcm2835_otp.c | 187 +++++++++++++++++++++++++++++++++ hw/nvram/meson.build | 1 + include/hw/nvram/bcm2835_otp.h | 67 ++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 hw/nvram/bcm2835_otp.c create mode 100644 include/hw/nvram/bcm2835_otp.h diff --git a/hw/nvram/bcm2835_otp.c b/hw/nvram/bcm2835_otp.c new file mode 100644 index 0000000000..c4aed28472 --- /dev/null +++ b/hw/nvram/bcm2835_otp.c @@ -0,0 +1,187 @@ +/* + * BCM2835 One-Time Programmable (OTP) Memory + * + * The OTP implementation is mostly a stub except for the OTP rows + * which are accessed directly by other peripherals such as the mailbox. + * + * The OTP registers are unimplemented due to lack of documentation. + * + * Copyright (c) 2024 Rayhan Faizel + * + * SPDX-License-Identifier: MIT + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "hw/nvram/bcm2835_otp.h" +#include "migration/vmstate.h" + +/* OTP rows are 1-indexed */ +uint32_t bcm2835_otp_get_row(BCM2835OTPState *s, unsigned int row) +{ + assert(row <=3D BCM2835_OTP_ROW_COUNT && row >=3D 1); + + return s->otp_rows[row - 1]; +} + +void bcm2835_otp_set_row(BCM2835OTPState *s, unsigned int row, + uint32_t value) +{ + assert(row <=3D BCM2835_OTP_ROW_COUNT && row >=3D 1); + + /* Real OTP rows work as e-fuses */ + s->otp_rows[row - 1] |=3D value; +} + +static uint64_t bcm2835_otp_read(void *opaque, hwaddr addr, unsigned size) +{ + switch (addr) { + case BCM2835_OTP_BOOTMODE_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_BOOTMODE_REG\n"); + break; + case BCM2835_OTP_CONFIG_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_CONFIG_REG\n"); + break; + case BCM2835_OTP_CTRL_LO_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_CTRL_LO_REG\n"); + break; + case BCM2835_OTP_CTRL_HI_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_CTRL_HI_REG\n"); + break; + case BCM2835_OTP_STATUS_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_STATUS_REG\n"); + break; + case BCM2835_OTP_BITSEL_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_BITSEL_REG\n"); + break; + case BCM2835_OTP_DATA_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_DATA_REG\n"); + break; + case BCM2835_OTP_ADDR_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_ADDR_REG\n"); + break; + case BCM2835_OTP_WRITE_DATA_READ_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_WRITE_DATA_READ_REG\n"); + break; + case BCM2835_OTP_INIT_STATUS_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_INIT_STATUS_REG\n"); + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, add= r); + } + + return 0; +} + +static void bcm2835_otp_write(void *opaque, hwaddr addr, + uint64_t value, unsigned int size) +{ + switch (addr) { + case BCM2835_OTP_BOOTMODE_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_BOOTMODE_REG\n"); + break; + case BCM2835_OTP_CONFIG_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_CONFIG_REG\n"); + break; + case BCM2835_OTP_CTRL_LO_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_CTRL_LO_REG\n"); + break; + case BCM2835_OTP_CTRL_HI_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_CTRL_HI_REG\n"); + break; + case BCM2835_OTP_STATUS_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_STATUS_REG\n"); + break; + case BCM2835_OTP_BITSEL_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_BITSEL_REG\n"); + break; + case BCM2835_OTP_DATA_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_DATA_REG\n"); + break; + case BCM2835_OTP_ADDR_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_ADDR_REG\n"); + break; + case BCM2835_OTP_WRITE_DATA_READ_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_WRITE_DATA_READ_REG\n"); + break; + case BCM2835_OTP_INIT_STATUS_REG: + qemu_log_mask(LOG_UNIMP, + "bcm2835_otp: BCM2835_OTP_INIT_STATUS_REG\n"); + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, add= r); + } +} + +static const MemoryRegionOps bcm2835_otp_ops =3D { + .read =3D bcm2835_otp_read, + .write =3D bcm2835_otp_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static void bcm2835_otp_realize(DeviceState *dev, Error **errp) +{ + BCM2835OTPState *s =3D BCM2835_OTP(dev); + memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_otp_ops, s, + TYPE_BCM2835_OTP, 0x80); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); + + memset(s->otp_rows, 0x00, sizeof(s->otp_rows)); +} + +static const VMStateDescription vmstate_bcm2835_otp =3D { + .name =3D TYPE_BCM2835_OTP, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_ARRAY(otp_rows, BCM2835OTPState, BCM2835_OTP_ROW_CO= UNT), + VMSTATE_END_OF_LIST() + } +}; + +static void bcm2835_otp_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D bcm2835_otp_realize; + dc->vmsd =3D &vmstate_bcm2835_otp; +} + +static const TypeInfo bcm2835_otp_info =3D { + .name =3D TYPE_BCM2835_OTP, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(BCM2835OTPState), + .class_init =3D bcm2835_otp_class_init, +}; + +static void bcm2835_otp_register_types(void) +{ + type_register_static(&bcm2835_otp_info); +} + +type_init(bcm2835_otp_register_types) diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build index 4996c72456..10f3639db6 100644 --- a/hw/nvram/meson.build +++ b/hw/nvram/meson.build @@ -1,5 +1,6 @@ system_ss.add(files('fw_cfg-interface.c')) system_ss.add(files('fw_cfg.c')) +system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_otp.c')) system_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c')) system_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c')) system_ss.add(when: 'CONFIG_NMC93XX_EEPROM', if_true: files('eeprom93xx.c'= )) diff --git a/include/hw/nvram/bcm2835_otp.h b/include/hw/nvram/bcm2835_otp.h new file mode 100644 index 0000000000..6d4f2937e2 --- /dev/null +++ b/include/hw/nvram/bcm2835_otp.h @@ -0,0 +1,67 @@ +/* + * BCM2835 One-Time Programmable (OTP) Memory + * + * Copyright (c) 2024 Rayhan Faizel + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BCM2835_OTP_H +#define BCM2835_OTP_H + +#include "hw/sysbus.h" +#include "qom/object.h" + +#define TYPE_BCM2835_OTP "bcm2835-otp" +OBJECT_DECLARE_SIMPLE_TYPE(BCM2835OTPState, BCM2835_OTP) + +#define BCM2835_OTP_ROW_COUNT 66 + +/* https://elinux.org/BCM2835_registers#OTP */ +#define BCM2835_OTP_BOOTMODE_REG 0x00 +#define BCM2835_OTP_CONFIG_REG 0x04 +#define BCM2835_OTP_CTRL_LO_REG 0x08 +#define BCM2835_OTP_CTRL_HI_REG 0x0c +#define BCM2835_OTP_STATUS_REG 0x10 +#define BCM2835_OTP_BITSEL_REG 0x14 +#define BCM2835_OTP_DATA_REG 0x18 +#define BCM2835_OTP_ADDR_REG 0x1c +#define BCM2835_OTP_WRITE_DATA_READ_REG 0x20 +#define BCM2835_OTP_INIT_STATUS_REG 0x24 + + +/* -- Row 32: Undocumented -- */ + +#define BCM2835_OTP_ROW_32 32 + +/* Lock OTP Programming (Customer OTP and private key) */ +#define BCM2835_OTP_ROW_32_LOCK BIT(6) + +/* -- Row 36-43: Customer OTP -- */ + +#define BCM2835_OTP_CUSTOMER_OTP 36 +#define BCM2835_OTP_CUSTOMER_OTP_LEN 8 + +/* Magic numbers to lock programming of customer OTP and private key */ +#define BCM2835_OTP_LOCK_NUM1 0xffffffff +#define BCM2835_OTP_LOCK_NUM2 0xaffe0000 + +/* -- Row 56-63: Device-specific private key -- */ + +#define BCM2835_OTP_PRIVATE_KEY 56 +#define BCM2835_OTP_PRIVATE_KEY_LEN 8 + +struct BCM2835OTPState { + /* */ + SysBusDevice parent_obj; + + /* */ + MemoryRegion iomem; + uint32_t otp_rows[66]; +}; + + +uint32_t bcm2835_otp_get_row(BCM2835OTPState *s, unsigned int row); +void bcm2835_otp_set_row(BCM2835OTPState *s, unsigned int row, uint32_t va= lue); + +#endif --=20 2.34.1 From nobody Mon Nov 25 09:37:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716062771; cv=none; d=zohomail.com; s=zohoarc; b=PByHv7cmjUi/IODUpgXoGetZF+mEw/7w3BM3y9/mrGdSxfTacihm2sK7w6g9nKngdemhvPbW2PkFDhsHRvi3nG6HEDpq9JjZoyC1BaFjpGEMf2vv06+vYMoQSkJ8e18btGdD/VIz0ke7+7YeEU/BnrF8Z90WeV8fwRdcNIC/9eA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716062771; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nR1fFYfnhfe8OWUbCv/jg5IVIW3zj6nZbcBspKeIn5Q=; b=FK/lyU0VQty4995clJUtSjYeltORuRVO7O/msG1aDRSZWSXfi48VZtGi850ZMzMWZe8sK1fucheX/Sc9FLF15nJuxzuMcV+JqvawcLt8+1CMV1IbAMElQEuK0gOKAhiExvfST772a4Jb3vLf+mQgbqZbXH8Ahu+AIuOIpb1VlVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716062771261999.6038486511713; Sat, 18 May 2024 13:06:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8QIW-0003en-5Y; Sat, 18 May 2024 16:04:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8QIU-0003eQ-Qc; Sat, 18 May 2024 16:04:50 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8QIT-00062k-6n; Sat, 18 May 2024 16:04:50 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6f4302187c0so1692916b3a.1; Sat, 18 May 2024 13:04:48 -0700 (PDT) Received: from localhost.localdomain ([49.47.193.102]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2ae0de0sm16637481b3a.116.2024.05.18.13.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 13:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716062687; x=1716667487; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nR1fFYfnhfe8OWUbCv/jg5IVIW3zj6nZbcBspKeIn5Q=; b=CuekIlHJMGPeFTzwSjASRjhyrGFIe7DZvudEmnQ6gGiuA4ZVB2xBfg093BfX3TTv6F rSCa7E19Oc48vAB06331CxfemKEQue4ENYzFPGG6jN7v84N+106Tfodh6/C7hq0xdg6l VpolAf7xhJY1pZlxvSy8eQKQEzi0sEJNh2ksMelRrhNMrZelhxCHjTg0A4KeocvnMu1B CvPHHD3kRwDEqgon7/1uZ28ipIDVm2/PoKPULZeyVT79IbJo4YbfEDLJ1GRooFNpHXka JccyMImIYTZ3mDPe8tIo988bkbNcFHnDs5TVJ2s0T0oSbkMHYlD+7CE/orvQdQuGrmru 4Pvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716062687; x=1716667487; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nR1fFYfnhfe8OWUbCv/jg5IVIW3zj6nZbcBspKeIn5Q=; b=vl9J8ylOnfzchbpoXSnyBbtVByiLXDt7To1xhWnUH/rXgMSaz8CcUt1bEwZXrxh6xC oHZ+WBvP+wqQFvDd1NhzFq2EUMXMNeUi+5zMMuCcNHIjXlQ0LSvIpDM7ZG+eowZvBkuQ YoxnYm0UTFhBr/DNfVIr28j6rQejCv7NKMsJl/CPsxq1ky9vLoy9Z+e8I7HT7Tpr0h/y OAW7TFCC8R/3/4J/05En6xLwL4JIDyr5mtYGEbKjReFiOjyn0umJXEtnd5cdRqSdgOtj 2hR8UfvOy+oAyiiI2v/4OwvUfETB5ckZAoUkrRhKQg8WOFMt/lI9zb0ki4lnhRo4ZfEL lknw== X-Forwarded-Encrypted: i=1; AJvYcCXeXx7N1Lric7ElccrqwKk6yh3rSgXNHw6NbZl8yM64vvuRTMLogsR0Id0OF5zb4UwEBVy4U8ngbJDLJX0gjirVDwcp X-Gm-Message-State: AOJu0YwS6zQjQBmxBkrRFOE3FBVXuZPijj1m4y24zED2O7vsY8wv27l0 YfLvfdxS6O+U75X7BSoFIXq/H4EIA7jl2t8s2RHjo8H94GYD6UQ0Ih0M9w== X-Google-Smtp-Source: AGHT+IGXYgeZ921Lu3BijGCvIvEJoD8KZE4qEF2C1j3hD9AHlEnb8AvnJa4rumDEMuk/bf0KORcomQ== X-Received: by 2002:a05:6a20:3949:b0:1af:58f8:1190 with SMTP id adf61e73a8af0-1b1ca3c3ebfmr3180971637.12.1716062686671; Sat, 18 May 2024 13:04:46 -0700 (PDT) From: Rayhan Faizel To: qemu-devel@nongnu.org Cc: philmd@linaro.org, peter.maydell@linaro.org, qemu-arm@nongnu.org, Rayhan Faizel Subject: [PATCH v2 2/3] hw/arm: Connect OTP device to BCM2835 Date: Sun, 19 May 2024 01:31:35 +0530 Message-Id: <20240518200136.1448672-3-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240518200136.1448672-1-rayhan.faizel@gmail.com> References: <20240518200136.1448672-1-rayhan.faizel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=rayhan.faizel@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716062771797100001 Content-Type: text/plain; charset="utf-8" Replace stubbed OTP memory region with the new OTP device. Signed-off-by: Rayhan Faizel --- hw/arm/bcm2835_peripherals.c | 13 ++++++++++++- include/hw/arm/bcm2835_peripherals.h | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 1695d8b453..7d735bb56c 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -116,6 +116,10 @@ static void raspi_peripherals_base_init(Object *obj) object_property_add_const_link(OBJECT(&s->fb), "dma-mr", OBJECT(&s->gpu_bus_mr)); =20 + /* OTP */ + object_initialize_child(obj, "bcm2835-otp", &s->otp, + TYPE_BCM2835_OTP); + /* Property channel */ object_initialize_child(obj, "property", &s->property, TYPE_BCM2835_PROPERTY); @@ -374,6 +378,14 @@ void bcm_soc_peripherals_common_realize(DeviceState *d= ev, Error **errp) sysbus_connect_irq(SYS_BUS_DEVICE(&s->fb), 0, qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_FB)); =20 + /* OTP */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->otp), errp)) { + return; + } + + memory_region_add_subregion(&s->peri_mr, OTP_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->otp), 0)); + /* Property channel */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->property), errp)) { return; @@ -500,7 +512,6 @@ void bcm_soc_peripherals_common_realize(DeviceState *de= v, Error **errp) create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100); create_unimp(s, &s->bscsl, "bcm2835-spis", BSC_SL_OFFSET, 0x100); - create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80); create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000); create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000); create_unimp(s, &s->v3d, "bcm2835-v3d", V3D_OFFSET, 0x1000); diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_= peripherals.h index 636203baa5..1eeaeec9e0 100644 --- a/include/hw/arm/bcm2835_peripherals.h +++ b/include/hw/arm/bcm2835_peripherals.h @@ -33,6 +33,7 @@ #include "hw/usb/hcd-dwc2.h" #include "hw/ssi/bcm2835_spi.h" #include "hw/i2c/bcm2835_i2c.h" +#include "hw/nvram/bcm2835_otp.h" #include "hw/misc/unimp.h" #include "qom/object.h" =20 @@ -71,7 +72,7 @@ struct BCMSocPeripheralBaseState { BCM2835SPIState spi[1]; BCM2835I2CState i2c[3]; OrIRQState orgated_i2c_irq; - UnimplementedDeviceState otp; + BCM2835OTPState otp; UnimplementedDeviceState dbus; UnimplementedDeviceState ave0; UnimplementedDeviceState v3d; --=20 2.34.1 From nobody Mon Nov 25 09:37:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716062773; cv=none; d=zohomail.com; s=zohoarc; b=oEr1WkwKrsl65XzfbuwXoVwPkXj+mxZ8AnBPzlos48Bnkh5d665r4qp1I9YGUZN8RpWX0aqh51se0/2mgFuKOQNHcBer8MPkKKTvHF2PdLnxPW1UqA1+fl5ZFG9kUiePawqjWih+CG6pXEm7gWhVxyoH8f3URQFNRJgV2IzO/Oc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716062773; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aaz6YUca/EDsN6sz3NrbzFJ3pzsAImLY6LO7ZyVY8kw=; b=Gxj6j8ngHcthRqNxgZOMTFKG/Bi/p3nSc0UbWOEh1b1khq61MlTJfL6pFFgrASVUGKNzADnwseizs0DE4rMj15yvTEFEG5taVNOlo9MEbQ3JgTptBi0EjyBzUEt42YbP83OtCAXknbvTC/1dY4y27awYZJR6v0avGA+PUN1NyOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716062773286455.52768757902163; Sat, 18 May 2024 13:06:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8QIY-0003g5-3V; Sat, 18 May 2024 16:04:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8QIW-0003fN-UR; Sat, 18 May 2024 16:04:52 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8QIV-00062y-4N; Sat, 18 May 2024 16:04:52 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ee5235f5c9so40414735ad.2; Sat, 18 May 2024 13:04:50 -0700 (PDT) Received: from localhost.localdomain ([49.47.193.102]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2ae0de0sm16637481b3a.116.2024.05.18.13.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 13:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716062689; x=1716667489; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aaz6YUca/EDsN6sz3NrbzFJ3pzsAImLY6LO7ZyVY8kw=; b=XpjwQjIWp4YXUbksCREuwjvBm4K0xBBx+uqhDTrbsKi8LDo+mgcmlqoYW/MS/8cu33 3MkeIzmraP9EQ6dXN0ufiLoShOJZX39JY9q0n9n4f4JZKk4Zb1KxucgtQMJyXzz1pEBN 7pq8CX2e7g+VoLQrjXOpSJSGyAOOR4dFkBI8kuk6S3uqxXCHeMhPpSqipbk2HUEUGedY E7Kd8iDVmGAUG2hUCL0oRaWCne91xgvbZ5us/F0UhCz3TeEKaBaXTMERPH1OseI6GlhG 8NtjVVwojSQaRowdVt3YGx5W+84SoVGKJpr9L82tpcvQagNrqKze61WuhtjSHOFkNeHH FnGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716062689; x=1716667489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aaz6YUca/EDsN6sz3NrbzFJ3pzsAImLY6LO7ZyVY8kw=; b=AFXPFP7ZlS9np5PBBlYqYClTavwnZVj9W/VWbkWqWg3aDGTURriaRBfsFwLXItpNCp vSIkcWIuAiRVCRT/tldyaGuHwAJ2mQg1uKGCKknQO3efRfgS2e8AkN2C1dWTt3p9To20 JK8bd2A+cFskhcZbioNH2LleYi8MqQSZOMJ59rP8dWFUbH75e3oDX98jhl3TEbU4Zgwd B/xtOGmrR2NBzulRkFv/7V3ILXBE8yroaRcnZkJZstI8vlMRfIkmvliIrT28tDM60MKg WxNcEtTmbomUMkaXSq67l/Qd/pA/h4E2qluqyAJeIYXv9Awi8RNjvWtP8GvUD9rFjkJC m3BQ== X-Forwarded-Encrypted: i=1; AJvYcCU/dAOPUMrjQopvDk6rk/iUjIfoQghUzJP4mAXNef+CyCXSFQNHmqarS14rLKwChZmELrk/tc9Sn4O95BFtaqzMk4aS X-Gm-Message-State: AOJu0YzVgI3alyMGfjQTC2eykAOqGP+Zmf4ogv3ZqyPAFhj1qQfVSeOo 9wz3rCcDN1acxDE60mZkZ+KcQLcGNG6QGA8oMZ4yo6GOZalzyG6MTR7igg== X-Google-Smtp-Source: AGHT+IH6N6nXiBweY4zQ5zuuoCf/WmlvPCc22QMTvqnCZt/5+5BkOYRlkMgZGAnobxQEXjgQ4+FAUg== X-Received: by 2002:a05:6a20:d487:b0:1af:f8bd:1e4e with SMTP id adf61e73a8af0-1aff8bd202dmr19259554637.62.1716062689050; Sat, 18 May 2024 13:04:49 -0700 (PDT) From: Rayhan Faizel To: qemu-devel@nongnu.org Cc: philmd@linaro.org, peter.maydell@linaro.org, qemu-arm@nongnu.org, Rayhan Faizel Subject: [PATCH v2 3/3] hw/misc: Implement mailbox properties for customer OTP and device specific private keys Date: Sun, 19 May 2024 01:31:36 +0530 Message-Id: <20240518200136.1448672-4-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240518200136.1448672-1-rayhan.faizel@gmail.com> References: <20240518200136.1448672-1-rayhan.faizel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=rayhan.faizel@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716062773747100005 Content-Type: text/plain; charset="utf-8" Four mailbox properties are implemented as follows: 1. Customer OTP: GET_CUSTOMER_OTP and SET_CUSTOMER_OTP 2. Device-specific private key: GET_PRIVATE_KEY and SET_PRIVATE_KEY. The customer OTP is located in the rows 36-43. The device-specific private = key is located in the rows 56-63. The customer OTP can be locked with the magic numbers 0xffffffff 0xaffe0000 when running the SET_CUSTOMER_OTP mailbox command. Bit 6 of row 32 indicates this lock, which is undocumented. The lock also applies to the device-speci= fic private key. Signed-off-by: Rayhan Faizel --- hw/arm/bcm2835_peripherals.c | 2 + hw/misc/bcm2835_property.c | 87 ++++++++++++++++++++++++++++ include/hw/arm/raspberrypi-fw-defs.h | 2 + include/hw/misc/bcm2835_property.h | 2 + 4 files changed, 93 insertions(+) diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 7d735bb56c..ac153a96b9 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -132,6 +132,8 @@ static void raspi_peripherals_base_init(Object *obj) OBJECT(&s->fb)); object_property_add_const_link(OBJECT(&s->property), "dma-mr", OBJECT(&s->gpu_bus_mr)); + object_property_add_const_link(OBJECT(&s->property), "otp", + OBJECT(&s->otp)); =20 /* Extended Mass Media Controller */ object_initialize_child(obj, "sdhci", &s->sdhci, TYPE_SYSBUS_SDHCI); diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index bdd9a6bbce..63de3db621 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -32,6 +32,7 @@ static void bcm2835_property_mbox_push(BCM2835PropertySta= te *s, uint32_t value) uint32_t tmp; int n; uint32_t offset, length, color; + uint32_t start_num, number, otp_row; =20 /* * Copy the current state of the framebuffer config; we will update @@ -322,6 +323,89 @@ static void bcm2835_property_mbox_push(BCM2835Property= State *s, uint32_t value) 0); resplen =3D VCHI_BUSADDR_SIZE; break; + + /* Customer OTP */ + + case RPI_FWREQ_GET_CUSTOMER_OTP: + start_num =3D ldl_le_phys(&s->dma_as, value + 12); + number =3D ldl_le_phys(&s->dma_as, value + 16); + + resplen =3D 8 + 4 * number; + + for (n =3D start_num; n < start_num + number && + n < BCM2835_OTP_CUSTOMER_OTP_LEN; n++) { + otp_row =3D bcm2835_otp_get_row(s->otp, + BCM2835_OTP_CUSTOMER_OTP + n= ); + stl_le_phys(&s->dma_as, + value + 20 + ((n - start_num) << 2), otp_row); + } + break; + case RPI_FWREQ_SET_CUSTOMER_OTP: + start_num =3D ldl_le_phys(&s->dma_as, value + 12); + number =3D ldl_le_phys(&s->dma_as, value + 16); + + resplen =3D 4; + + /* Magic numbers to permanently lock customer OTP */ + if (start_num =3D=3D BCM2835_OTP_LOCK_NUM1 && + number =3D=3D BCM2835_OTP_LOCK_NUM2) { + bcm2835_otp_set_row(s->otp, + BCM2835_OTP_ROW_32, + BCM2835_OTP_ROW_32_LOCK); + break; + } + + /* If row 32 has the lock bit, don't allow further writes */ + if (bcm2835_otp_get_row(s->otp, BCM2835_OTP_ROW_32) & + BCM2835_OTP_ROW_32_LOCK) { + break; + } + + for (n =3D start_num; n < start_num + number && + n < BCM2835_OTP_CUSTOMER_OTP_LEN; n++) { + otp_row =3D ldl_le_phys(&s->dma_as, + value + 20 + ((n - start_num) << 2)); + bcm2835_otp_set_row(s->otp, + BCM2835_OTP_CUSTOMER_OTP + n, otp_row); + } + break; + + /* Device-specific private key */ + + case RPI_FWREQ_GET_PRIVATE_KEY: + start_num =3D ldl_le_phys(&s->dma_as, value + 12); + number =3D ldl_le_phys(&s->dma_as, value + 16); + + resplen =3D 8 + 4 * number; + + for (n =3D start_num; n < start_num + number && + n < BCM2835_OTP_PRIVATE_KEY_LEN; n++) { + otp_row =3D bcm2835_otp_get_row(s->otp, + BCM2835_OTP_PRIVATE_KEY + n); + stl_le_phys(&s->dma_as, + value + 20 + ((n - start_num) << 2), otp_row); + } + break; + case RPI_FWREQ_SET_PRIVATE_KEY: + start_num =3D ldl_le_phys(&s->dma_as, value + 12); + number =3D ldl_le_phys(&s->dma_as, value + 16); + + resplen =3D 4; + + /* If row 32 has the lock bit, don't allow further writes */ + if (bcm2835_otp_get_row(s->otp, BCM2835_OTP_ROW_32) & + BCM2835_OTP_ROW_32_LOCK) { + break; + } + + for (n =3D start_num; n < start_num + number && + n < BCM2835_OTP_PRIVATE_KEY_LEN; n++) { + otp_row =3D ldl_le_phys(&s->dma_as, + value + 20 + ((n - start_num) << 2)); + bcm2835_otp_set_row(s->otp, + BCM2835_OTP_PRIVATE_KEY + n, otp_row); + } + break; default: qemu_log_mask(LOG_UNIMP, "bcm2835_property: unhandled tag 0x%08x\n", tag); @@ -449,6 +533,9 @@ static void bcm2835_property_realize(DeviceState *dev, = Error **errp) s->dma_mr =3D MEMORY_REGION(obj); address_space_init(&s->dma_as, s->dma_mr, TYPE_BCM2835_PROPERTY "-memo= ry"); =20 + obj =3D object_property_get_link(OBJECT(dev), "otp", &error_abort); + s->otp =3D BCM2835_OTP(obj); + /* TODO: connect to MAC address of USB NIC device, once we emulate it = */ qemu_macaddr_default_if_unset(&s->macaddr); =20 diff --git a/include/hw/arm/raspberrypi-fw-defs.h b/include/hw/arm/raspberr= ypi-fw-defs.h index 8b404e0533..60b8e5b451 100644 --- a/include/hw/arm/raspberrypi-fw-defs.h +++ b/include/hw/arm/raspberrypi-fw-defs.h @@ -56,6 +56,7 @@ enum rpi_firmware_property_tag { RPI_FWREQ_GET_THROTTLED =3D 0x00030046, RPI_FWREQ_GET_CLOCK_MEASURED =3D 0x00030047, RPI_FWREQ_NOTIFY_REBOOT =3D 0x00030048, + RPI_FWREQ_GET_PRIVATE_KEY =3D 0x00030081, RPI_FWREQ_SET_CLOCK_STATE =3D 0x00038001, RPI_FWREQ_SET_CLOCK_RATE =3D 0x00038002, RPI_FWREQ_SET_VOLTAGE =3D 0x00038003, @@ -73,6 +74,7 @@ enum rpi_firmware_property_tag { RPI_FWREQ_SET_PERIPH_REG =3D 0x00038045, RPI_FWREQ_GET_POE_HAT_VAL =3D 0x00030049, RPI_FWREQ_SET_POE_HAT_VAL =3D 0x00038049, + RPI_FWREQ_SET_PRIVATE_KEY =3D 0x00038081, RPI_FWREQ_SET_POE_HAT_VAL_OLD =3D 0x00030050, RPI_FWREQ_NOTIFY_XHCI_RESET =3D 0x00030058, RPI_FWREQ_GET_REBOOT_FLAGS =3D 0x00030064, diff --git a/include/hw/misc/bcm2835_property.h b/include/hw/misc/bcm2835_p= roperty.h index ba8896610c..2f93fd0c75 100644 --- a/include/hw/misc/bcm2835_property.h +++ b/include/hw/misc/bcm2835_property.h @@ -11,6 +11,7 @@ #include "hw/sysbus.h" #include "net/net.h" #include "hw/display/bcm2835_fb.h" +#include "hw/nvram/bcm2835_otp.h" #include "qom/object.h" =20 #define TYPE_BCM2835_PROPERTY "bcm2835-property" @@ -26,6 +27,7 @@ struct BCM2835PropertyState { MemoryRegion iomem; qemu_irq mbox_irq; BCM2835FBState *fbdev; + BCM2835OTPState *otp; =20 MACAddr macaddr; uint32_t board_rev; --=20 2.34.1