phy: phy-can-transceiver: Support TJA1048/TJA1051
Subsystems (4)
v4 cover phy: phy-can-transceiver: Support TJA1048/TJA1051
TJA1048 is a Dual channel can transceiver with Sleep mode supported. TJA1051 is a Single Channel can transceiver with Sleep mode supported.
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,6: Update dts to use phys
---
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/[email protected]
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/[email protected]
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/[email protected]
---
Peng Fan (6):
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
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 | 30 +++++- 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 | 120 +++++++++++++++------ 5 files changed, 141 insertions(+), 82 deletions(-)
---
base-commit: 6aea185bfe693f3b373488217c198d2c3daed6eb
change-id: 20250821-can-c832cb4f0323
Best regards,
Signature · 1 line
Peng Fan <[email protected]>
PATCH v4 1/6 dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
The TJA105[1,7] is a high-speed CAN transceiver which is a pin-compatible alternative for TI TCAN1043 with sleep mode supported, and has a compatible programming model, therefore use ti,tcan1043 as fallback compatible.
The TJA1048 is a dual high-speed CAN transceiver with sleep mode supported.
--- .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +28 -2
@@ -19,18 +19,25 @@ properties: - enum: - microchip,ata6561 - const: ti,tcan1042 + - items: + - enum: + - nxp,tja1051 + - nxp,tja1057 + - const: ti,tcan1043 - enum: - ti,tcan1042 - ti,tcan1043 + - nxp,tja1048 - nxp,tjr1443 '#phy-cells': - const: 0 + enum: [0, 1] standby-gpios: description: gpio node to toggle standby signal on transceiver - maxItems: 1 + minItems: 1 + maxItems: 2 enable-gpios: description:
@@ -53,6 +60,25 @@ required: - compatible - '#phy-cells' +allOf: + - if: + properties: + compatible: + contains: + const: nxp,tja1048 + then: + properties: + '#phy-cells': + const: 1 + standby-gpios: + minItems: 2 + else: + properties: + '#phy-cells': + const: 0 + standby-gpios: + maxItems: 1 + additionalProperties: false examples:
Signature · 1 line
2.37.1
Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
Quoted 31 lines · Peng Fan
The TJA105[1,7] is a high-speed CAN transceiver which is a pin-compatible alternative for TI TCAN1043 with sleep mode supported, and has a compatible programming model, therefore use ti,tcan1043 as fallback compatible.
The TJA1048 is a dual high-speed CAN transceiver with sleep mode supported.
Reviewed-by Frank Li <[email protected]>Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +6
-0@@ -19,18 +19,25 @@ properties: - enum: - microchip,ata6561 - const: ti,tcan1042 + - items: + - enum: + - nxp,tja1051 + - nxp,tja1057 + - const: ti,tcan1043 - enum: - ti,tcan1042 - ti,tcan1043 + - nxp,tja1048 - nxp,tjr1443
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml properties: · line 40
Quoted 10 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +3
-2'#phy-cells': - const: 0 + enum: [0, 1] standby-gpios: description: gpio node to toggle standby signal on transceiver - maxItems: 1 + minItems: 1 + maxItems: 2
You're adding a second standby gpio, which one is which?
I assume you mean that item 1 is stbn1 and item 2 is stbn 2 for tja1048. Might be kinda obvious, but I think it should be mentioned.
tja105{1,7} don't have a standby gpio, but they do have a silent mode. silent mode seems fundamentally different to standby, since the receiver still works. Seems like that should be handled differently, no?
Quoted 33 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +19
-0enable-gpios: description:@@ -53,6 +60,25 @@ required: - compatible - '#phy-cells' +allOf: + - if: + properties: + compatible: + contains: + const: nxp,tja1048 + then: + properties: + '#phy-cells': + const: 1 + standby-gpios: + minItems: 2 + else: + properties: + '#phy-cells': + const: 0 + standby-gpios: + maxItems: 1 + additionalProperties: false examples:Signature · 2 lines
-- 2.37.1
Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
Quoted 47 lines · Conor Dooley
Quoted 31 lines · Peng Fan
The TJA105[1,7] is a high-speed CAN transceiver which is a pin-compatible alternative for TI TCAN1043 with sleep mode supported, and has a compatible programming model, therefore use ti,tcan1043 as fallback compatible.
The TJA1048 is a dual high-speed CAN transceiver with sleep mode supported.
Reviewed-by Frank Li <[email protected]>Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +6
-0@@ -19,18 +19,25 @@ properties: - enum: - microchip,ata6561 - const: ti,tcan1042 + - items: + - enum: + - nxp,tja1051 + - nxp,tja1057 + - const: ti,tcan1043 - enum: - ti,tcan1042 - ti,tcan1043 + - nxp,tja1048 - nxp,tjr1443Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml properties: · line 40
Quoted 10 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +3
-2'#phy-cells': - const: 0 + enum: [0, 1] standby-gpios: description: gpio node to toggle standby signal on transceiver - maxItems: 1 + minItems: 1 + maxItems: 2You're adding a second standby gpio, which one is which?
I assume you mean that item 1 is stbn1 and item 2 is stbn 2 for tja1048. Might be kinda obvious, but I think it should be mentioned.
Quoted 3 lines
tja105{1,7} don't have a standby gpio, but they do have a silent mode. silent mode seems fundamentally different to standby, since the receiver still works. Seems like that should be handled differently, no?
The docs for standby mode for the tcan1043 don't match with the tja1051, "Standby mode is a low power mode where the driver and receiver are disabled," so does the fallback compatible even make sense? Seems like a combination of enable and standby gpios are used to put the tcan device into silent mode but the tja1051 has a pin for that alone and seemingly does not support standby at all?
Quoted 34 lines
Quoted 34 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +19
-0enable-gpios: description:@@ -53,6 +60,25 @@ required: - compatible - '#phy-cells' +allOf: + - if: + properties: + compatible: + contains: + const: nxp,tja1048 + then: + properties: + '#phy-cells': + const: 1 + standby-gpios: + minItems: 2 + else: + properties: + '#phy-cells': + const: 0 + standby-gpios: + maxItems: 1 + additionalProperties: false examples:Signature · 2 lines
-- 2.37.1
RE: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
Hi Conor,
Quoted 59 lines
Subject: Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can:
Document NXP TJA105X/1048Quoted 4 lines · Conor Dooley
Quoted 3 lines · Peng Fan
The TJA105[1,7] is a high-speed CAN transceiver which is a pin-compatible alternative for TI TCAN1043 with sleep mode supported, and has a compatible programming model, therefore
use ti,tcan1043 as fallback compatible.
Quoted 2 lines
Quoted 2 lines
The TJA1048 is a dual high-speed CAN transceiver with sleep mode
supported.
Quoted 5 lines
Quoted 5 lines
Reviewed-by Frank Li <[email protected]>Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 30++++++++++++++++++++--
Quoted 7 lines
Quoted 7 lines
1 file changed, 28 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yamlb/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yamlindex
4a8c3829d85d3c4a4963750d03567c1c345beb91..f8e0c24856a2ba83b5c988b246Quoted 3 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-
Quoted 3 lines
464f47e11a032f100644Documentation/devicetree/bindings/phy/ti,tcan104x- renamed from Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +0
-0
can.yamlQuoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/phy/ti,tcan104x- renamed from Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +7
-1@@ -19,18 +19,25 @@ properties: - enum: - microchip,ata6561 - const: ti,tcan1042 + - items: + - enum: + - nxp,tja1051 + - nxp,tja1057 + - const: ti,tcan1043 - enum: - ti,tcan1042 - ti,tcan1043 + - nxp,tja1048 - nxp,tjr1443 '#phy-cells': - const: 0 + enum: [0, 1]Quoted 9 lines
Documentation/devicetree/bindings/phy/ti,tcan104x- properties: · line 40
Quoted 6 lines
Documentation/devicetree/bindings/phy/ti,tcan104x- renamed from Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +2
-1standby-gpios: description: gpio node to toggle standby signal on transceiver - maxItems: 1 + minItems: 1 + maxItems: 2You're adding a second standby gpio, which one is which? I assume you mean that item 1 is stbn1 and item 2 is stbn 2 for
Quoted 1 line
tja1048.
Yes. There are two standby pins.
Quoted 1 line
Quoted 1 line
Might be kinda obvious, but I think it should be mentioned.
I could update description as below.
"
description:
gpio node to toggle standby signal on transceiver. For two Items, item 1 is for stbn1, item 2 is for stbn2.
"
Quoted 3 lines
Quoted 2 lines
tja105{1,7} don't have a standby gpio, but they do have a silent
mode.
Right. Tja105{1,7} has a pin S for silent mode.
Quoted 9 lines
Quoted 2 lines
silent mode seems fundamentally different to standby, since the receiver still works. Seems like that should be handled differently, no?
The docs for standby mode for the tcan1043 don't match with the tja1051, "Standby mode is a low power mode where the driver and receiver are disabled," so does the fallback compatible even make sense? Seems like a combination of enable and standby gpios are used to put the tcan device into silent mode but the tja1051 has a pin for that alone and seemingly does not support standby at all?
Thanks for looking into the details. I also read more into the datasheet.
Tcan1043:
EN nSTB
H H ---> normal mode L H ---> slient mode H L ---> standby mode
L X --->off mode
TJA1051
EN S
H L --> normal mode
H H --> slient mode
L X --> off mode
Your analysis is correct. silent is different with standby, but we only wanna to use normal and off mode
If we need to handle differently, I need
to add a new optional property
silent-gpios:
description:
gpio node to toggle silent signal on transceiver
minItems: 1
How do you think?
Thanks,
Peng.
Quoted 36 lines
Quoted 35 lines
Quoted 35 lines
Documentation/devicetree/bindings/phy/ti,tcan104x- renamed from Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +19
-1enable-gpios: description:@@ -53,6 +60,25 @@ required: - compatible - '#phy-cells' +allOf: + - if: + properties: + compatible: + contains: + const: nxp,tja1048 + then: + properties: + '#phy-cells': + const: 1 + standby-gpios: + minItems: 2 + else: + properties: + '#phy-cells': + const: 0 + standby-gpios: + maxItems: 1 + additionalProperties: false examples: --2.37.1
Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
Quoted 65 lines · Peng Fan
Hi Conor,
Quoted 59 lines
Subject: Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can:
Document NXP TJA105X/1048Quoted 4 lines · Conor Dooley
Quoted 3 lines · Peng Fan
The TJA105[1,7] is a high-speed CAN transceiver which is a pin-compatible alternative for TI TCAN1043 with sleep mode supported, and has a compatible programming model, therefore
use ti,tcan1043 as fallback compatible.
Quoted 2 lines
Quoted 2 lines
The TJA1048 is a dual high-speed CAN transceiver with sleep mode
supported.
Quoted 5 lines
Quoted 5 lines
Reviewed-by Frank Li <[email protected]>Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 30++++++++++++++++++++--
Quoted 7 lines
Quoted 7 lines
1 file changed, 28 insertions(+), 2 deletions(-)diff --git
a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yamlb/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yamlindex
4a8c3829d85d3c4a4963750d03567c1c345beb91..f8e0c24856a2ba83b5c988b246Quoted 3 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-
Quoted 3 lines
464f47e11a032f100644Documentation/devicetree/bindings/phy/ti,tcan104x- renamed from Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +0
-0
can.yamlQuoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/phy/ti,tcan104x- renamed from Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +7
-1@@ -19,18 +19,25 @@ properties: - enum: - microchip,ata6561 - const: ti,tcan1042 + - items: + - enum: + - nxp,tja1051 + - nxp,tja1057 + - const: ti,tcan1043 - enum: - ti,tcan1042 - ti,tcan1043 + - nxp,tja1048 - nxp,tjr1443 '#phy-cells': - const: 0 + enum: [0, 1]Quoted 9 lines
Documentation/devicetree/bindings/phy/ti,tcan104x- properties: · line 40
Quoted 6 lines
Documentation/devicetree/bindings/phy/ti,tcan104x- renamed from Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +2
-1standby-gpios: description: gpio node to toggle standby signal on transceiver - maxItems: 1 + minItems: 1 + maxItems: 2You're adding a second standby gpio, which one is which? I assume you mean that item 1 is stbn1 and item 2 is stbn 2 for
Quoted 1 line
tja1048.
Yes. There are two standby pins.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Might be kinda obvious, but I think it should be mentioned.
I could update description as below.
"
description:
gpio node to toggle standby signal on transceiver. For two Items, item 1 is for stbn1, item 2 is for stbn2.
Sure.
Quoted 26 lines
Quoted 4 lines
Quoted 3 lines
tja105{1,7} don't have a standby gpio, but they do have a silent
mode.
Right. Tja105{1,7} has a pin S for silent mode.
Quoted 9 lines
Quoted 2 lines
silent mode seems fundamentally different to standby, since the receiver still works. Seems like that should be handled differently, no?
The docs for standby mode for the tcan1043 don't match with the tja1051, "Standby mode is a low power mode where the driver and receiver are disabled," so does the fallback compatible even make sense? Seems like a combination of enable and standby gpios are used to put the tcan device into silent mode but the tja1051 has a pin for that alone and seemingly does not support standby at all?
Thanks for looking into the details. I also read more into the datasheet.
Tcan1043:
EN nSTBH H ---> normal mode L H ---> slient mode H L ---> standby modeL X --->off mode
Quoted 8 lines
TJA1051
EN S
H L --> normal mode
H H --> slient mode
L X --> off modeYour analysis is correct. silent is different with standby, but we only wanna to use normal and off mode
In addition, it looks like there are some tja1051 devices that don't even have the enable pin? Of the 4 SKUs, there are 2 that use pin5 as Vio and 1 that has it n/c. Only the T/E device has an enable there.
Quoted 7 lines
If we need to handle differently, I need
to add a new optional propertysilent-gpios:
description:
gpio node to toggle silent signal on transceiver
minItems: 1
Ye, I think so. And probably add some if/then to use it instead of standby on the relevant chips.
RE: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
Hi Conor,
Quoted 119 lines
Subject: Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can:
Document NXP TJA105X/1048Quoted 13 lines · Peng Fan
Hi Conor,
Quoted 11 lines
Subject: Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can:
Document NXP TJA105X/1048Quoted 4 lines · Conor Dooley
Quoted 3 lines · Peng Fan
The TJA105[1,7] is a high-speed CAN transceiver which is a pin-compatible alternative for TI TCAN1043 with sleep mode supported, and has a compatible programming model, therefore
use ti,tcan1043 as fallback compatible.
Quoted 2 lines
Quoted 2 lines
The TJA1048 is a dual high-speed CAN transceiver with sleep
mode
Quoted 11 lines
Quoted 11 lines
supported.
Quoted 5 lines
Quoted 5 lines
Reviewed-by Frank Li <[email protected]>Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/phy/ti,tcan104x-can.yaml | 30++++++++++++++++++++--
Quoted 4 lines
Quoted 4 lines
1 file changed, 28 insertions(+), 2 deletions(-)diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-
can.yamlQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
b/Documentation/devicetree/bindings/phy/ti,tcan104x-
can.yamlQuoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
index
4a8c3829d85d3c4a4963750d03567c1c345beb91..f8e0c24856a2ba83Quoted 3 lines
Quoted 3 lines
b5c988b246Quoted 2 lines
Quoted 2 lines
464f47e11a032f100644
--- a/Documentation/devicetree/bindings/phy/ti,tcan104x-
can.yamlQuoted 34 lines
Quoted 30 lines
Quoted 1 line
Quoted 1 line
+++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-
can.yamlQuoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +7
-1@@ -19,18 +19,25 @@ properties: - enum: - microchip,ata6561 - const: ti,tcan1042 + - items: + - enum: + - nxp,tja1051 + - nxp,tja1057 + - const: ti,tcan1043 - enum: - ti,tcan1042 - ti,tcan1043 + - nxp,tja1048 - nxp,tjr1443 '#phy-cells': - const: 0 + enum: [0, 1]Quoted 9 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml properties: · line 40
Quoted 6 lines
Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +2
-1standby-gpios: description: gpio node to toggle standby signal on transceiver - maxItems: 1 + minItems: 1 + maxItems: 2You're adding a second standby gpio, which one is which? I assume you mean that item 1 is stbn1 and item 2 is stbn 2 for
Quoted 1 line
tja1048.
Yes. There are two standby pins.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Might be kinda obvious, but I think it should be mentioned.
I could update description as below.
"
description:
gpio node to toggle standby signal on transceiver. For two Items, item 1 is for stbn1, item 2 is for stbn2.Sure.
Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
tja105{1,7} don't have a standby gpio, but they do have a silent
mode.
Right. Tja105{1,7} has a pin S for silent mode.
Quoted 2 lines
Quoted 2 lines
silent mode seems fundamentally different to standby, since the receiver still works. Seems like that should be handled differently,
no?
Quoted 5 lines
Quoted 5 lines
The docs for standby mode for the tcan1043 don't match with the tja1051, "Standby mode is a low power mode where the driver and receiver are disabled," so does the fallback compatible even make sense? Seems like a combination of enable and standby gpios are
used
Quoted 4 lines
Quoted 2 lines
to put the tcan device into silent mode but the tja1051 has a pin for that alone and seemingly does not support standby at all?
Thanks for looking into the details. I also read more into the
datasheet.
Quoted 14 lines
Tcan1043:
EN nSTBH H ---> normal mode L H ---> slient mode H L ---> standby modeL X --->off mode
TJA1051
EN S
H L --> normal mode
H H --> slient mode
L X --> off mode
Quoted 6 lines
Quoted 2 lines
Your analysis is correct. silent is different with standby, but we only wanna to use normal and off mode
In addition, it looks like there are some tja1051 devices that don't even have the enable pin? Of the 4 SKUs, there are 2 that use pin5 as Vio and 1 that has it n/c. Only the T/E device has an enable there.
Thanks again for the detailed reading into datasheet.
Yes. But I would like to only keep one compatible "nxp,tja1051" from a board design level, EN could be always tied to high for TJA1051T/E. So to dt-binding, EN it is optional for all TJA1051 variants.
I am thinking to use below compatible in V4 for the devices added in this patch. Does this look good to you?
- items:
- const: nxp,tja1057
- const: nxp,tja1051
- enum:
....
- nxp,tja1048
- nxp,tja1051
....
Quoted 11 lines
Quoted 8 lines
If we need to handle differently, I need to add a new optional property
silent-gpios:
description:
gpio node to toggle silent signal on transceiver
minItems: 1Ye, I think so. And probably add some if/then to use it instead of standby on the relevant chips.
Yes. Agree.
Thanks,
Peng.
RE: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
Quoted 3 lines
Subject: RE: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can:
Document NXP TJA105X/1048
...
Quoted 10 lines
Thanks again for the detailed reading into datasheet.
Yes. But I would like to only keep one compatible "nxp,tja1051" from a board design level, EN could be always tied to high for TJA1051T/E. So to dt-binding, EN it is optional for all TJA1051 variants.
I am thinking to use below compatible in V4 for the devices added in this patch. Does this look good to you?
Quoted 7 lines
- items:
- const: nxp,tja1057
- const: nxp,tja1051
- enum:
....
- nxp,tja1048
- nxp,tja1051
Considering TJA1057 does not have EN, I may need to use:
- enum:
....
- nxp,tja1048
- nxp,tja1051
- nxp,tja1057
....
Thanks,
Peng.
Quoted 19 lines
....Quoted 11 lines
Quoted 8 lines
If we need to handle differently, I need to add a new optional property
silent-gpios:
description:
gpio node to toggle silent signal on transceiver
minItems: 1Ye, I think so. And probably add some if/then to use it instead of standby on the relevant chips.
Yes. Agree.
Thanks,
Peng.
Re: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can: Document NXP TJA105X/1048
Quoted 22 lines · Peng Fan
Quoted 3 lines
Subject: RE: [PATCH v4 1/6] dt-bindings: phy: ti,tcan104x-can:
Document NXP TJA105X/1048...
Quoted 10 lines
Thanks again for the detailed reading into datasheet.
Yes. But I would like to only keep one compatible "nxp,tja1051" from a board design level, EN could be always tied to high for TJA1051T/E. So to dt-binding, EN it is optional for all TJA1051 variants.
I am thinking to use below compatible in V4 for the devices added in this patch. Does this look good to you?
Quoted 7 lines
- items:
- const: nxp,tja1057
- const: nxp,tja1051
- enum:
....
- nxp,tja1048
- nxp,tja1051
Quoted 7 lines
Considering TJA1057 does not have EN, I may need to use:
- enum:
....
- nxp,tja1048
- nxp,tja1051
- nxp,tja1057
....
Seems reasonable to me, go for it.
PATCH v4 2/6 phy: phy-can-transceiver: Introduce can_transceiver_priv
In reply to Peng FanTo prepare for dual-channel phy support, introduce can_transceiver_priv as a higher level encapsulation for phy and mux_state.
No functional changes.
--- drivers/phy/phy-can-transceiver.c | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-)
drivers/phy/phy-can-transceiver.c +27 -14
@@ -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);
Signature · 1 line
2.37.1
PATCH v4 3/6 phy: phy-can-transceiver: Add dual channel support for TJA1048
In reply to Peng Fan- 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
--- drivers/phy/phy-can-transceiver.c | 91 ++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 26 deletions(-)
drivers/phy/phy-can-transceiver.c +65 -26
@@ -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); }
Signature · 1 line
2.37.1
PATCH v4 4/6 arm64: dts: imx95-15x15-evk: Use phys to replace xceiver-supply
In reply to Peng FanThe 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.
--- arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
arch/arm64/boot/dts/freescale/imx95-15x15-evk.dts +6 -7
@@ -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", "ti,tcan1043"; + #phy-cells = <0>; + max-bitrate = <5000000>; + standby-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"; };
Signature · 1 line
2.37.1
PATCH v4 5/6 arm64: dts: imx8mp-evk: Use phys to replace xceiver-supply
In reply to Peng FanThe TJA1048 used on i.MX8MP-EVK is actually high-speed CAN transceiver, not a regulator supply. So use phys to reflect the truth.
--- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 43 +++++++++------------------- 1 file changed, 13 insertions(+), 30 deletions(-)
arch/arm64/boot/dts/freescale/imx8mp-evk.dts +13 -30
@@ -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 */ >; };
Signature · 1 line
2.37.1
PATCH v4 6/6 arm64: dts: imx93-11x11-evk: Use phys to replace xceiver-supply
In reply to Peng FanThe TJA1057 used on i.MX93 EVK is actually high-speed CAN transceiver, not a regulator supply. So use phys to reflect the truth.
--- arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts +8 -9
@@ -62,6 +62,13 @@ vdevbuffer: vdevbuffer@a4020000 { }; + flexcan_phy: can-phy { + compatible = "nxp,tja1057", "ti,tcan1043"; + #phy-cells = <0>; + max-bitrate = <5000000>; + standby-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"; };
Signature · 1 line
2.37.1