From patchwork Thu Aug 24 09:28:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 716528 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp1237319wrp; Thu, 24 Aug 2023 02:33:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTQN3sinXLNJhhIMBVNWY0SkCY9LtAEtwk/C9sID0kXfSSAUKl1g1Blwmcl0DpQeFqTPfq X-Received: by 2002:a05:620a:4001:b0:763:a20c:fe8b with SMTP id h1-20020a05620a400100b00763a20cfe8bmr17926983qko.13.1692869621275; Thu, 24 Aug 2023 02:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692869621; cv=none; d=google.com; s=arc-20160816; b=JxFYqMW4NVxpPLVrbsiA7S9pR/wtZeAmxqA6pVe6/KqLjpCBn0IpNQF9Fnys8FY3Ne albf5mktsfZIYAjwjqwmM/Dmhn7NjUw+VRc1KPWbQlJTy5/uS5PjdyRJeYoGGbij37GR ZNbR6GhGk8SgEcSALPMskn/+tWij6Yx8991/Qq+CRzGdlS77niePWij6ES+AbV8lWREN G5CYiMehUf4FexkH4h8sh0H3OdcYXdNDh2ksZYIeMKyxFtNfbUBEcn4sbEv3Q/KhAZ2V vH/fJk2+3gwHxw0JJd0q+Jql/GDmmvahM37K3eK9gurQ0Lr8IpTK2yzNgr0JdtOHKHke OdQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=2+oT7kMqYhvSyyz6Tbvx+jHqU2XcDlccNKL4oRSp59M=; fh=bFDrUYhlTVi/QyetgXx/byg2+yO/22Hp9SjwoefyKLk=; b=Yn6BAp5hROCN8zLwucEYV27bPs3YZvFOi4A3i+3kLtqyRz3/A9U/7QsrscO6+b0E5F o/Y911zg5LJ9nD3pYFZiW5nR3k51mkQOYJySm4dUADZDDtlFod5/5RhKmSQVgTW90+HV jAewYEmRVDQ1Z5iM1cG3S87tSKG+QyXSFru3lNj/ALkSoCUD9888h7aaoTChBCy5vKdJ av/l7V3n0ri56pR+pczv34momdBYiFcGQn3hNhzqYEF5NvlBGzNd8D1hAFL6CiueTcxz sJ/LbckKpdLkEH52RCIdFdJXfrMETso59BJJ9c6iHAT8uiNxvaV4XYSMS8we5zXblRp9 2q/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bCR+cdV3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id eb5-20020a05620a480500b0076d87eaf26fsi923264qkb.103.2023.08.24.02.33.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Aug 2023 02:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bCR+cdV3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ6eF-0004cM-H8; Thu, 24 Aug 2023 05:29:03 -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 1qZ6e0-00044E-Dr for qemu-devel@nongnu.org; Thu, 24 Aug 2023 05:28:51 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZ6dt-0004xE-NV for qemu-devel@nongnu.org; Thu, 24 Aug 2023 05:28:46 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40078c4855fso11523085e9.3 for ; Thu, 24 Aug 2023 02:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692869318; x=1693474118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2+oT7kMqYhvSyyz6Tbvx+jHqU2XcDlccNKL4oRSp59M=; b=bCR+cdV3LRthJ+azgzC3gYabHNFv7Q8nPZgr7SMOUHQhRAY/XuqHGpBxb59Wt+8F/n HpHdmt73d6x90mKUEi91FyPA5nOPP0bQMMVXCUrne5EUDSvYIpp0l6PO/gV2uQIVROlQ EcP5s7aQakm4wLShiNStDbEqf8XDtPo06qleMrEwXPkEubzkNyHUBMemBo/rHgJiN2Ay KjM8zEB16gvxLDRRn5iEz52ycgXQjnYurZxPaM2qv007//FBkHUYT66aPYTUpQhpJP5r r99IwETjXsVkH1LUuJE2Q49rxLI01Ag5B0QSF5YgsEtvuF/aESqxEzBNl864GMlJnykv 3UrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692869318; x=1693474118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2+oT7kMqYhvSyyz6Tbvx+jHqU2XcDlccNKL4oRSp59M=; b=fsIZLaRqBuq99CpEFApeiQj9mIU1039Fra4peoecuD+m623YzJyD5WVs0u3Bgw7eUw xkOOtOpYH5aNDAmN/Xirqeu1zgKWZN/G0vRMNFYudDT5D6XbeMp6CNUxzKFf11NZPoVw 5Z0+l7thYgrrDGk1LeL3ZDuRQe0UcKZ3h6t/KrtFe6RHKIRx+c9ip5UCspmPCR6qNHzp RtigimcaOYZEuAP12kPqcq27gmZDku5LnTba00GJMPVudt4LjwmG9W+wNAyoW/0eNYek o23+jlQ+/Wemjl+ZmpzlJBZTxOMXfjfCANUeVaUYAoT6JSrT2t+aQwTl99OE/qLfARYA w7cQ== X-Gm-Message-State: AOJu0YxgLM5gkUBk2MyyhTu5zTXm7NXkg5bWfyNwdioR9nnrPDeTG+av 84NCu3x+uXYDYWiK/wVGCkbTxF3iCslpo6iUYNA= X-Received: by 2002:a1c:7908:0:b0:3fe:111b:7fc4 with SMTP id l8-20020a1c7908000000b003fe111b7fc4mr11238916wme.21.1692869318256; Thu, 24 Aug 2023 02:28:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id s12-20020adfeccc000000b00317b5c8a4f1sm21844004wro.60.2023.08.24.02.28.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 02:28:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/35] hw/gpio/nrf51: implement DETECT signal Date: Thu, 24 Aug 2023 10:28:02 +0100 Message-Id: <20230824092836.2239644-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824092836.2239644-1-peter.maydell@linaro.org> References: <20230824092836.2239644-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Chris Laplante Implement nRF51 DETECT signal in the GPIO peripheral. The reference manual makes mention of a per-pin DETECT signal, but these are not exposed to the user. See https://devzone.nordicsemi.com/f/nordic-q-a/39858/gpio-per-pin-detect-signal-available for more information. Currently, I don't see a reason to model these. Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell Message-id: 20230728160324.1159090-2-chris@laplante.io Signed-off-by: Peter Maydell --- include/hw/gpio/nrf51_gpio.h | 1 + hw/gpio/nrf51_gpio.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/hw/gpio/nrf51_gpio.h b/include/hw/gpio/nrf51_gpio.h index 8f9c2f86da3..fcfa2bac173 100644 --- a/include/hw/gpio/nrf51_gpio.h +++ b/include/hw/gpio/nrf51_gpio.h @@ -64,6 +64,7 @@ struct NRF51GPIOState { uint32_t old_out_connected; qemu_irq output[NRF51_GPIO_PINS]; + qemu_irq detect; }; diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c index b47fddf4ed6..08396c69a4b 100644 --- a/hw/gpio/nrf51_gpio.c +++ b/hw/gpio/nrf51_gpio.c @@ -78,6 +78,7 @@ static void update_state(NRF51GPIOState *s) int pull; size_t i; bool connected_out, dir, connected_in, out, in, input; + bool assert_detect = false; for (i = 0; i < NRF51_GPIO_PINS; i++) { pull = pull_value(s->cnf[i]); @@ -99,7 +100,15 @@ static void update_state(NRF51GPIOState *s) qemu_log_mask(LOG_GUEST_ERROR, "GPIO pin %zu short circuited\n", i); } - if (!connected_in) { + if (connected_in) { + uint32_t detect_config = extract32(s->cnf[i], 16, 2); + if ((detect_config == 2) && (in == 1)) { + assert_detect = true; + } + if ((detect_config == 3) && (in == 0)) { + assert_detect = true; + } + } else { /* * Floating input: the output stimulates IN if connected, * otherwise pull-up/pull-down resistors put a value on both @@ -116,6 +125,8 @@ static void update_state(NRF51GPIOState *s) } update_output_irq(s, i, connected_out, out); } + + qemu_set_irq(s->detect, assert_detect); } /* @@ -291,6 +302,7 @@ static void nrf51_gpio_init(Object *obj) qdev_init_gpio_in(DEVICE(s), nrf51_gpio_set, NRF51_GPIO_PINS); qdev_init_gpio_out(DEVICE(s), s->output, NRF51_GPIO_PINS); + qdev_init_gpio_out_named(DEVICE(s), &s->detect, "detect", 1); } static void nrf51_gpio_class_init(ObjectClass *klass, void *data)