M_CAN Framework
Subsystems (5)
v3 cover M_CAN Framework
All
Well it has taken me a while to get this working and ported to a provide a m_can framework that manages the Bosch m_can stack and abstracts away devices to use that framework.
The m_can.c is the framework that devices register to.
The device abstractions can provide read/write capability as well as bit timings and also provide any other initializations that are device specific.
The m_can platform code will need to be updated as I have not tested this code. The tcan code is working.
Dan
Dan Murphy (4):
can: m_can: Create a m_can platform framework
can: m_can: Migrate the m_can code to use the framework
dt-bindings: can: tcan4x5x: Add DT bindings for TCAN4x5X driver
can: tcan4x5x: Add tcan4x5x driver to the kernel
.../devicetree/bindings/net/can/tcan4x5x.txt | 37 + drivers/net/can/m_can/Kconfig | 18 + drivers/net/can/m_can/Makefile | 4 +- drivers/net/can/m_can/m_can.c | 765 +++++++++--------- drivers/net/can/m_can/m_can_platform.c | 212 +++++ drivers/net/can/m_can/m_can_platform.h | 163 ++++ drivers/net/can/m_can/tcan4x5x.c | 458 +++++++++++ 7 files changed, 1253 insertions(+), 404 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/can/tcan4x5x.txt create mode 100644 drivers/net/can/m_can/m_can_platform.c create mode 100644 drivers/net/can/m_can/m_can_platform.h create mode 100644 drivers/net/can/m_can/tcan4x5x.c
Signature · 1 line
2.20.1.98.gecbdaf0899
PATCH v3 1/4 can: m_can: Create a m_can platform framework
Create a m_can platform framework that peripherial devices can register to and use common code and register sets. The peripherial devices may provide read/write and configuration support of the IP.
--- drivers/net/can/m_can/m_can.c | 6 + drivers/net/can/m_can/m_can_platform.c | 212 +++++++++++++++++++++++++ drivers/net/can/m_can/m_can_platform.h | 163 +++++++++++++++++++ 3 files changed, 381 insertions(+) create mode 100644 drivers/net/can/m_can/m_can_platform.c create mode 100644 drivers/net/can/m_can/m_can_platform.h
drivers/net/can/m_can/m_can.c +6 -0
@@ -414,6 +414,9 @@ static inline void m_can_config_endisable(const struct m_can_priv *priv,u32 timeout =10 ;u32 val =0 ; +if (cccr &CCCR_CSR ) + cccr &= ~CCCR_CSR ; +if (enable) {/* enable m_can configuration */ m_can_write (priv,M_CAN_CCCR , cccr |CCCR_INIT );
@@ -1155,6 +1158,9 @@ static void m_can_chip_config(struct net_device *dev)m_can_set_bittiming (dev);m_can_config_endisable (priv, false); + +if (priv->device_init) + priv->device_init (priv); }static void m_can_start (struct net_device *dev)
drivers/net/can/m_can/m_can_platform.c new file +212 -0
212 lines not on this page · raw message
drivers/net/can/m_can/m_can_platform.h new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
2.20.1.98.gecbdaf0899
PATCH v3 2/4 can: m_can: Migrate the m_can code to use the framework
In reply to Dan MurphyMigrate the m_can code to use the m_can_platform framework code.
--- drivers/net/can/m_can/Kconfig | 12 + drivers/net/can/m_can/Makefile | 4 +- drivers/net/can/m_can/m_can.c | 759 ++++++++++++------------- drivers/net/can/m_can/m_can_platform.h | 2 +- 4 files changed, 372 insertions(+), 405 deletions(-)
drivers/net/can/m_can/Kconfig +12 -0
@@ -1,5 +1,17 @@ config CAN_M_CAN + tristate "Bosch M_CAN support" + ---help--- + Say Y here if you want to support for Bosch M_CAN controller. + +config CAN_M_CAN_CORE + depends on CAN_M_CAN + tristate "Bosch M_CAN Core support" + ---help--- + Say Y here if you want to support for Bosch M_CAN controller. + +config CAN_M_CAN_PLATFORM depends on HAS_IOMEM + depends on CAN_M_CAN_CORE tristate "Bosch M_CAN devices" ---help--- Say Y here if you want to support for Bosch M_CAN controller.
drivers/net/can/m_can/Makefile +3 -1
@@ -2,4 +2,6 @@ # Makefile for the Bosch M_CAN controller driver. # -obj-$(CONFIG_CAN_M_CAN) += m_can.o +obj-$(CONFIG_CAN_M_CAN_CORE) += m_can.o +obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o +obj-$(CONFIG_CAN_M_CAN_TCAN4X5X) += tcan4x5x.o
drivers/net/can/m_can/m_can.c +356 -403
1,158 lines not on this page · raw message
drivers/net/can/m_can/m_can_platform.h +1 -1
@@ -156,7 +156,7 @@ int m_can_core_register(struct m_can_classdev *m_can_dev);void m_can_core_unregister (struct m_can_classdev *m_can_dev);int m_can_core_get_clocks (struct m_can_classdev *m_can_dev);void m_can_init_ram (struct m_can_classdev *priv); -void m_can_config_endisable (const struct m_can_classdev *priv,bool enable); +void m_can_config_endisable (struct m_can_classdev *priv,bool enable);int m_can_core_suspend (struct device *dev);int m_can_core_resume (struct device *dev);
Signature · 1 line
2.20.1.98.gecbdaf0899
PATCH v3 3/4 dt-bindings: can: tcan4x5x: Add DT bindings for TCAN4x5X driver
In reply to Dan MurphyDT binding documentation for TI TCAN4x5x driver.
--- .../devicetree/bindings/net/can/tcan4x5x.txt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/can/tcan4x5x.txt
Documentation/devicetree/bindings/net/can/tcan4x5x.txt new file +37 -0
@@ -0,0 +1,37 @@ +Texas Instruments TCAN4x5x CAN Controller +================================================ + +This file provides device node information for the TCAN4x5x interface contains. + +Required properties: + - compatible: "ti,tcan4x5x" + - reg: 0 + - #address-cells: 1 + - #size-cells: 0 + - spi-max-frequency: Maximum frequency of the SPI bus the chip can + operate at should be less than or equal to 18 MHz. + - data-ready-gpios: Interrupt GPIO for data and error reporting. + - device-wake-gpios: Wake up GPIO to wake up the TCAN device. + - device-state-gpios: Input GPIO that indicates if the device is in + a sleep state or if the device is active. + +See Documentation/devicetree/bindings/net/can/m_can.txt for additional +required property details. + +Optional properties: + - reset-gpios: Hardwired output GPIO. If not defined then software + reset. + +Example: +tcan4x5x: tcan4x5x@0 { + compatible = "ti,tcan4x5x"; + reg = <0>; + #address-cells = <1>; + #size-cells = <1>; + spi-max-frequency = <10000000>; + bosch,mram-cfg = <0x0 0 0 32 0 0 1 1>; + data-ready-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>; + device-state-gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>; + device-wake-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 27 GPIO_ACTIVE_LOW>; +};
Signature · 1 line
2.20.1.98.gecbdaf0899
PATCH v3 4/4 can: tcan4x5x: Add tcan4x5x driver to the kernel
In reply to Dan MurphyAdd 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.
--- drivers/net/can/m_can/Kconfig | 6 + drivers/net/can/m_can/tcan4x5x.c | 458 +++++++++++++++++++++++++++++++ 2 files changed, 464 insertions(+) create mode 100644 drivers/net/can/m_can/tcan4x5x.c
drivers/net/can/m_can/Kconfig +6 -0
@@ -15,3 +15,9 @@ config CAN_M_CAN_PLATFORM tristate "Bosch M_CAN devices" ---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.
drivers/net/can/m_can/tcan4x5x.c new file +458 -0
458 lines not on this page · raw message
Signature · 1 line
2.20.1.98.gecbdaf0899