Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp246828rdb; Tue, 5 Dec 2023 04:32:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAvMP2ugXPL0Lk2phjo+v2Wb83p5sYX1z8baBw0rBbqOeCGFJZudwGjRL4+RiQ3ALA267B X-Received: by 2002:a05:6a00:1a93:b0:6bd:9281:9453 with SMTP id e19-20020a056a001a9300b006bd92819453mr918606pfv.9.1701779560368; Tue, 05 Dec 2023 04:32:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701779560; cv=none; d=google.com; s=arc-20160816; b=Hvz0cSw5LHivWv1r/LX1qbvO3dXgLjSZ+UWFpfmWvEEMHvrAXvyri+9sKWw+/qwN0J FlZ8orZR2EFpERRaFpfbKHtkMHEeiCFCjzngLLDq1XQma3kIFFcyfnYaApEnc0v5c1Kt ZNf9AE6UZUwmiELWW5eUYovrm2RIbsQMZ73Nos+wobjZKPBXDysr706/hCSdNQer6q/7 bjaw7saY2YpUveayfJ5sxYPscpnRWSS9nWsT59Z6BrvfdSy8b9ehGAVNFv4wPdRCd/+b n86RVqIr9Z5KRde/r9m0hZY0Funen32p7YkSRzMl12sRGwT/byJWUuiGjVlL40oFR3bj F9PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=DgcnHD3vyBMyp03Zy3XMz8GUwdycjO24GHf/1xFuXTY=; fh=A6l4RJV3JGYn82fdtPKvU/a3R8btA5WgMn4UZ0Eb0Hc=; b=MSmA9JMlo2m1T7Lkxbbo6UNCcMdZkd+j9zLf4+e7fVMtn+rH9LAljMcADqn7v8Scuo 3v50hFvA7SgerCSGONpKopewmfXQgO33hW3Xb0LZ0rO8v2nQj5dPiKT8fbQMwFJ78EmU nYdS/TsEwlUaffiNAmKCrHhnhbxvt8vtxXXTjVApBwObc9RBF+YMavXAk8ZO1KTOnD+g jONnAXJJaQxAO1IPsgn1/E7KefUwXNwfbLVsXWVqYbhwhNqMIREvNEb1ay+2il+oxd7K fI09jLjIWaaieAX+KmKhEoEYzM+fPMRfqFRsJdhGIBMWo9WAhUdJJIRn+l8s6Rc04HDE 752A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LBVKtPQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g2-20020a056a0023c200b006ce4caaeaadsi3753345pfc.158.2023.12.05.04.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 04:32:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LBVKtPQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1432E8048C24; Tue, 5 Dec 2023 04:32:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345110AbjLEMcX (ORCPT + 99 others); Tue, 5 Dec 2023 07:32:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231888AbjLEMcH (ORCPT ); Tue, 5 Dec 2023 07:32:07 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D310C6; Tue, 5 Dec 2023 04:32:09 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5B801FF811; Tue, 5 Dec 2023 12:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701779528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DgcnHD3vyBMyp03Zy3XMz8GUwdycjO24GHf/1xFuXTY=; b=LBVKtPQmrUQ6Vu0G6IcPAIa8eJoxjxXJkgPJpFKcHVeuiAv6/8G9VGnHA5N8JqYmKhT4TB rbS6qBwhmw9YFtJb1d2+jAIzzEgLmCsKG7EwK8FsFnP13KTeVJfi/62NqzRtmHgES/9XHx b8Q6znSSChPfEGHvAy3iISOdVQl43UBChfES/DAms5SmpIPq6x9C5AckHcNjiJQ8EtgUz6 tfH3YL9GyBR3qqMLENJEj1B5/EGrU0T8wOXU34b50N4WTrNYh4OwbP/LrzjiT2YMlGVXZz dd3ktMSEwO96aaAwPW709BuHUke59iTw9AoljYR7k17TTOQWvbkwk3J3KbLBmw== Date: Tue, 5 Dec 2023 13:32:05 +0100 From: Maxime Chevallier To: Serge Semin Cc: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support Message-ID: <20231205133205.3309ab91@device.home> In-Reply-To: <20231205103559.9605-10-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 05 Dec 2023 04:32:38 -0800 (PST) Hi Serge, On Tue, 5 Dec 2023 13:35:30 +0300 Serge Semin wrote: > Synopsys DesignWare XPCS IP-core can be synthesized with the device CSRs > being accessible over MCI or APB3 interface instead of the MDIO bus (see > the CSR_INTERFACE HDL parameter). Thus all the PCS registers can be just > memory mapped and be a subject of standard MMIO operations of course > taking into account the way the Clause C45 CSRs mapping is defined. This > commit is about adding a device driver for the DW XPCS Management > Interface platform device and registering it in the framework of the > kernel MDIO subsystem. > > DW XPCS platform device is supposed to be described by the respective > compatible string "snps,dw-xpcs-mi", CSRs memory space and optional > peripheral bus clock source. Note depending on the INDIRECT_ACCESS DW XPCS > IP-core synthesize parameter the memory-mapped reg-space can be > represented as either directly or indirectly mapped Clause 45 space. In > the former case the particular address is determined based on the MMD > device and the registers offset (5 + 16 bits all together) within the > device reg-space. In the later case there is only 256 lower address bits > are utilized for the registers mapping. The upper bits are supposed to be > written into the respective viewport CSR in order to reach the entire C45 > space. Too bad the mdio-regmap driver can't be re-used here, it would deal with reg width for you, for example. I guess the main reason would be the direct vs indirect accesses ? I do have a comment tough : [...] > +static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) > +{ > + return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); > +} > + > +static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) > +{ > + return FIELD_GET(0x1fff00, csr); > +} > + > +static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) > +{ > + return FIELD_GET(0xff, csr); > +} You shouldn't use inline in C files, only in headers. Maxime