Skip to content

Commit b817f50

Browse files
MrVanvinodkoul
authored andcommitted
phy: phy-can-transceiver: Add support for TJA105{1,7}
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> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Link: https://patch.msgid.link/20251001-can-v7-5-fad29efc3884@nxp.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent d02a7eb commit b817f50

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

drivers/phy/phy-can-transceiver.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ struct can_transceiver_data {
1818
#define CAN_TRANSCEIVER_STB_PRESENT BIT(0)
1919
#define CAN_TRANSCEIVER_EN_PRESENT BIT(1)
2020
#define CAN_TRANSCEIVER_DUAL_CH BIT(2)
21+
#define CAN_TRANSCEIVER_SILENT_PRESENT BIT(3)
2122
};
2223

2324
struct can_transceiver_phy {
2425
struct phy *generic_phy;
26+
struct gpio_desc *silent_gpio;
2527
struct gpio_desc *standby_gpio;
2628
struct gpio_desc *enable_gpio;
2729
struct can_transceiver_priv *priv;
@@ -47,6 +49,7 @@ static int can_transceiver_phy_power_on(struct phy *phy)
4749
return ret;
4850
}
4951
}
52+
gpiod_set_value_cansleep(can_transceiver_phy->silent_gpio, 0);
5053
gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
5154
gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
5255

@@ -59,6 +62,7 @@ static int can_transceiver_phy_power_off(struct phy *phy)
5962
struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
6063
struct can_transceiver_priv *priv = can_transceiver_phy->priv;
6164

65+
gpiod_set_value_cansleep(can_transceiver_phy->silent_gpio, 1);
6266
gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
6367
gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
6468
if (priv->mux_state)
@@ -85,6 +89,14 @@ static const struct can_transceiver_data tja1048_drvdata = {
8589
.flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_DUAL_CH,
8690
};
8791

92+
static const struct can_transceiver_data tja1051_drvdata = {
93+
.flags = CAN_TRANSCEIVER_SILENT_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
94+
};
95+
96+
static const struct can_transceiver_data tja1057_drvdata = {
97+
.flags = CAN_TRANSCEIVER_SILENT_PRESENT,
98+
};
99+
88100
static const struct of_device_id can_transceiver_phy_ids[] = {
89101
{
90102
.compatible = "ti,tcan1042",
@@ -98,6 +110,14 @@ static const struct of_device_id can_transceiver_phy_ids[] = {
98110
.compatible = "nxp,tja1048",
99111
.data = &tja1048_drvdata
100112
},
113+
{
114+
.compatible = "nxp,tja1051",
115+
.data = &tja1051_drvdata
116+
},
117+
{
118+
.compatible = "nxp,tja1057",
119+
.data = &tja1057_drvdata
120+
},
101121
{
102122
.compatible = "nxp,tjr1443",
103123
.data = &tcan1043_drvdata
@@ -144,6 +164,7 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
144164
const struct can_transceiver_data *drvdata;
145165
const struct of_device_id *match;
146166
struct phy *phy;
167+
struct gpio_desc *silent_gpio;
147168
struct gpio_desc *standby_gpio;
148169
struct gpio_desc *enable_gpio;
149170
struct mux_state *mux_state;
@@ -203,7 +224,16 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
203224
can_transceiver_phy->enable_gpio = enable_gpio;
204225
}
205226

227+
if (drvdata->flags & CAN_TRANSCEIVER_SILENT_PRESENT) {
228+
silent_gpio = devm_gpiod_get_index_optional(dev, "silent", i,
229+
GPIOD_OUT_LOW);
230+
if (IS_ERR(silent_gpio))
231+
return PTR_ERR(silent_gpio);
232+
can_transceiver_phy->silent_gpio = silent_gpio;
233+
}
234+
206235
phy_set_drvdata(can_transceiver_phy->generic_phy, can_transceiver_phy);
236+
207237
}
208238

209239
phy_provider = devm_of_phy_provider_register(dev, can_transceiver_phy_xlate);

0 commit comments

Comments
 (0)