From patchwork Fri Oct 27 14:39:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 738686 Delivered-To: patch@linaro.org Received: by 2002:a5d:5101:0:b0:32d:baff:b0ca with SMTP id s1csp473709wrt; Fri, 27 Oct 2023 07:44:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnLcjF/+kzKfxeEAO0FW+7gqbpEVRCMsLS5199wEmww4tcxrFdZxKvC6ubYzvNnag9tGWI X-Received: by 2002:a5b:88a:0:b0:d9b:ea48:e5c8 with SMTP id e10-20020a5b088a000000b00d9bea48e5c8mr2592519ybq.59.1698417850629; Fri, 27 Oct 2023 07:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698417850; cv=none; d=google.com; s=arc-20160816; b=qLfdmLTbHKVXxrUxLnUOw4B325ZAjILHbzLlLIS8QfEvgIFQblGjtpCK84S8QchKtt VOUbBDpTEQN0vsF14c+WzGyGzXiwi3TjsvCiW2fzeH/Zvifyqf0P60qz+nWLd4xPh7wN dmQ68mzckbblZxwJ1X6VY4WfgNa6ptGspLn0Lr3p4UUtLzS+v4wz1VeDwrk0uaAKZmth WkbLnJd+ZQC6AZrxFuO2mNq8kqNZa2SWij08VS1qFfvJD3culs6RnGxH2a+5ApxWjgsm +iHCmna+afN4wrrpgWxkmvJboSWFoUchDUdrSGJAndUceF594MRdRaNpIWlwbAWKkXhP M1sw== 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=C/6VeNVqAYw8mGQFBhg791eUfLvyqSXTXHYdCSjH8yk=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=vebVXKaAtKcI+lrBVcqZkryD/eR0XtOkJLHIuJjSTorkzGCgQGf4xNc+sbxla9tC9v Zp/NBsQy/Y91uwGUWUpdTe3P8ELk3nKGqr/8ZZOBe+UoEM9zKMFzjczM49TCvWc4/kUx iloh5kK5SuR8MzxqXE+Jd561tITd+geFRLhb2abQ0cKNM/GpBx9LrT3nxf+NLbwa0dEM CC/yuynx6gkRkS53sXFxxzTMJQTQz5U4vLbEMgovW2AtX44/HLypvMXccEiKM6DcnVde n+YAoe1q2ky1fNADmJPyHA7YqSkAHLAgEqHuhSJnDDX1s2uovLzGqRZZ4k6/gWIeSf1R e0zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vZEtMhPz; 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 n145-20020a254097000000b00d9cb86ddc0dsi2640872yba.414.2023.10.27.07.44.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Oct 2023 07:44:10 -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=vZEtMhPz; 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 1qwO0s-0000Z4-4J; Fri, 27 Oct 2023 10:40:38 -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 1qwO0P-0007P1-KM for qemu-devel@nongnu.org; Fri, 27 Oct 2023 10:40:12 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwO0L-0008Gt-KD for qemu-devel@nongnu.org; Fri, 27 Oct 2023 10:40:09 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32dc9ff4a8fso1387645f8f.1 for ; Fri, 27 Oct 2023 07:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698417603; x=1699022403; 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=C/6VeNVqAYw8mGQFBhg791eUfLvyqSXTXHYdCSjH8yk=; b=vZEtMhPzKekhXh76WmTClQQ8SjmGWPldSizovVdp9dniFOHODLpWlAxsRqhFWdfMjD VB3OUo8oMxzpasmL2OCEUVzZHoEVNu43GvBreoRyi5erbvcnRkPPNC2BdSPDAHh6rnmQ mLv+bnSlU8sh2wYjhHBS6bAHMww4+Wm/gHjpCUNALcjPFOYBcu4t/ojjIBgED/qARn6H JT04unsR9JaAoS9UBKvFXx9rbZZxKlu73v6K0AJwhs1ElWyPncA/fHfB4HCN7LsiyZk6 GoLUFE1G3bIx8OTHK1U16Jq9X77UWmexDfuY9orqCIcehyNS2Fb8RWTvRd24pcvHtgOY /WKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698417603; x=1699022403; 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=C/6VeNVqAYw8mGQFBhg791eUfLvyqSXTXHYdCSjH8yk=; b=J/NbrYIory/RiyhpJVICTJpDMel3RGsPA2kWEwgg8RVdEAhxuQ4EeN0d9keGOOQi+E VbSMNUFrzsylURqloW/w81wEXd974brqv0HqoRL5NVow/WkMx0dk93wOrczGSOK9RdnE 8FEmegttrY9ed/JEqXxw2QBVKPHVAk0/joSBGJN8JLsHoBYB16yby1C7w1108GOYXvH+ 39rLqCHXiGGPKDr2T/uh089M6ND6218be4p+anZDaA9fx7/Sudl5+X7wCYf51M57ZxCu lIzovw/pPf9u9OKVKX5oOVEl0HOTzOQddCdPkxud7LbsjwGIO42Gbxhu8C5pqSXKaq0z qq4Q== X-Gm-Message-State: AOJu0Yyby4r1dSPUuRAKZiiIWaRb/cw1Pe7gS222+EjnqPJ2rkNaBmxq I06oN7+UrNmX0sTZ/Z69yEm8G7O/8WewPsKsYII= X-Received: by 2002:a5d:4fc9:0:b0:31f:9b4f:1910 with SMTP id h9-20020a5d4fc9000000b0031f9b4f1910mr2335234wrw.63.1698417603370; Fri, 27 Oct 2023 07:40:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id e2-20020a5d5002000000b0031c6581d55esm1874123wrt.91.2023.10.27.07.40.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 07:40:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 39/41] hw/net/cadence_gem: use FIELD to describe PHYMNTNC register fields Date: Fri, 27 Oct 2023 15:39:40 +0100 Message-Id: <20231027143942.3413881-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231027143942.3413881-1-peter.maydell@linaro.org> References: <20231027143942.3413881-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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: Luc Michel Use the FIELD macro to describe the PHYMNTNC register fields. Signed-off-by: Luc Michel Reviewed-by: sai.pavan.boddu@amd.com Message-id: 20231017194422.4124691-10-luc.michel@amd.com Signed-off-by: Peter Maydell --- hw/net/cadence_gem.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index dffcc64df25..373d3ee0712 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -194,6 +194,14 @@ REG32(IDR, 0x2c) /* Interrupt Disable reg */ REG32(IMR, 0x30) /* Interrupt Mask reg */ REG32(PHYMNTNC, 0x34) /* Phy Maintenance reg */ + FIELD(PHYMNTNC, DATA, 0, 16) + FIELD(PHYMNTNC, REG_ADDR, 18, 5) + FIELD(PHYMNTNC, PHY_ADDR, 23, 5) + FIELD(PHYMNTNC, OP, 28, 2) + FIELD(PHYMNTNC, ST, 30, 2) +#define MDIO_OP_READ 0x3 +#define MDIO_OP_WRITE 0x2 + REG32(RXPAUSE, 0x38) /* RX Pause Time reg */ REG32(TXPAUSE, 0x3c) /* TX Pause Time reg */ REG32(TXPARTIALSF, 0x40) /* TX Partial Store and Forward */ @@ -342,13 +350,6 @@ REG32(TYPE2_COMPARE_0_WORD_1, 0x704) -#define GEM_PHYMNTNC_OP_R 0x20000000 /* read operation */ -#define GEM_PHYMNTNC_OP_W 0x10000000 /* write operation */ -#define GEM_PHYMNTNC_ADDR 0x0F800000 /* Address bits */ -#define GEM_PHYMNTNC_ADDR_SHFT 23 -#define GEM_PHYMNTNC_REG 0x007C0000 /* register bits */ -#define GEM_PHYMNTNC_REG_SHIFT 18 - /* Marvell PHY definitions */ #define BOARD_PHY_ADDRESS 0 /* PHY address we will emulate a device at */ @@ -1541,12 +1542,12 @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size) /* The interrupts get updated at the end of the function. */ break; case R_PHYMNTNC: - if (retval & GEM_PHYMNTNC_OP_R) { + if (FIELD_EX32(retval, PHYMNTNC, OP) == MDIO_OP_READ) { uint32_t phy_addr, reg_num; - phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; + phy_addr = FIELD_EX32(retval, PHYMNTNC, PHY_ADDR); if (phy_addr == s->phy_addr) { - reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; + reg_num = FIELD_EX32(retval, PHYMNTNC, REG_ADDR); retval &= 0xFFFF0000; retval |= gem_phy_read(s, reg_num); } else { @@ -1664,12 +1665,12 @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, s->sar_active[(offset - R_SPADDR1HI) / 2] = true; break; case R_PHYMNTNC: - if (val & GEM_PHYMNTNC_OP_W) { + if (FIELD_EX32(val, PHYMNTNC, OP) == MDIO_OP_WRITE) { uint32_t phy_addr, reg_num; - phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; + phy_addr = FIELD_EX32(val, PHYMNTNC, PHY_ADDR); if (phy_addr == s->phy_addr) { - reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; + reg_num = FIELD_EX32(val, PHYMNTNC, REG_ADDR); gem_phy_write(s, reg_num, val); } }