From nobody Thu May 2 21:11:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593375793; cv=none; d=zohomail.com; s=zohoarc; b=UP6dwW+zCt2xD5pW5P8aJJQsn7M7gT8qPYNEpHFZcIc3+QelikBUYFnQWcPM7Hp9ZmHhcsDJdEeHs0BydN69zt42CSL/RmuYgI7ViYlwD0IwK/6l9V4g0aIMkcaQHAQXIeZpifw+O3jUr77DGoT5ZrCfDtKvJwPbhxNC6nSld34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593375793; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qFOF+/V3LOqqbyK7Pj+oCn3G9r0BHeEmFhyqi5oym00=; b=lRrZW8RL+fXd0JThRJvsITAOMQmJNSO9zzX/EfcPVPpWHOVfc8oGWhDUr1IKMydVRXYkjHMwlOsNiA2xRJ7Xk+plQVXWpmDYVZGHRqivwFqWZN/kh6jOZeDwMixyVOBojLpN2hTFLKA0oXxj8n1BIGq7fEGd3aFthEvQp27Vs+M= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593375793360664.9004314325506; Sun, 28 Jun 2020 13:23:13 -0700 (PDT) Received: from localhost ([::1]:37084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpdpY-0007oL-6H for importer@patchew.org; Sun, 28 Jun 2020 16:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpdnu-0005mR-Dp for qemu-devel@nongnu.org; Sun, 28 Jun 2020 16:21:30 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:42895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpdns-0004EE-HR for qemu-devel@nongnu.org; Sun, 28 Jun 2020 16:21:30 -0400 Received: from localhost.localdomain (lns-bzn-59-82-252-130-88.adsl.proxad.net [82.252.130.88]) (Authenticated sender: jcd@tribudubois.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 2709EFF804; Sun, 28 Jun 2020 20:21:25 +0000 (UTC) X-Originating-IP: 82.252.130.88 From: Jean-Christophe Dubois To: qemu-devel@nongnu.org, peter.maydell@linaro.org, peter.chubb@nicta.com.au, f4bug@amsat.org Subject: [PATCH 1/3] Add a phy-num property to the i.MX FEC emulator Date: Sun, 28 Jun 2020 22:20:56 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=217.70.183.199; envelope-from=jcd@tribudubois.net; helo=relay9-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/28 16:21:22 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Christophe Dubois Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We need a solution to use an Ethernet PHY that is not the first device on the MDIO bus (device 0 on MDIO bus). As an example with the i.MX6UL the NXP SOC has 2 Ethernet devices but only one MDIO bus on which the 2 related PHY are connected but at unique addresses. Signed-off-by: Jean-Christophe Dubois --- hw/net/imx_fec.c | 24 +++++++++++++++++------- hw/net/trace-events | 4 ++-- include/hw/net/imx_fec.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index eefedc252de..2c148040414 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -280,12 +280,16 @@ static void imx_phy_reset(IMXFECState *s) static uint32_t imx_phy_read(IMXFECState *s, int reg) { uint32_t val; + uint32_t phy =3D reg / 32; =20 - if (reg > 31) { - /* we only advertise one phy */ + if (phy !=3D s->phy_num) { + qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad phy num %u\n", + TYPE_IMX_FEC, __func__, phy); return 0; } =20 + reg %=3D 32; + switch (reg) { case 0: /* Basic Control */ val =3D s->phy_control; @@ -331,20 +335,25 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg) break; } =20 - trace_imx_phy_read(val, reg); + trace_imx_phy_read(val, phy, reg); =20 return val; } =20 static void imx_phy_write(IMXFECState *s, int reg, uint32_t val) { - trace_imx_phy_write(val, reg); + uint32_t phy =3D reg / 32; =20 - if (reg > 31) { - /* we only advertise one phy */ + if (phy !=3D s->phy_num) { + qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad phy num %u\n", + TYPE_IMX_FEC, __func__, phy); return; } =20 + reg %=3D 32; + + trace_imx_phy_write(val, phy, reg); + switch (reg) { case 0: /* Basic Control */ if (val & 0x8000) { @@ -926,7 +935,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, = uint64_t value, extract32(value, 18, 10))); } else { - /* This a write operation */ + /* This is a write operation */ imx_phy_write(s, extract32(value, 18, 10), extract32(value, 0,= 16)); } /* raise the interrupt as the PHY operation is done */ @@ -1315,6 +1324,7 @@ static void imx_eth_realize(DeviceState *dev, Error *= *errp) static Property imx_eth_properties[] =3D { DEFINE_NIC_PROPERTIES(IMXFECState, conf), DEFINE_PROP_UINT32("tx-ring-num", IMXFECState, tx_ring_num, 1), + DEFINE_PROP_UINT32("phy-num", IMXFECState, phy_num, 0), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/net/trace-events b/hw/net/trace-events index e6875c4c0f6..5db45456d92 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -413,8 +413,8 @@ i82596_set_multicast(uint16_t count) "Added %d multicas= t entries" i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION" =20 # imx_fec.c -imx_phy_read(uint32_t val, int reg) "0x%04"PRIx32" <=3D reg[%d]" -imx_phy_write(uint32_t val, int reg) "0x%04"PRIx32" =3D> reg[%d]" +imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <=3D phy[%d].r= eg[%d]" +imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" =3D> phy[%d].= reg[%d]" imx_phy_update_link(const char *s) "%s" imx_phy_reset(void) "" imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PR= Ix64" flags 0x%04x len %d data 0x%08x" diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h index 7b3faa40194..9f03034b893 100644 --- a/include/hw/net/imx_fec.h +++ b/include/hw/net/imx_fec.h @@ -268,6 +268,7 @@ typedef struct IMXFECState { uint32_t phy_advertise; uint32_t phy_int; uint32_t phy_int_mask; + uint32_t phy_num; =20 bool is_fec; =20 --=20 2.25.1 From nobody Thu May 2 21:11:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593375766; cv=none; d=zohomail.com; s=zohoarc; b=In9AQ+Xv7wEaGcXWK3C1xV7wwbuICvDGpxeQ02QCyzKNitRMEbT6X5XCvIjai5Y4UpjJkGDUwd73pnFO7nGBKNPJ1C7ANRttfiefvKtQelqeIQIlnw340CiZtku01an+IuLB16VsY9KMAbKNm53BHtCojl0aqZ2IyZZeoyTHfEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593375766; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wa5DLVGTGab3Knx2Eft/VOA7dr7s/Ur+ejmid647J/0=; b=MksM1WWF56svg8cEaOf5NKvTUieBVu9p3pVtsEMBeyzZYKTJr3jwhQTacg+Nza3IeJsi891znw9qb9yRJVC9ZR+SFJmBoILHP3aBeqh/zJftkA01bWwx+w0fbXHAVRRzH3eKKXvWR/I//ASPtVbIAXsN0MUE4Jj8fIWcyE0U574= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593375766595712.5151337388113; Sun, 28 Jun 2020 13:22:46 -0700 (PDT) Received: from localhost ([::1]:34844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpdp7-0006tC-Bc for importer@patchew.org; Sun, 28 Jun 2020 16:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpdnw-0005pG-Ho for qemu-devel@nongnu.org; Sun, 28 Jun 2020 16:21:32 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:46563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpdnu-0004EW-Rz for qemu-devel@nongnu.org; Sun, 28 Jun 2020 16:21:32 -0400 Received: from localhost.localdomain (lns-bzn-59-82-252-130-88.adsl.proxad.net [82.252.130.88]) (Authenticated sender: jcd@tribudubois.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 93E32FF805; Sun, 28 Jun 2020 20:21:28 +0000 (UTC) X-Originating-IP: 82.252.130.88 From: Jean-Christophe Dubois To: qemu-devel@nongnu.org, peter.maydell@linaro.org, peter.chubb@nicta.com.au, f4bug@amsat.org Subject: [PATCH 2/3] Add the ability to select a different PHY for each i.MX6UL FEC interface Date: Sun, 28 Jun 2020 22:20:57 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=217.70.183.199; envelope-from=jcd@tribudubois.net; helo=relay9-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/28 16:21:22 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Christophe Dubois Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add properties to the i.MX6UL processor to be able to select a particular PHY on the MDIO bus for each FEC device. Signed-off-by: Jean-Christophe Dubois --- hw/arm/fsl-imx6ul.c | 10 ++++++++++ include/hw/arm/fsl-imx6ul.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c index 6446034711e..51b2f256ec8 100644 --- a/hw/arm/fsl-imx6ul.c +++ b/hw/arm/fsl-imx6ul.c @@ -427,6 +427,9 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error = **errp) FSL_IMX6UL_ENET2_TIMER_IRQ, }; =20 + object_property_set_uint(OBJECT(&s->eth[i]), + s->phy_num[i], + "phy-num", &error_abort); object_property_set_uint(OBJECT(&s->eth[i]), FSL_IMX6UL_ETH_NUM_TX_RINGS, "tx-ring-num", &error_abort); @@ -607,10 +610,17 @@ static void fsl_imx6ul_realize(DeviceState *dev, Erro= r **errp) FSL_IMX6UL_OCRAM_ALIAS_ADDR, &s->ocram_ali= as); } =20 +static Property fsl_imx6ul_properties[] =3D { + DEFINE_PROP_UINT32("fec1-phy-num", FslIMX6ULState, phy_num[0], 0), + DEFINE_PROP_UINT32("fec2-phy-num", FslIMX6ULState, phy_num[1], 1), + DEFINE_PROP_END_OF_LIST(), +}; + static void fsl_imx6ul_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); =20 + device_class_set_props(dc, fsl_imx6ul_properties); dc->realize =3D fsl_imx6ul_realize; dc->desc =3D "i.MX6UL SOC"; /* Reason: Uses serial_hds and nd_table in realize() directly */ diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h index 37c89cc5f92..fcbaf3dc861 100644 --- a/include/hw/arm/fsl-imx6ul.h +++ b/include/hw/arm/fsl-imx6ul.h @@ -87,6 +87,8 @@ typedef struct FslIMX6ULState { MemoryRegion caam; MemoryRegion ocram; MemoryRegion ocram_alias; + + uint32_t phy_num[FSL_IMX6UL_NUM_ETHS]; } FslIMX6ULState; =20 enum FslIMX6ULMemoryMap { --=20 2.25.1 From nobody Thu May 2 21:11:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593375837; cv=none; d=zohomail.com; s=zohoarc; b=chJChUKCsX5axzll8VcG6qUILI2FdG63dbbjLVXlMbrznIL9+P0PTKUDw3g4u9K5RZ77BnppO9+Ums1twzy2gcry0FFnMk5+BLat/kdVbishGkQt5GJ0kpyud8pvrjTSIfUix2HUZ+P1kfLLUzbuO6b+xxvjVj8ww9UKnY0L/MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593375837; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HlY4y40UWeMI3+xOT7Ze2m/s5Zc1s/u8kWE6VGN6muQ=; b=EUfYV5datSZGZIHreZ6sAZ6K9+HfRvN8rIm2br7OkFg+4dZEb4MWsYyWwILiPSD9Qd2FongmML8+GJFVJE1wupWlh5HVXmvCSYfOyT0THw9+mfSfZX3W9bqlmmxLqpLg2RnomcRpoWtmTB+rlw9cCujZqSQN9mR3nLw4wXXvrC4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593375837113324.9032366487206; Sun, 28 Jun 2020 13:23:57 -0700 (PDT) Received: from localhost ([::1]:40016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpdqF-0000bv-UC for importer@patchew.org; Sun, 28 Jun 2020 16:23:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpdnz-0005tZ-KS for qemu-devel@nongnu.org; Sun, 28 Jun 2020 16:21:35 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:47701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpdny-0004Ep-1e for qemu-devel@nongnu.org; Sun, 28 Jun 2020 16:21:35 -0400 Received: from localhost.localdomain (lns-bzn-59-82-252-130-88.adsl.proxad.net [82.252.130.88]) (Authenticated sender: jcd@tribudubois.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 826C7FF803; Sun, 28 Jun 2020 20:21:30 +0000 (UTC) X-Originating-IP: 82.252.130.88 From: Jean-Christophe Dubois To: qemu-devel@nongnu.org, peter.maydell@linaro.org, peter.chubb@nicta.com.au, f4bug@amsat.org Subject: [PATCH 3/3] Select MDIO device 2 and 1 as PHY devices for i.MX6UL EVK board. Date: Sun, 28 Jun 2020 22:20:58 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=217.70.183.199; envelope-from=jcd@tribudubois.net; helo=relay9-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/28 16:21:22 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Christophe Dubois Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The i.MX6UL EVK 14x14 board uses: - PHY 2 for FEC 1 - PHY 1 for FEC 2 Signed-off-by: Jean-Christophe Dubois --- hw/arm/mcimx6ul-evk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c index 2f845cedfce..9033d3f8f38 100644 --- a/hw/arm/mcimx6ul-evk.c +++ b/hw/arm/mcimx6ul-evk.c @@ -40,6 +40,8 @@ static void mcimx6ul_evk_init(MachineState *machine) =20 s =3D FSL_IMX6UL(object_new(TYPE_FSL_IMX6UL)); object_property_add_child(OBJECT(machine), "soc", OBJECT(s)); + object_property_set_uint(OBJECT(s), 2, "fec1-phy-num", &error_fatal); + object_property_set_uint(OBJECT(s), 1, "fec2-phy-num", &error_fatal); qdev_realize(DEVICE(s), NULL, &error_fatal); =20 memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR, --=20 2.25.1