From patchwork Sun May 15 15:28:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 9096561 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 18EE5BF29F for ; Sun, 15 May 2016 15:32:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E2D12028D for ; Sun, 15 May 2016 15:32:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 988DD20279 for ; Sun, 15 May 2016 15:32:44 +0000 (UTC) Received: from localhost ([::1]:40622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1y27-0000IW-UL for patchwork-qemu-devel@patchwork.kernel.org; Sun, 15 May 2016 11:32:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1y0j-0006E5-6B for qemu-devel@nongnu.org; Sun, 15 May 2016 11:31:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1y0Z-0007Fy-3F for qemu-devel@nongnu.org; Sun, 15 May 2016 11:31:16 -0400 Received: from mail-lb0-x243.google.com ([2a00:1450:4010:c04::243]:34668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1y0Y-0007Fj-Sa for qemu-devel@nongnu.org; Sun, 15 May 2016 11:31:07 -0400 Received: by mail-lb0-x243.google.com with SMTP id bg8so5930802lbc.1 for ; Sun, 15 May 2016 08:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lJvACvG2lwgbNRaRtbmjtmtE+VsvN5TXUGCIclw1FEM=; b=w5F7cNt0OxBFfzGeIDlnXM/GgmlMUQr4Oiw7aqVbS1QP3L6vd8cVR+KyMz5rq2R2bJ EnUqa2qxiKl/NViOSfQuUiRjjmg6CpxH+lFoi/MxEPqhNJP3yIijXrVQ2drpAsHznEJp eho4WeJ1vzbn5GqKUgiSNJ+oXOrva48CPBFFZDdAjKJh3Ee0X21UFIDJ7cxQJgHCYq1R btvUfKoo4FG0f5+wS89cr/VHFMvp4IOE9Rp7ftyn9HDJ5ZTwRMvZ9PmaPESvVB9FVuwt 9n7NMrJMogrNinf2xid2rsz2RGZiM1PH6INsrIfm2UUhpz3kEXwZHVr7fkUElsdbYbza X/Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lJvACvG2lwgbNRaRtbmjtmtE+VsvN5TXUGCIclw1FEM=; b=gffaCuqs/rw9G+U6U6LQgTMj+lv1fszUFUDwzufaKL3Dr40udnwjHVvi8eiMWDr3fC CJiyoW7/sAcDi9TwAeNvAPe70j7d3nFRkrLxkP/qha3R6W+EREGfNGgTep191xMW3rQ3 iSo8meNhxOFUWQW4qi37GmiTBan8NO5Caxic8grj2Ke+S8Appct1ppBJtLaneOT4g546 Cgh3FAgwZsrI60O70bFcaKhln7cLlOzschLqt7jIi7w3tm3F67UUZ28bhMcGLQawshAV ZT8mDAegOY+xJHK2mBNqFLQea6aQTwqwRohKrqvfRqiBeqtMvXbzKnASrJ6+m0TCxM5m WqtQ== X-Gm-Message-State: AOPr4FXcIYCZBD83VauLvpSqvz6lLX5ZnXg+TOxKAgoZjADX33Tdu9P63RMPfGJTnKSFIw== X-Received: by 10.112.169.42 with SMTP id ab10mr8893487lbc.63.1463326266165; Sun, 15 May 2016 08:31:06 -0700 (PDT) Received: from octofox.metropolis ([5.19.183.212]) by smtp.gmail.com with ESMTPSA id tg1sm4505275lbb.7.2016.05.15.08.31.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 May 2016 08:31:05 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Sun, 15 May 2016 18:28:08 +0300 Message-Id: <1463326089-15526-2-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1463326089-15526-1-git-send-email-jcmvbkbc@gmail.com> References: <1463326089-15526-1-git-send-email-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::243 Subject: [Qemu-devel] [PATCH 1/2] hw/net/opencores_eth: use mii.h 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: Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Drop local definitions of MII registers and use constants from mii.h for registers and register bits. No functional changes. Signed-off-by: Max Filippov --- hw/net/opencores_eth.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c index c6094fb..c269992 100644 --- a/hw/net/opencores_eth.c +++ b/hw/net/opencores_eth.c @@ -33,6 +33,7 @@ #include "qemu/osdep.h" #include "hw/hw.h" +#include "hw/net/mii.h" #include "hw/sysbus.h" #include "net/net.h" #include "sysemu/sysemu.h" @@ -55,12 +56,6 @@ /* PHY MII registers */ enum { - MII_BMCR, - MII_BMSR, - MII_PHYIDR1, - MII_PHYIDR2, - MII_ANAR, - MII_ANLPAR, MII_REG_MAX = 16, }; @@ -72,10 +67,11 @@ typedef struct Mii { static void mii_set_link(Mii *s, bool link_ok) { if (link_ok) { - s->regs[MII_BMSR] |= 0x4; - s->regs[MII_ANLPAR] |= 0x01e1; + s->regs[MII_BMSR] |= MII_BMSR_LINK_ST; + s->regs[MII_ANLPAR] |= MII_ANLPAR_TXFD | MII_ANLPAR_TX | + MII_ANLPAR_10FD | MII_ANLPAR_10 | MII_ANLPAR_CSMACD; } else { - s->regs[MII_BMSR] &= ~0x4; + s->regs[MII_BMSR] &= ~MII_BMSR_LINK_ST; s->regs[MII_ANLPAR] &= 0x01ff; } s->link_ok = link_ok; @@ -84,11 +80,14 @@ static void mii_set_link(Mii *s, bool link_ok) static void mii_reset(Mii *s) { memset(s->regs, 0, sizeof(s->regs)); - s->regs[MII_BMCR] = 0x1000; - s->regs[MII_BMSR] = 0x7868; /* no ext regs */ - s->regs[MII_PHYIDR1] = 0x2000; - s->regs[MII_PHYIDR2] = 0x5c90; - s->regs[MII_ANAR] = 0x01e1; + s->regs[MII_BMCR] = MII_BMCR_AUTOEN; + s->regs[MII_BMSR] = MII_BMSR_100TX_FD | MII_BMSR_100TX_HD | + MII_BMSR_10T_FD | MII_BMSR_10T_HD | MII_BMSR_MFPS | + MII_BMSR_AN_COMP | MII_BMSR_AUTONEG; + s->regs[MII_PHYID1] = 0x2000; + s->regs[MII_PHYID2] = 0x5c90; + s->regs[MII_ANAR] = MII_ANAR_TXFD | MII_ANAR_TX | + MII_ANAR_10FD | MII_ANAR_10 | MII_ANAR_CSMACD; mii_set_link(s, s->link_ok); } @@ -98,7 +97,7 @@ static void mii_ro(Mii *s, uint16_t v) static void mii_write_bmcr(Mii *s, uint16_t v) { - if (v & 0x8000) { + if (v & MII_BMCR_RESET) { mii_reset(s); } else { s->regs[MII_BMCR] = v; @@ -110,8 +109,8 @@ static void mii_write_host(Mii *s, unsigned idx, uint16_t v) static void (*reg_write[MII_REG_MAX])(Mii *s, uint16_t v) = { [MII_BMCR] = mii_write_bmcr, [MII_BMSR] = mii_ro, - [MII_PHYIDR1] = mii_ro, - [MII_PHYIDR2] = mii_ro, + [MII_PHYID1] = mii_ro, + [MII_PHYID2] = mii_ro, }; if (idx < MII_REG_MAX) {