{"id":817652,"url":"http://patchwork.ozlabs.org/api/patches/817652/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170922171323.10348-4-f4bug@amsat.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170922171323.10348-4-f4bug@amsat.org>","list_archive_url":null,"date":"2017-09-22T17:13:19","name":"[v5,3/7] hw/mdio: Generalize phy initialization routine","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f0f4be304b5954f2b7d5cf9f341f2caad7c77b91","submitter":{"id":70924,"url":"http://patchwork.ozlabs.org/api/people/70924/?format=json","name":"Philippe Mathieu-Daudé","email":"f4bug@amsat.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170922171323.10348-4-f4bug@amsat.org/mbox/","series":[{"id":4680,"url":"http://patchwork.ozlabs.org/api/series/4680/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4680","date":"2017-09-22T17:13:16","name":"Generalize MDIO framework","version":5,"mbox":"http://patchwork.ozlabs.org/series/4680/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817652/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817652/checks/","tags":{},"related":[],"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\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"YLeeiRAm\"; 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 3xzKpx4V2Pz9s7h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 23 Sep 2017 03:14:49 +1000 (AEST)","from localhost ([::1]:60285 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 1dvRXL-0003gz-Jl\n\tfor incoming@patchwork.ozlabs.org; Fri, 22 Sep 2017 13:14:47 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:59391)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dvRWQ-0003KE-BS\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:53 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dvRWP-0003TU-3d\n\tfor qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:50 -0400","from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:37391)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dvRWO-0003TF-Ur; Fri, 22 Sep 2017 13:13:49 -0400","by mail-qt0-x243.google.com with SMTP id u48so1045059qtc.4;\n\tFri, 22 Sep 2017 10:13:48 -0700 (PDT)","from yoga.lan ([181.93.89.178]) by smtp.gmail.com with ESMTPSA id\n\tf69sm238468qke.27.2017.09.22.10.13.45\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 22 Sep 2017 10:13:47 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=jCs+7aCSuo0aq+jzG5++EzGklGRDA53oMWn9sbBVFsw=;\n\tb=YLeeiRAm0VUquG/5X8LwPPrSgjE97CwpNLDMl8nk+O+lJTez84dGyJSbOwKh4bSEYE\n\tZzk5+LcVVrZdQ4qQ0WqUp9qRLmoTLYW4jrTonBl5io/+SHOq1oAzHyA54qKiXmfOEPp1\n\tChue8LcGCZ6vPe0ZWkf+NaF0IdRMznFOvkn6DAGCR6itNo572eYJRbtOTCJEm2Fcu3dl\n\tO8/BpJTE3QAB8XVblnlpaJtNMRrrIYukepkgAeQfL61bBswu4iTXzga0gf/tPdTgLn1/\n\tuYYBuEUVqdrjmgZdg/mHmOY36bRhf7Qx28+GA403uazPHAPctlzx2y2pALDWBCzLEBj/\n\trUbg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:mime-version:content-transfer-encoding;\n\tbh=jCs+7aCSuo0aq+jzG5++EzGklGRDA53oMWn9sbBVFsw=;\n\tb=PTDz20lJS18CWKqDJxuhXxNUCSs87VoNtDQDwwmaUhZCS7BUpPM8e6zFPpA9ZqO2Bw\n\tiq8TNySi3qDTcqZqzTOH9o3Di7W31+dIR8Y82jktIE5noFR9uygTjltEq02NB/kMpBoE\n\tQ1wvHHwx80L0Ax3h0JtdoBs96hgkbvSK/RAhfEWAfIrzDWZOJQLDpdyxScc1FajaR/Iw\n\twJpkb4etq0KOYRmfuBbTchZHVnEHqsIuFpsvk1aNmrvDFXTeT+wpFFTqpDjlXLbKWEVF\n\tUm2/dZsJi0WGn/aaGHC4jFIF3ZOPQ47eQVb9JhNqdjrg5xTcGznwyZIi2F5g7Kf8V1UG\n\tFE1Q==","X-Gm-Message-State":"AHPjjUjQug8SpCSxt3XSgR/aFPmk7gaOpQBQDh1t3SpaJtnyuPMpaxo0\n\tfxrOPgT5lBHtJ3+4Ub0yP1Y=","X-Google-Smtp-Source":"AOwi7QDVzy6vUZzcLCl9Od/fHGIiJ78o0vmMgVRtMESEj/wlmblcJcY78cDCs9Pd08/R9vysomowBw==","X-Received":"by 10.200.33.131 with SMTP id 3mr7516611qty.177.1506100428426;\n\tFri, 22 Sep 2017 10:13:48 -0700 (PDT)","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","To":"Peter Maydell <peter.maydell@linaro.org>, Grant Likely\n\t<grant.likely@arm.com>, Jason Wang <jasowang@redhat.com>, \"Edgar E.\n\tIglesias\" <edgar.iglesias@gmail.com>, Alistair Francis\n\t<alistair.francis@xilinx.com>, \tFam Zheng <famz@redhat.com>,\n\t=?utf-8?q?Andreas_F=C3=A4rber?= <afaerber@suse.de>","Date":"Fri, 22 Sep 2017 14:13:19 -0300","Message-Id":"<20170922171323.10348-4-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","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400d:c0d::243","Subject":"[Qemu-devel] [PATCH v5 3/7] hw/mdio: Generalize phy initialization\n\troutine","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":"qemu-arm@nongnu.org, qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu?=\n\t=?utf-8?q?-Daud=C3=A9?= <f4bug@amsat.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>"},"content":"From: Grant Likely <grant.likely@arm.com>\n\nThere really isn't anything tdk-specific about tdk_init() other than the\nphy id registers. The function should instead be generalized for any\nphy, at least as far as the ID registers are concerned. For the most\npart the read/write behaviour should be very similar across PHYs.\n\nThis patch renames tdk_{read,write,init}() to mdio_phy_*() so it can be\nused for any PHY.\n\nMore work definitely needs to be done here to make it easy to override\nthe default behaviour for specific PHYs, but this at least is a\nreasonable start.\n\nSigned-off-by: Grant Likely <grant.likely@arm.com>\nSigned-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n[PMD: just rebased]\n---\n include/hw/net/mdio.h   |  2 +-\n hw/net/etraxfs_eth.c    |  2 +-\n hw/net/mdio.c           | 14 +++++++-------\n hw/net/xilinx_axienet.c |  2 +-\n 4 files changed, 10 insertions(+), 10 deletions(-)","diff":"diff --git a/include/hw/net/mdio.h b/include/hw/net/mdio.h\nindex 7ffa4389b9..b3b4f497c0 100644\n--- a/include/hw/net/mdio.h\n+++ b/include/hw/net/mdio.h\n@@ -86,7 +86,7 @@ struct qemu_mdio {\n     struct qemu_phy *devs[32];\n };\n \n-void tdk_init(struct qemu_phy *phy);\n+void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2);\n void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy,\n                  unsigned int addr);\n uint16_t mdio_read_req(struct qemu_mdio *bus, uint8_t addr, uint8_t req);\ndiff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c\nindex f8d8f8441d..4c5415771f 100644\n--- a/hw/net/etraxfs_eth.c\n+++ b/hw/net/etraxfs_eth.c\n@@ -333,7 +333,7 @@ static int fs_eth_init(SysBusDevice *sbd)\n     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);\n \n \n-    tdk_init(&s->phy);\n+    mdio_phy_init(&s->phy, 0x0300, 0xe400);\n     mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr);\n     return 0;\n }\ndiff --git a/hw/net/mdio.c b/hw/net/mdio.c\nindex 3d70d99077..33bfbb4623 100644\n--- a/hw/net/mdio.c\n+++ b/hw/net/mdio.c\n@@ -43,7 +43,7 @@\n  * linux driver (PHYID and Diagnostics reg).\n  * TODO: Add friendly names for the register nums.\n  */\n-static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)\n+static unsigned int mdio_phy_read(struct qemu_phy *phy, unsigned int req)\n {\n     int regnum;\n     unsigned r = 0;\n@@ -107,7 +107,7 @@ static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)\n     return r;\n }\n \n-static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)\n+static void mdio_phy_write(struct qemu_phy *phy, unsigned int req, unsigned int data)\n {\n     int regnum;\n \n@@ -120,18 +120,18 @@ static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)\n     }\n }\n \n-void tdk_init(struct qemu_phy *phy)\n+void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2)\n {\n     phy->regs[PHY_CTRL] = 0x3100;\n     /* PHY Id. */\n-    phy->regs[PHY_ID1] = 0x0300;\n-    phy->regs[PHY_ID2] = 0xe400;\n+    phy->regs[PHY_ID1] = id1;\n+    phy->regs[PHY_ID2] = id2;\n     /* Autonegotiation advertisement reg. */\n     phy->regs[PHY_AUTONEG_ADV] = 0x01e1;\n     phy->link = 1;\n \n-    phy->read = tdk_read;\n-    phy->write = tdk_write;\n+    phy->read = mdio_phy_read;\n+    phy->write = mdio_phy_write;\n }\n \n void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy, unsigned int addr)\ndiff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c\nindex 1e859fdaae..408cd6e675 100644\n--- a/hw/net/xilinx_axienet.c\n+++ b/hw/net/xilinx_axienet.c\n@@ -791,7 +791,7 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)\n                           object_get_typename(OBJECT(dev)), dev->id, s);\n     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);\n \n-    tdk_init(&s->TEMAC.phy);\n+    mdio_phy_init(&s->TEMAC.phy, 0x0300, 0xe400);\n     mdio_attach(&s->TEMAC.mdio_bus, &s->TEMAC.phy, s->c_phyaddr);\n \n     s->TEMAC.parent = s;\n","prefixes":["v5","3/7"]}