* [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051
@ 2025-09-09 5:40 Peng Fan
2025-09-09 5:40 ` [PATCH v6 1/9] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048 Peng Fan
` (9 more replies)
0 siblings, 10 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
TJA1048 is a Dual channel can transceiver with Sleep mode supported.
TJA105{1,7} is a Single Channel can transceiver with Sleep mode supported.
Frank, I dropped your R-b in patch 1, since this patch changes a bit compared
with V4. Thanks for helping reviewing.
To support them:
patch 1: add binding doc
patch 2/3: To support dual channel,
- 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
patch 4,5: Simplify code and check return value of GPIOD API
patch 6: Add TJA1051,7 support
Others: Update dts to use phys.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Changes in v6:
- Update dt-bindings per Krzysztof's comments
"define if:then:, without any else:, for each variant"
- Add R-b from Frank
- Link to v5: https://lore.kernel.org/r/20250904-can-v5-0-23d8129b5e5d@nxp.com
Changes in v5:
- Update patch 1 dt-bindings for TJA1051 and TJA1057 and allOf entries
for them, per Conor's comments. Thanks Conor for detailed review on
the dt-binding patch.
- Add two new patches patch {3,4} to simplify code and check return value of
gpiod API.
- Add patch 6 because TJA1051 and TJA1057 use their own compatible strings
- Link to v4: https://lore.kernel.org/r/20250901-can-v4-0-e42b5fe2cf9e@nxp.com
Changes in v4:
- Add R-b from Frank for patch 1, 2, 3, 6
- Address the minor comments from Frank regarding min/maxItems, commit
log
- Link to v3: https://lore.kernel.org/r/20250829-can-v3-0-3b2f34094f59@nxp.com
Changes in v3:
- Patch 1: Add TJA1057, update #phy-cells
- Patch 2,3: Separate patch 2 into two patches per Frank, 1st introduce
can_transceiver_priv, 2nd support dual chan by adding num_ch
- Patch 6: Change to 5Mbps rate
- Patch 4,5: Add R-b from Frank
- Link to v2: https://lore.kernel.org/r/20250825-can-v2-0-c461e9fcbc14@nxp.com
Changes in v2:
- Update standby-gpios constraints per Conor's comments
- Drop patch 2 which is not needed.
- Link to v1: https://lore.kernel.org/r/20250822-can-v1-0-c075f702adea@nxp.com
---
Peng Fan (9):
dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
phy: phy-can-transceiver: Introduce can_transceiver_priv
phy: phy-can-transceiver: Add dual channel support for TJA1048
phy: phy-can-transceiver: Drop the gpio desc check
phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep
phy: phy-can-transceiver: Add support for TJA105{1,7}
arm64: dts: imx95-15x15-evk: Use phys to replace xceiver-supply
arm64: dts: imx8mp-evk: Use phys to replace xceiver-supply
arm64: dts: imx93-11x11-evk: Use phys to replace xceiver-supply
.../devicetree/bindings/phy/ti,tcan104x-can.yaml | 69 +++++++-
arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 43 ++---
arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts | 17 +-
arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts | 13 +-
drivers/phy/phy-can-transceiver.c | 180 ++++++++++++++++-----
5 files changed, 229 insertions(+), 93 deletions(-)
---
base-commit: da57e528a86120a1187edf3e2c9affb4083d342d
change-id: 20250821-can-c832cb4f0323
Best regards,
--
Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v6 1/9] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-10 2:33 ` Rob Herring (Arm)
2025-09-09 5:40 ` [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv Peng Fan
` (8 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
The TJA1048 is a dual high-speed CAN transceiver with sleep mode supported
and no EN pin.
The TJA1051 is a high-speed CAN transceiver with slient mode supported,
but only TJA1051T/E has EN pin. To make it simple, make enable-gpios as
optional for TJA1051.
The TJA1057 is a high-speed CAN transceiver with slient mode supported
and no EN pin.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
.../devicetree/bindings/phy/ti,tcan104x-can.yaml | 69 +++++++++++++++++++++-
1 file changed, 66 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
index 138923ffedfeeb6a0b391cae863723ec70bf2c88..c686d06f5f5619552bf041c951e36b71cb68c2a0 100644
--- a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
+++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
@@ -23,16 +23,26 @@ properties:
- enum:
- ti,tcan1042
- ti,tcan1043
+ - nxp,tja1048
+ - nxp,tja1051
+ - nxp,tja1057
- nxp,tjr1443
'#phy-cells':
- const: 0
+ enum: [0, 1]
- standby-gpios:
+ silent-gpios:
description:
- gpio node to toggle standby signal on transceiver
+ gpio node to toggle silent signal on transceiver
maxItems: 1
+ standby-gpios:
+ description:
+ gpio node to toggle standby signal on transceiver. For two Items, item 1
+ is for stbn1, item 2 is for stbn2.
+ minItems: 1
+ maxItems: 2
+
enable-gpios:
description:
gpio node to toggle enable signal on transceiver
@@ -54,6 +64,59 @@ required:
- compatible
- '#phy-cells'
+allOf:
+ - if:
+ properties:
+ compatible:
+ enum:
+ - nxp,tjr1443
+ - ti,tcan1042
+ - ti,tcan1043
+ then:
+ properties:
+ '#phy-cells':
+ const: 0
+ silent-gpios: false
+ standby-gpios:
+ maxItems: 1
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nxp,tja1048
+ then:
+ properties:
+ '#phy-cells':
+ const: 1
+ enable-gpios: false
+ silent-gpios: false
+ standby-gpios:
+ minItems: 2
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nxp,tja1051
+ then:
+ properties:
+ '#phy-cells':
+ const: 0
+ standby-gpios: false
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nxp,tja1057
+ then:
+ properties:
+ '#phy-cells':
+ const: 0
+ enable-gpios: false
+ standby-gpios: false
+
additionalProperties: false
examples:
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
2025-09-09 5:40 ` [PATCH v6 1/9] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048 Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-19 19:08 ` Marc Kleine-Budde
2025-09-20 4:37 ` Vincent Mailhol
2025-09-09 5:40 ` [PATCH v6 3/9] phy: phy-can-transceiver: Add dual channel support for TJA1048 Peng Fan
` (7 subsequent siblings)
9 siblings, 2 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
To prepare for dual-channel phy support, introduce can_transceiver_priv as
a higher level encapsulation for phy and mux_state.
No functional changes.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/phy/phy-can-transceiver.c | 41 ++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index f59caff4b3d4c267feca4220bf1547b6fad08f95..6415c6af0e8414a6cc8d15958a17ee749a3f28e9 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -23,6 +23,11 @@ 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;
};
@@ -32,8 +37,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 +61,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;
}
@@ -107,7 +112,7 @@ 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;
@@ -117,18 +122,25 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
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;
-
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);
+
+ priv->can_transceiver_phy = devm_kzalloc(dev, 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;
+ priv->mux_state = mux_state;
phy = devm_phy_create(dev, dev->of_node,
&can_transceiver_phy_ops);
@@ -142,23 +154,24 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
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;
+ priv->can_transceiver_phy->generic_phy = phy;
+ priv->can_transceiver_phy->priv = priv;
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;
+ priv->can_transceiver_phy->standby_gpio = standby_gpio;
}
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->enable_gpio = enable_gpio;
}
- phy_set_drvdata(can_transceiver_phy->generic_phy, can_transceiver_phy);
+ phy_set_drvdata(priv->can_transceiver_phy->generic_phy, priv->can_transceiver_phy);
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 3/9] phy: phy-can-transceiver: Add dual channel support for TJA1048
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
2025-09-09 5:40 ` [PATCH v6 1/9] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048 Peng Fan
2025-09-09 5:40 ` [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-19 19:11 ` Marc Kleine-Budde
2025-09-09 5:40 ` [PATCH v6 4/9] phy: phy-can-transceiver: Drop the gpio desc check Peng Fan
` (6 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
- Introduce new flag CAN_TRANSCEIVER_DUAL_CH to indicate the phy has two
channels.
- Alloc a phy for each channel
- Support TJA1048 which is a dual high-speed CAN transceiver with sleep
mode supported.
- Add can_transceiver_phy_xlate for parsing phy
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/phy/phy-can-transceiver.c | 91 ++++++++++++++++++++++++++++-----------
1 file changed, 65 insertions(+), 26 deletions(-)
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index 6415c6af0e8414a6cc8d15958a17ee749a3f28e9..f06b1df76ada023f432dce892c3346f45397ab54 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -17,6 +17,7 @@ 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 {
@@ -29,6 +30,7 @@ struct can_transceiver_phy {
struct can_transceiver_priv {
struct can_transceiver_phy *can_transceiver_phy;
struct mux_state *mux_state;
+ int num_ch;
};
/* Power on function */
@@ -81,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",
@@ -90,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
@@ -108,6 +118,25 @@ 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];
+ if (idx >= priv->num_ch)
+ return ERR_PTR(-EINVAL);
+
+ return priv->can_transceiver_phy[idx].generic_phy;
+}
+
static int can_transceiver_phy_probe(struct platform_device *pdev)
{
struct phy_provider *phy_provider;
@@ -120,7 +149,8 @@ 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;
+ int num_ch = 1;
+ int err, i;
match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node);
drvdata = match->data;
@@ -131,7 +161,11 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
- priv->can_transceiver_phy = devm_kzalloc(dev, sizeof(struct can_transceiver_phy),
+ 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;
@@ -142,38 +176,43 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
priv->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);
- }
-
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;
- priv->can_transceiver_phy->generic_phy = phy;
- priv->can_transceiver_phy->priv = priv;
+ 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);
- priv->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);
- priv->can_transceiver_phy->enable_gpio = enable_gpio;
- }
+ priv->can_transceiver_phy[i].generic_phy = phy;
+ priv->can_transceiver_phy[i].priv = priv;
- phy_set_drvdata(priv->can_transceiver_phy->generic_phy, priv->can_transceiver_phy);
+ 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(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
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 4/9] phy: phy-can-transceiver: Drop the gpio desc check
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
` (2 preceding siblings ...)
2025-09-09 5:40 ` [PATCH v6 3/9] phy: phy-can-transceiver: Add dual channel support for TJA1048 Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-09 5:40 ` [PATCH v6 5/9] phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep Peng Fan
` (5 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
gpiod_set_value_cansleep has an internal check on gpio_desc using
'VALIDATE_DESC(desc)', the check before invoking gpiod_set_value_cansleep
could be removed.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/phy/phy-can-transceiver.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index f06b1df76ada023f432dce892c3346f45397ab54..b7d75a78d9242e2003660a87d2d4c9f784aea523 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -46,10 +46,8 @@ static int can_transceiver_phy_power_on(struct phy *phy)
return ret;
}
}
- if (can_transceiver_phy->standby_gpio)
- gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
- if (can_transceiver_phy->enable_gpio)
- gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
+ gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
+ gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
return 0;
}
@@ -59,10 +57,8 @@ static int can_transceiver_phy_power_off(struct phy *phy)
{
struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
- if (can_transceiver_phy->standby_gpio)
- 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);
+ gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
+ gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
if (can_transceiver_phy->priv->mux_state)
mux_state_deselect(can_transceiver_phy->priv->mux_state);
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 5/9] phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
` (3 preceding siblings ...)
2025-09-09 5:40 ` [PATCH v6 4/9] phy: phy-can-transceiver: Drop the gpio desc check Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-19 19:18 ` Marc Kleine-Budde
2025-09-09 5:40 ` [PATCH v6 6/9] phy: phy-can-transceiver: Add support for TJA105{1,7} Peng Fan
` (4 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
gpiod_set_value_cansleep might return failure, propagate the return value
of gpiod_set_value_cansleep to parent.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/phy/phy-can-transceiver.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index b7d75a78d9242e2003660a87d2d4c9f784aea523..ccb29e1dfe0d07005b4bcd8fefa2787292d921a0 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -46,23 +46,32 @@ static int can_transceiver_phy_power_on(struct phy *phy)
return ret;
}
}
- gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
- gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
- return 0;
+ ret = gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
+ if (ret)
+ return ret;
+
+ return gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
}
/* Power off function */
static int can_transceiver_phy_power_off(struct phy *phy)
{
struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+ int ret;
+
+ ret = gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
+ if (ret)
+ return ret;
+
+ ret = gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
+ if (ret)
+ return ret;
- gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
- gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
if (can_transceiver_phy->priv->mux_state)
- mux_state_deselect(can_transceiver_phy->priv->mux_state);
+ ret = mux_state_deselect(can_transceiver_phy->priv->mux_state);
- return 0;
+ return ret;
}
static const struct phy_ops can_transceiver_phy_ops = {
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 6/9] phy: phy-can-transceiver: Add support for TJA105{1,7}
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
` (4 preceding siblings ...)
2025-09-09 5:40 ` [PATCH v6 5/9] phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-09 5:40 ` [PATCH v6 7/9] arm64: dts: imx95-15x15-evk: Use phys to replace xceiver-supply Peng Fan
` (3 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
Support TJA105{1,7} which are a single channel high-speed CAN transceiver
with silent mode supported.
phy mode is not implemented as of now. silent settings are kept in
phy_power_on and phy_power_off. After phy mode is supported, the silent
settings could be moved to phy_set_mode.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/phy/phy-can-transceiver.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index ccb29e1dfe0d07005b4bcd8fefa2787292d921a0..d9fd3564970695d5460ffdc4e8636dd7638d64a2 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -18,10 +18,12 @@ struct can_transceiver_data {
#define CAN_TRANSCEIVER_STB_PRESENT BIT(0)
#define CAN_TRANSCEIVER_EN_PRESENT BIT(1)
#define CAN_TRANSCEIVER_DUAL_CH BIT(2)
+#define CAN_TRANSCEIVER_SILENT_PRESENT BIT(3)
};
struct can_transceiver_phy {
struct phy *generic_phy;
+ struct gpio_desc *silent_gpio;
struct gpio_desc *standby_gpio;
struct gpio_desc *enable_gpio;
struct can_transceiver_priv *priv;
@@ -47,6 +49,10 @@ static int can_transceiver_phy_power_on(struct phy *phy)
}
}
+ ret = gpiod_set_value_cansleep(can_transceiver_phy->silent_gpio, 0);
+ if (ret)
+ return ret;
+
ret = gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
if (ret)
return ret;
@@ -60,6 +66,10 @@ static int can_transceiver_phy_power_off(struct phy *phy)
struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
int ret;
+ ret = gpiod_set_value_cansleep(can_transceiver_phy->silent_gpio, 1);
+ if (ret)
+ return ret;
+
ret = gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
if (ret)
return ret;
@@ -92,6 +102,14 @@ static const struct can_transceiver_data tja1048_drvdata = {
.flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_DUAL_CH,
};
+static const struct can_transceiver_data tja1051_drvdata = {
+ .flags = CAN_TRANSCEIVER_SILENT_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
+};
+
+static const struct can_transceiver_data tja1057_drvdata = {
+ .flags = CAN_TRANSCEIVER_SILENT_PRESENT,
+};
+
static const struct of_device_id can_transceiver_phy_ids[] = {
{
.compatible = "ti,tcan1042",
@@ -105,6 +123,14 @@ static const struct of_device_id can_transceiver_phy_ids[] = {
.compatible = "nxp,tja1048",
.data = &tja1048_drvdata
},
+ {
+ .compatible = "nxp,tja1051",
+ .data = &tja1051_drvdata
+ },
+ {
+ .compatible = "nxp,tja1057",
+ .data = &tja1057_drvdata
+ },
{
.compatible = "nxp,tjr1443",
.data = &tcan1043_drvdata
@@ -150,6 +176,7 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
const struct can_transceiver_data *drvdata;
const struct of_device_id *match;
struct phy *phy;
+ struct gpio_desc *silent_gpio;
struct gpio_desc *standby_gpio;
struct gpio_desc *enable_gpio;
struct mux_state *mux_state;
@@ -213,6 +240,14 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
priv->can_transceiver_phy[i].enable_gpio = enable_gpio;
}
+ if (drvdata->flags & CAN_TRANSCEIVER_SILENT_PRESENT) {
+ silent_gpio = devm_gpiod_get_index_optional(dev, "silent", i,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(silent_gpio))
+ return PTR_ERR(silent_gpio);
+ priv->can_transceiver_phy[i].silent_gpio = silent_gpio;
+ }
+
phy_set_drvdata(priv->can_transceiver_phy[i].generic_phy,
&priv->can_transceiver_phy[i]);
}
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 7/9] arm64: dts: imx95-15x15-evk: Use phys to replace xceiver-supply
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
` (5 preceding siblings ...)
2025-09-09 5:40 ` [PATCH v6 6/9] phy: phy-can-transceiver: Add support for TJA105{1,7} Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-09 5:40 ` [PATCH v6 8/9] arm64: dts: imx8mp-evk: " Peng Fan
` (2 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
The TJA1051T/3 used on i.MX95-15x15-EVK is actually high-speed CAN
transceiver, not a regulator supply. So use phys to reflect the truth.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts b/arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts
index 148243470dd4ab03afdae949c8316f31467d1377..a15f021498869918945405cc7f34ea7e27ae6aea 100644
--- a/arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts
@@ -106,12 +106,11 @@ reg_audio_switch1: regulator-audio-switch1 {
gpio = <&pcal6524 0 GPIO_ACTIVE_LOW>;
};
- reg_can2_stby: regulator-can2-stby {
- compatible = "regulator-fixed";
- regulator-max-microvolt = <3300000>;
- regulator-min-microvolt = <3300000>;
- regulator-name = "can2-stby";
- gpio = <&pcal6524 14 GPIO_ACTIVE_LOW>;
+ flexcan2_phy: can-phy {
+ compatible = "nxp,tja1051";
+ #phy-cells = <0>;
+ max-bitrate = <5000000>;
+ silent-gpios = <&pcal6524 14 GPIO_ACTIVE_HIGH>;
};
reg_m2_pwr: regulator-m2-pwr {
@@ -317,7 +316,7 @@ &enetc_port1 {
&flexcan2 {
pinctrl-0 = <&pinctrl_flexcan2>;
pinctrl-names = "default";
- xceiver-supply = <®_can2_stby>;
+ phys = <&flexcan2_phy>;
status = "okay";
};
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 8/9] arm64: dts: imx8mp-evk: Use phys to replace xceiver-supply
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
` (6 preceding siblings ...)
2025-09-09 5:40 ` [PATCH v6 7/9] arm64: dts: imx95-15x15-evk: Use phys to replace xceiver-supply Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-09 5:40 ` [PATCH v6 9/9] arm64: dts: imx93-11x11-evk: " Peng Fan
2025-09-18 13:35 ` [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
9 siblings, 0 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
The TJA1048 used on i.MX8MP-EVK is actually high-speed CAN transceiver,
not a regulator supply. So use phys to reflect the truth.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 43 +++++++++-------------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts
index 3730792daf5010213cbb9f6869a8110ea28eb48a..59891627dc462d37dfd620eb68b893546cc20d6a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts
@@ -56,6 +56,16 @@ memory@40000000 {
<0x1 0x00000000 0 0xc0000000>;
};
+ flexcan_phy: can-phy {
+ compatible = "nxp,tja1048";
+ #phy-cells = <1>;
+ max-bitrate = <5000000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_flexcan_phy>;
+ standby-gpios = <&gpio5 5 GPIO_ACTIVE_LOW>,
+ <&gpio4 27 GPIO_ACTIVE_LOW>;
+ };
+
native-hdmi-connector {
compatible = "hdmi-connector";
label = "HDMI OUT";
@@ -103,28 +113,6 @@ reg_audio_pwr: regulator-audio-pwr {
enable-active-high;
};
- reg_can1_stby: regulator-can1-stby {
- compatible = "regulator-fixed";
- regulator-name = "can1-stby";
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_flexcan1_reg>;
- regulator-min-microvolt = <3300000>;
- regulator-max-microvolt = <3300000>;
- gpio = <&gpio5 5 GPIO_ACTIVE_HIGH>;
- enable-active-high;
- };
-
- reg_can2_stby: regulator-can2-stby {
- compatible = "regulator-fixed";
- regulator-name = "can2-stby";
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_flexcan2_reg>;
- regulator-min-microvolt = <3300000>;
- regulator-max-microvolt = <3300000>;
- gpio = <&gpio4 27 GPIO_ACTIVE_HIGH>;
- enable-active-high;
- };
-
reg_pcie0: regulator-pcie {
compatible = "regulator-fixed";
pinctrl-names = "default";
@@ -431,14 +419,14 @@ ethphy1: ethernet-phy@1 {
&flexcan1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flexcan1>;
- xceiver-supply = <®_can1_stby>;
+ phys = <&flexcan_phy 0>;
status = "okay";
};
&flexcan2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flexcan2>;
- xceiver-supply = <®_can2_stby>;
+ phys = <&flexcan_phy 1>;
status = "disabled";/* can2 pin conflict with pdm */
};
@@ -903,14 +891,9 @@ MX8MP_IOMUXC_SAI5_RXD3__CAN2_TX 0x154
>;
};
- pinctrl_flexcan1_reg: flexcan1reggrp {
+ pinctrl_flexcan_phy: flexcanphygrp {
fsl,pins = <
MX8MP_IOMUXC_SPDIF_EXT_CLK__GPIO5_IO05 0x154 /* CAN1_STBY */
- >;
- };
-
- pinctrl_flexcan2_reg: flexcan2reggrp {
- fsl,pins = <
MX8MP_IOMUXC_SAI2_MCLK__GPIO4_IO27 0x154 /* CAN2_STBY */
>;
};
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v6 9/9] arm64: dts: imx93-11x11-evk: Use phys to replace xceiver-supply
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
` (7 preceding siblings ...)
2025-09-09 5:40 ` [PATCH v6 8/9] arm64: dts: imx8mp-evk: " Peng Fan
@ 2025-09-09 5:40 ` Peng Fan
2025-09-18 13:35 ` [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
9 siblings, 0 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-09 5:40 UTC (permalink / raw)
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, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Peng Fan, Frank Li
The TJA1057 used on i.MX93 EVK is actually high-speed CAN
transceiver, not a regulator supply. So use phys to reflect the truth.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts b/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts
index e24e12f04526c3a08c0bdc6134297fb010e6e926..19d63f7efdc51bb097c6e51bbe7bfaa533218ecc 100644
--- a/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts
@@ -62,6 +62,13 @@ vdevbuffer: vdevbuffer@a4020000 {
};
+ flexcan_phy: can-phy {
+ compatible = "nxp,tja1057";
+ #phy-cells = <0>;
+ max-bitrate = <5000000>;
+ silent-gpios = <&adp5585 6 GPIO_ACTIVE_HIGH>;
+ };
+
reg_vdd_12v: regulator-vdd-12v {
compatible = "regulator-fixed";
regulator-name = "VDD_12V";
@@ -87,14 +94,6 @@ reg_audio_pwr: regulator-audio-pwr {
enable-active-high;
};
- reg_can2_standby: regulator-can2-standby {
- compatible = "regulator-fixed";
- regulator-name = "can2-stby";
- regulator-min-microvolt = <3300000>;
- regulator-max-microvolt = <3300000>;
- gpio = <&adp5585 6 GPIO_ACTIVE_LOW>;
- };
-
reg_m2_pwr: regulator-m2-pwr {
compatible = "regulator-fixed";
regulator-name = "M.2-power";
@@ -284,7 +283,7 @@ ethphy2: ethernet-phy@2 {
&flexcan2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flexcan2>;
- xceiver-supply = <®_can2_standby>;
+ phys = <&flexcan_phy>;
status = "okay";
};
--
2.37.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v6 1/9] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
2025-09-09 5:40 ` [PATCH v6 1/9] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048 Peng Fan
@ 2025-09-10 2:33 ` Rob Herring (Arm)
0 siblings, 0 replies; 17+ messages in thread
From: Rob Herring (Arm) @ 2025-09-10 2:33 UTC (permalink / raw)
To: Peng Fan
Cc: Vinod Koul, Shawn Guo, imx, devicetree, linux-can, linux-phy,
Aswath Govindraju, Vincent Mailhol, Pengutronix Kernel Team,
Conor Dooley, Fabio Estevam, Frank Li, Frank Li,
Kishon Vijay Abraham I, linux-arm-kernel, Krzysztof Kozlowski,
Sascha Hauer, linux-kernel, Marc Kleine-Budde, Haibo Chen
On Tue, 09 Sep 2025 13:40:11 +0800, Peng Fan wrote:
> The TJA1048 is a dual high-speed CAN transceiver with sleep mode supported
> and no EN pin.
>
> The TJA1051 is a high-speed CAN transceiver with slient mode supported,
> but only TJA1051T/E has EN pin. To make it simple, make enable-gpios as
> optional for TJA1051.
>
> The TJA1057 is a high-speed CAN transceiver with slient mode supported
> and no EN pin.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 69 +++++++++++++++++++++-
> 1 file changed, 66 insertions(+), 3 deletions(-)
>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
` (8 preceding siblings ...)
2025-09-09 5:40 ` [PATCH v6 9/9] arm64: dts: imx93-11x11-evk: " Peng Fan
@ 2025-09-18 13:35 ` Peng Fan
9 siblings, 0 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-18 13:35 UTC (permalink / raw)
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, Frank Li, Haibo Chen,
linux-can, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel
Hi Marc, Vinod and all
> dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
> phy: phy-can-transceiver: Introduce can_transceiver_priv
> phy: phy-can-transceiver: Add dual channel support for TJA1048
> phy: phy-can-transceiver: Drop the gpio desc check
> phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep
> phy: phy-can-transceiver: Add support for TJA105{1,7}
Any comments in the driver Patch [1-5]?
Thanks,
Peng
> arm64: dts: imx95-15x15-evk: Use phys to replace xceiver-supply
> arm64: dts: imx8mp-evk: Use phys to replace xceiver-supply
> arm64: dts: imx93-11x11-evk: Use phys to replace xceiver-supply
>
> .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 69 +++++++-
> arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 43 ++---
> arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts | 17 +-
> arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts | 13 +-
> drivers/phy/phy-can-transceiver.c | 180 ++++++++++++++++-----
> 5 files changed, 229 insertions(+), 93 deletions(-)
>---
>base-commit: da57e528a86120a1187edf3e2c9affb4083d342d
>change-id: 20250821-can-c832cb4f0323
>
>Best regards,
>--
>Peng Fan <peng.fan@nxp.com>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv
2025-09-09 5:40 ` [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv Peng Fan
@ 2025-09-19 19:08 ` Marc Kleine-Budde
2025-09-20 4:37 ` Vincent Mailhol
1 sibling, 0 replies; 17+ messages in thread
From: Marc Kleine-Budde @ 2025-09-19 19:08 UTC (permalink / raw)
To: Peng Fan
Cc: 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, linux-can, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]
On 09.09.2025 13:40:12, Peng Fan wrote:
> To prepare for dual-channel phy support, introduce can_transceiver_priv as
> a higher level encapsulation for phy and mux_state.
>
> No functional changes.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/phy/phy-can-transceiver.c | 41 ++++++++++++++++++++++++++-------------
> 1 file changed, 27 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
> index f59caff4b3d4c267feca4220bf1547b6fad08f95..6415c6af0e8414a6cc8d15958a17ee749a3f28e9 100644
> --- a/drivers/phy/phy-can-transceiver.c
> +++ b/drivers/phy/phy-can-transceiver.c
> @@ -23,6 +23,11 @@ struct can_transceiver_phy {
> struct phy *generic_phy;
> struct gpio_desc *standby_gpio;
> struct gpio_desc *enable_gpio;
> + struct can_transceiver_priv *priv;
Can you convert this into a flexible-array? This reduces the overhead of
a 2nd allocation.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v6 3/9] phy: phy-can-transceiver: Add dual channel support for TJA1048
2025-09-09 5:40 ` [PATCH v6 3/9] phy: phy-can-transceiver: Add dual channel support for TJA1048 Peng Fan
@ 2025-09-19 19:11 ` Marc Kleine-Budde
0 siblings, 0 replies; 17+ messages in thread
From: Marc Kleine-Budde @ 2025-09-19 19:11 UTC (permalink / raw)
To: Peng Fan
Cc: 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, linux-can, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]
On 09.09.2025 13:40:13, Peng Fan wrote:
> - Introduce new flag CAN_TRANSCEIVER_DUAL_CH to indicate the phy has two
> channels.
> - Alloc a phy for each channel
> - Support TJA1048 which is a dual high-speed CAN transceiver with sleep
> mode supported.
> - Add can_transceiver_phy_xlate for parsing phy
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/phy/phy-can-transceiver.c | 91 ++++++++++++++++++++++++++++-----------
> 1 file changed, 65 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
> index 6415c6af0e8414a6cc8d15958a17ee749a3f28e9..f06b1df76ada023f432dce892c3346f45397ab54 100644
> --- a/drivers/phy/phy-can-transceiver.c
> +++ b/drivers/phy/phy-can-transceiver.c
> @@ -17,6 +17,7 @@ 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 {
> @@ -29,6 +30,7 @@ struct can_transceiver_phy {
> struct can_transceiver_priv {
> struct can_transceiver_phy *can_transceiver_phy;
> struct mux_state *mux_state;
> + int num_ch;
As a flexible array this looks like:
struct can_transceiver_priv {
struct can_transceiver_phy *can_transceiver_phy;
int num_ch;
struct mux_state mux_state[] __counted_by(num_ch);
}
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v6 5/9] phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep
2025-09-09 5:40 ` [PATCH v6 5/9] phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep Peng Fan
@ 2025-09-19 19:18 ` Marc Kleine-Budde
2025-09-22 4:44 ` Peng Fan
0 siblings, 1 reply; 17+ messages in thread
From: Marc Kleine-Budde @ 2025-09-19 19:18 UTC (permalink / raw)
To: Peng Fan
Cc: 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, linux-can, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 594 bytes --]
On 09.09.2025 13:40:15, Peng Fan wrote:
> gpiod_set_value_cansleep might return failure, propagate the return value
> of gpiod_set_value_cansleep to parent.
Are there any expectations of the phy framework from the driver if the
switch on or off fails? Do you have to roll back any changes in case of
an error?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv
2025-09-09 5:40 ` [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv Peng Fan
2025-09-19 19:08 ` Marc Kleine-Budde
@ 2025-09-20 4:37 ` Vincent Mailhol
1 sibling, 0 replies; 17+ messages in thread
From: Vincent Mailhol @ 2025-09-20 4:37 UTC (permalink / raw)
To: Peng Fan
Cc: linux-can, linux-phy, devicetree, linux-kernel, imx,
linux-arm-kernel, Marc Kleine-Budde, 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
A couple nitpicks. I was hesitating to send this, but because it seems there
will be a v7 anyway, could be worth to integrate these as well.
On 09/09/2025 at 14:40, Peng Fan wrote:
> To prepare for dual-channel phy support, introduce can_transceiver_priv as
> a higher level encapsulation for phy and mux_state.
>
> No functional changes.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/phy/phy-can-transceiver.c | 41 ++++++++++++++++++++++++++-------------
> 1 file changed, 27 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
> index f59caff4b3d4c267feca4220bf1547b6fad08f95..6415c6af0e8414a6cc8d15958a17ee749a3f28e9 100644
> --- a/drivers/phy/phy-can-transceiver.c
> +++ b/drivers/phy/phy-can-transceiver.c
> @@ -23,6 +23,11 @@ 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;
> };
>
> @@ -32,8 +37,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 +61,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;
> }
> @@ -107,7 +112,7 @@ 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;
Considering the number on time you are accessing priv->can_transceiver_phy, I
think it is better to keep this local variable.
With this, the patch diff is also smaller.
> + struct can_transceiver_priv *priv;
> const struct can_transceiver_data *drvdata;
> const struct of_device_id *match;
> struct phy *phy;
> @@ -117,18 +122,25 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
> 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;
> -
> 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);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sizeof(*priv)
> + if (!priv)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, priv);
> +
> + priv->can_transceiver_phy = devm_kzalloc(dev, sizeof(struct can_transceiver_phy),
After adding back the can_transceiver_phy variable:
sizeof(*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;
> + priv->mux_state = mux_state;
>
> phy = devm_phy_create(dev, dev->of_node,
> &can_transceiver_phy_ops);
> @@ -142,23 +154,24 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
> 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;
> + priv->can_transceiver_phy->generic_phy = phy;
> + priv->can_transceiver_phy->priv = priv;
>
> 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;
> + priv->can_transceiver_phy->standby_gpio = standby_gpio;
> }
>
> 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->enable_gpio = enable_gpio;
> }
>
> - phy_set_drvdata(can_transceiver_phy->generic_phy, can_transceiver_phy);
> + phy_set_drvdata(priv->can_transceiver_phy->generic_phy, priv->can_transceiver_phy);
>
> phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
Yours sincerely,
Vincent Mailhol
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v6 5/9] phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep
2025-09-19 19:18 ` Marc Kleine-Budde
@ 2025-09-22 4:44 ` Peng Fan
0 siblings, 0 replies; 17+ messages in thread
From: Peng Fan @ 2025-09-22 4:44 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Peng Fan, 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, linux-can, linux-phy, devicetree,
linux-kernel, imx, linux-arm-kernel
On Fri, Sep 19, 2025 at 09:18:21PM +0200, Marc Kleine-Budde wrote:
>On 09.09.2025 13:40:15, Peng Fan wrote:
>> gpiod_set_value_cansleep might return failure, propagate the return value
>> of gpiod_set_value_cansleep to parent.
>
>Are there any expectations of the phy framework from the driver if the
>switch on or off fails? Do you have to roll back any changes in case of
>an error?
The phy framework expects return value, so if on or off fails, the
phy framework will record and handle properly, but if one of GPIO settings
fail, the driver itself should handle it and need to roll back. I will update
in V7.
Thanks,
Peng
>
>Marc
>
>--
>Pengutronix e.K. | Marc Kleine-Budde |
>Embedded Linux | https://www.pengutronix.de |
>Vertretung N??rnberg | Phone: +49-5121-206917-129 |
>Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-09-22 3:33 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09 5:40 [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
2025-09-09 5:40 ` [PATCH v6 1/9] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048 Peng Fan
2025-09-10 2:33 ` Rob Herring (Arm)
2025-09-09 5:40 ` [PATCH v6 2/9] phy: phy-can-transceiver: Introduce can_transceiver_priv Peng Fan
2025-09-19 19:08 ` Marc Kleine-Budde
2025-09-20 4:37 ` Vincent Mailhol
2025-09-09 5:40 ` [PATCH v6 3/9] phy: phy-can-transceiver: Add dual channel support for TJA1048 Peng Fan
2025-09-19 19:11 ` Marc Kleine-Budde
2025-09-09 5:40 ` [PATCH v6 4/9] phy: phy-can-transceiver: Drop the gpio desc check Peng Fan
2025-09-09 5:40 ` [PATCH v6 5/9] phy: phy-can-transceiver: Propagate return value of gpiod_set_value_cansleep Peng Fan
2025-09-19 19:18 ` Marc Kleine-Budde
2025-09-22 4:44 ` Peng Fan
2025-09-09 5:40 ` [PATCH v6 6/9] phy: phy-can-transceiver: Add support for TJA105{1,7} Peng Fan
2025-09-09 5:40 ` [PATCH v6 7/9] arm64: dts: imx95-15x15-evk: Use phys to replace xceiver-supply Peng Fan
2025-09-09 5:40 ` [PATCH v6 8/9] arm64: dts: imx8mp-evk: " Peng Fan
2025-09-09 5:40 ` [PATCH v6 9/9] arm64: dts: imx93-11x11-evk: " Peng Fan
2025-09-18 13:35 ` [PATCH v6 0/9] phy: phy-can-transceiver: Support TJA1048/TJA1051 Peng Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).