From patchwork Fri Sep 22 17:13:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 114067 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3537243qgf; Fri, 22 Sep 2017 10:16:54 -0700 (PDT) X-Received: by 10.200.57.29 with SMTP id s29mr9592070qtb.309.1506100614437; Fri, 22 Sep 2017 10:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506100614; cv=none; d=google.com; s=arc-20160816; b=FiUjp4UVXiWj6TbzogN2qEhoMo0kkfnPkGGHZiW0B62pkxzRL2Lz+gv204p8luSfsQ bF9Sh0p6qK9h95f4IvjbfqkCahVP+ni+F3RDQAZr+TN9NhlkhEgECUZWVQU+YwN6FFXM AIRIQzb1wEIMHhQxrtQB81LACs0ciFTjo5skkmWeaUb2BWKjaLRctT0QwyBrzDJ9bYq1 MnHsqOZJnNU20AwTdoFiZw/1tEoe7ewmyqUyexBEeXSThQ7EmXfQP0ldArLQ52/IotDx OEgVLBlPzww/dcN9t6zBT8q44gp5P2/IPtsqei64ycMdo4q+XkgPAuCXFwrhkRagwco4 kzAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=7KpW00sMxw16wF0mIEkeF89e/zuRxR6YFdtK1trbEKw=; b=ckl5nzZRQOlJZMkUTV/sH5pnM4X7rwkBHCE7eqMPXyVQuFv08gDXFDPo9RKu6QcXSk o6LWfCLosknOXNo6DIcEa5bcxbh4dXnnn49iaP4OypmB/NmAMufBpG4vahNbUjx4nSZm RhWudxTt/PaLe8FfsrunSQJEQLBp0w9KU/c1wX8Oo7XoHDuNknzLbvWO+xUVAXJCV3Dt Yd0Lgpx77UJnFhR5EdUs0w4vafeo+ra1Kc5FdjdQkFJq8R9QcJzuqbMe+/UO6qcMj/vH 9doRJOGjhc8n0AMX0/xAH5M+pyhc3/phzbuegm/wLAxE55mNqiNQhxRclEiIzxO1F0bI cqqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dkwLpiyk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b201si220424qkg.491.2017.09.22.10.16.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Sep 2017 10:16:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dkwLpiyk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:60296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvRZM-00064W-Cn for patch@linaro.org; Fri, 22 Sep 2017 13:16:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvRWM-00039s-QP for qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvRWL-0003R5-LA for qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:46 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:34548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvRWL-0003Qf-HY for qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:45 -0400 Received: by mail-qt0-x244.google.com with SMTP id q8so1046258qtb.1 for ; Fri, 22 Sep 2017 10:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7KpW00sMxw16wF0mIEkeF89e/zuRxR6YFdtK1trbEKw=; b=dkwLpiykxStyziN1uZTOc3Q0x+iplgNaM4q2eajF6cygNLZv36rS/6ca8ks6y8bmAJ XIRR1TMy7ZM7VPDH3+jYgpBgdJyjI+Z71UjV6rBJosKAy0whq7Dl4NydzekajkTU+O5o pyEhtxJ4J62kmmZWwa6Yj/4dBoGH3KSCnR10bCiQiurF45nRP4LZ7rD0fDA2vTXGVKOO wJULB8boK7/LzIxPutMChP8EYuk2laoedurlXrnNjSJblJNsr2fnR8XR4ChqcAJ5D+kR N01DFss0aQ2WTOK5KVyUeuMQdzq/pWIIJiBpvYzI0E991fL4THeMxtnLupJ3erDiSAeA qMmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7KpW00sMxw16wF0mIEkeF89e/zuRxR6YFdtK1trbEKw=; b=qgDdbMpTZsCTcLgiFchJVZcn+BaDECLhDR6Le+Un1stS4P40EaAFGgCw5NaAb7DjtQ C3ZwAftX+5xwL5qA1v9MBMrXwQccvLdEYeJ7yd5F50w2DWGtJlraotLrjt0WzlZULQXF zsR1N+NHjdPY1/BdiGnyk93Q3IRefmjVYiJIKh1R6UrvwFxtRX0k+CvS3rT1slk9mR35 timVQpyGRUmvsbsrrPGF9cMUKs9ZG+vsQM9F+9s89wRVTHlzvcc/9vFpAfMu9lA5aFTT PTHRjxbLUe0xP6o+ZTa1h+RbxIkfTI6iKPFDl30803Z8kfb0TdpsArF3pHbgy9lNJXxO 5gSw== X-Gm-Message-State: AHPjjUg+HTHLGp7ieQSaJZ/mPQGaPrBwIe1o7dNx+EfyjysEVNG9P6DO Oe5Tg1SU0P5mXE8cqAZMMC0= X-Google-Smtp-Source: AOwi7QDDU3npOe0uC7MpnaysQKFhER0t1R1l+gFO4/6wkrwIQcuTDw6LG9uUMRijv+r3JuGqEniXmw== X-Received: by 10.200.43.228 with SMTP id n33mr9705232qtn.241.1506100425068; Fri, 22 Sep 2017 10:13:45 -0700 (PDT) Received: from yoga.lan ([181.93.89.178]) by smtp.gmail.com with ESMTPSA id f69sm238468qke.27.2017.09.22.10.13.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 10:13:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Peter Maydell , Grant Likely , Jason Wang Date: Fri, 22 Sep 2017 14:13:18 -0300 Message-Id: <20170922171323.10348-3-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170922171323.10348-1-f4bug@amsat.org> References: <20170922171323.10348-1-f4bug@amsat.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH v5 2/7] hw/mdio: Add PHY register definition X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Grant Likely Trivial patch to add #defines for defined PHY register address and bit fields Signed-off-by: Grant Likely Signed-off-by: Philippe Mathieu-Daudé --- include/hw/net/mdio.h | 24 ++++++++++++++++++++++-- hw/net/mdio.c | 8 ++++---- 2 files changed, 26 insertions(+), 6 deletions(-) -- 2.14.1 Reviewed-by: Alistair Francis diff --git a/include/hw/net/mdio.h b/include/hw/net/mdio.h index ac36aed3c3..7ffa4389b9 100644 --- a/include/hw/net/mdio.h +++ b/include/hw/net/mdio.h @@ -25,14 +25,34 @@ * THE SOFTWARE. */ -/* PHY Advertisement control register */ +/* PHY MII Register/Bit Definitions */ +/* PHY Registers defined by IEEE */ +#define PHY_CTRL 0x00 /* Control Register */ +#define PHY_STATUS 0x01 /* Status Regiser */ +#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */ +#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */ +#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */ +#define PHY_LP_ABILITY 0x05 /* Link Partner Ability (Base Page) */ +#define PHY_AUTONEG_EXP 0x06 /* Autoneg Expansion Reg */ +#define PHY_NEXT_PAGE_TX 0x07 /* Next Page TX */ +#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */ +#define PHY_1000T_CTRL 0x09 /* 1000Base-T Control Reg */ +#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */ +#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */ + +#define NUM_PHY_REGS 0x20 /* 5 bit address bus (0-0x1F) */ + +#define PHY_CTRL_RST 0x8000 /* PHY reset command */ +#define PHY_CTRL_ANEG_RST 0x0200 /* Autonegotiation reset command */ + +/* PHY Advertisement control and remote capability registers (same bitfields) */ #define PHY_ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */ #define PHY_ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */ #define PHY_ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */ #define PHY_ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */ struct qemu_phy { - uint32_t regs[32]; + uint32_t regs[NUM_PHY_REGS]; int link; diff --git a/hw/net/mdio.c b/hw/net/mdio.c index 3763fcc8af..3d70d99077 100644 --- a/hw/net/mdio.c +++ b/hw/net/mdio.c @@ -122,12 +122,12 @@ static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data) void tdk_init(struct qemu_phy *phy) { - phy->regs[0] = 0x3100; + phy->regs[PHY_CTRL] = 0x3100; /* PHY Id. */ - phy->regs[2] = 0x0300; - phy->regs[3] = 0xe400; + phy->regs[PHY_ID1] = 0x0300; + phy->regs[PHY_ID2] = 0xe400; /* Autonegotiation advertisement reg. */ - phy->regs[4] = 0x01e1; + phy->regs[PHY_AUTONEG_ADV] = 0x01e1; phy->link = 1; phy->read = tdk_read;