[PATCH can-next v2 3/4] can: flexcan: add support for SpacemiT K1 CAN0

From: Liu Changjie

Date: Wed Dec 02 2026 - 09:57:49 EST


On K1, the RST bit in APBC_CAN_CLK_RST holds both the register interface
and the CAN protocol engine in reset at power-on. Enabling the two clocks
alone leaves the controller in reset.

Match the K1 controller and deassert the reset before register access.
Request the line as optional so existing platforms without a reset line
can continue to probe. The K1 binding requires a reset specifier.

Signed-off-by: Liu Changjie <liucj1228@xxxxxxxxxxx>
---
drivers/net/can/flexcan/flexcan-core.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index 6febf0c08..84727ff45 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -31,6 +31,7 @@
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
+#include <linux/reset.h>

#include "flexcan.h"

@@ -399,6 +400,14 @@ static const struct flexcan_devtype_data nxp_s32g2_devtype_data = {
FLEXCAN_QUIRK_SECONDARY_MB_IRQ,
};

+static const struct flexcan_devtype_data spacemit_k1_devtype_data = {
+ .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
+ FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_BROKEN_PERR_STATE |
+ FLEXCAN_QUIRK_USE_RX_MAILBOX | FLEXCAN_QUIRK_SUPPORT_FD |
+ FLEXCAN_QUIRK_SUPPORT_ECC | FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
+ FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
+};
+
static const struct can_bittiming_const flexcan_bittiming_const = {
.name = DRV_NAME,
.tseg1_min = 4,
@@ -2079,6 +2088,7 @@ static const struct of_device_id flexcan_of_match[] = {
{ .compatible = "fsl,ls1021ar2-flexcan", .data = &fsl_ls1021a_r2_devtype_data, },
{ .compatible = "fsl,lx2160ar1-flexcan", .data = &fsl_lx2160a_r1_devtype_data, },
{ .compatible = "nxp,s32g2-flexcan", .data = &nxp_s32g2_devtype_data, },
+ { .compatible = "spacemit,k1-flexcan", .data = &spacemit_k1_devtype_data, },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, flexcan_of_match);
@@ -2099,6 +2109,7 @@ static int flexcan_probe(struct platform_device *pdev)
struct net_device *dev;
struct flexcan_priv *priv;
struct regulator *reg_xceiver;
+ struct reset_control *rst;
struct phy *transceiver;
struct clk *clk_ipg = NULL, *clk_per = NULL;
struct flexcan_regs __iomem *regs;
@@ -2156,6 +2167,10 @@ static int flexcan_probe(struct platform_device *pdev)
if (IS_ERR(regs))
return PTR_ERR(regs);

+ rst = devm_reset_control_get_optional_exclusive_deasserted(&pdev->dev, NULL);
+ if (IS_ERR(rst))
+ return dev_err_probe(&pdev->dev, PTR_ERR(rst), "failed to deassert reset\n");
+
devtype_data = device_get_match_data(&pdev->dev);

if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) &&

--
2.56.1