Commit 50ad649d authored by David S. Miller's avatar David S. Miller
Browse files

Merge tag 'linux-can-next-for-5.20-20220720' of...

Merge tag 'linux-can-next-for-5.20-20220720' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next



Marc Kleine-Budde says:

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

The first 6 patches target the slcan driver. Dan Carpenter contributes
a hardening patch, followed by 5 cleanup patches.

Biju Das contributes 5 patches to prepare the sja1000 driver to
support the Renesas RZ/N1 SJA1000 CAN controller.

Dario Binacchi's patch for the slcan driver fixes a sleep with held
spin lock.

Another patch by Dario Binacchi fixes a wrong comment in the c_can
driver.

Pavel Pisa updates the CTU CAN FD IP core registers.

Stephane Grosjean contributes 3 patches to the peak_usb driver for
cleanups and support of a new MCU.

The last 12 patches are by Vincent Mailhol, they fix and improve the
txerr and rxerr reporting in all CAN drivers.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c2fe9ec3 1dbd8748
Loading
Loading
Loading
Loading
+132 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/can/nxp,sja1000.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Memory mapped SJA1000 CAN controller from NXP (formerly Philips)

maintainers:
  - Wolfgang Grandegger <wg@grandegger.com>

properties:
  compatible:
    oneOf:
      - enum:
          - nxp,sja1000
          - technologic,sja1000
      - items:
          - enum:
              - renesas,r9a06g032-sja1000 # RZ/N1D
              - renesas,r9a06g033-sja1000 # RZ/N1S
          - const: renesas,rzn1-sja1000 # RZ/N1

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  clocks:
    maxItems: 1

  reg-io-width:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: I/O register width (in bytes) implemented by this device
    default: 1
    enum: [ 1, 2, 4 ]

  nxp,external-clock-frequency:
    $ref: /schemas/types.yaml#/definitions/uint32
    default: 16000000
    description: |
      Frequency of the external oscillator clock in Hz.
      The internal clock frequency used by the SJA1000 is half of that value.

  nxp,tx-output-mode:
    $ref: /schemas/types.yaml#/definitions/uint32
    enum: [ 0, 1, 2, 3 ]
    default: 1
    description: |
      operation mode of the TX output control logic. Valid values are:
        <0> : bi-phase output mode
        <1> : normal output mode (default)
        <2> : test output mode
        <3> : clock output mode

  nxp,tx-output-config:
    $ref: /schemas/types.yaml#/definitions/uint32
    default: 0x02
    description: |
      TX output pin configuration. Valid values are any one of the below
      or combination of TX0 and TX1:
        <0x01> : TX0 invert
        <0x02> : TX0 pull-down (default)
        <0x04> : TX0 pull-up
        <0x06> : TX0 push-pull
        <0x08> : TX1 invert
        <0x10> : TX1 pull-down
        <0x20> : TX1 pull-up
        <0x30> : TX1 push-pull

  nxp,clock-out-frequency:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: |
      clock frequency in Hz on the CLKOUT pin.
      If not specified or if the specified value is 0, the CLKOUT pin
      will be disabled.

  nxp,no-comparator-bypass:
    type: boolean
    description: Allows to disable the CAN input comparator.

required:
  - compatible
  - reg
  - interrupts

allOf:
  - $ref: can-controller.yaml#
  - if:
      properties:
        compatible:
          contains:
            enum:
              - technologic,sja1000
              - renesas,rzn1-sja1000
    then:
      required:
        - reg-io-width
  - if:
      properties:
        compatible:
          contains:
            const: renesas,rzn1-sja1000
    then:
      required:
        - clocks

unevaluatedProperties: false

examples:
  - |
    can@1a000 {
        compatible = "technologic,sja1000";
        reg = <0x1a000 0x100>;
        interrupts = <1>;
        reg-io-width = <2>;
        nxp,tx-output-config = <0x06>;
        nxp,external-clock-frequency = <24000000>;
    };

  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/clock/r9a06g032-sysctrl.h>

    can@52104000 {
        compatible = "renesas,r9a06g032-sja1000", "renesas,rzn1-sja1000";
        reg = <0x52104000 0x800>;
        reg-io-width = <4>;
        interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&sysctrl R9A06G032_HCLK_CAN0>;
    };
+0 −58
Original line number Diff line number Diff line
Memory mapped SJA1000 CAN controller from NXP (formerly Philips)

Required properties:

- compatible : should be one of "nxp,sja1000", "technologic,sja1000".

- reg : should specify the chip select, address offset and size required
	to map the registers of the SJA1000. The size is usually 0x80.

- interrupts: property with a value describing the interrupt source
	(number and sensitivity) required for the SJA1000.

Optional properties:

- reg-io-width : Specify the size (in bytes) of the IO accesses that
	should be performed on the device.  Valid value is 1, 2 or 4.
	This property is ignored for technologic version.
	Default to 1 (8 bits).

