From patchwork Fri Oct 23 10:56:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 298645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44856C388F9 for ; Fri, 23 Oct 2020 10:57:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 069C020FC3 for ; Fri, 23 Oct 2020 10:57:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S462634AbgJWK5C (ORCPT ); Fri, 23 Oct 2020 06:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S462577AbgJWK4k (ORCPT ); Fri, 23 Oct 2020 06:56:40 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D35C6C0613D4 for ; Fri, 23 Oct 2020 03:56:39 -0700 (PDT) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVukG-00087m-Kp; Fri, 23 Oct 2020 12:56:28 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kVukF-0001k0-C3; Fri, 23 Oct 2020 12:56:27 +0200 From: Oleksij Rempel To: Andrew Lunn , "David S. Miller" , Florian Fainelli , Heiner Kallweit , Jakub Kicinski , Oliver Hartkopp Cc: Oleksij Rempel , David Jander , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Russell King , mkl@pengutronix.de, Marek Vasut , linux-can@vger.kernel.org Subject: [RFC PATCH v1 0/6] add initial CAN PHY support Date: Fri, 23 Oct 2020 12:56:20 +0200 Message-Id: <20201023105626.6534-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch set is introducing PHY support for CAN. Why it is needed? - A usual CAN PHY has an enable or silent mode pin. This pin needs to be pulled into the correct direction, so that the CAN controller can access the CAN network. So far this has been "hacked" into the CAN controller driver, by enabling/disabling regulators. Better use proper PHY drivers instead. - Bit rate limits. There are different types of CAN PHYs not all support all bit rates. Further the upper limit of CAN FD PHYs is not given by the standard by by the PHY itself. Use the PHY link framework to validate bit rate limits. - The upcoming CAN SIC and CAN SIC XL PHYs use a different interface to the CAN controller. This means the controller needs to know which type of PHY is attached to configure the interface in the correct mode. Use PHY link for that, too. - Another topic is cable testing/diagnostics. Unfortunately this is not standardized in CAN, but there are several boards that implement CAN cable testing in some way or another. Use PHY framework as an abstraction. - The class of CAN low-speed PHYs has enhanced error detection capabilities, compared to normal (CAN high-speed and CAN FD) PHYs. Use PHY framework to implement CAN low-speed PHY drivers. Oleksij Rempel (6): net: phy: add CAN PHY Virtual Bus net: phy: add a driver for generic CAN PHYs net: phy: add CAN interface mode net: add CAN specific link modes can: flexcan: add phylink support can: flexcan: add ethtool support drivers/net/can/Kconfig | 2 + drivers/net/can/flexcan.c | 244 +++++++++++++++++++++++++++++++++- drivers/net/phy/Kconfig | 14 ++ drivers/net/phy/Makefile | 2 + drivers/net/phy/can_phy_bus.c | 196 +++++++++++++++++++++++++++ drivers/net/phy/can_phy_drv.c | 236 ++++++++++++++++++++++++++++++++ drivers/net/phy/phy-core.c | 2 +- drivers/net/phy/phy.c | 2 + include/linux/can/phy.h | 21 +++ include/linux/phy.h | 3 + include/uapi/linux/ethtool.h | 9 ++ net/ethtool/common.c | 7 + net/ethtool/linkmodes.c | 7 + 13 files changed, 743 insertions(+), 2 deletions(-) create mode 100644 drivers/net/phy/can_phy_bus.c create mode 100644 drivers/net/phy/can_phy_drv.c create mode 100644 include/linux/can/phy.h