Skip to content

Commit 4f77610

Browse files
karstenkoenignashif
authored andcommitted
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 <[email protected]>
1 parent 35b9308 commit 4f77610

File tree

4 files changed

+34
-80
lines changed

4 files changed

+34
-80
lines changed

drivers/can/Kconfig.mcp2515

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ config CAN_MCP2515
1414

1515
if CAN_MCP2515
1616

17-
config CAN_MCP2515_NAME
18-
string "Driver name"
19-
default "MCP2515"
20-
2117
config CAN_MCP2515_OSC_FREQ
2218
int "Oscillator frequency"
2319
default 8000000
@@ -52,38 +48,6 @@ config CAN_SJW
5248
help
5349
Resynchronization jump width (ISO 11898-1)
5450

55-
config CAN_MCP2515_SPI_PORT_NAME
56-
string "SPI device where MCP2515 is connected"
57-
default "SPI_1"
58-
help
59-
Specify the device name of the SPI device to which MCP2515 is
60-
connected.
61-
62-
config CAN_MCP2515_SPI_SLAVE
63-
int "SPI Slave Select where MCP2515 is connected"
64-
default 1
65-
help
66-
Specify the slave select pin of the SPI to which MCP2515 is
67-
connected.
68-
69-
config CAN_MCP2515_SPI_FREQ
70-
int "SPI frequency to use with MCP2515"
71-
default 1000000
72-
help
73-
SPI frequency to use with MCP2515
74-
75-
config CAN_MCP2515_INT_PORT_NAME
76-
string "INT GPIO controller port name"
77-
default "GPIO_0"
78-
help
79-
GPIO port where INT is connected.
80-
81-
config CAN_MCP2515_INT_PIN
82-
int "INT GPIO pin"
83-
default 19
84-
help
85-
GPIO pin where INT is connected.
86-
8751
config CAN_MCP2515_INT_THREAD_STACK_SIZE
8852
int "Stack size for interrupt handler"
8953
default 512
@@ -104,22 +68,6 @@ config CAN_MCP2515_GPIO_SPI_CS
10468
This option is useful if one needs to manage SPI CS through a GPIO
10569
pin to by-pass the SPI controller's CS logic.
10670

107-
if CAN_MCP2515_GPIO_SPI_CS
108-
config CAN_MCP2515_SPI_CS_PORT_NAME
109-
string "GPIO driver's name to use to drive SPI CS through"
110-
help
111-
This option is mandatory to set which GPIO controller to use in
112-
order to actually emulate the SPI CS.
113-
114-
config CAN_MCP2515_SPI_CS_PIN
115-
int "GPIO PIN to use to drive SPI CS through"
116-
default 0
117-
help
118-
This option is mandatory to set which GPIO pin to use in order
119-
to actually emulate the SPI CS.
120-
121-
endif #CAN_MCP2515_GPIO_SPI_CS
122-
12371
config CAN_MCP2515_MAX_FILTER
12472
int "Maximum number of concurrent active filters"
12573
default 5

drivers/can/mcp2515.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -615,24 +615,24 @@ static struct mcp2515_data mcp2515_data_1 = {
615615
};
616616

617617
static const struct mcp2515_config mcp2515_config_1 = {
618-
.spi_port = CONFIG_CAN_MCP2515_SPI_PORT_NAME,
619-
.spi_freq = CONFIG_CAN_MCP2515_SPI_FREQ,
620-
.spi_slave = CONFIG_CAN_MCP2515_SPI_SLAVE,
621-
.int_pin = CONFIG_CAN_MCP2515_INT_PIN,
622-
.int_port = CONFIG_CAN_MCP2515_INT_PORT_NAME,
618+
.spi_port = DT_MICROCHIP_MCP2515_0_BUS_NAME,
619+
.spi_freq = DT_MICROCHIP_MCP2515_0_SPI_MAX_FREQUENCY,
620+
.spi_slave = DT_MICROCHIP_MCP2515_0_BASE_ADDRESS,
621+
.int_pin = DT_MICROCHIP_MCP2515_0_INT_GPIOS_PIN,
622+
.int_port = DT_MICROCHIP_MCP2515_0_INT_GPIOS_CONTROLLER,
623623
.int_thread_stack_size = CONFIG_CAN_MCP2515_INT_THREAD_STACK_SIZE,
624624
.int_thread_priority = CONFIG_CAN_MCP2515_INT_THREAD_PRIO,
625625
#ifdef CONFIG_CAN_MCP2515_GPIO_SPI_CS
626-
.spi_cs_pin = CONFIG_CAN_MCP2515_SPI_CS_PIN,
627-
.spi_cs_port = CONFIG_CAN_MCP2515_SPI_CS_PORT_NAME,
626+
.spi_cs_pin = DT_MICROCHIP_MCP2515_0_CS_GPIOS_PIN,
627+
.spi_cs_port = DT_MICROCHIP_MCP2515_0_CS_GPIOS_CONTROLLER,
628628
#endif /* CAN_MCP2515_GPIO_SPI_CS */
629629
.tq_sjw = CONFIG_CAN_SJW,
630630
.tq_prop = CONFIG_CAN_PROP_SEG,
631631
.tq_bs1 = CONFIG_CAN_PHASE_SEG1,
632632
.tq_bs2 = CONFIG_CAN_PHASE_SEG2,
633633
};
634634

635-
DEVICE_AND_API_INIT(can_mcp2515_1, CONFIG_CAN_MCP2515_NAME, &mcp2515_init,
635+
DEVICE_AND_API_INIT(can_mcp2515_1, DT_MICROCHIP_MCP2515_0_LABEL, &mcp2515_init,
636636
&mcp2515_data_1, &mcp2515_config_1, POST_KERNEL,
637637
CONFIG_CAN_MCP2515_INIT_PRIORITY, &can_api_funcs);
638638

dts/bindings/can/mcp,mcp2515.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Copyright (c) 2019 Karsten Koenig
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
---
7+
title: MCP2515 CAN
8+
version: 0.1
9+
10+
description: >
11+
This binding gives a base representation of the MCP2515 SPI CAN controller
12+
13+
inherits:
14+
!include [can.yaml, spi-device.yaml]
15+
16+
properties:
17+
compatible:
18+
type: string
19+
category: required
20+
description: compatible strings
21+
constraint: "microchip,mcp2515"
22+
int-gpios:
23+
type: compound
24+
category: required
25+
generation: define, use-prop-name
26+
...

0 commit comments

Comments
 (0)