Re: [PATCH v5 5/5] can: tcan4x5x: Add tcan4x5x driver to the kernel
Wolfgang On 2/28/19 2:07 PM, Wolfgang Grandegger wrote: > > Am 28.02.19 um 19:03 schrieb Dan Murphy: >> >> Wolfgang >> >> On 2/28/19 11:50 AM, Wolfgang Grandegger wrote: >>> >>> >>> Am 14.02.19 um 19:27 schrieb Dan Murphy: Add the TCAN4x5x SPI CAN driver. This device uses the Bosch MCAN IP core along with a SPI interface map. Leverage the MCAN common core code to manage the MCAN IP. This device has a special method to indicate a write/read operation on the data payload. >>> >>> Please expand the text to approx. 72 lines.>> >> >> 72 lines or characters? > > Characters, of course! > OK. Just clarifying. I did not think you were asking me to write a book here Signed-off-by: Dan Murphy --- v5 - Changes to accomodate previous patches for functionality - https://lore.kernel.org/patchwork/patch/1033096/ drivers/net/can/m_can/Kconfig| 6 + drivers/net/can/m_can/Makefile | 1 + drivers/net/can/m_can/tcan4x5x.c | 531 +++ 3 files changed, 538 insertions(+) create mode 100644 drivers/net/can/m_can/tcan4x5x.c diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig index 66e31022a5fa..6c0ab4703fb7 100644 --- a/drivers/net/can/m_can/Kconfig +++ b/drivers/net/can/m_can/Kconfig @@ -9,3 +9,9 @@ config CAN_M_CAN_PLATFORM depends on CAN_M_CAN ---help--- Say Y here if you want to support for Bosch M_CAN controller. + +config CAN_M_CAN_TCAN4X5X + depends on CAN_M_CAN + tristate "TCAN4X5X M_CAN device" + ---help--- +Say Y here if you want to support for TI M_CAN controller. >>> >>> Could yo please be a bit more verbose here. >> >> ACK >> >>> diff --git a/drivers/net/can/m_can/Makefile b/drivers/net/can/m_can/Makefile index 057bbcdb3c74..e77f0eccff97 100644 --- a/drivers/net/can/m_can/Makefile +++ b/drivers/net/can/m_can/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_CAN_M_CAN) += m_can.o obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o +obj-$(CONFIG_CAN_M_CAN_TCAN4X5X) += tcan4x5x.o diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c new file mode 100644 index ..606cd1925009 --- /dev/null +++ b/drivers/net/can/m_can/tcan4x5x.c @@ -0,0 +1,531 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPI to CAN driver for the Texas Instruments TCAN4x5x +// Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include + +#include +#include + +#include "m_can.h" + +#define DEVICE_NAME "tcan4x5x" +#define TCAN4X5X_EXT_CLK_DEF 4000 + +#define TCAN4X5X_DEV_ID0 0x00 +#define TCAN4X5X_DEV_ID1 0x04 +#define TCAN4X5X_REV 0x08 +#define TCAN4X5X_STATUS 0x0C +#define TCAN4X5X_ERROR_STATUS 0x10 +#define TCAN4X5X_CONTROL 0x14 + +#define TCAN4X5X_CONFIG 0x800 +#define TCAN4X5X_TS_PRESCALE 0x804 +#define TCAN4X5X_TEST_REG 0x808 +#define TCAN4X5X_INT_FLAGS0x820 +#define TCAN4X5X_MCAN_INT_REG 0x824 +#define TCAN4X5X_INT_EN 0x830 + + +/* Interrupt bits */ +#define TCAN4X5X_CANBUSTERMOPEN_INT_ENBIT(30) +#define TCAN4X5X_CANHCANL_INT_EN BIT(29) +#define TCAN4X5X_CANHBAT_INT_EN BIT(28) +#define TCAN4X5X_CANLGND_INT_EN BIT(27) +#define TCAN4X5X_CANBUSOPEN_INT_ENBIT(26) +#define TCAN4X5X_CANBUSGND_INT_EN BIT(25) +#define TCAN4X5X_CANBUSBAT_INT_EN BIT(24) +#define TCAN4X5X_UVSUP_INT_EN BIT(22) +#define TCAN4X5X_UVIO_INT_EN BIT(21) +#define TCAN4X5X_TSD_INT_EN BIT(19) +#define TCAN4X5X_ECCERR_INT_ENBIT(16) +#define TCAN4X5X_CANINT_INT_ENBIT(15) +#define TCAN4X5X_LWU_INT_EN BIT(14) +#define TCAN4X5X_CANSLNT_INT_EN BIT(10) +#define TCAN4X5X_CANDOM_INT_ENBIT(8) +#define TCAN4X5X_CANBUS_ERR_INT_ENBIT(5) +#define TCAN4X5X_BUS_FAULTBIT(4) +#define TCAN4X5X_MCAN_INT BIT(1) +#define TCAN4X5X_ENABLE_TCAN_INT (TCAN4X5X_MCAN_INT | \ + TCAN4X5X_BUS_FAULT | \ + TCAN4X5X_CANBUS_ERR_INT_EN | \ + TCAN4X5X_CANINT_INT_EN) + +/* MCAN Interrupt bits */ +#define TCAN4X5X_MCAN_IR_ARA BIT(29) +#define TCAN4X5X_MCAN_IR_PED BIT(28) +#define TCAN4X5X_MCAN_IR_PEA BIT(27) +#define TCAN4X5X_MCAN_IR_WD BIT(26) +#define TCAN4X5X_MCAN_IR_BO BIT(25) +#define TCAN4X5X_MCAN_IR_EW
Re: [PATCH v5 5/5] can: tcan4x5x: Add tcan4x5x driver to the kernel
Am 28.02.19 um 19:03 schrieb Dan Murphy: > > Wolfgang > > On 2/28/19 11:50 AM, Wolfgang Grandegger wrote: >> >> >> Am 14.02.19 um 19:27 schrieb Dan Murphy: >>> Add the TCAN4x5x SPI CAN driver. This device >>> uses the Bosch MCAN IP core along with a SPI >>> interface map. Leverage the MCAN common core >>> code to manage the MCAN IP. >>> >>> This device has a special method to indicate a >>> write/read operation on the data payload. >> >> Please expand the text to approx. 72 lines.>> > > 72 lines or characters? Characters, of course! >>> Signed-off-by: Dan Murphy >>> --- >>> >>> v5 - Changes to accomodate previous patches for functionality - >>> https://lore.kernel.org/patchwork/patch/1033096/ >>> >>> drivers/net/can/m_can/Kconfig| 6 + >>> drivers/net/can/m_can/Makefile | 1 + >>> drivers/net/can/m_can/tcan4x5x.c | 531 +++ >>> 3 files changed, 538 insertions(+) >>> create mode 100644 drivers/net/can/m_can/tcan4x5x.c >>> >>> diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig >>> index 66e31022a5fa..6c0ab4703fb7 100644 >>> --- a/drivers/net/can/m_can/Kconfig >>> +++ b/drivers/net/can/m_can/Kconfig >>> @@ -9,3 +9,9 @@ config CAN_M_CAN_PLATFORM >>> depends on CAN_M_CAN >>> ---help--- >>> Say Y here if you want to support for Bosch M_CAN controller. >>> + >>> +config CAN_M_CAN_TCAN4X5X >>> + depends on CAN_M_CAN >>> + tristate "TCAN4X5X M_CAN device" >>> + ---help--- >>> + Say Y here if you want to support for TI M_CAN controller. >> >> Could yo please be a bit more verbose here. > > ACK > >> >>> diff --git a/drivers/net/can/m_can/Makefile b/drivers/net/can/m_can/Makefile >>> index 057bbcdb3c74..e77f0eccff97 100644 >>> --- a/drivers/net/can/m_can/Makefile >>> +++ b/drivers/net/can/m_can/Makefile >>> @@ -4,3 +4,4 @@ >>> >>> obj-$(CONFIG_CAN_M_CAN) += m_can.o >>> obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o >>> +obj-$(CONFIG_CAN_M_CAN_TCAN4X5X) += tcan4x5x.o >>> diff --git a/drivers/net/can/m_can/tcan4x5x.c >>> b/drivers/net/can/m_can/tcan4x5x.c >>> new file mode 100644 >>> index ..606cd1925009 >>> --- /dev/null >>> +++ b/drivers/net/can/m_can/tcan4x5x.c >>> @@ -0,0 +1,531 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +// SPI to CAN driver for the Texas Instruments TCAN4x5x >>> +// Copyright (C) 2018-19 Texas Instruments Incorporated - >>> http://www.ti.com/ >>> + >>> +#include >>> +#include >>> + >>> +#include >>> +#include >>> + >>> +#include "m_can.h" >>> + >>> +#define DEVICE_NAME "tcan4x5x" >>> +#define TCAN4X5X_EXT_CLK_DEF 4000 >>> + >>> +#define TCAN4X5X_DEV_ID0 0x00 >>> +#define TCAN4X5X_DEV_ID1 0x04 >>> +#define TCAN4X5X_REV 0x08 >>> +#define TCAN4X5X_STATUS0x0C >>> +#define TCAN4X5X_ERROR_STATUS 0x10 >>> +#define TCAN4X5X_CONTROL 0x14 >>> + >>> +#define TCAN4X5X_CONFIG0x800 >>> +#define TCAN4X5X_TS_PRESCALE 0x804 >>> +#define TCAN4X5X_TEST_REG 0x808 >>> +#define TCAN4X5X_INT_FLAGS 0x820 >>> +#define TCAN4X5X_MCAN_INT_REG 0x824 >>> +#define TCAN4X5X_INT_EN0x830 >>> + >>> + >>> +/* Interrupt bits */ >>> +#define TCAN4X5X_CANBUSTERMOPEN_INT_EN BIT(30) >>> +#define TCAN4X5X_CANHCANL_INT_EN BIT(29) >>> +#define TCAN4X5X_CANHBAT_INT_ENBIT(28) >>> +#define TCAN4X5X_CANLGND_INT_ENBIT(27) >>> +#define TCAN4X5X_CANBUSOPEN_INT_EN BIT(26) >>> +#define TCAN4X5X_CANBUSGND_INT_EN BIT(25) >>> +#define TCAN4X5X_CANBUSBAT_INT_EN BIT(24) >>> +#define TCAN4X5X_UVSUP_INT_EN BIT(22) >>> +#define TCAN4X5X_UVIO_INT_EN BIT(21) >>> +#define TCAN4X5X_TSD_INT_ENBIT(19) >>> +#define TCAN4X5X_ECCERR_INT_EN BIT(16) >>> +#define TCAN4X5X_CANINT_INT_EN BIT(15) >>> +#define TCAN4X5X_LWU_INT_ENBIT(14) >>> +#define TCAN4X5X_CANSLNT_INT_ENBIT(10) >>> +#define TCAN4X5X_CANDOM_INT_EN BIT(8) >>> +#define TCAN4X5X_CANBUS_ERR_INT_EN BIT(5) >>> +#define TCAN4X5X_BUS_FAULT BIT(4) >>> +#define TCAN4X5X_MCAN_INT BIT(1) >>> +#define TCAN4X5X_ENABLE_TCAN_INT (TCAN4X5X_MCAN_INT | \ >>> + TCAN4X5X_BUS_FAULT | \ >>> + TCAN4X5X_CANBUS_ERR_INT_EN | \ >>> + TCAN4X5X_CANINT_INT_EN) >>> + >>> +/* MCAN Interrupt bits */ >>> +#define TCAN4X5X_MCAN_IR_ARA BIT(29) >>> +#define TCAN4X5X_MCAN_IR_PED BIT(28) >>> +#define TCAN4X5X_MCAN_IR_PEA BIT(27) >>> +#define TCAN4X5X_MCAN_IR_WDBIT(26) >>> +#define TCAN4X5X_MCAN_IR_BOBIT(25) >>> +#define TCAN4X5X_MCAN_IR_EWBIT(24) >>> +#define TCAN4X5X_MCAN_IR_EPBIT(23) >>> +#define TCAN4X5X_MCAN_IR_ELO BIT(22) >>> +#define TCAN4X5X_MCAN_IR_BEU BIT(21) >>> +#define TCAN4X5X_MCAN_IR_BEC BIT(20) >>> +#define
Re: [PATCH v5 5/5] can: tcan4x5x: Add tcan4x5x driver to the kernel
Wolfgang On 2/28/19 11:50 AM, Wolfgang Grandegger wrote: > > > Am 14.02.19 um 19:27 schrieb Dan Murphy: >> Add the TCAN4x5x SPI CAN driver. This device >> uses the Bosch MCAN IP core along with a SPI >> interface map. Leverage the MCAN common core >> code to manage the MCAN IP. >> >> This device has a special method to indicate a >> write/read operation on the data payload. > > Please expand the text to approx. 72 lines. > 72 lines or characters? >> Signed-off-by: Dan Murphy >> --- >> >> v5 - Changes to accomodate previous patches for functionality - >> https://lore.kernel.org/patchwork/patch/1033096/ >> >> drivers/net/can/m_can/Kconfig| 6 + >> drivers/net/can/m_can/Makefile | 1 + >> drivers/net/can/m_can/tcan4x5x.c | 531 +++ >> 3 files changed, 538 insertions(+) >> create mode 100644 drivers/net/can/m_can/tcan4x5x.c >> >> diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig >> index 66e31022a5fa..6c0ab4703fb7 100644 >> --- a/drivers/net/can/m_can/Kconfig >> +++ b/drivers/net/can/m_can/Kconfig >> @@ -9,3 +9,9 @@ config CAN_M_CAN_PLATFORM >> depends on CAN_M_CAN >> ---help--- >>Say Y here if you want to support for Bosch M_CAN controller. >> + >> +config CAN_M_CAN_TCAN4X5X >> +depends on CAN_M_CAN >> +tristate "TCAN4X5X M_CAN device" >> +---help--- >> + Say Y here if you want to support for TI M_CAN controller. > > Could yo please be a bit more verbose here. ACK > >> diff --git a/drivers/net/can/m_can/Makefile b/drivers/net/can/m_can/Makefile >> index 057bbcdb3c74..e77f0eccff97 100644 >> --- a/drivers/net/can/m_can/Makefile >> +++ b/drivers/net/can/m_can/Makefile >> @@ -4,3 +4,4 @@ >> >> obj-$(CONFIG_CAN_M_CAN) += m_can.o >> obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o >> +obj-$(CONFIG_CAN_M_CAN_TCAN4X5X) += tcan4x5x.o >> diff --git a/drivers/net/can/m_can/tcan4x5x.c >> b/drivers/net/can/m_can/tcan4x5x.c >> new file mode 100644 >> index ..606cd1925009 >> --- /dev/null >> +++ b/drivers/net/can/m_can/tcan4x5x.c >> @@ -0,0 +1,531 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +// SPI to CAN driver for the Texas Instruments TCAN4x5x >> +// Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ >> + >> +#include >> +#include >> + >> +#include >> +#include >> + >> +#include "m_can.h" >> + >> +#define DEVICE_NAME "tcan4x5x" >> +#define TCAN4X5X_EXT_CLK_DEF4000 >> + >> +#define TCAN4X5X_DEV_ID00x00 >> +#define TCAN4X5X_DEV_ID10x04 >> +#define TCAN4X5X_REV0x08 >> +#define TCAN4X5X_STATUS 0x0C >> +#define TCAN4X5X_ERROR_STATUS 0x10 >> +#define TCAN4X5X_CONTROL0x14 >> + >> +#define TCAN4X5X_CONFIG 0x800 >> +#define TCAN4X5X_TS_PRESCALE0x804 >> +#define TCAN4X5X_TEST_REG 0x808 >> +#define TCAN4X5X_INT_FLAGS 0x820 >> +#define TCAN4X5X_MCAN_INT_REG 0x824 >> +#define TCAN4X5X_INT_EN 0x830 >> + >> + >> +/* Interrupt bits */ >> +#define TCAN4X5X_CANBUSTERMOPEN_INT_EN BIT(30) >> +#define TCAN4X5X_CANHCANL_INT_ENBIT(29) >> +#define TCAN4X5X_CANHBAT_INT_EN BIT(28) >> +#define TCAN4X5X_CANLGND_INT_EN BIT(27) >> +#define TCAN4X5X_CANBUSOPEN_INT_EN BIT(26) >> +#define TCAN4X5X_CANBUSGND_INT_EN BIT(25) >> +#define TCAN4X5X_CANBUSBAT_INT_EN BIT(24) >> +#define TCAN4X5X_UVSUP_INT_EN BIT(22) >> +#define TCAN4X5X_UVIO_INT_ENBIT(21) >> +#define TCAN4X5X_TSD_INT_EN BIT(19) >> +#define TCAN4X5X_ECCERR_INT_EN BIT(16) >> +#define TCAN4X5X_CANINT_INT_EN BIT(15) >> +#define TCAN4X5X_LWU_INT_EN BIT(14) >> +#define TCAN4X5X_CANSLNT_INT_EN BIT(10) >> +#define TCAN4X5X_CANDOM_INT_EN BIT(8) >> +#define TCAN4X5X_CANBUS_ERR_INT_EN BIT(5) >> +#define TCAN4X5X_BUS_FAULT BIT(4) >> +#define TCAN4X5X_MCAN_INT BIT(1) >> +#define TCAN4X5X_ENABLE_TCAN_INT(TCAN4X5X_MCAN_INT | \ >> +TCAN4X5X_BUS_FAULT | \ >> +TCAN4X5X_CANBUS_ERR_INT_EN | \ >> +TCAN4X5X_CANINT_INT_EN) >> + >> +/* MCAN Interrupt bits */ >> +#define TCAN4X5X_MCAN_IR_ARABIT(29) >> +#define TCAN4X5X_MCAN_IR_PEDBIT(28) >> +#define TCAN4X5X_MCAN_IR_PEABIT(27) >> +#define TCAN4X5X_MCAN_IR_WD BIT(26) >> +#define TCAN4X5X_MCAN_IR_BO BIT(25) >> +#define TCAN4X5X_MCAN_IR_EW BIT(24) >> +#define TCAN4X5X_MCAN_IR_EP BIT(23) >> +#define TCAN4X5X_MCAN_IR_ELOBIT(22) >> +#define TCAN4X5X_MCAN_IR_BEUBIT(21) >> +#define TCAN4X5X_MCAN_IR_BECBIT(20) >> +#define TCAN4X5X_MCAN_IR_DRXBIT(19) >> +#define TCAN4X5X_MCAN_IR_TOOBIT(18) >> +#define TCAN4X5X_MCAN_IR_MRAF BIT(17) >> +#define TCAN4X5X_MCAN_IR_TSW
Re: [PATCH v5 5/5] can: tcan4x5x: Add tcan4x5x driver to the kernel
Am 14.02.19 um 19:27 schrieb Dan Murphy: > Add the TCAN4x5x SPI CAN driver. This device > uses the Bosch MCAN IP core along with a SPI > interface map. Leverage the MCAN common core > code to manage the MCAN IP. > > This device has a special method to indicate a > write/read operation on the data payload. Please expand the text to approx. 72 lines. > Signed-off-by: Dan Murphy > --- > > v5 - Changes to accomodate previous patches for functionality - > https://lore.kernel.org/patchwork/patch/1033096/ > > drivers/net/can/m_can/Kconfig| 6 + > drivers/net/can/m_can/Makefile | 1 + > drivers/net/can/m_can/tcan4x5x.c | 531 +++ > 3 files changed, 538 insertions(+) > create mode 100644 drivers/net/can/m_can/tcan4x5x.c > > diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig > index 66e31022a5fa..6c0ab4703fb7 100644 > --- a/drivers/net/can/m_can/Kconfig > +++ b/drivers/net/can/m_can/Kconfig > @@ -9,3 +9,9 @@ config CAN_M_CAN_PLATFORM > depends on CAN_M_CAN > ---help--- > Say Y here if you want to support for Bosch M_CAN controller. > + > +config CAN_M_CAN_TCAN4X5X > + depends on CAN_M_CAN > + tristate "TCAN4X5X M_CAN device" > + ---help--- > + Say Y here if you want to support for TI M_CAN controller. Could yo please be a bit more verbose here. > diff --git a/drivers/net/can/m_can/Makefile b/drivers/net/can/m_can/Makefile > index 057bbcdb3c74..e77f0eccff97 100644 > --- a/drivers/net/can/m_can/Makefile > +++ b/drivers/net/can/m_can/Makefile > @@ -4,3 +4,4 @@ > > obj-$(CONFIG_CAN_M_CAN) += m_can.o > obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o > +obj-$(CONFIG_CAN_M_CAN_TCAN4X5X) += tcan4x5x.o > diff --git a/drivers/net/can/m_can/tcan4x5x.c > b/drivers/net/can/m_can/tcan4x5x.c > new file mode 100644 > index ..606cd1925009 > --- /dev/null > +++ b/drivers/net/can/m_can/tcan4x5x.c > @@ -0,0 +1,531 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// SPI to CAN driver for the Texas Instruments TCAN4x5x > +// Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ > + > +#include > +#include > + > +#include > +#include > + > +#include "m_can.h" > + > +#define DEVICE_NAME "tcan4x5x" > +#define TCAN4X5X_EXT_CLK_DEF 4000 > + > +#define TCAN4X5X_DEV_ID0 0x00 > +#define TCAN4X5X_DEV_ID1 0x04 > +#define TCAN4X5X_REV 0x08 > +#define TCAN4X5X_STATUS 0x0C > +#define TCAN4X5X_ERROR_STATUS0x10 > +#define TCAN4X5X_CONTROL 0x14 > + > +#define TCAN4X5X_CONFIG 0x800 > +#define TCAN4X5X_TS_PRESCALE 0x804 > +#define TCAN4X5X_TEST_REG0x808 > +#define TCAN4X5X_INT_FLAGS 0x820 > +#define TCAN4X5X_MCAN_INT_REG0x824 > +#define TCAN4X5X_INT_EN 0x830 > + > + > +/* Interrupt bits */ > +#define TCAN4X5X_CANBUSTERMOPEN_INT_EN BIT(30) > +#define TCAN4X5X_CANHCANL_INT_EN BIT(29) > +#define TCAN4X5X_CANHBAT_INT_EN BIT(28) > +#define TCAN4X5X_CANLGND_INT_EN BIT(27) > +#define TCAN4X5X_CANBUSOPEN_INT_EN BIT(26) > +#define TCAN4X5X_CANBUSGND_INT_ENBIT(25) > +#define TCAN4X5X_CANBUSBAT_INT_ENBIT(24) > +#define TCAN4X5X_UVSUP_INT_ENBIT(22) > +#define TCAN4X5X_UVIO_INT_EN BIT(21) > +#define TCAN4X5X_TSD_INT_EN BIT(19) > +#define TCAN4X5X_ECCERR_INT_EN BIT(16) > +#define TCAN4X5X_CANINT_INT_EN BIT(15) > +#define TCAN4X5X_LWU_INT_EN BIT(14) > +#define TCAN4X5X_CANSLNT_INT_EN BIT(10) > +#define TCAN4X5X_CANDOM_INT_EN BIT(8) > +#define TCAN4X5X_CANBUS_ERR_INT_EN BIT(5) > +#define TCAN4X5X_BUS_FAULT BIT(4) > +#define TCAN4X5X_MCAN_INTBIT(1) > +#define TCAN4X5X_ENABLE_TCAN_INT (TCAN4X5X_MCAN_INT | \ > + TCAN4X5X_BUS_FAULT | \ > + TCAN4X5X_CANBUS_ERR_INT_EN | \ > + TCAN4X5X_CANINT_INT_EN) > + > +/* MCAN Interrupt bits */ > +#define TCAN4X5X_MCAN_IR_ARA BIT(29) > +#define TCAN4X5X_MCAN_IR_PED BIT(28) > +#define TCAN4X5X_MCAN_IR_PEA BIT(27) > +#define TCAN4X5X_MCAN_IR_WD BIT(26) > +#define TCAN4X5X_MCAN_IR_BO BIT(25) > +#define TCAN4X5X_MCAN_IR_EW BIT(24) > +#define TCAN4X5X_MCAN_IR_EP BIT(23) > +#define TCAN4X5X_MCAN_IR_ELO BIT(22) > +#define TCAN4X5X_MCAN_IR_BEU BIT(21) > +#define TCAN4X5X_MCAN_IR_BEC BIT(20) > +#define TCAN4X5X_MCAN_IR_DRX BIT(19) > +#define TCAN4X5X_MCAN_IR_TOO BIT(18) > +#define TCAN4X5X_MCAN_IR_MRAFBIT(17) > +#define TCAN4X5X_MCAN_IR_TSW BIT(16) > +#define TCAN4X5X_MCAN_IR_TEFLBIT(15) > +#define TCAN4X5X_MCAN_IR_TEFFBIT(14) > +#define TCAN4X5X_MCAN_IR_TEFWBIT(13) > +#define TCAN4X5X_MCAN_IR_TEFNBIT(12) > +#define TCAN4X5X_MCAN_IR_TFE
[PATCH v5 5/5] can: tcan4x5x: Add tcan4x5x driver to the kernel
Add the TCAN4x5x SPI CAN driver. This device uses the Bosch MCAN IP core along with a SPI interface map. Leverage the MCAN common core code to manage the MCAN IP. This device has a special method to indicate a write/read operation on the data payload. Signed-off-by: Dan Murphy --- v5 - Changes to accomodate previous patches for functionality - https://lore.kernel.org/patchwork/patch/1033096/ drivers/net/can/m_can/Kconfig| 6 + drivers/net/can/m_can/Makefile | 1 + drivers/net/can/m_can/tcan4x5x.c | 531 +++ 3 files changed, 538 insertions(+) create mode 100644 drivers/net/can/m_can/tcan4x5x.c diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig index 66e31022a5fa..6c0ab4703fb7 100644 --- a/drivers/net/can/m_can/Kconfig +++ b/drivers/net/can/m_can/Kconfig @@ -9,3 +9,9 @@ config CAN_M_CAN_PLATFORM depends on CAN_M_CAN ---help--- Say Y here if you want to support for Bosch M_CAN controller. + +config CAN_M_CAN_TCAN4X5X + depends on CAN_M_CAN + tristate "TCAN4X5X M_CAN device" + ---help--- + Say Y here if you want to support for TI M_CAN controller. diff --git a/drivers/net/can/m_can/Makefile b/drivers/net/can/m_can/Makefile index 057bbcdb3c74..e77f0eccff97 100644 --- a/drivers/net/can/m_can/Makefile +++ b/drivers/net/can/m_can/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_CAN_M_CAN) += m_can.o obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o +obj-$(CONFIG_CAN_M_CAN_TCAN4X5X) += tcan4x5x.o diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c new file mode 100644 index ..606cd1925009 --- /dev/null +++ b/drivers/net/can/m_can/tcan4x5x.c @@ -0,0 +1,531 @@ +// SPDX-License-Identifier: GPL-2.0 +// SPI to CAN driver for the Texas Instruments TCAN4x5x +// Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ + +#include +#include + +#include +#include + +#include "m_can.h" + +#define DEVICE_NAME "tcan4x5x" +#define TCAN4X5X_EXT_CLK_DEF 4000 + +#define TCAN4X5X_DEV_ID0 0x00 +#define TCAN4X5X_DEV_ID1 0x04 +#define TCAN4X5X_REV 0x08 +#define TCAN4X5X_STATUS0x0C +#define TCAN4X5X_ERROR_STATUS 0x10 +#define TCAN4X5X_CONTROL 0x14 + +#define TCAN4X5X_CONFIG0x800 +#define TCAN4X5X_TS_PRESCALE 0x804 +#define TCAN4X5X_TEST_REG 0x808 +#define TCAN4X5X_INT_FLAGS 0x820 +#define TCAN4X5X_MCAN_INT_REG 0x824 +#define TCAN4X5X_INT_EN0x830 + + +/* Interrupt bits */ +#define TCAN4X5X_CANBUSTERMOPEN_INT_EN BIT(30) +#define TCAN4X5X_CANHCANL_INT_EN BIT(29) +#define TCAN4X5X_CANHBAT_INT_ENBIT(28) +#define TCAN4X5X_CANLGND_INT_ENBIT(27) +#define TCAN4X5X_CANBUSOPEN_INT_EN BIT(26) +#define TCAN4X5X_CANBUSGND_INT_EN BIT(25) +#define TCAN4X5X_CANBUSBAT_INT_EN BIT(24) +#define TCAN4X5X_UVSUP_INT_EN BIT(22) +#define TCAN4X5X_UVIO_INT_EN BIT(21) +#define TCAN4X5X_TSD_INT_ENBIT(19) +#define TCAN4X5X_ECCERR_INT_EN BIT(16) +#define TCAN4X5X_CANINT_INT_EN BIT(15) +#define TCAN4X5X_LWU_INT_ENBIT(14) +#define TCAN4X5X_CANSLNT_INT_ENBIT(10) +#define TCAN4X5X_CANDOM_INT_EN BIT(8) +#define TCAN4X5X_CANBUS_ERR_INT_EN BIT(5) +#define TCAN4X5X_BUS_FAULT BIT(4) +#define TCAN4X5X_MCAN_INT BIT(1) +#define TCAN4X5X_ENABLE_TCAN_INT (TCAN4X5X_MCAN_INT | \ + TCAN4X5X_BUS_FAULT | \ + TCAN4X5X_CANBUS_ERR_INT_EN | \ + TCAN4X5X_CANINT_INT_EN) + +/* MCAN Interrupt bits */ +#define TCAN4X5X_MCAN_IR_ARA BIT(29) +#define TCAN4X5X_MCAN_IR_PED BIT(28) +#define TCAN4X5X_MCAN_IR_PEA BIT(27) +#define TCAN4X5X_MCAN_IR_WDBIT(26) +#define TCAN4X5X_MCAN_IR_BOBIT(25) +#define TCAN4X5X_MCAN_IR_EWBIT(24) +#define TCAN4X5X_MCAN_IR_EPBIT(23) +#define TCAN4X5X_MCAN_IR_ELO BIT(22) +#define TCAN4X5X_MCAN_IR_BEU BIT(21) +#define TCAN4X5X_MCAN_IR_BEC BIT(20) +#define TCAN4X5X_MCAN_IR_DRX BIT(19) +#define TCAN4X5X_MCAN_IR_TOO BIT(18) +#define TCAN4X5X_MCAN_IR_MRAF BIT(17) +#define TCAN4X5X_MCAN_IR_TSW BIT(16) +#define TCAN4X5X_MCAN_IR_TEFL BIT(15) +#define TCAN4X5X_MCAN_IR_TEFF BIT(14) +#define TCAN4X5X_MCAN_IR_TEFW BIT(13) +#define TCAN4X5X_MCAN_IR_TEFN BIT(12) +#define TCAN4X5X_MCAN_IR_TFE BIT(11) +#define TCAN4X5X_MCAN_IR_TCF BIT(10) +#define TCAN4X5X_MCAN_IR_TCBIT(9) +#define TCAN4X5X_MCAN_IR_HPM BIT(8) +#define TCAN4X5X_MCAN_IR_RF1L BIT(7) +#define TCAN4X5X_MCAN_IR_RF1F BIT(6) +#define TCAN4X5X_MCAN_IR_RF1W BIT(5) +#define TCAN4X5X_MCAN_IR_RF1N BIT(4) +#define