From patchwork Wed Mar 9 06:04:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aswath Govindraju X-Patchwork-Id: 12774787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8374C433F5 for ; Wed, 9 Mar 2022 06:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RsjuXx1apqH8OgPbk0DNMwA2af6/lDmM0k2zhRhH2oc=; b=oR2l50TvZ86tg+ yVU5SKLn+tjrGj5qVIfWpQlyMfAz78dG7vRJwlpfbrRQVwps0tz1jxHukeA02p5G3rlMiotx1YKgz kTOQkZq8zrMXHrWWUVf5EdN432wEh1qim0KitIZbwhCyxP0lAql8V1VMULdgJ8Ca3NJX4t84KWuT0 +oOWM2ASpkG52EqXxva3aC9CTR96sehpbxVIDPmbVVVXI9gwCQa1okAmJBc5BM21wfTANUiGrfzxk fmJj6uhYqxqZn4AEqRXwJWniEEMjnDHLw/MhYUDMr+/G0bxOXwfLXaMUhzln3w7Q1zl0KjibcsoWz QJDX6WNuJJEyudnQmqhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRpRQ-007QWJ-Di; Wed, 09 Mar 2022 06:04:56 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRpRM-007QTx-NA for linux-phy@lists.infradead.org; Wed, 09 Mar 2022 06:04:55 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 22964ie1029513; Wed, 9 Mar 2022 00:04:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1646805884; bh=tFs5PFMWcC0txVuAfsKe7VrAX6diWqLbUfTm5GvmMME=; h=From:To:CC:Subject:Date; b=h54dv5iNtqQuaFAAI0Zfe/ukpi3/9ahSpim8Wjd2zTYX4CEylNbsOX7/l+EjYikL8 tdaaetS8pc5I4pQZooinYPNn6FQtZCbsoi6s+a5M1PZU7slW+sqnMEXwUwrOOnueEf WeVTXBavaKUzWXXDT4wi1K6wN9H3mG17bWXxaNTU= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 22964iqE037203 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 9 Mar 2022 00:04:44 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 9 Mar 2022 00:04:44 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Wed, 9 Mar 2022 00:04:44 -0600 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 22964eNu098487; Wed, 9 Mar 2022 00:04:41 -0600 From: Aswath Govindraju To: CC: Aswath Govindraju , Kishon Vijay Abraham I , Vinod Koul , Wolfgang Grandegger , Marc Kleine-Budde , , , Subject: [PATCH v4] phy: phy-can-transceiver: Add support for setting mux Date: Wed, 9 Mar 2022 11:34:29 +0530 Message-ID: <20220309060429.26366-1-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220308_220452_897948_7AF77221 X-CRM114-Status: GOOD ( 19.84 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org On some boards, for routing CAN signals from controller to transceiver, muxes might need to be set. Therefore, add support for setting the mux by reading the mux-states property from the device tree node. Signed-off-by: Aswath Govindraju --- Changes since v3: - Rebased on top of the linux-next head - Dependencies are now merged in linux next. 84564481bc45 (mux: Add support for reading mux state from consumer DT node) - Dropped bindings patch from the series since it has been picked up from the earlier version https://lore.kernel.org/all/YieG22mgIzsL7TMn@robh.at.kernel.org/ Changes since v2: - Fixed the bindings removing the description about the arguments in mux-states property Changes since v1: - Fixed the description for mux-states property in bindings file - appended declaration of variable ret in the end drivers/phy/Kconfig | 1 + drivers/phy/phy-can-transceiver.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 82b63e60c5a2..300b0f2b5f84 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -64,6 +64,7 @@ config USB_LGM_PHY config PHY_CAN_TRANSCEIVER tristate "CAN transceiver PHY" select GENERIC_PHY + select MULTIPLEXER help This option enables support for CAN transceivers as a PHY. This driver provides function for putting the transceivers in various diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c index 6f3fe37dee0e..95c6dbb52da7 100644 --- a/drivers/phy/phy-can-transceiver.c +++ b/drivers/phy/phy-can-transceiver.c @@ -10,6 +10,7 @@ #include #include #include +#include struct can_transceiver_data { u32 flags; @@ -21,13 +22,22 @@ struct can_transceiver_phy { struct phy *generic_phy; struct gpio_desc *standby_gpio; struct gpio_desc *enable_gpio; + struct mux_state *mux_state; }; /* Power on function */ static int can_transceiver_phy_power_on(struct phy *phy) { struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy); - + int ret; + + if (can_transceiver_phy->mux_state) { + ret = mux_state_select(can_transceiver_phy->mux_state); + if (ret) { + dev_err(&phy->dev, "Failed to select CAN mux: %d\n", ret); + return ret; + } + } if (can_transceiver_phy->standby_gpio) gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0); if (can_transceiver_phy->enable_gpio) @@ -45,6 +55,8 @@ static int can_transceiver_phy_power_off(struct phy *phy) gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1); if (can_transceiver_phy->enable_gpio) gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0); + if (can_transceiver_phy->mux_state) + mux_state_deselect(can_transceiver_phy->mux_state); return 0; } @@ -95,6 +107,16 @@ static int can_transceiver_phy_probe(struct platform_device *pdev) match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node); drvdata = match->data; + if (of_property_read_bool(dev->of_node, "mux-states")) { + struct mux_state *mux_state; + + mux_state = devm_mux_state_get(dev, NULL); + if (IS_ERR(mux_state)) + return dev_err_probe(&pdev->dev, PTR_ERR(mux_state), + "failed to get mux\n"); + can_transceiver_phy->mux_state = mux_state; + } + phy = devm_phy_create(dev, dev->of_node, &can_transceiver_phy_ops); if (IS_ERR(phy)) {