From patchwork Fri Nov 2 19:26:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 992538 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42msTr0Z9czB4ZJ for ; Sat, 3 Nov 2018 06:25:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726106AbeKCEcV (ORCPT ); Sat, 3 Nov 2018 00:32:21 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:52474 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbeKCEcV (ORCPT ); Sat, 3 Nov 2018 00:32:21 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id wA2JNlpx077280; Fri, 2 Nov 2018 14:23:47 -0500 Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wA2JNlx5045107 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 14:23:47 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 2 Nov 2018 14:23:47 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 2 Nov 2018 14:23:47 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wA2JNfvV000522; Fri, 2 Nov 2018 14:23:45 -0500 From: Faiz Abbas To: , , , CC: , , , , , Subject: [PATCH 1/6] phy: Add max_bitrate attribute & phy_get_max_bitrate() Date: Sat, 3 Nov 2018 00:56:11 +0530 Message-ID: <20181102192616.28291-2-faiz_abbas@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181102192616.28291-1-faiz_abbas@ti.com> References: <20181102192616.28291-1-faiz_abbas@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In some subsystems (eg. CAN) the physical layer capabilities are the limiting factor in the datarate of the device. Typically, the physical layer transceiver does not provide a way to discover this limitation at runtime. Thus this information needs to be represented as a phy attribute which is read from the device tree. Therefore, add an optional max_bitrate attribute to the generic phy sybsystem. Also add the complementary API which enables the consumer to get max_bitrate. Signed-off-by: Faiz Abbas --- include/linux/phy/phy.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 03b319f89a34..31574464f09f 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -72,6 +72,7 @@ struct phy_ops { */ struct phy_attrs { u32 bus_width; + u32 max_bitrate; enum phy_mode mode; }; @@ -179,6 +180,10 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width) { phy->attrs.bus_width = bus_width; } +static inline int phy_get_max_bitrate(struct phy *phy) +{ + return phy->attrs.max_bitrate; +} struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); From patchwork Fri Nov 2 19:26:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 992535 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42msTf23JyzB4Z7 for ; Sat, 3 Nov 2018 06:24:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726956AbeKCEc1 (ORCPT ); Sat, 3 Nov 2018 00:32:27 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:54046 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbeKCEcY (ORCPT ); Sat, 3 Nov 2018 00:32:24 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wA2JNpZm078001; Fri, 2 Nov 2018 14:23:51 -0500 Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wA2JNpTh045127 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 14:23:51 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 2 Nov 2018 14:23:50 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 2 Nov 2018 14:23:50 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wA2JNfvW000522; Fri, 2 Nov 2018 14:23:48 -0500 From: Faiz Abbas To: , , , CC: , , , , , Subject: [PATCH 2/6] dt-bindings: phy: phy-of-simple: Document new binding Date: Sat, 3 Nov 2018 00:56:12 +0530 Message-ID: <20181102192616.28291-3-faiz_abbas@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181102192616.28291-1-faiz_abbas@ti.com> References: <20181102192616.28291-1-faiz_abbas@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add documentation for the generic simple phy implementation. Signed-off-by: Faiz Abbas --- .../devicetree/bindings/phy/phy-of-simple.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-of-simple.txt diff --git a/Documentation/devicetree/bindings/phy/phy-of-simple.txt b/Documentation/devicetree/bindings/phy/phy-of-simple.txt new file mode 100644 index 000000000000..696f2763395c --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-of-simple.txt @@ -0,0 +1,29 @@ +Generic simple phy device tree binding +-------------------------------------- + +A good number of phy implementations merely read dts properties, +enable clocks, regulators or do resets without having a dedicated register +map. This binding implements a generic phy driver which can be used for +such simple implementations and avoid boilerplate code duplication. + +Required Properties: +- compatible : must be "simple-phy" +- phy-cells : must be 0 + +Optional Properties: +- bus-width : generic bus-width. Must be positive. +- max-bitrate : generic max-bitrate. Must be positive. +- pwr : phandle to phy pwr regulator node. + +Example: + +The following example is a can transceiver implemented as a generic phy. +It has a max-bitrate property and a pwr regulator. + + +transceiver1: can-transceiver { + compatible = "simple-phy"; + max-bitrate = <5000000>; + pwr-supply = <&transceiver1_fixed>; + #phy-cells = <0>; +}; From patchwork Fri Nov 2 19:26:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 992530 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42msT22nnQzB4X0 for ; Sat, 3 Nov 2018 06:24:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728215AbeKCEca (ORCPT ); Sat, 3 Nov 2018 00:32:30 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:57302 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbeKCEc3 (ORCPT ); Sat, 3 Nov 2018 00:32:29 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id wA2JNse0011817; Fri, 2 Nov 2018 14:23:54 -0500 Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wA2JNsLp045151 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 14:23:54 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 2 Nov 2018 14:23:53 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 2 Nov 2018 14:23:53 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wA2JNfvX000522; Fri, 2 Nov 2018 14:23:51 -0500 From: Faiz Abbas To: , , , CC: , , , , , Subject: [PATCH 3/6] phy: phy-of-simple: Add support for simple generic phy driver Date: Sat, 3 Nov 2018 00:56:13 +0530 Message-ID: <20181102192616.28291-4-faiz_abbas@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181102192616.28291-1-faiz_abbas@ti.com> References: <20181102192616.28291-1-faiz_abbas@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A good number of phy implementations don't have a dedicated register map and only do simple clock or regulator configurations. Add support for a generic driver which just does such simple configurations. The driver optionally gets all the generic phy attributes and also the pwr regulator node. It also includes a generic implementation of phy_power_on() and phy_power_off(). Signed-off-by: Faiz Abbas --- drivers/phy/Kconfig | 7 +++ drivers/phy/Makefile | 1 + drivers/phy/phy-of-simple.c | 90 +++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 drivers/phy/phy-of-simple.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 60f949e2a684..e66039560da9 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -40,6 +40,13 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config PHY_OF_SIMPLE + tristate "PHY Simple Driver" + select GENERIC_PHY + help + This driver supports simple generic phy implementations which don't + need a dedicated register map. + source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/broadcom/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 0301e25d07c1..ffef0fdf2c68 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,6 +4,7 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_OF_SIMPLE) += phy-of-simple.o obj-$(CONFIG_PHY_LPC18XX_USB_OTG) += phy-lpc18xx-usb-otg.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o diff --git a/drivers/phy/phy-of-simple.c b/drivers/phy/phy-of-simple.c new file mode 100644 index 000000000000..0194aae90d3c --- /dev/null +++ b/drivers/phy/phy-of-simple.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * phy-of-simple.c - phy driver for simple implementations + * + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com + * + */ +#include +#include +#include +#include + +static int phy_simple_power_on(struct phy *phy) +{ + if (phy->pwr) + return regulator_enable(phy->pwr); + + return 0; +} + +static int phy_simple_power_off(struct phy *phy) +{ + if (phy->pwr) + return regulator_disable(phy->pwr); + + return 0; +} + +static const struct phy_ops phy_simple_ops = { + .power_on = phy_simple_power_on, + .power_off = phy_simple_power_off, + .owner = THIS_MODULE, +}; + +int phy_simple_probe(struct platform_device *pdev) +{ + struct phy_provider *phy_provider; + struct device *dev = &pdev->dev; + struct regulator *pwr = NULL; + struct phy *phy; + u32 bus_width = 0; + u32 max_bitrate = 0; + int ret; + + phy = devm_phy_create(dev, dev->of_node, + &phy_simple_ops); + + if (IS_ERR(phy)) { + dev_err(dev, "Failed to create phy\n"); + return PTR_ERR(phy); + } + + device_property_read_u32(dev, "bus-width", &bus_width); + phy->attrs.bus_width = bus_width; + device_property_read_u32(dev, "max-bitrate", &max_bitrate); + phy->attrs.max_bitrate = max_bitrate; + + pwr = devm_regulator_get_optional(dev, "pwr"); + if (IS_ERR(pwr)) { + ret = PTR_ERR(pwr); + dev_err(dev, "Couldn't get regulator. ret=%d\n", ret); + return ret; + } + phy->pwr = pwr; + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + + return PTR_ERR_OR_ZERO(phy_provider); +} + +static const struct of_device_id phy_simple_dt_ids[] = { + { .compatible = "simple-phy"}, + {} +}; + +MODULE_DEVICE_TABLE(of, phy_simple_phy_dt_ids); + +static struct platform_driver phy_simple_driver = { + .probe = phy_simple_probe, + .driver = { + .name = "phy-of-simple", + .of_match_table = phy_simple_dt_ids, + }, +}; + +module_platform_driver(phy_simple_driver); + +MODULE_AUTHOR("Faiz Abbas "); +MODULE_DESCRIPTION("Simple PHY driver"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Nov 2 19:26:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 992533 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="W3GSQCd1"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42msTX4DMwzB4Yy for ; Sat, 3 Nov 2018 06:24:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728140AbeKCEca (ORCPT ); Sat, 3 Nov 2018 00:32:30 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:54064 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727952AbeKCEc3 (ORCPT ); Sat, 3 Nov 2018 00:32:29 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wA2JNvDx078018; Fri, 2 Nov 2018 14:23:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1541186637; bh=7rqeRlMU/MryScBAG/F9EVyizjBgZJ6+Y03xj5k0G6g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=W3GSQCd1EaNCmslfZ9lBuDRWEiySuQz/n8XAJNKkgLPyoV2w55tW6YNcKlMv6ySIh o3L0OIj+C4SN7BOdRUtOOps0s4jWdDJj2MS2WTEwcIlR2XGvf671jnw/lYx6vxXrNZ 1YR3xKLBobbYaUJnsUMsDv9KS48taH0G6+gZ5V1I= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wA2JNvXh117580 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 14:23:57 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 2 Nov 2018 14:23:56 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 2 Nov 2018 14:23:57 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wA2JNfvY000522; Fri, 2 Nov 2018 14:23:54 -0500 From: Faiz Abbas To: , , , CC: , , , , , Subject: [PATCH 4/6] dt-bindings: can: m_can: Document transceiver implementation as a phy Date: Sat, 3 Nov 2018 00:56:14 +0530 Message-ID: <20181102192616.28291-5-faiz_abbas@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181102192616.28291-1-faiz_abbas@ti.com> References: <20181102192616.28291-1-faiz_abbas@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some transceivers need a configuration step (for example, pulling a standby line low) for them to start sending messages. Instead of a parent child relationship, the transceiver can be implemented as a phy with the configuration done in the phy driver. The bitrate limitations can then be obtained by the driver using said phy node. Document the above implementation. Signed-off-by: Faiz Abbas --- .../devicetree/bindings/net/can/m_can.txt | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/m_can.txt b/Documentation/devicetree/bindings/net/can/m_can.txt index ed614383af9c..c11548e74278 100644 --- a/Documentation/devicetree/bindings/net/can/m_can.txt +++ b/Documentation/devicetree/bindings/net/can/m_can.txt @@ -42,12 +42,14 @@ Required properties: Please refer to 2.4.1 Message RAM Configuration in Bosch M_CAN user manual for details. +Optional properties: +- phy-names : must be "can_transceiver". The transceiver + typically limits the maximum bitrate of the + system. The phy node is used to discover this + limitation. +- phys : phandle to the transceiver implemented as a phy + node. -Optional Subnode: -- can-transceiver : Can-transceiver subnode describing maximum speed - that can be used for CAN/CAN-FD modes. See - Documentation/devicetree/bindings/net/can/can-transceiver.txt - for details. Example: SoC dtsi: m_can1: can@20e8000 { @@ -64,12 +66,18 @@ m_can1: can@20e8000 { }; Board dts: + &m_can1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_m_can1>; status = "enabled"; + phy-names = "can_transceiver"; + phys = <&transceiver1>; +}; - can-transceiver { - max-bitrate = <5000000>; - }; +transceiver1: can-transceiver { + compatible = "simple-phy"; + max-bitrate = <5000000>; + pwr-supply = <&transceiver1_fixed>; + #phy-cells = <0>; }; From patchwork Fri Nov 2 19:26:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 992531 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42msT822FYzB4X0 for ; Sat, 3 Nov 2018 06:24:28 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbeKCEcq (ORCPT ); Sat, 3 Nov 2018 00:32:46 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:54066 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728033AbeKCEca (ORCPT ); Sat, 3 Nov 2018 00:32:30 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wA2JO08X078029; Fri, 2 Nov 2018 14:24:00 -0500 Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wA2JO0E4127883 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 14:24:00 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 2 Nov 2018 14:24:00 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 2 Nov 2018 14:24:00 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wA2JNfvZ000522; Fri, 2 Nov 2018 14:23:57 -0500 From: Faiz Abbas To: , , , CC: , , , , , Subject: [PATCH 5/6] dt-bindings: can: can-transceiver: Remove legacy binding documentation Date: Sat, 3 Nov 2018 00:56:15 +0530 Message-ID: <20181102192616.28291-6-faiz_abbas@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181102192616.28291-1-faiz_abbas@ti.com> References: <20181102192616.28291-1-faiz_abbas@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With the transceiver node being implemented as a phy, remove the legacy dcoumentation. Don't remove the code implementing it to maintain dt compatibility. Signed-off-by: Faiz Abbas --- .../bindings/net/can/can-transceiver.txt | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 Documentation/devicetree/bindings/net/can/can-transceiver.txt diff --git a/Documentation/devicetree/bindings/net/can/can-transceiver.txt b/Documentation/devicetree/bindings/net/can/can-transceiver.txt deleted file mode 100644 index 0011f53ff159..000000000000 --- a/Documentation/devicetree/bindings/net/can/can-transceiver.txt +++ /dev/null @@ -1,24 +0,0 @@ -Generic CAN transceiver Device Tree binding ------------------------------- - -CAN transceiver typically limits the max speed in standard CAN and CAN FD -modes. Typically these limitations are static and the transceivers themselves -provide no way to detect this limitation at runtime. For this situation, -the "can-transceiver" node can be used. - -Required Properties: - max-bitrate: a positive non 0 value that determines the max - speed that CAN/CAN-FD can run. Any other value - will be ignored. - -Examples: - -Based on Texas Instrument's TCAN1042HGV CAN Transceiver - -m_can0 { - .... - can-transceiver { - max-bitrate = <5000000>; - }; - ... -}; From patchwork Fri Nov 2 19:26:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 992529 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42msSy5RjCzB4X0 for ; Sat, 3 Nov 2018 06:24:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728274AbeKCEcf (ORCPT ); Sat, 3 Nov 2018 00:32:35 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:57314 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbeKCEce (ORCPT ); Sat, 3 Nov 2018 00:32:34 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id wA2JO3qD011849; Fri, 2 Nov 2018 14:24:03 -0500 Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wA2JO32m128026 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 14:24:03 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 2 Nov 2018 14:24:03 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 2 Nov 2018 14:24:03 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wA2JNfva000522; Fri, 2 Nov 2018 14:24:00 -0500 From: Faiz Abbas To: , , , CC: , , , , , Subject: [PATCH 6/6] can: m_can: Add support for transceiver as phy Date: Sat, 3 Nov 2018 00:56:16 +0530 Message-ID: <20181102192616.28291-7-faiz_abbas@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181102192616.28291-1-faiz_abbas@ti.com> References: <20181102192616.28291-1-faiz_abbas@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support for implementing the transceiver device as a phy. Instead of a child node, the max_bitrate information is obtained by getting a phy attribute. Fallback to the legacy API if no phy node is found. Signed-off-by: Faiz Abbas --- drivers/net/can/m_can/m_can.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 9b449400376b..ed6d84acea20 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -26,6 +26,7 @@ #include #include #include +#include #include /* napi related */ @@ -1582,6 +1583,7 @@ static int m_can_plat_probe(struct platform_device *pdev) struct device_node *np; u32 mram_config_vals[MRAM_CFG_LEN]; u32 tx_fifo_size; + struct phy *transceiver; np = pdev->dev.of_node; @@ -1671,7 +1673,26 @@ static int m_can_plat_probe(struct platform_device *pdev) devm_can_led_init(dev); - of_can_transceiver(dev); + transceiver = devm_phy_optional_get(&pdev->dev, "can_transceiver"); + if (IS_ERR(transceiver)) { + ret = PTR_ERR(transceiver); + dev_err(&pdev->dev, "Couldn't get phy. err=%d\n", ret); + return ret; + } + + if (!transceiver) { + dev_warn(&pdev->dev, "No transceiver phy. Falling back to legacy API\n"); + of_can_transceiver(dev); + } else { + ret = phy_power_on(transceiver); + if (ret) { + dev_err(&pdev->dev, "phy_power_on err:%d\n", ret); + return ret; + } + priv->can.bitrate_max = phy_get_max_bitrate(transceiver); + if (!priv->can.bitrate_max) + dev_warn(&pdev->dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit\n"); + } dev_info(&pdev->dev, "%s device registered (irq=%d, version=%d)\n", KBUILD_MODNAME, dev->irq, priv->version);