Skip to content

Commit

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

Marc Kleine-Budde says:

====================
pull-request: can-next 2024-02-20

this is a pull request of 9 patches for net-next/master.

The first patch is by Francesco Dolcini and removes a redundant check
for pm_clock_support from the m_can driver.

Martin Hundebøll contributes 3 patches to the m_can/tcan4x5x driver to
allow resume upon RX of a CAN frame.

3 patches by Srinivas Goud add support for ECC statistics to the
xilinx_can driver.

The last 2 patches are by Oliver Hartkopp and me, target the CAN RAW
protocol and fix an error in the getsockopt() for CAN-XL introduced in
the previous pull request to net-next (linux-can-next-for-6.9-20240213).

linux-can-next-for-6.9-20240220

* tag 'linux-can-next-for-6.9-20240220' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
  can: raw: raw_getsockopt(): reduce scope of err
  can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
  can: xilinx_can: Add ethtool stats interface for ECC errors
  can: xilinx_can: Add ECC support
  dt-bindings: can: xilinx_can: Add 'xlnx,has-ecc' optional property
  can: tcan4x5x: support resuming from rx interrupt signal
  can: m_can: allow keeping the transceiver running in suspend
  dt-bindings: can: tcan4x5x: Document the wakeup-source flag
  can: m_can: remove redundant check for pm_clock_support
====================

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
Paolo Abeni committed Feb 20, 2024
2 parents 219eee9 + 00bf80c commit 4934446
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/net/can/tcan4x5x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Optional properties:
available with tcan4552/4553.
- device-wake-gpios: Wake up GPIO to wake up the TCAN device. Not
available with tcan4552/4553.
- wakeup-source: Leave the chip running when suspended, and configure
the RX interrupt to wake up the device.

Example:
tcan4x5x: tcan4x5x@0 {
Expand All @@ -42,4 +44,5 @@ tcan4x5x: tcan4x5x@0 {
device-state-gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>;
device-wake-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>;
wakeup-source;
};
5 changes: 5 additions & 0 deletions Documentation/devicetree/bindings/net/can/xilinx,can.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ properties:
resets:
maxItems: 1

xlnx,has-ecc:
$ref: /schemas/types.yaml#/definitions/flag
description: CAN TX_OL, TX_TL and RX FIFOs have ECC support(AXI CAN)

required:
- compatible
- reg
Expand Down Expand Up @@ -137,6 +141,7 @@ examples:
interrupts = <GIC_SPI 59 IRQ_TYPE_EDGE_RISING>;
tx-fifo-depth = <0x40>;
rx-fifo-depth = <0x40>;
xlnx,has-ecc;
};
- |
Expand Down
30 changes: 20 additions & 10 deletions drivers/net/can/m_can/m_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -2312,11 +2312,9 @@ int m_can_class_register(struct m_can_classdev *cdev)
}
}

if (cdev->pm_clock_support) {
ret = m_can_clk_start(cdev);
if (ret)
return ret;
}
ret = m_can_clk_start(cdev);
if (ret)
return ret;

if (cdev->is_peripheral) {
ret = can_rx_offload_add_manual(cdev->net, &cdev->offload,
Expand Down Expand Up @@ -2384,7 +2382,15 @@ int m_can_class_suspend(struct device *dev)
if (netif_running(ndev)) {
netif_stop_queue(ndev);
netif_device_detach(ndev);
m_can_stop(ndev);

/* leave the chip running with rx interrupt enabled if it is
* used as a wake-up source.
*/
if (cdev->pm_wake_source)
m_can_write(cdev, M_CAN_IE, IR_RF0N);
else
m_can_stop(ndev);

m_can_clk_stop(cdev);
}

Expand All @@ -2411,11 +2417,15 @@ int m_can_class_resume(struct device *dev)
ret = m_can_clk_start(cdev);
if (ret)
return ret;
ret = m_can_start(ndev);
if (ret) {
m_can_clk_stop(cdev);

return ret;
if (cdev->pm_wake_source) {
m_can_write(cdev, M_CAN_IE, cdev->active_interrupts);
} else {
ret = m_can_start(ndev);
if (ret) {
m_can_clk_stop(cdev);
return ret;
}
}

netif_device_attach(ndev);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/can/m_can/m_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct m_can_classdev {
u32 irqstatus;

int pm_clock_support;
int pm_wake_source;
int is_peripheral;

// Cached M_CAN_IE register content
Expand Down
1 change: 1 addition & 0 deletions drivers/net/can/m_can/m_can_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
mcan_class->dev = &pci->dev;
mcan_class->net->irq = pci_irq_vector(pci, 0);
mcan_class->pm_clock_support = 1;
mcan_class->pm_wake_source = 0;
mcan_class->can.clock.freq = id->driver_data;
mcan_class->ops = &m_can_pci_ops;

Expand Down
1 change: 1 addition & 0 deletions drivers/net/can/m_can/m_can_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ static int m_can_plat_probe(struct platform_device *pdev)

mcan_class->net->irq = irq;
mcan_class->pm_clock_support = 1;
mcan_class->pm_wake_source = 0;
mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
mcan_class->dev = &pdev->dev;
mcan_class->transceiver = transceiver;
Expand Down
33 changes: 32 additions & 1 deletion drivers/net/can/m_can/tcan4x5x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
priv->spi = spi;

mcan_class->pm_clock_support = 0;
mcan_class->pm_wake_source = device_property_read_bool(&spi->dev, "wakeup-source");
mcan_class->can.clock.freq = freq;
mcan_class->dev = &spi->dev;
mcan_class->ops = &tcan4x5x_ops;
Expand Down Expand Up @@ -459,6 +460,9 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
goto out_power;
}

if (mcan_class->pm_wake_source)
device_init_wakeup(&spi->dev, true);

ret = m_can_class_register(mcan_class);
if (ret) {
dev_err(&spi->dev, "Failed registering m_can device %pe\n",
Expand Down Expand Up @@ -487,6 +491,29 @@ static void tcan4x5x_can_remove(struct spi_device *spi)
m_can_class_free_dev(priv->cdev.net);
}

static int __maybe_unused tcan4x5x_suspend(struct device *dev)
{
struct m_can_classdev *cdev = dev_get_drvdata(dev);
struct spi_device *spi = to_spi_device(dev);

if (cdev->pm_wake_source)
enable_irq_wake(spi->irq);

return m_can_class_suspend(dev);
}

static int __maybe_unused tcan4x5x_resume(struct device *dev)
{
struct m_can_classdev *cdev = dev_get_drvdata(dev);
struct spi_device *spi = to_spi_device(dev);
int ret = m_can_class_resume(dev);

if (cdev->pm_wake_source)
disable_irq_wake(spi->irq);

return ret;
}

static const struct of_device_id tcan4x5x_of_match[] = {
{
.compatible = "ti,tcan4x5x",
Expand All @@ -505,11 +532,15 @@ static const struct spi_device_id tcan4x5x_id_table[] = {
};
MODULE_DEVICE_TABLE(spi, tcan4x5x_id_table);

static const struct dev_pm_ops tcan4x5x_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(tcan4x5x_suspend, tcan4x5x_resume)
};

static struct spi_driver tcan4x5x_can_driver = {
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = tcan4x5x_of_match,
.pm = NULL,
.pm = &tcan4x5x_pm_ops,
},
.id_table = tcan4x5x_id_table,
.probe = tcan4x5x_can_probe,
Expand Down
Loading

0 comments on commit 4934446

Please sign in to comment.