Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1505500iob; Fri, 29 Apr 2022 06:53:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0gqBwnU5q+WA0BwunD89IELxN1ZNWAHJpyiCmqS+IJ3ynhIYuhJCmi99QF/D4c+i/34sC X-Received: by 2002:a63:18c:0:b0:3aa:d794:7c44 with SMTP id 134-20020a63018c000000b003aad7947c44mr29764462pgb.126.1651240410650; Fri, 29 Apr 2022 06:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651240410; cv=none; d=google.com; s=arc-20160816; b=dkTMU1d9or3fUySU2apybcu0jsGUnQoc5OLmlzspCj5RR2XxfgXdP+bev1rUFwjKQI DAg9HWSU4x6Y5bqA9mnvZ2AWGRzZRuBymVFPyb/kxvBouIcGKUqcHl+8wtPOVgSfmKWP RhO3sxHimwEfZoZhQlpcK7KBtmwgaDEtrbic3bDunefDeZCFKEVhNiRb6O0pgFDozRxV +B50DTQDSYyvXwlWjOpqJmIop1RLIP/YWEvTOf4JyVMK/quk51LokWkEZFcZoPMRJvNJ /SbZb6lx7+BNAPaQgCGdqSCxOvS3DiWVD2FSvDl9naGzxrOtyGTNErAGmAuRXBHcjYto lGCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=810WVWqP/hZF1NMKzf5cATOlxW75bWI6UJtYB2eczzg=; b=UO1Xx7IK8cflsMcvv91gJYgQVaLPzHFQ0f77ugjd7vuoj1vOxfS0pQlhvOKvVdbP3y Zx0IN8JhRr2xFlZuKGzrSiHiDCtAtYpVmDxeZZ4gA4iqW/WsNf7FAbDF4UHpcxNsTQF9 h0tn98brsP5gMHJThmjV5GyDLcoG+4/uWw2C6D8riAuDY1L8FWsRqR74x0DXd5VPbUxY KBjDEv1VqkAdfxXZWnbEYQgirjfJkX2Vf0vB5cjCZI7DLoEtIY270t/HMfJ6RU6KXD2h 5XJK03A7vHoJSGc61jU6DeqDv/IdK50lhBwnFNYaBrQiBUls4kt5+UvKdTzNmhjPI1oc dQww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=4AQnes1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l62-20020a639141000000b003ab00460a05si6479507pge.118.2022.04.29.06.53.13; Fri, 29 Apr 2022 06:53:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=4AQnes1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353231AbiD1XUa (ORCPT + 99 others); Thu, 28 Apr 2022 19:20:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbiD1XU3 (ORCPT ); Thu, 28 Apr 2022 19:20:29 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0A2840935; Thu, 28 Apr 2022 16:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=810WVWqP/hZF1NMKzf5cATOlxW75bWI6UJtYB2eczzg=; b=4AQnes1B0vsSlqlcfMiO57RV7j QvPbQxQQwd+ZompegfVs1Gr6w3fgp+yav0rRZq2aW03tK1pIUxmZfUjxX5UzP44Tq1VSajsjnrKRx TIbb/ThR0jVVGBb0Uo/UfbNKtHXiemu2x6zBcYuCGpCBJU7x3NUEVzEOEDEgJeGOHScs=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nkDNn-000OKv-Bo; Fri, 29 Apr 2022 01:17:11 +0200 Date: Fri, 29 Apr 2022 01:17:11 +0200 From: Andrew Lunn To: Nathan Rossi Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni Subject: Re: [PATCH v2] net: dsa: mv88e6xxx: Single chip mode detection for MV88E6*41 Message-ID: References: <20220427130928.540007-1-nathan@nathanrossi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220427130928.540007-1-nathan@nathanrossi.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 27, 2022 at 01:09:28PM +0000, Nathan Rossi wrote: > The mv88e6xxx driver expects switches that are configured in single chip > addressing mode to have the MDIO address configured as 0. This is due to > the switch ADDR pins representing the single chip addressing mode as 0. > However depending on the device (e.g. MV88E6*41) the switch does not > respond on address 0 or any other address below 16 (the first port > address) in single chip addressing mode. This allows for other devices > to be on the same shared MDIO bus despite the switch being in single > chip addressing mode. > > When using a switch that works this way it is not possible to configure > switch driver as single chip addressing via device tree, along with > another MDIO device on the same bus with address 0, as both devices > would have the same address of 0 resulting in mdiobus_register_device > -EBUSY errors for one of the devices with address 0. > > In order to support this configuration the switch node can have its MDIO > address configured as 16 (the first address that the device responds > to). During initialization the driver will treat this address similar to > how address 0 is, however because this address is also a valid > multi-chip address (in certain switch models, but not all) the driver > will configure the SMI in single chip addressing mode and attempt to > detect the switch model. If the device is configured in single chip > addressing mode this will succeed and the initialization process can > continue. If it fails to detect a valid model this is because the switch > model register is not a valid register when in multi-chip mode, it will > then fall back to the existing SMI initialization process using the MDIO > address as the multi-chip mode address. > > This detection method is safe if the device is in either mode because > the single chip addressing mode read is a direct SMI/MDIO read operation > and has no side effects compared to the SMI writes required for the > multi-chip addressing mode. > > In order to implement this change, the reset gpio configuration is moved > to occur before any SMI initialization. This ensures that the device has > the same/correct reset gpio state for both mv88e6xxx_smi_init calls. > > Signed-off-by: Nathan Rossi Reviewed-by: Andrew Lunn Andrew