Skip to content

Commit

Permalink
Merge tag 'linux-can-next-for-6.11-20240629' of git://git.kernel.org/…
Browse files Browse the repository at this point in the history
…pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2024-06-29

Geert Uytterhoeven contributes 3 patches with small improvements and
cleanups for the rcar_canfd driver.

A patch by Christophe JAILLET constifies the struct m_can_ops in the
m_can driver to reduce the code size.

The last 9 patches are by me an work around erratum DS80000789E 6 of
mcp2518fd.

* tag 'linux-can-next-for-6.11-20240629' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
  can: mcp251xfd: tef: update workaround for erratum DS80000789E 6 of mcp2518fd
  can: mcp251xfd: tef: prepare to workaround broken TEF FIFO tail index erratum
  can: mcp251xfd: rx: add workaround for erratum DS80000789E 6 of mcp2518fd
  can: mcp251xfd: rx: prepare to workaround broken RX FIFO head index erratum
  can: mcp251xfd: mcp251xfd_handle_rxif_ring_uinc(): factor out in separate function
  can: mcp251xfd: clarify the meaning of timestamp
  can: mcp251xfd: move mcp251xfd_timestamp_start()/stop() into mcp251xfd_chip_start/stop()
  can: mcp251xfd: update errata references
  can: mcp251xfd: properly indent labels
  can: gs_usb: add VID/PID for Xylanta SAINT3 product family
  can: m_can: Constify struct m_can_ops
  can: rcar_canfd: Remove superfluous parentheses in address calculations
  can: rcar_canfd: Improve printing of global operational state
  can: rcar_canfd: Simplify clock handling
====================

Link: https://patch.msgid.link/20240629114017.1080160-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jul 2, 2024
2 parents 74d6529 + ae44fa9 commit 1eea11e
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 230 deletions.
2 changes: 1 addition & 1 deletion drivers/net/can/m_can/m_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct m_can_classdev {

ktime_t irq_timer_wait;

struct m_can_ops *ops;
const struct m_can_ops *ops;

int version;
u32 irqstatus;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/m_can/m_can_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
return 0;
}

