[{"id":1865285,"web_url":"http://patchwork.ozlabs.org/comment/1865285/","msgid":"<CAKmqyKNxnfSyUzzo5=2VyvM86osApVzyRVCGpE2qhzAefZpALg@mail.gmail.com>","list_archive_url":null,"date":"2018-02-27T22:31:43","subject":"Re: [Qemu-devel] [PATCH v5 2/7] hw/mdio: Add PHY register definition","submitter":{"id":64571,"url":"http://patchwork.ozlabs.org/api/people/64571/","name":"Alistair Francis","email":"alistair23@gmail.com"},"content":"On Fri, Sep 22, 2017 at 10:13 AM, Philippe Mathieu-Daudé\n<f4bug@amsat.org> wrote:\n> From: Grant Likely <grant.likely@arm.com>\n>\n> Trivial patch to add #defines for defined PHY register address and bit fields\n>\n> Signed-off-by: Grant Likely <grant.likely@arm.com>\n> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n\nReviewed-by: Alistair Francis <alistair.francis@xilinx.com>\n\nAlistair\n\n> ---\n>  include/hw/net/mdio.h | 24 ++++++++++++++++++++++--\n>  hw/net/mdio.c         |  8 ++++----\n>  2 files changed, 26 insertions(+), 6 deletions(-)\n>\n> diff --git a/include/hw/net/mdio.h b/include/hw/net/mdio.h\n> index ac36aed3c3..7ffa4389b9 100644\n> --- a/include/hw/net/mdio.h\n> +++ b/include/hw/net/mdio.h\n> @@ -25,14 +25,34 @@\n>   * THE SOFTWARE.\n>   */\n>\n> -/* PHY Advertisement control register */\n> +/* PHY MII Register/Bit Definitions */\n> +/* PHY Registers defined by IEEE */\n> +#define PHY_CTRL         0x00 /* Control Register */\n> +#define PHY_STATUS       0x01 /* Status Regiser */\n> +#define PHY_ID1          0x02 /* Phy Id Reg (word 1) */\n> +#define PHY_ID2          0x03 /* Phy Id Reg (word 2) */\n> +#define PHY_AUTONEG_ADV  0x04 /* Autoneg Advertisement */\n> +#define PHY_LP_ABILITY   0x05 /* Link Partner Ability (Base Page) */\n> +#define PHY_AUTONEG_EXP  0x06 /* Autoneg Expansion Reg */\n> +#define PHY_NEXT_PAGE_TX 0x07 /* Next Page TX */\n> +#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */\n> +#define PHY_1000T_CTRL   0x09 /* 1000Base-T Control Reg */\n> +#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */\n> +#define PHY_EXT_STATUS   0x0F /* Extended Status Reg */\n> +\n> +#define NUM_PHY_REGS     0x20  /* 5 bit address bus (0-0x1F) */\n> +\n> +#define PHY_CTRL_RST            0x8000 /* PHY reset command */\n> +#define PHY_CTRL_ANEG_RST       0x0200 /* Autonegotiation reset command */\n> +\n> +/* PHY Advertisement control and remote capability registers (same bitfields) */\n>  #define PHY_ADVERTISE_10HALF    0x0020  /* Try for 10mbps half-duplex  */\n>  #define PHY_ADVERTISE_10FULL    0x0040  /* Try for 10mbps full-duplex  */\n>  #define PHY_ADVERTISE_100HALF   0x0080  /* Try for 100mbps half-duplex */\n>  #define PHY_ADVERTISE_100FULL   0x0100  /* Try for 100mbps full-duplex */\n>\n>  struct qemu_phy {\n> -    uint32_t regs[32];\n> +    uint32_t regs[NUM_PHY_REGS];\n>\n>      int link;\n>\n> diff --git a/hw/net/mdio.c b/hw/net/mdio.c\n> index 3763fcc8af..3d70d99077 100644\n> --- a/hw/net/mdio.c\n> +++ b/hw/net/mdio.c\n> @@ -122,12 +122,12 @@ static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)\n>\n>  void tdk_init(struct qemu_phy *phy)\n>  {\n> -    phy->regs[0] = 0x3100;\n> +    phy->regs[PHY_CTRL] = 0x3100;\n>      /* PHY Id. */\n> -    phy->regs[2] = 0x0300;\n> -    phy->regs[3] = 0xe400;\n> +    phy->regs[PHY_ID1] = 0x0300;\n> +    phy->regs[PHY_ID2] = 0xe400;\n>      /* Autonegotiation advertisement reg. */\n> -    phy->regs[4] = 0x01e1;\n> +    phy->regs[PHY_AUTONEG_ADV] = 0x01e1;\n>      phy->link = 1;\n>\n>      phy->read = tdk_read;\n> --\n> 2.14.1\n>\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=gmail.com","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"l9zTzJqa\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3zrYP36XbZz9s1t\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 28 Feb 2018 09:32:55 +1100 (AEDT)","from localhost ([::1]:40464 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1eqnnq-0000ZQ-2Y\n\tfor incoming@patchwork.ozlabs.org; Tue, 27 Feb 2018 17:32:54 -0500","from eggs.gnu.org ([2001:4830:134:3::10]:47691)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <alistair23@gmail.com>) id 1eqnnF-0000Y1-8L\n\tfor qemu-devel@nongnu.org; Tue, 27 Feb 2018 17:32:18 -0500","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <alistair23@gmail.com>) id 1eqnnE-0002UO-0D\n\tfor qemu-devel@nongnu.org; Tue, 27 Feb 2018 17:32:17 -0500","from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:40619)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <alistair23@gmail.com>)\n\tid 1eqnnD-0002UB-P1\n\tfor qemu-devel@nongnu.org; Tue, 27 Feb 2018 17:32:15 -0500","by mail-lf0-x243.google.com with SMTP id 37so621788lfs.7\n\tfor <qemu-devel@nongnu.org>; Tue, 27 Feb 2018 14:32:15 -0800 (PST)","by 10.46.32.215 with HTTP; Tue, 27 Feb 2018 14:31:43 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=KKfu6MIYDkWhTQozvfiN9LgbNzJAh/BdnVI+woRlUrc=;\n\tb=l9zTzJqaJLlanKeFEPc7vYUKc+TQ9XwbLkX8HJcmpqFhBx9olkayHX+va4lgPoeuT3\n\th45fuX4pBq3PdYoNW2aTO4F3YzQuSTEwN4lUCriehC6FP/A3aSZPYGdcAiBGLaFCVnjt\n\tj++KTJueMN+csVIlF82HZFEySrQLwzehxYGdMohRX7Xnu2L/iCsRubJGOLo/at9dxZRV\n\tVNw8Dt/RU4e5AE8L08na6DDQswk38L8T181sT9dT5+N9w0Rxc9/f/IGi90Cp+25lsQCJ\n\tiiOt3eW/GQv7p7yAFdMHF7f1lRaytk2kQLispGr6j3fXfEl1tw/a2JSIGv/BLX6WKuP5\n\tZUiQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=KKfu6MIYDkWhTQozvfiN9LgbNzJAh/BdnVI+woRlUrc=;\n\tb=aq0P9ZwT7g4U3fivqM8VvVWmsnsFQb1VdrsABGbcDOtI/bWYdmq2PsqQTZ8Aig3tD/\n\tZC5ezOzs1syg0vrxpyG9H+ad8vF8mIHujuQuoYVCi+NMtDb0ZMhps2I7jYeG2C6ktZyd\n\thBf/v1gg6xq6e1cXPTDIR9KSi/fqhg1e0J/yIdoDz7/M7ArGGEKLTYUliNlgLPpwnMSE\n\tG18DBT66kSqlLo4zPOPqlpTlb8dLell1mCtoVYpypWaci3fOiq5oYiKl5tUhSUPWycO3\n\t3FtjQJMHF8/Q0D49cJOrL/StZD1BzCKrrEG6xAqbFEszOA38TiHlGbBZ6V/jEvkZxjal\n\tpcaQ==","X-Gm-Message-State":"APf1xPDBO7+A5K4IaYdQSwogizuOtatDHmzxTSdREtr8krdyyDjSaeS9\n\tY+6YleaWyXVtsxzu7sNL4LGsqhYCdTJFjEuIBIY=","X-Google-Smtp-Source":"AG47ELsE/4Ss92OXs7H1ZM33sAa63qcLJszlN067czZ4rLNM631UMKAPKJm5zlVO7p25nXIWjXR8vK+2YwrrSN79eKg=","X-Received":"by 10.25.67.18 with SMTP id q18mr12109832lfa.114.1519770734525; \n\tTue, 27 Feb 2018 14:32:14 -0800 (PST)","MIME-Version":"1.0","In-Reply-To":"<20170922171323.10348-3-f4bug@amsat.org>","References":"<20170922171323.10348-1-f4bug@amsat.org>\n\t<20170922171323.10348-3-f4bug@amsat.org>","From":"Alistair Francis <alistair23@gmail.com>","Date":"Tue, 27 Feb 2018 14:31:43 -0800","Message-ID":"<CAKmqyKNxnfSyUzzo5=2VyvM86osApVzyRVCGpE2qhzAefZpALg@mail.gmail.com>","To":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2a00:1450:4010:c07::243","Subject":"Re: [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":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Peter Maydell <peter.maydell@linaro.org>,\n\tJason Wang <jasowang@redhat.com>, Grant Likely <grant.likely@arm.com>,\n\t\"qemu-devel@nongnu.org Developers\" <qemu-devel@nongnu.org>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]