From patchwork Fri Aug 9 18:08:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 818123 Delivered-To: patch@linaro.org Received: by 2002:a5d:5711:0:b0:367:895a:4699 with SMTP id a17csp421037wrv; Fri, 9 Aug 2024 11:10:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUfUaM1cmel+Xgnm4B2MXFN5PfKX5DUw2OmbZCDu7c3z8zLgIJaiIWTNcNdahtIikQY4JZgj92hAcLkm3xhliEl X-Google-Smtp-Source: AGHT+IEYd2Q7f2NZTGH25FTuH8RWBo2Pm5P8r9K5UszYx9SSsaJu9U4ptAjFWGZGSyHTo5Qrjna8 X-Received: by 2002:a05:620a:44c1:b0:79f:b3d:bed1 with SMTP id af79cd13be357-7a4c1880efbmr282660085a.49.1723227017749; Fri, 09 Aug 2024 11:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723227017; cv=none; d=google.com; s=arc-20160816; b=hwX8tNPdjCrUflXC4pwd3DqHnGrC/tPKjf5El+NEYb52D3ivn9l+keqgvLskeWI48q c2Owy3gGKqSrNi45AGX4+rxqHHL+77LXgiK59HoqNICruJvH2WRzs/+JLhjdAo8sSDY+ bBrBqA6EaDyNgVY8N4uneswEQ5PdzlSMPjdSZzPtswk024+sTj7UsnX6f54Y1Kgpma2D owTM5/57aqF4T+lPw1+MwmsU5z+uGeNc5STjkv5ZEgcxCfS49E0Vycl2wSnGoX2wHfQx DjntDCsW1thad6lvXznfyzWEV2oySkxateKM5idwfUgTveemqUsE4x2d+dCAiFadZ0CQ aptw== 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=y9/XnuauRRdGNB5+R3kAgyNx59VWh+he+xrVnHsAoO8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=JFDLZ6Zx5a4QpYcg2HcPIGGD8UnARx5xQ+8L2gGopJhXAPf+Ywi1qwADc+h/pXfnW9 qGSIvi1//q4V5pBcIUykaygJ7K4Qn/hYigFsmaK82pyESfF1h1n7y5eHZNqAMsCd9sqF B3rr+8V2Gb5mmYb9YVBBhprWgEcheeDKCbLrxtN64v/QrpCGgBniR+3LgW0dx7EY6z9/ 6urKxx+qjh3HsUWa5xBeqgG433hjQvmitvyQeasYJ1YUZiPNAmkuImW76MIRc75J4oIY IO+RD5AIHfD8PUHN9tYFZKfJ6FbcYYa3AYTh5HT1AR35cWBdLrBOKrjFjOh5QSztKVpi /bKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zf5WlLYe; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a4c7e2560asi3526585a.784.2024.08.09.11.10.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Aug 2024 11:10:17 -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=Zf5WlLYe; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1scU3G-0002rz-9k; Fri, 09 Aug 2024 14:09:22 -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 1scU38-0002cJ-28 for qemu-devel@nongnu.org; Fri, 09 Aug 2024 14:09:14 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1scU36-0007Ez-5L for qemu-devel@nongnu.org; Fri, 09 Aug 2024 14:09:13 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-36868fcb919so1413442f8f.2 for ; Fri, 09 Aug 2024 11:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723226950; x=1723831750; darn=nongnu.org; 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=y9/XnuauRRdGNB5+R3kAgyNx59VWh+he+xrVnHsAoO8=; b=Zf5WlLYe0k7jXqj6Xfq2eJinHrjFah5/m/KCXTDCO0EaQ3cDkb6+5+bP833kYdha6M I4svKiIWNByLIavroP3mxCKOa4EdVSnbpLBmexStsRnZ5tZCEmJmfb8B5z9L1whZ/qLf ruDMROuWpX3l8NG0oYdiVyW1RB3znKvY65U2yD5V64GMRFhMlZK/bMxUiquFANr+d6UU hfTpyimC4NIJVhTxvBjR8idVLz6o9A4zYP77rXBFb/NeZblBCNuafn3QOWKKyNyqFNZX darFQM9fN3B4h+9HoWBmQSqs77fmsdXk2X85CRHXcMYz3k+qWBpapXEmqBvXp0Yxow+b honw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723226950; x=1723831750; 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=y9/XnuauRRdGNB5+R3kAgyNx59VWh+he+xrVnHsAoO8=; b=XD4Q+dCmilA/9tPYydOVyecSYxxiPjeLOqbVZybExUVGIlVBku5xPQDaHHASezh52+ QJ4m5OjBo+GK6FhSihPklZmn70smLBqnhJ0nLtt8t1NycqSmahDQSZy2IsTkHSNcpLn1 m6Baa8bF6riqD4kxLJSwB9gok2QNv71PtyG9zvlalp9htkgM5j2tmRDrs2kuCw6e+vLL v4h7N36zvSZrzTOhemVU7W9IjaZ5/QrWugluowuaVatATXIHWXsXE16NHylhMmVvJT/6 kpJ//zKWpd3ZB7sReGe44NfB69C37RvcN6cji8Xgep7eTKaiNa8hQl1ZT6L0EDSrQ8ww A8cg== X-Gm-Message-State: AOJu0YwsadN3X2HgCF1lID2ELlp9HfJRG/nERdBo/MK0fTBP102tz+I7 uUmpQxbnY1h7GAza6vNMKL80GDBgdODBMzF1WvhPpdR+9bwuKkZD5AQ2zBIfoZmMB9l1mxhjXZ4 t X-Received: by 2002:adf:fe8b:0:b0:363:e0e2:eeff with SMTP id ffacd0b85a97d-36d5fa9d8b5mr2193544f8f.20.1723226950594; Fri, 09 Aug 2024 11:09:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4c937b6esm132262f8f.32.2024.08.09.11.09.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 11:09:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/11] arm/virt: place power button pin number on a define Date: Fri, 9 Aug 2024 19:08:35 +0100 Message-Id: <20240809180835.1243269-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809180835.1243269-1-peter.maydell@linaro.org> References: <20240809180835.1243269-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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: Mauro Carvalho Chehab Having magic numbers inside the code is not a good idea, as it is error-prone. So, instead, create a macro with the number definition. Link: https://lore.kernel.org/qemu-devel/CAFEAcA-PYnZ-32MRX+PgvzhnoAV80zBKMYg61j2f=oHaGfwSsg@mail.gmail.com/ Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Message-id: ef0e7f5fca6cd94eda415ecee670c3028c671b74.1723121692.git.mchehab+huawei@kernel.org Suggested-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/arm/virt.h | 3 +++ hw/arm/virt-acpi-build.c | 6 +++--- hw/arm/virt.c | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index ab961bb6a9b..a4d937ed45a 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -47,6 +47,9 @@ /* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */ #define PVTIME_SIZE_PER_CPU 64 +/* GPIO pins */ +#define GPIO_PIN_POWER_BUTTON 3 + enum { VIRT_FLASH, VIRT_MEM, diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index e10cad86dd7..f76fb117adf 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -154,10 +154,10 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, aml_append(dev, aml_name_decl("_CRS", crs)); Aml *aei = aml_resource_template(); - /* Pin 3 for power button */ - const uint32_t pin_list[1] = {3}; + + const uint32_t pin = GPIO_PIN_POWER_BUTTON; aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, - AML_EXCLUSIVE, AML_PULL_UP, 0, pin_list, 1, + AML_EXCLUSIVE, AML_PULL_UP, 0, &pin, 1, "GPO0", NULL, 0)); aml_append(dev, aml_name_decl("_AEI", aei)); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 719e83e6a1e..687fe0bb8bc 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1004,7 +1004,7 @@ static void virt_powerdown_req(Notifier *n, void *opaque) if (s->acpi_dev) { acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS); } else { - /* use gpio Pin 3 for power button event */ + /* use gpio Pin for power button event */ qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); } } @@ -1013,7 +1013,8 @@ static void create_gpio_keys(char *fdt, DeviceState *pl061_dev, uint32_t phandle) { gpio_key_dev = sysbus_create_simple("gpio-key", -1, - qdev_get_gpio_in(pl061_dev, 3)); + qdev_get_gpio_in(pl061_dev, + GPIO_PIN_POWER_BUTTON)); qemu_fdt_add_subnode(fdt, "/gpio-keys"); qemu_fdt_setprop_string(fdt, "/gpio-keys", "compatible", "gpio-keys"); @@ -1024,7 +1025,7 @@ static void create_gpio_keys(char *fdt, DeviceState *pl061_dev, qemu_fdt_setprop_cell(fdt, "/gpio-keys/poweroff", "linux,code", KEY_POWER); qemu_fdt_setprop_cells(fdt, "/gpio-keys/poweroff", - "gpios", phandle, 3, 0); + "gpios", phandle, GPIO_PIN_POWER_BUTTON, 0); } #define SECURE_GPIO_POWEROFF 0