net: can: Sort the Kconfig includes
Subsystems (4)
PATCH 1/5 net: can: Sort the Kconfig includes
Sort the Kconfig includes, no functional change.
--- drivers/net/can/Kconfig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/can/Kconfig +7 -7
@@ -147,22 +147,22 @@ config CAN_XILINXCAN Xilinx CAN driver. This driver supports both soft AXI CAN IP and Zynq CANPS IP. -source "drivers/net/can/mscan/Kconfig" - -source "drivers/net/can/sja1000/Kconfig" - source "drivers/net/can/c_can/Kconfig" +source "drivers/net/can/cc770/Kconfig" + source "drivers/net/can/m_can/Kconfig" -source "drivers/net/can/cc770/Kconfig" +source "drivers/net/can/mscan/Kconfig" + +source "drivers/net/can/sja1000/Kconfig" + +source "drivers/net/can/softing/Kconfig" source "drivers/net/can/spi/Kconfig" source "drivers/net/can/usb/Kconfig" -source "drivers/net/can/softing/Kconfig" - endif config CAN_DEBUG_DEVICES
Signature · 1 line
2.1.4
PATCH 2/5 net: can: Sort the Makefile
Just sort the drivers in the Makefile, no functional change.
--- drivers/net/can/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/can/Makefile +8 -8
@@ -14,21 +14,21 @@ obj-y += spi/ obj-y += usb/ obj-y += softing/ -obj-$(CONFIG_CAN_SJA1000) += sja1000/ -obj-$(CONFIG_CAN_MSCAN) += mscan/ -obj-$(CONFIG_CAN_C_CAN) += c_can/ -obj-$(CONFIG_CAN_M_CAN) += m_can/ -obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_AT91) += at91_can.o -obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o obj-$(CONFIG_CAN_BFIN) += bfin_can.o -obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o +obj-$(CONFIG_CAN_CC770) += cc770/ +obj-$(CONFIG_CAN_C_CAN) += c_can/ obj-$(CONFIG_CAN_FLEXCAN) += flexcan.o -obj-$(CONFIG_PCH_CAN) += pch_can.o obj-$(CONFIG_CAN_GRCAN) += grcan.o +obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o +obj-$(CONFIG_CAN_MSCAN) += mscan/ +obj-$(CONFIG_CAN_M_CAN) += m_can/ obj-$(CONFIG_CAN_RCAR) += rcar_can.o +obj-$(CONFIG_CAN_SJA1000) += sja1000/ obj-$(CONFIG_CAN_SUN4I) += sun4i_can.o +obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o obj-$(CONFIG_CAN_XILINXCAN) += xilinx_can.o +obj-$(CONFIG_PCH_CAN) += pch_can.o subdir-ccflags-y += -D__CHECK_ENDIAN__ subdir-ccflags-$(CONFIG_CAN_DEBUG_DEVICES) += -DDEBUG
Signature · 1 line
2.1.4
PATCH 3/5 of: Add vendor prefix for I/F/I
In reply to Marek VasutAdd vendor prefix for I/F/I, Ingenieurbüro Für IC-Technologie
http://www.ifi-pld.de/
--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -110,6 +110,7 @@ hp Hewlett Packard i2se I2SE GmbH ibm International Business Machines (IBM) idt Integrated Device Technologies, Inc. +ifi Ingenieurburo Fur Ic-Technologie (I/F/I) iom Iomega Corporation img Imagination Technologies Ltd. ingenic Ingenic Semiconductor
Signature · 1 line
2.1.4
PATCH 4/5 net: can: ifi: Add DT bindings for ifi,canfd
In reply to Marek VasutAdd device tree bindings for the I/F/I CANFD controller IP core.
--- Documentation/devicetree/bindings/net/can/ifi_canfd.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/can/ifi_canfd.txt
Documentation/devicetree/bindings/net/can/ifi_canfd.txt new file +15 -0
@@ -0,0 +1,15 @@ +IFI CANFD controller +-------------------- + +Required properties: + - compatible: Should be "ifi,canfd-1.0" + - reg: Should contain CAN controller registers location and length + - interrupts: Should contain IRQ line for the CAN controller + +Example: + + canfd0: canfd@ff220000 { + compatible = "ifi,canfd-1.0"; + reg = <0xff220000 0x00001000>; + interrupts = <0 43 0>; + };
Signature · 1 line
2.1.4
PATCH 5/5 net: can: ifi: Add IFI CANFD IP support
In reply to Marek VasutThe patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
NOTE: The driver is surprisingly similar to m_can, but the register
layout of the IFI core is completely different, so it's clear that those are two different IP cores.
--- drivers/net/can/Kconfig | 2 + drivers/net/can/Makefile | 1 + drivers/net/can/ifi_canfd/Kconfig | 8 + drivers/net/can/ifi_canfd/Makefile | 5 + drivers/net/can/ifi_canfd/ifi_canfd.c | 914 ++++++++++++++++++++++++++++++++++ 5 files changed, 930 insertions(+) create mode 100644 drivers/net/can/ifi_canfd/Kconfig create mode 100644 drivers/net/can/ifi_canfd/Makefile create mode 100644 drivers/net/can/ifi_canfd/ifi_canfd.c
drivers/net/can/Kconfig +2 -0
@@ -151,6 +151,8 @@ source "drivers/net/can/c_can/Kconfig" source "drivers/net/can/cc770/Kconfig" +source "drivers/net/can/ifi_canfd/Kconfig" + source "drivers/net/can/m_can/Kconfig" source "drivers/net/can/mscan/Kconfig"
drivers/net/can/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_C_CAN) += c_can/ obj-$(CONFIG_CAN_FLEXCAN) += flexcan.o obj-$(CONFIG_CAN_GRCAN) += grcan.o +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd/ obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o obj-$(CONFIG_CAN_MSCAN) += mscan/ obj-$(CONFIG_CAN_M_CAN) += m_can/
drivers/net/can/ifi_canfd/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +config CAN_IFI_CANFD + depends on HAS_IOMEM + tristate "IFI CAN_FD IP" + ---help--- + This driver adds support for the I/F/I CAN_FD soft IP block + connected to the "platform bus" (Linux abstraction for directly + to the processor attached devices). The CAN_FD is most often + synthesised into an FPGA or CPLD.
drivers/net/can/ifi_canfd/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the IFI CANFD controller driver. +# + +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd.o
drivers/net/can/ifi_canfd/ifi_canfd.c new file +914 -0
914 lines not on this page · raw message
Signature · 1 line
2.1.4
kbuild test robot
build botRe: [PATCH 5/5] net: can: ifi: Add IFI CANFD IP support
reproduce:
Hi Marek,
[auto build test WARNING on net/master]
[also build test WARNING on v4.4 next-20160111]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Marek-Vasut/net-can-Sort-the-Kconfig-includes/20160112-025020 config: x86_64-allmodconfig (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All warnings (new ones prefixed by >>):
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_isr':
>> drivers/net/can/ifi_canfd/ifi_canfd.c:486:27: warning: large integer implicitly truncated to unsigned type [-Woverflow]
const u32 clr_irq_mask = ~(IFI_CANFD_INTERRUPT_SET_IRQ |
^
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_start':
drivers/net/can/ifi_canfd/ifi_canfd.c:640:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
writel(~IFI_CANFD_INTERRUPT_SET_IRQ, priv->base + IFI_CANFD_INTERRUPT);
^
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_stop':
drivers/net/can/ifi_canfd/ifi_canfd.c:675:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
writel(~IFI_CANFD_INTERRUPT_SET_IRQ, priv->base + IFI_CANFD_INTERRUPT);
^vim +486 drivers/net/can/ifi_canfd/ifi_canfd.c
470 napi_complete(napi);
471 ifi_canfd_irq_enable(ndev, 1);
472 }
473
474 return work_done;
475 }
476
477 static irqreturn_t ifi_canfd_isr(int irq, void *dev_id)
478 {
479 struct net_device *ndev = (struct net_device *)dev_id;
480 struct ifi_canfd_priv *priv = netdev_priv(ndev);
481 struct net_device_stats *stats = &ndev->stats;
482 const u32 rx_irq_mask = IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY |
483 IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER;
484 const u32 tx_irq_mask = IFI_CANFD_INTERRUPT_TXFIFO_EMPTY |
485 IFI_CANFD_INTERRUPT_TXFIFO_REMOVE;
> 486 const u32 clr_irq_mask = ~(IFI_CANFD_INTERRUPT_SET_IRQ |
487 IFI_CANFD_INTERRUPT_ERROR_WARNING);
488 u32 isr;
489
490 isr = readl(priv->base + IFI_CANFD_INTERRUPT);
491
492 /* No interrupt */
493 if (isr == 0)
494 return IRQ_NONE;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 1 line · kbuild test robot
Hi Marek,
Hi Robot,
Quoted 19 lines
[auto build test WARNING on net/master]
[also build test WARNING on v4.4 next-20160111]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]url:
https://github.com/0day-ci/linux/commits/Marek-Vasut/net-can-Sort-the-Kcon
fig-includes/20160112-025020 config: x86_64-allmodconfig (attached as .config)
reproduce:# save the attached .config to linux build tree make ARCH=x86_64All warnings (new ones prefixed by >>):
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_isr':Quoted 2 lines
Quoted 2 lines
drivers/net/can/ifi_canfd/ifi_canfd.c:486:27: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Quoted 10 lines
const u32
clr_irq_mask= ~(IFI_CANFD_INTERRUPT_SET_IRQ |
^
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_start':
drivers/net/can/ifi_canfd/ifi_canfd.c:640:9: warning: large integer
implicitly truncated to unsigned type [-Woverflow]writel(~IFI_CANFD_INTERRUPT_SET_IRQ, priv->base + IFI_CANFD_INTERRUPT); ^
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_stop':
drivers/net/can/ifi_canfd/ifi_canfd.c:675:9: warning: large integer
implicitly truncated to unsigned type [-Woverflow]writel(~IFI_CANFD_INTERRUPT_SET_IRQ, priv->base + IFI_CANFD_INTERRUPT); ^
How did this splat came to be ? I would expect that the expansion goes like this:
const u32 clr_irq_mask = ~(IFI_CANFD_INTERRUPT_SET_IRQ |
IFI_CANFD_INTERRUPT_ERROR_WARNING);
const u32 clr_irq_mask = ~(BIT(31) | BIT(1));
const u32 clr_irq_mask = ~(0x80000002);
const u32 clr_irq_mask = 0x7ffffffd;
Did I miss something there ?
Thanks!
Best regards,
Marek Vasut
kbuild test robot
build botRe: [PATCH 5/5] net: can: ifi: Add IFI CANFD IP support
In reply to Marek Vasutreproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Marek,
[auto build test WARNING on net/master]
[also build test WARNING on v4.4 next-20160111]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Marek-Vasut/net-can-Sort-the-Kconfig-includes/20160112-025020 config: ia64-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All warnings (new ones prefixed by >>):
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_isr':
drivers/net/can/ifi_canfd/ifi_canfd.c:486:27: warning: large integer implicitly truncated to unsigned type [-Woverflow]
const u32 clr_irq_mask = ~(IFI_CANFD_INTERRUPT_SET_IRQ |
^
In file included from arch/ia64/include/asm/smp.h:20:0,
from include/linux/smp.h:59,
from include/linux/sched.h:34,
from arch/ia64/include/asm/delay.h:16,
from include/linux/delay.h:14,
from drivers/net/can/ifi_canfd/ifi_canfd.c:15:
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_start':
arch/ia64/include/asm/io.h:394:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]
#define writel(v,a) __writel((v), (a))
^
>> drivers/net/can/ifi_canfd/ifi_canfd.c:640:2: note: in expansion of macro 'writel'
writel(~IFI_CANFD_INTERRUPT_SET_IRQ, priv->base + IFI_CANFD_INTERRUPT);
^
drivers/net/can/ifi_canfd/ifi_canfd.c: In function 'ifi_canfd_stop':
arch/ia64/include/asm/io.h:394:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]
#define writel(v,a) __writel((v), (a))
^
drivers/net/can/ifi_canfd/ifi_canfd.c:675:2: note: in expansion of macro 'writel'
writel(~IFI_CANFD_INTERRUPT_SET_IRQ, priv->base + IFI_CANFD_INTERRUPT);
^vim +/writel +640 drivers/net/can/ifi_canfd/ifi_canfd.c
624 writel(0, priv->base + IFI_CANFD_STCMD);
625
626 ifi_canfd_set_bittiming(ndev);
627 ifi_canfd_set_filters(ndev);
628
629 /* Reset FIFOs */
630 writel(IFI_CANFD_RXSTCMD_RESET, priv->base + IFI_CANFD_RXSTCMD);
631 writel(0, priv->base + IFI_CANFD_RXSTCMD);
632 writel(IFI_CANFD_TXSTCMD_RESET, priv->base + IFI_CANFD_TXSTCMD);
633 writel(0, priv->base + IFI_CANFD_TXSTCMD);
634
635 /* Repeat transmission until successful */
636 writel(0, priv->base + IFI_CANFD_REPEAT);
637 writel(0, priv->base + IFI_CANFD_SUSPEND);
638
639 /* Clear all pending interrupts */
> 640 writel(~IFI_CANFD_INTERRUPT_SET_IRQ, priv->base + IFI_CANFD_INTERRUPT);
641
642 stcmd = IFI_CANFD_STCMD_ENABLE | IFI_CANFD_STCMD_NORMAL_MODE;
643
644 if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
645 stcmd |= IFI_CANFD_STCMD_BUSMONITOR;
646
647 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
648 stcmd |= IFI_CANFD_STCMD_LOOPBACK;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 5/5 net: can: ifi: Add IFI CANFD IP support
In reply to Marek VasutThe patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
---
V2: - Move request_irq()/free_irq() into ifi_canfd_open()/ifi_canfd_close()
just like other drivers do it to prevent crash when reloading module.
- Fix Woverflow complains on x86_64 and itanium, exactly the same way as in commit dec23dca5a9ca4b9eb2fb66926f567889028b904 .
NOTE: The driver is surprisingly similar to m_can, but the register
layout of the IFI core is completely different, so it's clear that those are two different IP cores.
--- drivers/net/can/Kconfig | 2 + drivers/net/can/Makefile | 1 + drivers/net/can/ifi_canfd/Kconfig | 8 + drivers/net/can/ifi_canfd/Makefile | 5 + drivers/net/can/ifi_canfd/ifi_canfd.c | 919 ++++++++++++++++++++++++++++++++++ 5 files changed, 935 insertions(+) create mode 100644 drivers/net/can/ifi_canfd/Kconfig create mode 100644 drivers/net/can/ifi_canfd/Makefile create mode 100644 drivers/net/can/ifi_canfd/ifi_canfd.c
drivers/net/can/Kconfig +2 -0
@@ -151,6 +151,8 @@ source "drivers/net/can/c_can/Kconfig" source "drivers/net/can/cc770/Kconfig" +source "drivers/net/can/ifi_canfd/Kconfig" + source "drivers/net/can/m_can/Kconfig" source "drivers/net/can/mscan/Kconfig"
drivers/net/can/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_C_CAN) += c_can/ obj-$(CONFIG_CAN_FLEXCAN) += flexcan.o obj-$(CONFIG_CAN_GRCAN) += grcan.o +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd/ obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o obj-$(CONFIG_CAN_MSCAN) += mscan/ obj-$(CONFIG_CAN_M_CAN) += m_can/
drivers/net/can/ifi_canfd/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +config CAN_IFI_CANFD + depends on HAS_IOMEM + tristate "IFI CAN_FD IP" + ---help--- + This driver adds support for the I/F/I CAN_FD soft IP block + connected to the "platform bus" (Linux abstraction for directly + to the processor attached devices). The CAN_FD is most often + synthesised into an FPGA or CPLD.
drivers/net/can/ifi_canfd/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the IFI CANFD controller driver. +# + +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd.o
drivers/net/can/ifi_canfd/ifi_canfd.c new file +919 -0
919 lines not on this page · raw message
Signature · 1 line
2.1.4
Marc Kleine-Budde
maintainerRe: [PATCH V2 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 257 lines · Marek Vasut
The patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
Signed-off-by Marek Vasut <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc Mark Rutland <[email protected]>Cc Oliver Hartkopp <[email protected]>Cc Wolfgang Grandegger <[email protected]>---
V2: - Move request_irq()/free_irq() into ifi_canfd_open()/ifi_canfd_close()
just like other drivers do it to prevent crash when reloading module.
- Fix Woverflow complains onx86_64and itanium, exactly the same way as in commitdec23dca5a9ca4b9eb2fb66926f567889028b904.NOTE: The driver is surprisingly similar to
m_can, but the register
layout of the IFI core is completely different, so it's clear that those are two different IP cores.--- drivers/net/can/Kconfig | 2 + drivers/net/can/Makefile | 1 + drivers/net/can/ifi_canfd/Kconfig | 8 + drivers/net/can/ifi_canfd/Makefile | 5 + drivers/net/can/ifi_canfd/ifi_canfd.c | 919 ++++++++++++++++++++++++++++++++++ 5 files changed, 935 insertions(+) create mode 100644 drivers/net/can/ifi_canfd/Kconfig create mode 100644 drivers/net/can/ifi_canfd/Makefile create mode 100644 drivers/net/can/ifi_canfd/ifi_canfd.cdrivers/net/can/Kconfig +2
-0@@ -151,6 +151,8 @@ source "drivers/net/can/c_can/Kconfig" source "drivers/net/can/cc770/Kconfig" +source "drivers/net/can/ifi_canfd/Kconfig" + source "drivers/net/can/m_can/Kconfig" source "drivers/net/can/mscan/Kconfig"drivers/net/can/Makefile +1
-0@@ -20,6 +20,7 @@ obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_C_CAN) += c_can/ obj-$(CONFIG_CAN_FLEXCAN) += flexcan.o obj-$(CONFIG_CAN_GRCAN) += grcan.o +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd/ obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o obj-$(CONFIG_CAN_MSCAN) += mscan/ obj-$(CONFIG_CAN_M_CAN) += m_can/drivers/net/can/ifi_canfd/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +config CAN_IFI_CANFD + depends on HAS_IOMEM + tristate "IFI CAN_FD IP" + ---help--- + This driver adds support for the I/F/I CAN_FD soft IP block + connected to the "platform bus" (Linux abstraction for directly + to the processor attached devices). The CAN_FD is most often + synthesised into an FPGA or CPLD.drivers/net/can/ifi_canfd/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# +# Makefile for the IFI CANFD controller driver. +# + +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd.odrivers/net/can/ifi_canfd/ifi_canfd.c new file +170
-0@@ -0,0 +1,919 @@ +/* +* CAN bus driver for IFI CANFD controller +* +* Copyright (C) 2016 Marek Vasut <[email protected]> +* +* Details about this controller can be found at +* http://www.ifi-pld.de/IP/CANFD/canfd.html +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#include <linux/can/dev.h> + +#define IFI_CANFD_STCMD 0x0 +#define IFI_CANFD_STCMD_HARDRESET 0xDEADCAFD +#define IFI_CANFD_STCMD_ENABLE BIT(0) +#define IFI_CANFD_STCMD_ERROR_ACTIVE BIT(2) +#define IFI_CANFD_STCMD_ERROR_PASSIVE BIT(3) +#define IFI_CANFD_STCMD_BUSOFF BIT(4) +#define IFI_CANFD_STCMD_BUSMONITOR BIT(16) +#define IFI_CANFD_STCMD_LOOPBACK BIT(18) +#define IFI_CANFD_STCMD_DISABLE_CANFD BIT(24) +#define IFI_CANFD_STCMD_ENABLE_ISO BIT(25) +#define IFI_CANFD_STCMD_NORMAL_MODE BIT(31) + +#define IFI_CANFD_RXSTCMD 0x4 +#define IFI_CANFD_RXSTCMD_REMOVE_MSG BIT(0) +#define IFI_CANFD_RXSTCMD_RESET BIT(7) +#define IFI_CANFD_RXSTCMD_EMPTY BIT(8) +#define IFI_CANFD_RXSTCMD_OVERFLOW BIT(13) + +#define IFI_CANFD_TXSTCMD 0x8 +#define IFI_CANFD_TXSTCMD_ADD_MSG BIT(0) +#define IFI_CANFD_TXSTCMD_HIGH_PRIO BIT(1) +#define IFI_CANFD_TXSTCMD_RESET BIT(7) +#define IFI_CANFD_TXSTCMD_EMPTY BIT(8) +#define IFI_CANFD_TXSTCMD_FULL BIT(12) +#define IFI_CANFD_TXSTCMD_OVERFLOW BIT(13) + +#define IFI_CANFD_INTERRUPT 0xc +#define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1) +#define IFI_CANFD_INTERRUPT_TXFIFO_EMPTY BIT(16) +#define IFI_CANFD_INTERRUPT_TXFIFO_REMOVE BIT(22) +#define IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY BIT(24) +#define IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER BIT(25) +#define IFI_CANFD_INTERRUPT_SET_IRQ BIT(31) + +#define IFI_CANFD_IRQMASK 0x10 +#define IFI_CANFD_IRQMASK_SET_ERR BIT(7) +#define IFI_CANFD_IRQMASK_SET_TS BIT(15) +#define IFI_CANFD_IRQMASK_TXFIFO_EMPTY BIT(16) +#define IFI_CANFD_IRQMASK_SET_TX BIT(23) +#define IFI_CANFD_IRQMASK_RXFIFO_NEMPTY BIT(24) +#define IFI_CANFD_IRQMASK_SET_RX BIT(31) + +#define IFI_CANFD_TIME 0x14 +#define IFI_CANFD_FTIME 0x18 +#define IFI_CANFD_TIME_TIMEB_OFF 0 +#define IFI_CANFD_TIME_TIMEA_OFF 8 +#define IFI_CANFD_TIME_PRESCALE_OFF 16 +#define IFI_CANFD_TIME_SJW_OFF_ISO 25 +#define IFI_CANFD_TIME_SJW_OFF_BOSCH 28 +#define IFI_CANFD_TIME_SET_SJW_BOSCH BIT(6) +#define IFI_CANFD_TIME_SET_TIMEB_BOSCH BIT(7) +#define IFI_CANFD_TIME_SET_PRESC_BOSCH BIT(14) +#define IFI_CANFD_TIME_SET_TIMEA_BOSCH BIT(15) + +#define IFI_CANFD_TDELAY 0x1c + +#define IFI_CANFD_ERROR 0x20 +#define IFI_CANFD_ERROR_TX_OFFSET 0 +#define IFI_CANFD_ERROR_TX_MASK 0xff +#define IFI_CANFD_ERROR_RX_OFFSET 16 +#define IFI_CANFD_ERROR_RX_MASK 0xff + +#define IFI_CANFD_ERRCNT 0x24 + +#define IFI_CANFD_SUSPEND 0x28 + +#define IFI_CANFD_REPEAT 0x2c + +#define IFI_CANFD_TRAFFIC 0x30 + +#define IFI_CANFD_TSCONTROL 0x34 + +#define IFI_CANFD_TSC 0x38 + +#define IFI_CANFD_TST 0x3c + +#define IFI_CANFD_RES1 0x40 + +#define IFI_CANFD_RES2 0x44 + +#define IFI_CANFD_PAR 0x48 + +#define IFI_CANFD_CANCLOCK 0x4c + +#define IFI_CANFD_SYSCLOCK 0x50 + +#define IFI_CANFD_VER 0x54 + +#define IFI_CANFD_IP_ID 0x58 +#define IFI_CANFD_IP_ID_VALUE 0xD073CAFD + +#define IFI_CANFD_TEST 0x5c + +#define IFI_CANFD_RXFIFO_TS_63_32 0x60 + +#define IFI_CANFD_RXFIFO_TS_31_0 0x64 + +#define IFI_CANFD_RXFIFO_DLC 0x68 +#define IFI_CANFD_RXFIFO_DLC_DLC_OFFSET 0 +#define IFI_CANFD_RXFIFO_DLC_DLC_MASK 0xf +#define IFI_CANFD_RXFIFO_DLC_RTR BIT(4) +#define IFI_CANFD_RXFIFO_DLC_EDL BIT(5) +#define IFI_CANFD_RXFIFO_DLC_BRS BIT(6) +#define IFI_CANFD_RXFIFO_DLC_ESI BIT(7) +#define IFI_CANFD_RXFIFO_DLC_OBJ_OFFSET 8 +#define IFI_CANFD_RXFIFO_DLC_OBJ_MASK 0x1ff +#define IFI_CANFD_RXFIFO_DLC_FNR_OFFSET 24 +#define IFI_CANFD_RXFIFO_DLC_FNR_MASK 0xff + +#define IFI_CANFD_RXFIFO_ID 0x6c +#define IFI_CANFD_RXFIFO_ID_ID_OFFSET 0 +#define IFI_CANFD_RXFIFO_ID_ID_STD_MASK 0x3ff +#define IFI_CANFD_RXFIFO_ID_ID_XTD_MASK 0x1fffffff +#define IFI_CANFD_RXFIFO_ID_IDE BIT(29) + +#define IFI_CANFD_RXFIFO_DATA 0x70/* 0x70..0xac */ + +#define IFI_CANFD_TXFIFO_SUSPEND_US 0xb0 + +#define IFI_CANFD_TXFIFO_REPEATCOUNT 0xb4 + +#define IFI_CANFD_TXFIFO_DLC 0xb8 +#define IFI_CANFD_TXFIFO_DLC_DLC_OFFSET 0 +#define IFI_CANFD_TXFIFO_DLC_DLC_MASK 0xf +#define IFI_CANFD_TXFIFO_DLC_RTR BIT(4) +#define IFI_CANFD_TXFIFO_DLC_EDL BIT(5) +#define IFI_CANFD_TXFIFO_DLC_BRS BIT(6) +#define IFI_CANFD_TXFIFO_DLC_FNR_OFFSET 24 +#define IFI_CANFD_TXFIFO_DLC_FNR_MASK 0xff + +#define IFI_CANFD_TXFIFO_ID 0xbc +#define IFI_CANFD_TXFIFO_ID_ID_OFFSET 0 +#define IFI_CANFD_TXFIFO_ID_ID_STD_MASK 0x3ff +#define IFI_CANFD_TXFIFO_ID_ID_XTD_MASK 0x1fffffff +#define IFI_CANFD_TXFIFO_ID_IDE BIT(29) + +#define IFI_CANFD_TXFIFO_DATA 0xc0/* 0xb0..0xfc */ + +#define IFI_CANFD_FILTER_MASK (n) (0x800 + ((n) * 8) + 0) +#define IFI_CANFD_FILTER_MASK_EXT BIT(29) +#define IFI_CANFD_FILTER_MASK_EDL BIT(30) +#define IFI_CANFD_FILTER_MASK_VALID BIT(31) + +#define IFI_CANFD_FILTER_IDENT (n) (0x800 + ((n) * 8) + 4)
drivers/net/can/ifi_canfd/ifi_canfd.c line 180
Quoted 10 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +10
-0+#define IFI_CANFD_FILTER_IDENT_IDE BIT(29) +#define IFI_CANFD_FILTER_IDENT_CANFD BIT(30) +#define IFI_CANFD_FILTER_IDENT_VALID BIT(31) + +/* IFI CANFD private data structure */ +struct ifi_canfd_priv { +struct can_priv can;/* must be the first member */ +struct napi_struct napi; +struct net_device *ndev; +struct device *device;
Nitpick: This variable is write only, correct? I can fix this while applying the patch.
drivers/net/can/ifi_canfd/ifi_canfd.c line 182
Quoted 2 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +2
-0+void __iomem *base; +};
Otherweise looks good.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Marc Kleine-Budde
maintainerRe: [PATCH V2 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 10 lines · Marc Kleine-Budde
drivers/net/can/ifi_canfd/ifi_canfd.c line 180
Quoted 6 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +6
-0+/* IFI CANFD private data structure */ +struct ifi_canfd_priv { +struct can_priv can;/* must be the first member */ +struct napi_struct napi; +struct net_device *ndev; +struct device *device;Nitpick: This variable is write only, correct? I can fix this while applying the patch.
Quoted 4 lines
drivers/net/can/ifi_canfd/ifi_canfd.c line 182
Quoted 2 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +2
-0+void __iomem *base; +};Otherweise looks good.
Until compiling:
Quoted 3 lines
drivers/net/can/ifi_canfd/ifi_canfd.c:486:40: warning: cast truncates bits from constant value (ffffffff7ffffffdbecomes7ffffffd)drivers/net/can/ifi_canfd/ifi_canfd.c:640:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)drivers/net/can/ifi_canfd/ifi_canfd.c:676:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)
target is ARMv5 with gcc version 4.9.2, compiled with C=2 using sparse v0.5.0.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Re: [PATCH V2 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 11 lines · Marc Kleine-Budde
Quoted 10 lines · Marc Kleine-Budde
drivers/net/can/ifi_canfd/ifi_canfd.c line 180
Quoted 6 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +6
-0+/* IFI CANFD private data structure */ +struct ifi_canfd_priv { +struct can_priv can;/* must be the first member */ +struct napi_struct napi; +struct net_device *ndev; +struct device *device;Nitpick: This variable is write only, correct? I can fix this while applying the patch.
Quoted 4 lines
Quoted 4 lines
drivers/net/can/ifi_canfd/ifi_canfd.c line 182
Quoted 2 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +2
-0+void __iomem *base; +};Otherweise looks good.
It's write-only, yeah. What would you propose to change here ?
Quoted 10 lines
Until compiling:
Quoted 6 lines
drivers/net/can/ifi_canfd/ifi_canfd.c:486:40: warning: cast truncates bits from constant value (ffffffff7ffffffdbecomes7ffffffd)drivers/net/can/ifi_canfd/ifi_canfd.c:640:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)drivers/net/can/ifi_canfd/ifi_canfd.c:676:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)target is ARMv5 with gcc version 4.9.2, compiled with C=2 using sparse v0.5.0.
It's again the BIT() macro :-/ Do you have any idea how to fix this please ? Doing something like u32 foo = ~BIT(31); triggers this splat and I am running out of ideas how to fix that.
Best regards,
Marek Vasut
Marc Kleine-Budde
maintainerRe: [PATCH V2 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 12 lines · Marek Vasut
Quoted 11 lines · Marc Kleine-Budde
Quoted 10 lines · Marc Kleine-Budde
drivers/net/can/ifi_canfd/ifi_canfd.c line 180
Quoted 6 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +6
-0+/* IFI CANFD private data structure */ +struct ifi_canfd_priv { +struct can_priv can;/* must be the first member */ +struct napi_struct napi; +struct net_device *ndev; +struct device *device;Nitpick: This variable is write only, correct? I can fix this while applying the patch.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/can/ifi_canfd/ifi_canfd.c line 182
Quoted 2 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +2
-0+void __iomem *base; +};Otherweise looks good.
It's write-only, yeah. What would you propose to change here ?
Remove it completely. :D
Quoted 8 lines
Quoted 8 lines
Until compiling:
Quoted 6 lines
drivers/net/can/ifi_canfd/ifi_canfd.c:486:40: warning: cast truncates bits from constant value (ffffffff7ffffffdbecomes7ffffffd)drivers/net/can/ifi_canfd/ifi_canfd.c:640:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)drivers/net/can/ifi_canfd/ifi_canfd.c:676:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)
Quoted 6 lines
Quoted 2 lines
target is ARMv5 with gcc version 4.9.2, compiled with C=2 using sparse v0.5.0.
It's again the
BIT()macro :-/ Do you have any idea how to fix this please ? Doing something like u32 foo = ~BIT(31); triggers this splat and I am running out of ideas how to fix that.
-#define IFI_CANFD_INTERRUPT_SET_IRQ BIT(31)
+#define IFI_CANFD_INTERRUPT_SET_IRQ ((u32)BIT(31))
...or change the bit to "30" :D
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Re: [PATCH V2 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 13 lines · Marc Kleine-Budde
Quoted 12 lines · Marek Vasut
Quoted 11 lines · Marc Kleine-Budde
Quoted 10 lines · Marc Kleine-Budde
drivers/net/can/ifi_canfd/ifi_canfd.c line 180
Quoted 6 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +6
-0+/* IFI CANFD private data structure */ +struct ifi_canfd_priv { +struct can_priv can;/* must be the first member */ +struct napi_struct napi; +struct net_device *ndev; +struct device *device;Nitpick: This variable is write only, correct? I can fix this while applying the patch.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/can/ifi_canfd/ifi_canfd.c line 182
Quoted 2 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +2
-0+void __iomem *base; +};Otherweise looks good.
It's write-only, yeah. What would you propose to change here ?
Remove it completely. :D
Erm, right. I see it now, thanks.
Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
Until compiling:
Quoted 6 lines
drivers/net/can/ifi_canfd/ifi_canfd.c:486:40: warning: cast truncates bits from constant value (ffffffff7ffffffdbecomes7ffffffd)drivers/net/can/ifi_canfd/ifi_canfd.c:640:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)drivers/net/can/ifi_canfd/ifi_canfd.c:676:9: warning: cast truncates bits from constant value (ffffffff7fffffffbecomes7fffffff)target is ARMv5 with gcc version 4.9.2, compiled with C=2 using sparse v0.5.0.
It's again the
BIT()macro :-/ Do you have any idea how to fix this please ? Doing something like u32 foo = ~BIT(31); triggers this splat and I am running out of ideas how to fix that.
Review
Quoted 2 lines
(quoted diff) +1
-1-#define IFI_CANFD_INTERRUPT_SET_IRQ BIT(31) +#define IFI_CANFD_INTERRUPT_SET_IRQ ((u32)BIT(31))
I see, so adding u32 also here works. I'm starting to wonder if the BIT macro is really that nice and if I shouldn't just use (1 << n) as usual.
Quoted 1 line
...or change the bit to "30" :D
:-)
I will send V3 in a bit.
Best regards,
Marek Vasut
PATCH v3 5/5 net: can: ifi: Add IFI CANFD IP support
In reply to Marc Kleine-BuddeThe patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
---
V2: - Move request_irq()/free_irq() into ifi_canfd_open()/ifi_canfd_close()
just like other drivers do it to prevent crash when reloading module.
- Fix Woverflow complains on x86_64 and itanium, exactly the same way as in commit dec23dca5a9ca4b9eb2fb66926f567889028b904 .
V3: - Hopefully fix all problems with BIT(31) by adding more u32 casts.
- Drop struct device from struct ifi_canfd_priv .
NOTE: The driver is surprisingly similar to m_can, but the register
layout of the IFI core is completely different, so it's clear that those are two different IP cores.
--- drivers/net/can/Kconfig | 2 + drivers/net/can/Makefile | 1 + drivers/net/can/ifi_canfd/Kconfig | 8 + drivers/net/can/ifi_canfd/Makefile | 5 + drivers/net/can/ifi_canfd/ifi_canfd.c | 917 ++++++++++++++++++++++++++++++++++ 5 files changed, 933 insertions(+) create mode 100644 drivers/net/can/ifi_canfd/Kconfig create mode 100644 drivers/net/can/ifi_canfd/Makefile create mode 100644 drivers/net/can/ifi_canfd/ifi_canfd.c
drivers/net/can/Kconfig +2 -0
@@ -151,6 +151,8 @@ source "drivers/net/can/c_can/Kconfig" source "drivers/net/can/cc770/Kconfig" +source "drivers/net/can/ifi_canfd/Kconfig" + source "drivers/net/can/m_can/Kconfig" source "drivers/net/can/mscan/Kconfig"
drivers/net/can/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_C_CAN) += c_can/ obj-$(CONFIG_CAN_FLEXCAN) += flexcan.o obj-$(CONFIG_CAN_GRCAN) += grcan.o +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd/ obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o obj-$(CONFIG_CAN_MSCAN) += mscan/ obj-$(CONFIG_CAN_M_CAN) += m_can/
drivers/net/can/ifi_canfd/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +config CAN_IFI_CANFD + depends on HAS_IOMEM + tristate "IFI CAN_FD IP" + ---help--- + This driver adds support for the I/F/I CAN_FD soft IP block + connected to the "platform bus" (Linux abstraction for directly + to the processor attached devices). The CAN_FD is most often + synthesised into an FPGA or CPLD.
drivers/net/can/ifi_canfd/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the IFI CANFD controller driver. +# + +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd.o
drivers/net/can/ifi_canfd/ifi_canfd.c new file +917 -0
917 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [PATCH V3 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 566 lines · Marek Vasut
The patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
Signed-off-by Marek Vasut <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc Mark Rutland <[email protected]>Cc Oliver Hartkopp <[email protected]>Cc Wolfgang Grandegger <[email protected]>---
V2: - Move request_irq()/free_irq() into ifi_canfd_open()/ifi_canfd_close()
just like other drivers do it to prevent crash when reloading module.
- Fix Woverflow complains onx86_64and itanium, exactly the same way as in commitdec23dca5a9ca4b9eb2fb66926f567889028b904.V3: - Hopefully fix all problems with BIT(31) by adding more u32 casts.
- Drop struct device from structifi_canfd_priv.NOTE: The driver is surprisingly similar to
m_can, but the register
layout of the IFI core is completely different, so it's clear that those are two different IP cores.--- drivers/net/can/Kconfig | 2 + drivers/net/can/Makefile | 1 + drivers/net/can/ifi_canfd/Kconfig | 8 + drivers/net/can/ifi_canfd/Makefile | 5 + drivers/net/can/ifi_canfd/ifi_canfd.c | 917 ++++++++++++++++++++++++++++++++++ 5 files changed, 933 insertions(+) create mode 100644 drivers/net/can/ifi_canfd/Kconfig create mode 100644 drivers/net/can/ifi_canfd/Makefile create mode 100644 drivers/net/can/ifi_canfd/ifi_canfd.cdrivers/net/can/Kconfig +2
-0@@ -151,6 +151,8 @@ source "drivers/net/can/c_can/Kconfig" source "drivers/net/can/cc770/Kconfig" +source "drivers/net/can/ifi_canfd/Kconfig" + source "drivers/net/can/m_can/Kconfig" source "drivers/net/can/mscan/Kconfig"drivers/net/can/Makefile +1
-0@@ -20,6 +20,7 @@ obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_C_CAN) += c_can/ obj-$(CONFIG_CAN_FLEXCAN) += flexcan.o obj-$(CONFIG_CAN_GRCAN) += grcan.o +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd/ obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o obj-$(CONFIG_CAN_MSCAN) += mscan/ obj-$(CONFIG_CAN_M_CAN) += m_can/drivers/net/can/ifi_canfd/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +config CAN_IFI_CANFD + depends on HAS_IOMEM + tristate "IFI CAN_FD IP" + ---help--- + This driver adds support for the I/F/I CAN_FD soft IP block + connected to the "platform bus" (Linux abstraction for directly + to the processor attached devices). The CAN_FD is most often + synthesised into an FPGA or CPLD.drivers/net/can/ifi_canfd/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# +# Makefile for the IFI CANFD controller driver. +# + +obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd.odrivers/net/can/ifi_canfd/ifi_canfd.c new file +476
-0@@ -0,0 +1,917 @@ +/* +* CAN bus driver for IFI CANFD controller +* +* Copyright (C) 2016 Marek Vasut <[email protected]> +* +* Details about this controller can be found at +* http://www.ifi-pld.de/IP/CANFD/canfd.html +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#include <linux/can/dev.h> + +#define IFI_CANFD_STCMD 0x0 +#define IFI_CANFD_STCMD_HARDRESET 0xDEADCAFD +#define IFI_CANFD_STCMD_ENABLE BIT(0) +#define IFI_CANFD_STCMD_ERROR_ACTIVE BIT(2) +#define IFI_CANFD_STCMD_ERROR_PASSIVE BIT(3) +#define IFI_CANFD_STCMD_BUSOFF BIT(4) +#define IFI_CANFD_STCMD_BUSMONITOR BIT(16) +#define IFI_CANFD_STCMD_LOOPBACK BIT(18) +#define IFI_CANFD_STCMD_DISABLE_CANFD BIT(24) +#define IFI_CANFD_STCMD_ENABLE_ISO BIT(25) +#define IFI_CANFD_STCMD_NORMAL_MODE ((u32)BIT(31)) + +#define IFI_CANFD_RXSTCMD 0x4 +#define IFI_CANFD_RXSTCMD_REMOVE_MSG BIT(0) +#define IFI_CANFD_RXSTCMD_RESET BIT(7) +#define IFI_CANFD_RXSTCMD_EMPTY BIT(8) +#define IFI_CANFD_RXSTCMD_OVERFLOW BIT(13) + +#define IFI_CANFD_TXSTCMD 0x8 +#define IFI_CANFD_TXSTCMD_ADD_MSG BIT(0) +#define IFI_CANFD_TXSTCMD_HIGH_PRIO BIT(1) +#define IFI_CANFD_TXSTCMD_RESET BIT(7) +#define IFI_CANFD_TXSTCMD_EMPTY BIT(8) +#define IFI_CANFD_TXSTCMD_FULL BIT(12) +#define IFI_CANFD_TXSTCMD_OVERFLOW BIT(13) + +#define IFI_CANFD_INTERRUPT 0xc +#define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1) +#define IFI_CANFD_INTERRUPT_TXFIFO_EMPTY BIT(16) +#define IFI_CANFD_INTERRUPT_TXFIFO_REMOVE BIT(22) +#define IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY BIT(24) +#define IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER BIT(25) +#define IFI_CANFD_INTERRUPT_SET_IRQ ((u32)BIT(31)) + +#define IFI_CANFD_IRQMASK 0x10 +#define IFI_CANFD_IRQMASK_SET_ERR BIT(7) +#define IFI_CANFD_IRQMASK_SET_TS BIT(15) +#define IFI_CANFD_IRQMASK_TXFIFO_EMPTY BIT(16) +#define IFI_CANFD_IRQMASK_SET_TX BIT(23) +#define IFI_CANFD_IRQMASK_RXFIFO_NEMPTY BIT(24) +#define IFI_CANFD_IRQMASK_SET_RX ((u32)BIT(31)) + +#define IFI_CANFD_TIME 0x14 +#define IFI_CANFD_FTIME 0x18 +#define IFI_CANFD_TIME_TIMEB_OFF 0 +#define IFI_CANFD_TIME_TIMEA_OFF 8 +#define IFI_CANFD_TIME_PRESCALE_OFF 16 +#define IFI_CANFD_TIME_SJW_OFF_ISO 25 +#define IFI_CANFD_TIME_SJW_OFF_BOSCH 28 +#define IFI_CANFD_TIME_SET_SJW_BOSCH BIT(6) +#define IFI_CANFD_TIME_SET_TIMEB_BOSCH BIT(7) +#define IFI_CANFD_TIME_SET_PRESC_BOSCH BIT(14) +#define IFI_CANFD_TIME_SET_TIMEA_BOSCH BIT(15) + +#define IFI_CANFD_TDELAY 0x1c + +#define IFI_CANFD_ERROR 0x20 +#define IFI_CANFD_ERROR_TX_OFFSET 0 +#define IFI_CANFD_ERROR_TX_MASK 0xff +#define IFI_CANFD_ERROR_RX_OFFSET 16 +#define IFI_CANFD_ERROR_RX_MASK 0xff + +#define IFI_CANFD_ERRCNT 0x24 + +#define IFI_CANFD_SUSPEND 0x28 + +#define IFI_CANFD_REPEAT 0x2c + +#define IFI_CANFD_TRAFFIC 0x30 + +#define IFI_CANFD_TSCONTROL 0x34 + +#define IFI_CANFD_TSC 0x38 + +#define IFI_CANFD_TST 0x3c + +#define IFI_CANFD_RES1 0x40 + +#define IFI_CANFD_RES2 0x44 + +#define IFI_CANFD_PAR 0x48 + +#define IFI_CANFD_CANCLOCK 0x4c + +#define IFI_CANFD_SYSCLOCK 0x50 + +#define IFI_CANFD_VER 0x54 + +#define IFI_CANFD_IP_ID 0x58 +#define IFI_CANFD_IP_ID_VALUE 0xD073CAFD + +#define IFI_CANFD_TEST 0x5c + +#define IFI_CANFD_RXFIFO_TS_63_32 0x60 + +#define IFI_CANFD_RXFIFO_TS_31_0 0x64 + +#define IFI_CANFD_RXFIFO_DLC 0x68 +#define IFI_CANFD_RXFIFO_DLC_DLC_OFFSET 0 +#define IFI_CANFD_RXFIFO_DLC_DLC_MASK 0xf +#define IFI_CANFD_RXFIFO_DLC_RTR BIT(4) +#define IFI_CANFD_RXFIFO_DLC_EDL BIT(5) +#define IFI_CANFD_RXFIFO_DLC_BRS BIT(6) +#define IFI_CANFD_RXFIFO_DLC_ESI BIT(7) +#define IFI_CANFD_RXFIFO_DLC_OBJ_OFFSET 8 +#define IFI_CANFD_RXFIFO_DLC_OBJ_MASK 0x1ff +#define IFI_CANFD_RXFIFO_DLC_FNR_OFFSET 24 +#define IFI_CANFD_RXFIFO_DLC_FNR_MASK 0xff + +#define IFI_CANFD_RXFIFO_ID 0x6c +#define IFI_CANFD_RXFIFO_ID_ID_OFFSET 0 +#define IFI_CANFD_RXFIFO_ID_ID_STD_MASK 0x3ff +#define IFI_CANFD_RXFIFO_ID_ID_XTD_MASK 0x1fffffff +#define IFI_CANFD_RXFIFO_ID_IDE BIT(29) + +#define IFI_CANFD_RXFIFO_DATA 0x70/* 0x70..0xac */ + +#define IFI_CANFD_TXFIFO_SUSPEND_US 0xb0 + +#define IFI_CANFD_TXFIFO_REPEATCOUNT 0xb4 + +#define IFI_CANFD_TXFIFO_DLC 0xb8 +#define IFI_CANFD_TXFIFO_DLC_DLC_OFFSET 0 +#define IFI_CANFD_TXFIFO_DLC_DLC_MASK 0xf +#define IFI_CANFD_TXFIFO_DLC_RTR BIT(4) +#define IFI_CANFD_TXFIFO_DLC_EDL BIT(5) +#define IFI_CANFD_TXFIFO_DLC_BRS BIT(6) +#define IFI_CANFD_TXFIFO_DLC_FNR_OFFSET 24 +#define IFI_CANFD_TXFIFO_DLC_FNR_MASK 0xff + +#define IFI_CANFD_TXFIFO_ID 0xbc +#define IFI_CANFD_TXFIFO_ID_ID_OFFSET 0 +#define IFI_CANFD_TXFIFO_ID_ID_STD_MASK 0x3ff +#define IFI_CANFD_TXFIFO_ID_ID_XTD_MASK 0x1fffffff +#define IFI_CANFD_TXFIFO_ID_IDE BIT(29) + +#define IFI_CANFD_TXFIFO_DATA 0xc0/* 0xb0..0xfc */ + +#define IFI_CANFD_FILTER_MASK (n) (0x800 + ((n) * 8) + 0) +#define IFI_CANFD_FILTER_MASK_EXT BIT(29) +#define IFI_CANFD_FILTER_MASK_EDL BIT(30) +#define IFI_CANFD_FILTER_MASK_VALID ((u32)BIT(31)) + +#define IFI_CANFD_FILTER_IDENT (n) (0x800 + ((n) * 8) + 4) +#define IFI_CANFD_FILTER_IDENT_IDE BIT(29) +#define IFI_CANFD_FILTER_IDENT_CANFD BIT(30) +#define IFI_CANFD_FILTER_IDENT_VALID ((u32)BIT(31)) + +/* IFI CANFD private data structure */ +struct ifi_canfd_priv { +struct can_priv can;/* must be the first member */ +struct napi_struct napi; +struct net_device *ndev; +void __iomem *base; +}; + +static void ifi_canfd_irq_enable (struct net_device *ndev,bool enable) +{ +struct ifi_canfd_priv *priv =netdev_priv (ndev); +u32 enirq =0 ; + +if (enable) { + enirq =IFI_CANFD_IRQMASK_TXFIFO_EMPTY | +IFI_CANFD_IRQMASK_RXFIFO_NEMPTY ; + } + +writel (IFI_CANFD_IRQMASK_SET_ERR | +IFI_CANFD_IRQMASK_SET_TS | +IFI_CANFD_IRQMASK_SET_TX | +IFI_CANFD_IRQMASK_SET_RX | enirq, + priv->base +IFI_CANFD_IRQMASK ); +} + +static void ifi_canfd_read_fifo (struct net_device *ndev) +{ +struct net_device_stats *stats = &ndev->stats; +struct ifi_canfd_priv *priv =netdev_priv (ndev); +struct canfd_frame *cf; +struct sk_buff *skb; +const u32 rx_irq_mask =IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY | +IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER ; +u32 rxdlc, rxid; +u32 dlc, id; +int i; + + rxdlc =readl (priv->base +IFI_CANFD_RXFIFO_DLC ); +if (rxdlc &IFI_CANFD_RXFIFO_DLC_EDL ) + skb =alloc_canfd_skb (ndev, &cf); +else + skb =alloc_can_skb (ndev, (struct can_frame **)&cf); + +if (!skb) { + stats->rx_dropped++; +return ; + } + + dlc = (rxdlc >>IFI_CANFD_RXFIFO_DLC_DLC_OFFSET ) & +IFI_CANFD_RXFIFO_DLC_DLC_MASK ; +if (rxdlc &IFI_CANFD_RXFIFO_DLC_EDL ) + cf->len =can_dlc2len (dlc); +else + cf->len =get_can_dlc (dlc); + + rxid =readl (priv->base +IFI_CANFD_RXFIFO_ID ); + id = (rxid >>IFI_CANFD_RXFIFO_ID_ID_OFFSET ); +if (id &IFI_CANFD_RXFIFO_ID_IDE ) + id &=IFI_CANFD_RXFIFO_ID_ID_XTD_MASK ; +else + id &=IFI_CANFD_RXFIFO_ID_ID_STD_MASK ; + cf->can_id = id; + +if (rxdlc &IFI_CANFD_RXFIFO_DLC_ESI ) { + cf->flags |=CANFD_ESI ; +netdev_dbg (ndev,"ESI Error\n" ); + } + +if (!(rxdlc &IFI_CANFD_RXFIFO_DLC_EDL ) && + (rxdlc &IFI_CANFD_RXFIFO_DLC_RTR )) { + cf->can_id |=CAN_RTR_FLAG ; + }else { +if (rxdlc &IFI_CANFD_RXFIFO_DLC_BRS ) + cf->flags |=CANFD_BRS ; + +for (i =0 ; i < cf->len; i +=4 ) { + *(u32 *)(cf->data + i) = +readl (priv->base +IFI_CANFD_RXFIFO_DATA + i); + } + } + +/* Remove the packet from FIFO */ +writel (IFI_CANFD_RXSTCMD_REMOVE_MSG , priv->base +IFI_CANFD_RXSTCMD ); +writel (rx_irq_mask, priv->base +IFI_CANFD_INTERRUPT ); + + stats->rx_packets++; + stats->rx_bytes += cf->len; + +netif_receive_skb (skb); +} + +static int ifi_canfd_do_rx_poll (struct net_device *ndev,int quota) +{ +struct ifi_canfd_priv *priv =netdev_priv (ndev); +u32 pkts =0 ; +u32 rxst; + + rxst =readl (priv->base +IFI_CANFD_RXSTCMD ); +if (rxst &IFI_CANFD_RXSTCMD_EMPTY ) { +netdev_dbg (ndev,"No messages in RX FIFO\n" ); +return 0 ; + } + +for (;;) { +if (rxst &IFI_CANFD_RXSTCMD_EMPTY ) +break ; +if (quota <=0 ) +break ; + +ifi_canfd_read_fifo (ndev); + quota--; + pkts++; + rxst =readl (priv->base +IFI_CANFD_RXSTCMD ); + } + +if (pkts) +can_led_event (ndev,CAN_LED_EVENT_RX ); + +return pkts; +} + +static int ifi_canfd_handle_lost_msg (struct net_device *ndev) +{ +struct net_device_stats *stats = &ndev->stats; +struct sk_buff *skb; +struct can_frame *frame; + +netdev_err (ndev,"RX FIFO overflow, message(s) lost.\n" ); + + stats->rx_errors++; + stats->rx_over_errors++; + + skb =alloc_can_err_skb (ndev, &frame); +if (unlikely (!skb)) +return 0 ; + + frame->can_id |=CAN_ERR_CRTL ; + frame->data[1 ] =CAN_ERR_CRTL_RX_OVERFLOW ; + +netif_receive_skb (skb); + +return 1 ; +} + +static int ifi_canfd_get_berr_counter (const struct net_device *ndev, +struct can_berr_counter *bec) +{ +struct ifi_canfd_priv *priv =netdev_priv (ndev); +u32 err; + + err =readl (priv->base +IFI_CANFD_ERROR ); + bec->rxerr = (err >>IFI_CANFD_ERROR_RX_OFFSET ) & +IFI_CANFD_ERROR_RX_MASK ; + bec->txerr = (err >>IFI_CANFD_ERROR_TX_OFFSET ) & +IFI_CANFD_ERROR_TX_MASK ; + +return 0 ; +} + +static int ifi_canfd_handle_state_change (struct net_device *ndev, +enum can_state new_state) +{ +struct ifi_canfd_priv *priv =netdev_priv (ndev); +struct net_device_stats *stats = &ndev->stats; +struct can_frame *cf; +struct sk_buff *skb; +struct can_berr_counter bec; + +switch (new_state) { +case CAN_STATE_ERROR_ACTIVE : +/* error warning state */ + priv->can.can_stats.error_warning++; + priv->can.state =CAN_STATE_ERROR_WARNING ; +break ; +case CAN_STATE_ERROR_PASSIVE : +/* error passive state */ + priv->can.can_stats.error_passive++; + priv->can.state =CAN_STATE_ERROR_PASSIVE ; +break ; +case CAN_STATE_BUS_OFF : +/* bus-off state */ + priv->can.state =CAN_STATE_BUS_OFF ; +ifi_canfd_irq_enable (ndev,0 ); + priv->can.can_stats.bus_off++; +can_bus_off (ndev); +break ; +default : +break ; + } + +/* propagate the error condition to the CAN stack */ + skb =alloc_can_err_skb (ndev, &cf); +if (unlikely (!skb)) +return 0 ; + +ifi_canfd_get_berr_counter (ndev, &bec); + +switch (new_state) { +case CAN_STATE_ERROR_ACTIVE : +/* error warning state */ + cf->can_id |=CAN_ERR_CRTL ; + cf->data[1 ] = (bec.txerr > bec.rxerr) ? +CAN_ERR_CRTL_TX_WARNING : +CAN_ERR_CRTL_RX_WARNING ; + cf->data[6 ] = bec.txerr; + cf->data[7 ] = bec.rxerr; +break ; +case CAN_STATE_ERROR_PASSIVE : +/* error passive state */ + cf->can_id |=CAN_ERR_CRTL ; + cf->data[1 ] |=CAN_ERR_CRTL_RX_PASSIVE ; +if (bec.txerr >127 ) + cf->data[1 ] |=CAN_ERR_CRTL_TX_PASSIVE ; + cf->data[6 ] = bec.txerr; + cf->data[7 ] = bec.rxerr; +break ; +case CAN_STATE_BUS_OFF : +/* bus-off state */ + cf->can_id |=CAN_ERR_BUSOFF ; +break ; +default : +break ; + } + + stats->rx_packets++; + stats->rx_bytes += cf->can_dlc; +netif_receive_skb (skb); + +return 1 ; +} + +static int ifi_canfd_handle_state_errors (struct net_device *ndev,u32 stcmd) +{ +struct ifi_canfd_priv *priv =netdev_priv (ndev); +int work_done =0 ; +u32 isr; + +/* +* The ErrWarn condition is a little special, since the bit is +* located in the INTERRUPT register instead of STCMD register. +*/ + isr =readl (priv->base +IFI_CANFD_INTERRUPT ); +if ((isr &IFI_CANFD_INTERRUPT_ERROR_WARNING ) && + (priv->can.state !=CAN_STATE_ERROR_WARNING )) { +/* Clear the interrupt */ +writel (IFI_CANFD_INTERRUPT_ERROR_WARNING , + priv->base +IFI_CANFD_INTERRUPT ); +netdev_dbg (ndev,"Error, entered warning state\n" ); + work_done +=ifi_canfd_handle_state_change (ndev, +CAN_STATE_ERROR_WARNING ); + } + +if ((stcmd &IFI_CANFD_STCMD_ERROR_PASSIVE ) && + (priv->can.state !=CAN_STATE_ERROR_PASSIVE )) { +netdev_dbg (ndev,"Error, entered passive state\n" ); + work_done +=ifi_canfd_handle_state_change (ndev, +CAN_STATE_ERROR_PASSIVE ); + } + +if ((stcmd &IFI_CANFD_STCMD_BUSOFF ) && + (priv->can.state !=CAN_STATE_BUS_OFF )) { +netdev_dbg (ndev,"Error, entered bus-off state\n" ); + work_done +=ifi_canfd_handle_state_change (ndev, +CAN_STATE_BUS_OFF ); + } + +return work_done; +} + +static int ifi_canfd_poll (struct napi_struct *napi,int quota) +{ +struct net_device *ndev = napi->dev; +struct ifi_canfd_priv *priv =netdev_priv (ndev); +const u32 stcmd_state_mask =IFI_CANFD_STCMD_ERROR_PASSIVE | +IFI_CANFD_STCMD_BUSOFF ; +int work_done =0 ; + +u32 stcmd =readl (priv->base +IFI_CANFD_STCMD ); +u32 rxstcmd =readl (priv->base +IFI_CANFD_STCMD ); + +/* Handle bus state changes */ +if ((stcmd & stcmd_state_mask) || + ((stcmd &IFI_CANFD_STCMD_ERROR_ACTIVE ) ==0 )) + work_done +=ifi_canfd_handle_state_errors (ndev, stcmd); + +/* Handle lost messages on RX */ +if (rxstcmd &IFI_CANFD_RXSTCMD_OVERFLOW ) + work_done +=ifi_canfd_handle_lost_msg (ndev); + +/* Handle normal messages on RX */ +if (!(rxstcmd &IFI_CANFD_RXSTCMD_EMPTY )) + work_done +=ifi_canfd_do_rx_poll (ndev, quota - work_done); + +if (work_done < quota) { +napi_complete (napi); +ifi_canfd_irq_enable (ndev,1 ); + } + +return work_done; +} + +static irqreturn_t ifi_canfd_isr (int irq,void *dev_id)
drivers/net/can/ifi_canfd/ifi_canfd.c line 486
Quoted 10 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +10
-0+{ +struct net_device *ndev = (struct net_device *)dev_id; +struct ifi_canfd_priv *priv =netdev_priv (ndev); +struct net_device_stats *stats = &ndev->stats; +const u32 rx_irq_mask =IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY | +IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER ; +const u32 tx_irq_mask =IFI_CANFD_INTERRUPT_TXFIFO_EMPTY | +IFI_CANFD_INTERRUPT_TXFIFO_REMOVE ; +const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | +IFI_CANFD_INTERRUPT_ERROR_WARNING ));
I've squashed:
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +2
-2- const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | - IFI_CANFD_INTERRUPT_ERROR_WARNING)); + const u32 clr_irq_mask = ~(IFI_CANFD_INTERRUPT_SET_IRQ | + IFI_CANFD_INTERRUPT_ERROR_WARNING);
and the driver compiles without warnings.
Applied to can-next.
thanks,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Re: [PATCH V3 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 25 lines · Marc Kleine-Budde
Quoted 24 lines · Marek Vasut
The patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
Signed-off-by Marek Vasut <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc Mark Rutland <[email protected]>Cc Oliver Hartkopp <[email protected]>Cc Wolfgang Grandegger <[email protected]>---
V2: - Move request_irq()/free_irq() into
ifi_canfd_open()/ifi_canfd_close()just like other drivers do it to prevent crash when reloading module.
- Fix Woverflow complains on
x86_64and itanium, exactly the same wayas in commit
dec23dca5a9ca4b9eb2fb66926f567889028b904.V3: - Hopefully fix all problems with BIT(31) by adding more u32 casts.
Quoted 8 lines
Quoted 8 lines
- Drop struct device from struct
ifi_canfd_priv.NOTE: The driver is surprisingly similar to
m_can, but the registerlayout of the IFI core is completely different, so it's clear that those are two different IP cores.
---
[...]
Hi,
Quoted 13 lines
drivers/net/can/ifi_canfd/ifi_canfd.c line 486
Quoted 11 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +11
-0+static irqreturn_t ifi_canfd_isr (int irq,void *dev_id) +{ +struct net_device *ndev = (struct net_device *)dev_id; +struct ifi_canfd_priv *priv =netdev_priv (ndev); +struct net_device_stats *stats = &ndev->stats; +const u32 rx_irq_mask =IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY | +IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER ; +const u32 tx_irq_mask =IFI_CANFD_INTERRUPT_TXFIFO_EMPTY | +IFI_CANFD_INTERRUPT_TXFIFO_REMOVE ; +const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | +IFI_CANFD_INTERRUPT_ERROR_WARNING ));I've squashed:
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +0
-2- const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | -
IFI_CANFD_INTERRUPT_ERROR_WARNING)); + const u32clr_irq_mask=
~(IFI_CANFD_INTERRUPT_SET_IRQ | +IFI_CANFD_INTERRUPT_ERROR_WARNING);and the driver compiles without warnings.
It doesn't , try with x86_64_defconfig, it will complain with -Woverflow on gcc 4.9 or newer. That's what the kernel robot complained about in V1 of the patch too.
I'd be happy to be proven wrong though.
Marc Kleine-Budde
maintainerRe: [PATCH V3 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 58 lines · Marek Vasut
Quoted 25 lines · Marc Kleine-Budde
Quoted 24 lines · Marek Vasut
The patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
Signed-off-by Marek Vasut <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc Mark Rutland <[email protected]>Cc Oliver Hartkopp <[email protected]>Cc Wolfgang Grandegger <[email protected]>---
V2: - Move request_irq()/free_irq() into
ifi_canfd_open()/ifi_canfd_close()just like other drivers do it to prevent crash when reloading module.
- Fix Woverflow complains on
x86_64and itanium, exactly the same wayas in commit
dec23dca5a9ca4b9eb2fb66926f567889028b904.V3: - Hopefully fix all problems with BIT(31) by adding more u32 casts.
Quoted 8 lines
Quoted 8 lines
- Drop struct device from struct
ifi_canfd_priv.NOTE: The driver is surprisingly similar to
m_can, but the registerlayout of the IFI core is completely different, so it's clear that those are two different IP cores.
---
[...]
Hi,
Quoted 19 lines
drivers/net/can/ifi_canfd/ifi_canfd.c line 486
Quoted 11 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +11
-0+static irqreturn_t ifi_canfd_isr (int irq,void *dev_id) +{ +struct net_device *ndev = (struct net_device *)dev_id; +struct ifi_canfd_priv *priv =netdev_priv (ndev); +struct net_device_stats *stats = &ndev->stats; +const u32 rx_irq_mask =IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY | +IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER ; +const u32 tx_irq_mask =IFI_CANFD_INTERRUPT_TXFIFO_EMPTY | +IFI_CANFD_INTERRUPT_TXFIFO_REMOVE ; +const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | +IFI_CANFD_INTERRUPT_ERROR_WARNING ));I've squashed:
Quoted 5 lines
Quoted 5 lines
(quoted diff) +0
-2- const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | -
IFI_CANFD_INTERRUPT_ERROR_WARNING)); + const u32clr_irq_mask=
~(IFI_CANFD_INTERRUPT_SET_IRQ | +IFI_CANFD_INTERRUPT_ERROR_WARNING);
Quoted 5 lines
Quoted 1 line
and the driver compiles without warnings.
It doesn't , try with
x86_64_defconfig, it will complain with -Woverflow on gcc 4.9 or newer. That's what the kernel robot complained about in V1 of the patch too.
Doh! Right, let's try this:
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-1-#define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1) +#define IFI_CANFD_INTERRUPT_ERROR_WARNING ((u32)BIT(1))I'd be happy to be proven wrong though.
/me too
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Re: [PATCH V3 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 66 lines · Marc Kleine-Budde
Quoted 59 lines · Marek Vasut
Quoted 26 lines · Marc Kleine-Budde
Quoted 25 lines · Marek Vasut
The patch adds support for IFI CAN/FD controller [1]. This driver currently supports sending and receiving both standard CAN and new CAN/FD frames. Both ISO and BOSCH variant of CAN/FD is supported.
[1] http://www.ifi-pld.de/IP/CANFD/canfd.html
Signed-off-by Marek Vasut <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc Mark Rutland <[email protected]>Cc Oliver Hartkopp <[email protected]>Cc Wolfgang Grandegger <[email protected]>---
V2: - Move request_irq()/free_irq() into
ifi_canfd_open()/ifi_canfd_close()just like other drivers do it to prevent crash when reloading module.
- Fix Woverflow complains on
x86_64and itanium, exactly the same wayas in commit
dec23dca5a9ca4b9eb2fb66926f567889028b904.V3: - Hopefully fix all problems with BIT(31) by adding more u32 casts.
Quoted 8 lines
Quoted 8 lines
- Drop struct device from struct
ifi_canfd_priv.NOTE: The driver is surprisingly similar to
m_can, but the registerlayout of the IFI core is completely different, so it's clear that those are two different IP cores.
---
[...]
Hi,
Quoted 19 lines
drivers/net/can/ifi_canfd/ifi_canfd.c line 486
Quoted 11 lines
drivers/net/can/ifi_canfd/ifi_canfd.c new file +11
-0+static irqreturn_t ifi_canfd_isr (int irq,void *dev_id) +{ +struct net_device *ndev = (struct net_device *)dev_id; +struct ifi_canfd_priv *priv =netdev_priv (ndev); +struct net_device_stats *stats = &ndev->stats; +const u32 rx_irq_mask =IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY | +IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER ; +const u32 tx_irq_mask =IFI_CANFD_INTERRUPT_TXFIFO_EMPTY | +IFI_CANFD_INTERRUPT_TXFIFO_REMOVE ; +const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | +IFI_CANFD_INTERRUPT_ERROR_WARNING ));I've squashed:
Quoted 5 lines
Quoted 5 lines
(quoted diff) +0
-2- const u32 clr_irq_mask = (u32)(~(IFI_CANFD_INTERRUPT_SET_IRQ | -
IFI_CANFD_INTERRUPT_ERROR_WARNING)); + const u32clr_irq_mask=
~(IFI_CANFD_INTERRUPT_SET_IRQ | +IFI_CANFD_INTERRUPT_ERROR_WARNING);Quoted 5 lines
Quoted 1 line
and the driver compiles without warnings.
It doesn't , try with
x86_64_defconfig, it will complain with -Woverflow on gcc 4.9 or newer. That's what the kernel robot complained about in V1 of the patch too.
Quoted 7 lines
Doh! Right, let's try this:
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-1-#define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1) +#define IFI_CANFD_INTERRUPT_ERROR_WARNING ((u32)BIT(1))I'd be happy to be proven wrong though.
/me too
I think that will do the trick too. Do you want a V4 patch or will you fix it?
Marc Kleine-Budde
maintainerRe: [PATCH V3 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 10 lines · Marek Vasut
Quoted 8 lines
Doh! Right, let's try this:
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-1-#define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1) +#define IFI_CANFD_INTERRUPT_ERROR_WARNING ((u32)BIT(1))I'd be happy to be proven wrong though.
/me too
I think that will do the trick too. Do you want a V4 patch or will you fix it?
I'll fix this.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Re: [PATCH V3 5/5] net: can: ifi: Add IFI CANFD IP support
Quoted 7 lines · Marc Kleine-Budde
Quoted 6 lines · Marek Vasut
Quoted 6 lines
Doh! Right, let's try this:
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-1-#define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1) +#define IFI_CANFD_INTERRUPT_ERROR_WARNING ((u32)BIT(1))I'd be happy to be proven wrong though.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
/me too
I think that will do the trick too. Do you want a V4 patch or will you fix it?
I'll fix this.
Thanks :)
Best regards,
Marek Vasut
Re: [PATCH V2 5/5] net: can: ifi: Add IFI CANFD IP support
In reply to Marek VasutQuoted 2 lines · Marek Vasut
I see, so adding u32 also here works. I'm starting to wonder if the BIT macro is really that nice and if I shouldn't just use (1 << n) as usual.
Actually, (1 << n) is not so good either when n is 31 - it can trigger overflow warnings since it will be presumed to be a signed value. (1U << n) should avoid that problem. Unfortunately, BIT() uses 1UL which produces 64-bit values on 64-bit arches. The bit ops are kind of a mess in that way. It would be nicer if BIT was restricted to int-size values and a new BIT_UL or something would produce the long values.