- nxp,external-clock-frequency : Frequency of the external oscillator
	clock in Hz. Note that the internal clock frequency used by the
	SJA1000 is half of that value. If not specified, a default value
	of 16000000 (16 MHz) is used.

- nxp,tx-output-mode : operation mode of the TX output control logic:
	<0x0> : bi-phase output mode
	<0x1> : normal output mode (default)
	<0x2> : test output mode
	<0x3> : clock output mode

- nxp,tx-output-config : TX output pin configuration:
	<0x01> : TX0 invert
	<0x02> : TX0 pull-down (default)
	<0x04> : TX0 pull-up
	<0x06> : TX0 push-pull
	<0x08> : TX1 invert
	<0x10> : TX1 pull-down
	<0x20> : TX1 pull-up
	<0x30> : TX1 push-pull

- nxp,clock-out-frequency : clock frequency in Hz on the CLKOUT pin.
	If not specified or if the specified value is 0, the CLKOUT pin
	will be disabled.

- nxp,no-comparator-bypass : Allows to disable the CAN input comparator.

For further information, please have a look to the SJA1000 data sheet.

Examples:

can@3,100 {
	compatible = "nxp,sja1000";
	reg = <3 0x100 0x80>;
	interrupts = <2 0>;
	interrupt-parent = <&mpic>;
	nxp,external-clock-frequency = <16000000>;
};
+3 −4
Original line number Diff line number Diff line
@@ -952,15 +952,14 @@ static int c_can_handle_state_change(struct net_device *dev,

	switch (error_type) {
	case C_CAN_NO_ERROR:
		/* error warning state */
		cf->can_id |= CAN_ERR_CRTL;
		cf->can_id |= CAN_ERR_CRTL | CAN_ERR_CNT;
		cf->data[1] = CAN_ERR_CRTL_ACTIVE;
		cf->data[6] = bec.txerr;
		cf->data[7] = bec.rxerr;
		break;
	case C_CAN_ERROR_WARNING:
		/* error warning state */
		cf->can_id |= CAN_ERR_CRTL;
		cf->can_id |= CAN_ERR_CRTL | CAN_ERR_CNT;
		cf->data[1] = (bec.txerr > bec.rxerr) ?
			CAN_ERR_CRTL_TX_WARNING :
			CAN_ERR_CRTL_RX_WARNING;
@@ -970,7 +969,7 @@ static int c_can_handle_state_change(struct net_device *dev,
		break;
	case C_CAN_ERROR_PASSIVE:
		/* error passive state */
		cf->can_id |= CAN_ERR_CRTL;
		cf->can_id |= CAN_ERR_CRTL | CAN_ERR_CNT;
		if (rx_err_passive)
			cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
		if (bec.txerr > 127)
+1 −0
Original line number Diff line number Diff line
@@ -512,6 +512,7 @@ static int cc770_err(struct net_device *dev, u8 status)

	/* Use extended functions of the CC770 */
	if (priv->control_normal_mode & CTRL_EAF) {
		cf->can_id |= CAN_ERR_CNT;
		cf->data[6] = cc770_read_reg(priv, tx_error_counter);
		cf->data[7] = cc770_read_reg(priv, rx_error_counter);
	}
+3 −2
Original line number Diff line number Diff line
@@ -847,7 +847,7 @@ static void ctucan_err_interrupt(struct net_device *ndev, u32 isr)
		case CAN_STATE_ERROR_PASSIVE:
			priv->can.can_stats.error_passive++;
			if (skb) {
				cf->can_id |= CAN_ERR_CRTL;
				cf->can_id |= CAN_ERR_CRTL | CAN_ERR_CNT;
				cf->data[1] = (bec.rxerr > 127) ?
						CAN_ERR_CRTL_RX_PASSIVE :
						CAN_ERR_CRTL_TX_PASSIVE;
@@ -858,7 +858,7 @@ static void ctucan_err_interrupt(struct net_device *ndev, u32 isr)
		case CAN_STATE_ERROR_WARNING:
			priv->can.can_stats.error_warning++;
			if (skb) {
				cf->can_id |= CAN_ERR_CRTL;
				cf->can_id |= CAN_ERR_CRTL | CAN_ERR_CNT;
				cf->data[1] |= (bec.txerr > bec.rxerr) ?
					CAN_ERR_CRTL_TX_WARNING :
					CAN_ERR_CRTL_RX_WARNING;
@@ -867,6 +867,7 @@ static void ctucan_err_interrupt(struct net_device *ndev, u32 isr)
			}
			break;
		case CAN_STATE_ERROR_ACTIVE:
			cf->can_id |= CAN_ERR_CNT;
			cf->data[1] = CAN_ERR_CRTL_ACTIVE;
			cf->data[6] = bec.txerr;
			cf->data[7] = bec.rxerr;
Loading