From nobody Sat Oct 4 01:44:56 2025 Received: from PA4PR04CU001.outbound.protection.outlook.com (mail-francecentralazon11013050.outbound.protection.outlook.com [40.107.162.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C62D027CB21; Fri, 22 Aug 2025 04:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.162.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755835573; cv=fail; b=ZiQav0LV2+A7w/xBpyrlVKEqcleEl7y+8LP9dgk+FjPL3a1AkU7LJl/qUff2IQEfKLsEe+i7XsBRH3sjbvRDmw0o1FrkNPNtqp3zQmFw6lW6MYwCohBtANwixAkrNK+tMJD/FXHRJ3D2I6zvP4R4o4OETei9c2hLkZDz6H3PQjM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755835573; c=relaxed/simple; bh=CVZIQ4AVFIw/s1OETU3s5dWu/tG87msffPU9zpJP2LM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=cUb95z+Q28n8UCoJw6tktigPqHOBe0ydX2C8naSyjHbaFwK2ykwotW2N1lhm2sPz0BAoCtcXmfuS2w/49pgXkAKR+Ou7WZxtFdpnXwAm1UXvWfVrM8Db5eBEw7BOeX5yXv7Zaan/3oy4k67IEzfxets4QJc/RRWRkf4JA4rli20= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=cfzJhc05; arc=fail smtp.client-ip=40.107.162.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="cfzJhc05" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iIBaYDUzqtIxhhcuG0+QFrx3UwRwbV1UwF0nrqOacfEWxoT6FOeZsJ7gh4Svdu0wfJGhMcs7SVlbFMas8EVru4tZ5O9NO5HiaXqzQK0ypzRRw0+s1SMG+401AIdQozNVybJMgGqQPdMCIxgIiAzMveNjEC1ndlE2qd+IOE8LmE0evMTduy5PW3PVBft97WRLpkrP7HW7sc6vJdejUZSeEe6YPW0V9Z0m0Bq1QgzcskYfXISZyDk1tF8dFnylCC09IJrBrEKR+2Chv5EtVFZZSmJWzHPtivvdWZTBOx66yoK982QOFm6EGcWSpnpNXKpsOGZME8LursxC48UKWBuUjg== 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=PyDtflgezckMwAVfnJ83Q9q7tEaJNr3QDTrqbUsNXP0=; b=jtTIcdaffPz85ARi0rWlA5HRcMf0sDfW6/OBJdKIyP62AZuopGgCif/Kbr7xPsiWfh9GyxTd/dMdSxSMoV2ZD0U0tetErReGhX+790kl77K0LPM6LNMegIRMKUdZ8v9fSJLlRkfNMjzLNctbRiwV3SSjRnHIjnNGDie8q7LCraUYlX6LquWz0lNVaIs7Sbsh4Eab1BhPiYlJ6ZsJPjmMviF1EmeKwjvlAJu1xXiMXJS7m2zFH5fT6EZ1689Jx1467bfKEEgfGQGAOfZsad7UhBvRLqR0OlySreasGA9lydevhCEOqlb7Gl9kUBlkbakx1RHITcKuSs6ukD4XoHoWhw== 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=PyDtflgezckMwAVfnJ83Q9q7tEaJNr3QDTrqbUsNXP0=; b=cfzJhc05AEzveGDrXtIN1ehQ7aNm2OFx/VX9n9zNTU95pSDuqc0lqOjIq69ykjWEsyoUhaEJJJe4ouIGiNOkonrJK3wVWzlg3PvfBWKxIlSHp7xH7Beq+EZQlz0yaHjyOFTCJCOA3atdG2t+QfLd1smwVtFLk0EA4gCWshcW0Oja0ofLHeH8IQOq6kqDVgAhfpP3skBif7irZDCTFjAcn4NIykBqiUxK8KkDZMov4gIFwkhgs4k6lpctrtTuxHni4GDazSAPgqFJ9vfKOpKqUJCJ2ZzsZXWWhDPab2F/p9RDNkJEdYCZt3JCShKe+8Eh4vcbg5UkGZDKzzdQGodMiw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by VI2PR04MB10569.eurprd04.prod.outlook.com (2603:10a6:800:273::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9052.12; Fri, 22 Aug 2025 04:06:07 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%7]) with mapi id 15.20.9052.014; Fri, 22 Aug 2025 04:06:07 +0000 From: Peng Fan Date: Fri, 22 Aug 2025 12:05:30 +0800 Subject: [PATCH 3/6] phy: phy-can-transceiver: Add dual channel support for TJA1048 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250822-can-v1-3-c075f702adea@nxp.com> References: <20250822-can-v1-0-c075f702adea@nxp.com> In-Reply-To: <20250822-can-v1-0-c075f702adea@nxp.com> To: 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 , Frank Li , Haibo Chen Cc: 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, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1755835544; l=7283; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=CVZIQ4AVFIw/s1OETU3s5dWu/tG87msffPU9zpJP2LM=; b=vCxqVceK3vZoMvcRCHaL3AlTMiF/+5SByFdZnianN7Wx1NBzFKzB1zI9TpaLasNMAcdO2oLFk kRvJOwt1SOgDfOm79A8icPYV8NgbJVOM1NMdpCMFBV+f5EhTNIMbeuY X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR04CA0189.apcprd04.prod.outlook.com (2603:1096:4:14::27) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|VI2PR04MB10569:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d6f6ad9-d4fc-4bfb-7bc2-08dde131382e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|52116014|19092799006|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dGYvaWhM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VVE5EbGkzMHl0Q3FBQjFRN0dJ?= =?utf-8?B?Rk5oSG9vNERJS1MwNVNscVBGa0tWMWgzM2VlR2dWZkxTcW0yMXV2NW84N1pJ?= =?utf-8?B?VWxqcFpUQWM3RFdndy9aQVZJdG9WRkVHWmNRTzBDcTdNeEdLeEdmVVh2Mkdi?= =?utf-8?B?TjNsWFcwNlBYSVVsRWpGVFhlellDVnYzUWRQM0lhYTR3SHdZWTROaVBOQUxZ?= =?utf-8?Q?5OBQIxlUPDylJVdSFi8mXDbhsAxlk8=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(52116014)(19092799006)(376014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OFV1VytJeGJmdTVrdlVvY0hPODVEYlFPZ1VDZ1o1UUtQb2U1UGxmdjB0RzZP?= =?utf-8?B?SERpRDluYytqYzdZM3UvMDZkdHhTZFhFOUdwUXpSOUF4bmhyY1ZLaHVDcFM5?= =?utf-8?B?YTdLZUFOQ01Hc3p3Wk5RUEcwMjFjbC90NyswUjQvYUVIT01Pb0dsWS9DTHNr?= =?utf-8?B?QmdJUmhIV0tSWTdDSW8yY3UwMkVkY0JmYlUzNHdJczJ4a0NMWENRNmVMT2Iv?= =?utf-8?B?dUp1R095c1pLRDlzRHVHSWQreVZZS3IxTmdWL0d5S2xoQU5FRkNhOVJMQjZF?= =?utf-8?B?N2UzUnF5dkFPQjNTK1Nkc29qU1RQWS93VzFNTm82c2ZoVEZNdnZmWlNDaTJl?= =?utf-8?B?WHlCTzJPcXJBUFNlaWs5dVdvYlpNNFp2M2lnSFF3WG9ETi9GUm9HT1gyaW1Z?= =?utf-8?B?WUNwbExZZWJhN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-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2025 04:06:07.2011 (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: bUAJjZP6/SNSD1rgAhKGIn6UhV0OxwXogWjkfnwxRHB3OXI3nrL5Dzg5QwQSISsCRomIk2oKw7FFY8dq9tUCkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10569 - 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-transc= eiver.c index b49371a1272cd8a25b5e2271586b756103c64f0a..0e7b23073bfa8eae7200d30dc65= 7a979f6cc9d86 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) }; =20 struct can_transceiver_phy { struct phy *generic_phy; struct gpio_desc *standby_gpio; struct gpio_desc *enable_gpio; + struct can_transceiver_priv *priv; +}; + +struct can_transceiver_priv { + struct can_transceiver_phy *can_transceiver_phy; struct mux_state *mux_state; + int num_ch; }; =20 /* Power on function */ @@ -32,8 +39,8 @@ static int can_transceiver_phy_power_on(struct phy *phy) struct can_transceiver_phy *can_transceiver_phy =3D phy_get_drvdata(phy); int ret; =20 - if (can_transceiver_phy->mux_state) { - ret =3D mux_state_select(can_transceiver_phy->mux_state); + if (can_transceiver_phy->priv->mux_state) { + ret =3D 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); =20 return 0; } @@ -76,6 +83,10 @@ static const struct can_transceiver_data tcan1043_drvdat= a =3D { .flags =3D CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT, }; =20 +static const struct can_transceiver_data tja1048_drvdata =3D { + .flags =3D CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_DUAL_CH, +}; + static const struct of_device_id can_transceiver_phy_ids[] =3D { { .compatible =3D "ti,tcan1042", @@ -85,6 +96,10 @@ static const struct of_device_id can_transceiver_phy_ids= [] =3D { .compatible =3D "ti,tcan1043", .data =3D &tcan1043_drvdata }, + { + .compatible =3D "nxp,tja1048", + .data =3D &tja1048_drvdata + }, { .compatible =3D "nxp,tja1051", .data =3D &tcan1043_drvdata @@ -107,11 +122,27 @@ devm_mux_state_get_optional(struct device *dev, const= char *mux_name) return devm_mux_state_get(dev, mux_name); } =20 +static struct phy *can_transceiver_phy_xlate(struct device *dev, const str= uct of_phandle_args *args) +{ + struct can_transceiver_priv *priv =3D dev_get_drvdata(dev); + u32 idx; + + if (priv->num_ch =3D=3D 1) + return priv->can_transceiver_phy[0].generic_phy; + + if (args->args_count !=3D 1) + return ERR_PTR(-EINVAL); + + idx =3D 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 =3D &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; @@ -119,52 +150,70 @@ static int can_transceiver_phy_probe(struct platform_= device *pdev) struct gpio_desc *enable_gpio; struct mux_state *mux_state; u32 max_bitrate =3D 0; - int err; - - can_transceiver_phy =3D devm_kzalloc(dev, sizeof(struct can_transceiver_p= hy), GFP_KERNEL); - if (!can_transceiver_phy) - return -ENOMEM; + int num_ch =3D 1; + int err, i; =20 match =3D of_match_node(can_transceiver_phy_ids, pdev->dev.of_node); drvdata =3D match->data; =20 + priv =3D devm_kzalloc(dev, sizeof(struct can_transceiver_priv), GFP_KERNE= L); + if (!priv) + return -ENOMEM; + + platform_set_drvdata(pdev, priv); + + if (drvdata->flags & CAN_TRANSCEIVER_DUAL_CH) + num_ch =3D 2; + + priv->num_ch =3D num_ch; + priv->can_transceiver_phy =3D devm_kcalloc(dev, num_ch, sizeof(struct can= _transceiver_phy), + GFP_KERNEL); + if (!priv->can_transceiver_phy) + return -ENOMEM; + mux_state =3D devm_mux_state_get_optional(dev, NULL); if (IS_ERR(mux_state)) return PTR_ERR(mux_state); =20 - can_transceiver_phy->mux_state =3D mux_state; - - phy =3D 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 =3D mux_state; =20 err =3D device_property_read_u32(dev, "max-bitrate", &max_bitrate); if ((err !=3D -EINVAL) && !max_bitrate) dev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitra= te limit\n"); - phy->attrs.max_link_rate =3D max_bitrate; =20 - can_transceiver_phy->generic_phy =3D phy; + for (i =3D 0; i < num_ch; i++) { + phy =3D 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); + } =20 - if (drvdata->flags & CAN_TRANSCEIVER_STB_PRESENT) { - standby_gpio =3D devm_gpiod_get_optional(dev, "standby", GPIOD_OUT_HIGH); - if (IS_ERR(standby_gpio)) - return PTR_ERR(standby_gpio); - can_transceiver_phy->standby_gpio =3D standby_gpio; - } + phy->attrs.max_link_rate =3D max_bitrate; =20 - if (drvdata->flags & CAN_TRANSCEIVER_EN_PRESENT) { - enable_gpio =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); - if (IS_ERR(enable_gpio)) - return PTR_ERR(enable_gpio); - can_transceiver_phy->enable_gpio =3D enable_gpio; - } + priv->can_transceiver_phy[i].generic_phy =3D phy; + priv->can_transceiver_phy[i].priv =3D priv; + + if (drvdata->flags & CAN_TRANSCEIVER_STB_PRESENT) { + standby_gpio =3D 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 =3D standby_gpio; + } + + if (drvdata->flags & CAN_TRANSCEIVER_EN_PRESENT) { + enable_gpio =3D 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 =3D enable_gpio; + } =20 - 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]); + } =20 - phy_provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate); + phy_provider =3D devm_of_phy_provider_register(dev, can_transceiver_phy_x= late); =20 return PTR_ERR_OR_ZERO(phy_provider); } --=20 2.37.1