static struct m_can_ops m_can_pci_ops = {
static const struct m_can_ops m_can_pci_ops = {
.read_reg = iomap_read_reg,
.write_reg = iomap_write_reg,
.write_fifo = iomap_write_fifo,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/m_can/m_can_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
return 0;
}

static struct m_can_ops m_can_plat_ops = {
static const struct m_can_ops m_can_plat_ops = {
.read_reg = iomap_read_reg,
.write_reg = iomap_write_reg,
.write_fifo = iomap_write_fifo,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/m_can/tcan4x5x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static int tcan4x5x_get_gpios(struct m_can_classdev *cdev,
return 0;
}

static struct m_can_ops tcan4x5x_ops = {
static const struct m_can_ops tcan4x5x_ops = {
.init = tcan4x5x_init,
.read_reg = tcan4x5x_read_reg,
.write_reg = tcan4x5x_write_reg,
Expand Down
41 changes: 16 additions & 25 deletions drivers/net/can/rcar/rcar_canfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,6 @@
*/
#define RCANFD_CFFIFO_IDX 0

/* fCAN clock select register settings */
enum rcar_canfd_fcanclk {
RCANFD_CANFDCLK = 0, /* CANFD clock */
RCANFD_EXTCLK, /* Externally input clock */
};

struct rcar_canfd_global;

struct rcar_canfd_hw_info {
Expand Down Expand Up @@ -545,8 +539,8 @@ struct rcar_canfd_global {
struct platform_device *pdev; /* Respective platform device */
struct clk *clkp; /* Peripheral clock */
struct clk *can_clk; /* fCAN clock */
enum rcar_canfd_fcanclk fcan; /* CANFD or Ext clock */
unsigned long channels_mask; /* Enabled channels mask */
bool extclk; /* CANFD or Ext clock */
bool fdmode; /* CAN FD or Classical CAN only mode */
struct reset_control *rstc1;
struct reset_control *rstc2;
Expand Down Expand Up @@ -633,28 +627,28 @@ static inline void rcar_canfd_update(u32 mask, u32 val, u32 __iomem *reg)

static inline u32 rcar_canfd_read(void __iomem *base, u32 offset)
{
return readl(base + (offset));
return readl(base + offset);
}

static inline void rcar_canfd_write(void __iomem *base, u32 offset, u32 val)
{
writel(val, base + (offset));
writel(val, base + offset);
}

static void rcar_canfd_set_bit(void __iomem *base, u32 reg, u32 val)
{
rcar_canfd_update(val, val, base + (reg));
rcar_canfd_update(val, val, base + reg);
}

static void rcar_canfd_clear_bit(void __iomem *base, u32 reg, u32 val)
{
rcar_canfd_update(val, 0, base + (reg));
rcar_canfd_update(val, 0, base + reg);
}

static void rcar_canfd_update_bit(void __iomem *base, u32 reg,
u32 mask, u32 val)
{
rcar_canfd_update(mask, val, base + (reg));
rcar_canfd_update(mask, val, base + reg);
}

static void rcar_canfd_get_data(struct rcar_canfd_channel *priv,
Expand All @@ -665,7 +659,7 @@ static void rcar_canfd_get_data(struct rcar_canfd_channel *priv,
lwords = DIV_ROUND_UP(cf->len, sizeof(u32));
for (i = 0; i < lwords; i++)
*((u32 *)cf->data + i) =
rcar_canfd_read(priv->base, off + (i * sizeof(u32)));
rcar_canfd_read(priv->base, off + i * sizeof(u32));
}

static void rcar_canfd_put_data(struct rcar_canfd_channel *priv,
Expand All @@ -675,7 +669,7 @@ static void rcar_canfd_put_data(struct rcar_canfd_channel *priv,

lwords = DIV_ROUND_UP(cf->len, sizeof(u32));
for (i = 0; i < lwords; i++)
rcar_canfd_write(priv->base, off + (i * sizeof(u32)),
rcar_canfd_write(priv->base, off + i * sizeof(u32),
*((u32 *)cf->data + i));
}

Expand Down Expand Up @@ -777,7 +771,7 @@ static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv)
cfg |= RCANFD_GCFG_CMPOC;

/* Set External Clock if selected */
if (gpriv->fcan != RCANFD_CANFDCLK)
if (gpriv->extclk)
cfg |= RCANFD_GCFG_DCS;

rcar_canfd_set_bit(gpriv->base, RCANFD_GCFG, cfg);
Expand Down Expand Up @@ -1941,16 +1935,12 @@ static int rcar_canfd_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(gpriv->can_clk),
"cannot get canfd clock\n");

gpriv->fcan = RCANFD_CANFDCLK;

/* CANFD clock may be further divided within the IP */
fcan_freq = clk_get_rate(gpriv->can_clk) / info->postdiv;
} else {
gpriv->fcan = RCANFD_EXTCLK;
fcan_freq = clk_get_rate(gpriv->can_clk);
gpriv->extclk = true;
}
fcan_freq = clk_get_rate(gpriv->can_clk);

if (gpriv->fcan == RCANFD_CANFDCLK)
/* CANFD clock is further divided by (1/2) within the IP */
fcan_freq /= info->postdiv;

addr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(addr)) {
Expand Down Expand Up @@ -2059,8 +2049,9 @@ static int rcar_canfd_probe(struct platform_device *pdev)
}

platform_set_drvdata(pdev, gpriv);
dev_info(dev, "global operational state (clk %d, fdmode %d)\n",
gpriv->fcan, gpriv->fdmode);
dev_info(dev, "global operational state (%s clk, %s mode)\n",
gpriv->extclk ? "ext" : "canfd",
gpriv->fdmode ? "fd" : "classical");
return 0;

fail_channel:
Expand Down
Loading

0 comments on commit 1eea11e

Please sign in to comment.