From mboxrd@z Thu Jan 1 00:00:00 1970 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 47B56CA0FE7 for ; Mon, 25 Aug 2025 16:34:18 +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:In-Reply-To:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n+z3qJ8HBCKa3Mdyct7XsfyIFhUy5CP/jmZVztFY6N4=; b=DN5X+SJhiJepCP EVmnXJKxNvq3Pj+0hcZN9ektuHpOw8+OpRxO/0+PowWV0X3zG9Jufh4Cir2vEGmK9y86XO+4EsaX3 s0a9mKNhi99xnTPR9omwMeMlxkHPvtp9y6SXXlr9IAA0DHbcue5S6CWva9mawTt2uF4jfQqqAEvVw e4MujuHbSiRl2DhprueFQsg8pQCdqZT72GLegRZ/yOvlc5Af68jO9zA4XZl0p89uzV1yYELEMos7I DRqrzH2yLXcg7TOBwgxjnCmkQ0VAg6fN2s9vFJltLekqnBstRD3zXwYcYx7A6fPB1vTbz6aHkmV5V C95Dq1WFpSgAuNX9dS6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uqa9C-00000008h7q-0AAr; Mon, 25 Aug 2025 16:34:18 +0000 Received: from mail-northeuropeazlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c200::1] helo=DB3PR0202CU003.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uqZVH-00000008ZUh-3Lw5; Mon, 25 Aug 2025 15:53:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vAW2iCyjwFYop6IKnA71uYlTyYNOI9zUQl8yEzzJK6kyLjPGE5Ut8qZfgQRqzcSaS0p67yQMleBwh1wymvoJvJfSMGZjwmCJLmgcgLHdRxvtpoYzd5n+VYiOorEb5OX6VBchavB8qAauQUrHPUz8iM/OQRWo3RBG7hc+3KiEXyRgI3ScYk46yZjX/fEz97DJacNFvnh/s7RU4M739VmXGnCoFmspYhR5UjkzCS324jAh7uG9yt1mwnf9hzectRwbHswkb8Rd2ztUauCNVHNMfjA77G2m+DwUADuF8+NZ27AS2dzDVTj/KIGBNnWFdqBtaio8cgQBd0V/CrdVQHF35g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F3DrOc2Ad6FUPHEneZ/jpVbmxs8aYEMV8KAxru+BCk0=; b=gjeqPsKAbJaP5yCgOG6Yz+Zk2lGNJrJuEcVGJWNhfOlLJ+qSBc0MP/wMb9wblJdabrVkYUq3QFOLaZLIhH1BG2hrH4jJLHjoLe6WH1/D12hOvvHAfg9Zibb49ut3p0YUP5bEWGLpSTorndYyl82G0xa2kTgeW6qrHlzmf629uxGlOAOEIm242Io2I1htN4sqMXNhRdp1mvEKpqOOu5WIRL73gOrVmRVa/AH5oGW9q1+7g+FUbTUmjW/rxDQgL37u9PoZJXvDA4BqQLy/bw5InNX8h67SXrzxAHjmRdprGpV+QoAuv3/KuJGRUDrSj8QdNMFlDNm4i7D1ku8KVAKAYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F3DrOc2Ad6FUPHEneZ/jpVbmxs8aYEMV8KAxru+BCk0=; b=cq/dojPtnN/DsiU4xvJLX8GkkDu87YZsxeK1u3Cpoq2Arg0RRUFbM4czDP11CxxRWfOWk3mHfPLMVZ6813WbskDyyPNwek0gc/TsX5J4wk1AGsIjXNm6QCVHszlRYLsUDC74Z6gapzuSaYD3/4vohhNQzDf526BocktquI19JSzFt0MexNuoija9o0dRuKbRIrF7nwH3HIISlKVgbwhof4ek12duC6LDmqNAZXqFeFHl5IuYVS3OEyaOKLoCv9M1td8ob7iLD2ZES0kHfAjE/e2Ul5aVnTaaJUy2h4Q5KcUhC4aVgYqv8B8AH8G4eM+XmOVtBrhZOVA4SJ5WqdoaBQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) by AM0PR04MB7171.eurprd04.prod.outlook.com (2603:10a6:208:19c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9073.13; Mon, 25 Aug 2025 15:52:56 +0000 Received: from DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d]) by DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d%5]) with mapi id 15.20.9073.009; Mon, 25 Aug 2025 15:52:56 +0000 Date: Mon, 25 Aug 2025 11:52:47 -0400 From: Frank Li To: Peng Fan Cc: Marc Kleine-Budde , Vincent Mailhol , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Aswath Govindraju , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Haibo Chen , linux-can@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 2/5] phy: phy-can-transceiver: Add dual channel support for TJA1048 Message-ID: References: <20250825-can-v2-0-c461e9fcbc14@nxp.com> <20250825-can-v2-2-c461e9fcbc14@nxp.com> Content-Disposition: inline In-Reply-To: <20250825-can-v2-2-c461e9fcbc14@nxp.com> X-ClientProxiedBy: SJ0PR13CA0010.namprd13.prod.outlook.com (2603:10b6:a03:2c0::15) To DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9626:EE_|AM0PR04MB7171:EE_ X-MS-Office365-Filtering-Correlation-Id: 37eebd0e-ef41-42df-ab1f-08dde3ef7587 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|19092799006|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JjEc8APjCMT/0mkpZtR1Skdeng/Wui4C8YngfOT4FKmY1jepFbnqoFFg+Y1J?= =?us-ascii?Q?+xRkdpJZWWJA7XvqbsnSBPWsel7WeRgCVzY5d0SC95hsYC24rmzPfUXMhRtF?= =?us-ascii?Q?Ix28FkG+0mL9hDKROFD5jv9cCOQTYQfVicw5zA9fd0nWAWfsQZrq7JhTUqDv?= =?us-ascii?Q?WTlp+QCPqljvddopur4D27egKMr57+ODunijQvJnF7S9s6LYUSadmW+7uvOz?= =?us-ascii?Q?HIjDCZSXUlZKsvw3n0gJheGhSN+RSMS5CtNnqEWUnhOP8XusCeFz2fLy6xSk?= =?us-ascii?Q?d9Agio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?= =?us-ascii?Q?p5vNPPWxlwBFW46pG1qj/kfnigkb4Z11UeqIKVW3OGCkXKXBD/buSoe93dEL?= =?us-ascii?Q?jfiszqjziOT9R1JIxmTUTDzklCvVLLc18ERX9lXBChD1PQd14zGEgC3i9Vnv?= =?us-ascii?Q?y3C1Or7F8T/9Ikr5wAEFngylvObI9IIuyubFAs09R4RPLiLL4idx8MPB/0ka?= =?us-ascii?Q?HZq2QZcKA7TQRx0w1tfZNr374rxsiaN/PqJM7DGLSU8MHXkNbWagF7v3BmIT?= =?us-ascii?Q?373JG5OIo3/kOC4A1gDu1CFunKAL6HXHWYp9unDVDMdTSlpH10nGbw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9626.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(19092799006)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bOZceR+0O5OY8PPymFTIJBUE5Sard4mM/xwKVSipX0QJ1japBImg/7hkoZkC?= =?us-ascii?Q?kJEjcSOAVRu9cgJ8D7l3DNNyMb+KHwzrHHOgZsm7hKG3qZT8O5gRrLs4iy0L?= =?us-ascii?Q?uYdJEXZ7yPZQvw3SeYj6W1zhtd7DhK/mgyLDiDt2Lmw2Krfg0O8LO7Mb2NLy?= =?us-ascii?Q?Z7f1VABYlrYptO1Z8hIcJTolBrxtjUxR4GDgJXxYIKgDPtgSY/RPzrb+ys9Q?= =?us-ascii?Q?QBlWag4zq/bAsGK3tVsfv/808IwKbJTErL9ZF5F6Ee0uBfJuKcWrf+u2gYw/?= =?us-ascii?Q?MVOufXahUzIbI3ImKKEbyQ9noz+P27U9mkl3trjr/dLP1YDzpVjiTeUxOOR5?= =?us-ascii?Q?rHTl9TJKPWxpv9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Rq?= =?us-ascii?Q?CTwtJSmlTBB4axrl7/E7rJEUSCNzArnwvDfqHTw13NwuyraDcg7cSSDChV5d?= =?us-ascii?Q?fU8JeooxF1FvoHnQoj15O32rJkJuEweXdC5RmBAZNo+fyQk++DDArCf88bZY?= =?us-ascii?Q?zcq3P6jsyNqJVI7C2MJPksXiZQ/rgHDUrhoeyzw/hZngdTcQVGJnK6XBLT9I?= =?us-ascii?Q?oCU3f/Eyza6GBB10QcSYUL+gD8hPpQ+70L62QNuBiCqlKyWGARr6GYwF33SR?= =?us-ascii?Q?TVGY/KCRMa02x7C+widNMv/6okFLtFbBYs+NdQ+/vVflnyGqRWTpNK1bHXh1?= =?us-ascii?Q?kNf75E0vTGtYRykEzUk=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37eebd0e-ef41-42df-ab1f-08dde3ef7587 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9626.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2025 15:52:56.6627 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2NA20u0hbkM5BiDBiTP9Z0kObjh0OjjYFxknWrorL6359dpW2y6ucyPACD9GiOgLZmWs/l4Pb3ssSlSGDbF3aA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7171 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250825_085303_997163_8B8568CF X-CRM114-Status: GOOD ( 29.12 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org On Mon, Aug 25, 2025 at 04:36:43PM +0800, Peng Fan wrote: > - Introduce new flag CAN_TRANSCEIVER_DUAL_CH to indicate the phy > has two channels. > - Introduce can_transceiver_priv as a higher level encapsulation for > phy, mux_state, num_ch. > - Alloc a phy for each channel > - Support TJA1048 which is a dual high-speed CAN transceiver with > Sleep mode supported. > > Signed-off-by: Peng Fan > --- > drivers/phy/phy-can-transceiver.c | 117 +++++++++++++++++++++++++++----------- > 1 file changed, 83 insertions(+), 34 deletions(-) > > diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c > index f59caff4b3d4c267feca4220bf1547b6fad08f95..8f0baf0d29536d2b18c5839d6275f020f9af7e45 100644 > --- a/drivers/phy/phy-can-transceiver.c > +++ b/drivers/phy/phy-can-transceiver.c > @@ -17,13 +17,20 @@ struct can_transceiver_data { > u32 flags; > #define CAN_TRANSCEIVER_STB_PRESENT BIT(0) > #define CAN_TRANSCEIVER_EN_PRESENT BIT(1) > +#define CAN_TRANSCEIVER_DUAL_CH BIT(2) > }; > > struct can_transceiver_phy { > struct phy *generic_phy; > struct gpio_desc *standby_gpio; > struct gpio_desc *enable_gpio; > + struct can_transceiver_priv *priv; > +}; I suggest create new patch, just add priv (without num_ch), which simple straight forward. Then add num_ch, which will be easy to review. Frank > + > +struct can_transceiver_priv { > + struct can_transceiver_phy *can_transceiver_phy; > struct mux_state *mux_state; > + int num_ch; > }; > > /* Power on function */ > @@ -32,8 +39,8 @@ 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 (can_transceiver_phy->priv->mux_state) { > + ret = mux_state_select(can_transceiver_phy->priv->mux_state); > if (ret) { > dev_err(&phy->dev, "Failed to select CAN mux: %d\n", ret); > return ret; > @@ -56,8 +63,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); > + if (can_transceiver_phy->priv->mux_state) > + mux_state_deselect(can_transceiver_phy->priv->mux_state); > > return 0; > } > @@ -76,6 +83,10 @@ static const struct can_transceiver_data tcan1043_drvdata = { > .flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT, > }; > > +static const struct can_transceiver_data tja1048_drvdata = { > + .flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_DUAL_CH, > +}; > + > static const struct of_device_id can_transceiver_phy_ids[] = { > { > .compatible = "ti,tcan1042", > @@ -85,6 +96,10 @@ static const struct of_device_id can_transceiver_phy_ids[] = { > .compatible = "ti,tcan1043", > .data = &tcan1043_drvdata > }, > + { > + .compatible = "nxp,tja1048", > + .data = &tja1048_drvdata > + }, > { > .compatible = "nxp,tjr1443", > .data = &tcan1043_drvdata > @@ -103,11 +118,27 @@ devm_mux_state_get_optional(struct device *dev, const char *mux_name) > return devm_mux_state_get(dev, mux_name); > } > > +static struct phy *can_transceiver_phy_xlate(struct device *dev, const struct of_phandle_args *args) > +{ > + struct can_transceiver_priv *priv = dev_get_drvdata(dev); > + u32 idx; > + > + if (priv->num_ch == 1) > + return priv->can_transceiver_phy[0].generic_phy; > + > + if (args->args_count != 1) > + return ERR_PTR(-EINVAL); > + > + idx = args->args[0]; > + > + return priv->can_transceiver_phy[idx].generic_phy; > +} > + > static int can_transceiver_phy_probe(struct platform_device *pdev) > { > struct phy_provider *phy_provider; > struct device *dev = &pdev->dev; > - struct can_transceiver_phy *can_transceiver_phy; > + struct can_transceiver_priv *priv; > const struct can_transceiver_data *drvdata; > const struct of_device_id *match; > struct phy *phy; > @@ -115,52 +146,70 @@ static int can_transceiver_phy_probe(struct platform_device *pdev) > struct gpio_desc *enable_gpio; > struct mux_state *mux_state; > u32 max_bitrate = 0; > - int err; > - > - can_transceiver_phy = devm_kzalloc(dev, sizeof(struct can_transceiver_phy), GFP_KERNEL); > - if (!can_transceiver_phy) > - return -ENOMEM; > + int num_ch = 1; > + int err, i; > > match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node); > drvdata = match->data; > > + priv = devm_kzalloc(dev, sizeof(struct can_transceiver_priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + platform_set_drvdata(pdev, priv); > + > + if (drvdata->flags & CAN_TRANSCEIVER_DUAL_CH) > + num_ch = 2; > + > + priv->num_ch = num_ch; > + priv->can_transceiver_phy = devm_kcalloc(dev, num_ch, sizeof(struct can_transceiver_phy), > + GFP_KERNEL); > + if (!priv->can_transceiver_phy) > + return -ENOMEM; > + > mux_state = devm_mux_state_get_optional(dev, NULL); > if (IS_ERR(mux_state)) > return PTR_ERR(mux_state); > > - can_transceiver_phy->mux_state = mux_state; > - > - phy = devm_phy_create(dev, dev->of_node, > - &can_transceiver_phy_ops); > - if (IS_ERR(phy)) { > - dev_err(dev, "failed to create can transceiver phy\n"); > - return PTR_ERR(phy); > - } > + priv->mux_state = mux_state; > > err = device_property_read_u32(dev, "max-bitrate", &max_bitrate); > if ((err != -EINVAL) && !max_bitrate) > dev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit\n"); > - phy->attrs.max_link_rate = max_bitrate; > > - can_transceiver_phy->generic_phy = phy; > + for (i = 0; i < num_ch; i++) { > + phy = devm_phy_create(dev, dev->of_node, &can_transceiver_phy_ops); > + if (IS_ERR(phy)) { > + dev_err(dev, "failed to create can transceiver phy\n"); > + return PTR_ERR(phy); > + } > > - if (drvdata->flags & CAN_TRANSCEIVER_STB_PRESENT) { > - standby_gpio = devm_gpiod_get_optional(dev, "standby", GPIOD_OUT_HIGH); > - if (IS_ERR(standby_gpio)) > - return PTR_ERR(standby_gpio); > - can_transceiver_phy->standby_gpio = standby_gpio; > - } > + phy->attrs.max_link_rate = max_bitrate; > > - if (drvdata->flags & CAN_TRANSCEIVER_EN_PRESENT) { > - enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); > - if (IS_ERR(enable_gpio)) > - return PTR_ERR(enable_gpio); > - can_transceiver_phy->enable_gpio = enable_gpio; > - } > + priv->can_transceiver_phy[i].generic_phy = phy; > + priv->can_transceiver_phy[i].priv = priv; > + > + if (drvdata->flags & CAN_TRANSCEIVER_STB_PRESENT) { > + standby_gpio = devm_gpiod_get_index_optional(dev, "standby", i, > + GPIOD_OUT_HIGH); > + if (IS_ERR(standby_gpio)) > + return PTR_ERR(standby_gpio); > + priv->can_transceiver_phy[i].standby_gpio = standby_gpio; > + } > + > + if (drvdata->flags & CAN_TRANSCEIVER_EN_PRESENT) { > + enable_gpio = devm_gpiod_get_index_optional(dev, "enable", i, > + GPIOD_OUT_LOW); > + if (IS_ERR(enable_gpio)) > + return PTR_ERR(enable_gpio); > + priv->can_transceiver_phy[i].enable_gpio = enable_gpio; > + } > > - phy_set_drvdata(can_transceiver_phy->generic_phy, can_transceiver_phy); > + phy_set_drvdata(priv->can_transceiver_phy[i].generic_phy, > + &priv->can_transceiver_phy[i]); > + } > > - phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); > + phy_provider = devm_of_phy_provider_register(dev, can_transceiver_phy_xlate); > > return PTR_ERR_OR_ZERO(phy_provider); > } > > -- > 2.37.1 > -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy