Skip to content
Permalink
Browse files

drivers: can: mcp2515: Rework for DTS SPI bindings

Adjusted the MCP2515 driver to switch from KConfig SPI configuration to
DTS based configuration.

Signed-off-by: Karsten Koenig <karsten.koenig.030@gmail.com>
  • Loading branch information...
karstenkoenig authored and nashif committed Feb 18, 2019
1 parent 35b9308 commit 4f7761047b676a79f1b5753971166400543150f4
Showing with 34 additions and 80 deletions.
  1. +0 −52 drivers/can/Kconfig.mcp2515
  2. +8 −8 drivers/can/mcp2515.c
  3. +0 −20 dts/bindings/can/mcp,mcp2515.yaml
  4. +26 −0 dts/bindings/can/microchip,mcp2515.yaml
@@ -14,10 +14,6 @@ config CAN_MCP2515

if CAN_MCP2515

config CAN_MCP2515_NAME
string "Driver name"
default "MCP2515"

config CAN_MCP2515_OSC_FREQ
int "Oscillator frequency"
default 8000000
@@ -52,38 +48,6 @@ config CAN_SJW
help
Resynchronization jump width (ISO 11898-1)

config CAN_MCP2515_SPI_PORT_NAME
string "SPI device where MCP2515 is connected"
default "SPI_1"
help
Specify the device name of the SPI device to which MCP2515 is
connected.

config CAN_MCP2515_SPI_SLAVE
int "SPI Slave Select where MCP2515 is connected"
default 1
help
Specify the slave select pin of the SPI to which MCP2515 is
connected.

config CAN_MCP2515_SPI_FREQ
int "SPI frequency to use with MCP2515"
default 1000000
help
SPI frequency to use with MCP2515

config CAN_MCP2515_INT_PORT_NAME
string "INT GPIO controller port name"
default "GPIO_0"
help
GPIO port where INT is connected.

config CAN_MCP2515_INT_PIN
int "INT GPIO pin"
default 19
help
GPIO pin where INT is connected.

config CAN_MCP2515_INT_THREAD_STACK_SIZE
int "Stack size for interrupt handler"
default 512
@@ -104,22 +68,6 @@ config CAN_MCP2515_GPIO_SPI_CS
This option is useful if one needs to manage SPI CS through a GPIO
pin to by-pass the SPI controller's CS logic.

if CAN_MCP2515_GPIO_SPI_CS
config CAN_MCP2515_SPI_CS_PORT_NAME
string "GPIO driver's name to use to drive SPI CS through"
help
This option is mandatory to set which GPIO controller to use in
order to actually emulate the SPI CS.

config CAN_MCP2515_SPI_CS_PIN
int "GPIO PIN to use to drive SPI CS through"
default 0
help
This option is mandatory to set which GPIO pin to use in order
to actually emulate the SPI CS.

endif #CAN_MCP2515_GPIO_SPI_CS

config CAN_MCP2515_MAX_FILTER
int "Maximum number of concurrent active filters"
default 5
@@ -615,24 +615,24 @@ static struct mcp2515_data mcp2515_data_1 = {
};

static const struct mcp2515_config mcp2515_config_1 = {
.spi_port = CONFIG_CAN_MCP2515_SPI_PORT_NAME,
.spi_freq = CONFIG_CAN_MCP2515_SPI_FREQ,
.spi_slave = CONFIG_CAN_MCP2515_SPI_SLAVE,
.int_pin = CONFIG_CAN_MCP2515_INT_PIN,
.int_port = CONFIG_CAN_MCP2515_INT_PORT_NAME,
.spi_port = DT_MICROCHIP_MCP2515_0_BUS_NAME,
.spi_freq = DT_MICROCHIP_MCP2515_0_SPI_MAX_FREQUENCY,
.spi_slave = DT_MICROCHIP_MCP2515_0_BASE_ADDRESS,
.int_pin = DT_MICROCHIP_MCP2515_0_INT_GPIOS_PIN,
.int_port = DT_MICROCHIP_MCP2515_0_INT_GPIOS_CONTROLLER,
.int_thread_stack_size = CONFIG_CAN_MCP2515_INT_THREAD_STACK_SIZE,
.int_thread_priority = CONFIG_CAN_MCP2515_INT_THREAD_PRIO,
#ifdef CONFIG_CAN_MCP2515_GPIO_SPI_CS
.spi_cs_pin = CONFIG_CAN_MCP2515_SPI_CS_PIN,
.spi_cs_port = CONFIG_CAN_MCP2515_SPI_CS_PORT_NAME,
.spi_cs_pin = DT_MICROCHIP_MCP2515_0_CS_GPIOS_PIN,
.spi_cs_port = DT_MICROCHIP_MCP2515_0_CS_GPIOS_CONTROLLER,
#endif /* CAN_MCP2515_GPIO_SPI_CS */
.tq_sjw = CONFIG_CAN_SJW,
.tq_prop = CONFIG_CAN_PROP_SEG,
.tq_bs1 = CONFIG_CAN_PHASE_SEG1,
.tq_bs2 = CONFIG_CAN_PHASE_SEG2,
};

DEVICE_AND_API_INIT(can_mcp2515_1, CONFIG_CAN_MCP2515_NAME, &mcp2515_init,
DEVICE_AND_API_INIT(can_mcp2515_1, DT_MICROCHIP_MCP2515_0_LABEL, &mcp2515_init,
&mcp2515_data_1, &mcp2515_config_1, POST_KERNEL,
CONFIG_CAN_MCP2515_INIT_PRIORITY, &can_api_funcs);

This file was deleted.

@@ -0,0 +1,26 @@
#
# Copyright (c) 2019 Karsten Koenig
#
# SPDX-License-Identifier: Apache-2.0
#
---
title: MCP2515 CAN
version: 0.1

description: >
This binding gives a base representation of the MCP2515 SPI CAN controller
inherits:
!include [can.yaml, spi-device.yaml]

properties:
compatible:
type: string
category: required
description: compatible strings
constraint: "microchip,mcp2515"
int-gpios:
type: compound
category: required
generation: define, use-prop-name
...

0 comments on commit 4f77610

Please sign in to comment.
You can’t perform that action at this time.