Skip to content

Commit

Permalink
drivers: spi: sam: Convert to DT_INST defines
Browse files Browse the repository at this point in the history
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
  • Loading branch information
nandojve committed Mar 9, 2020
1 parent d3d7ff9 commit b1782fb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 46 deletions.
20 changes: 10 additions & 10 deletions drivers/spi/spi_sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,30 +493,30 @@ static const struct spi_driver_api spi_sam_driver_api = {

#define PINS_SPI1_CS { PIN_SPI1_CS0, PIN_SPI1_CS1, PIN_SPI1_CS2, PIN_SPI1_CS3 }

#define SPI_SAM_DEFINE_CONFIG(n) \
#define SPI_SAM_DEFINE_CONFIG(n, m) \
static const struct spi_sam_config spi_sam_config_##n = { \
.regs = (Spi *)DT_SPI_##n##_BASE_ADDRESS, \
.periph_id = DT_SPI_##n##_PERIPHERAL_ID, \
.regs = (Spi *)DT_INST_##n##_ATMEL_SAM_SPI_BASE_ADDRESS,\
.periph_id = DT_INST_##n##_ATMEL_SAM_SPI_PERIPHERAL_ID, \
.pins = PINS_SPI##n, \
.cs = PINS_SPI##n##_CS, \
}

#define SPI_SAM_DEVICE_INIT(n) \
SPI_SAM_DEFINE_CONFIG(n); \
#define SPI_SAM_DEVICE_INIT(n, m) \
SPI_SAM_DEFINE_CONFIG(n, m); \
static struct spi_sam_data spi_sam_dev_data_##n = { \
SPI_CONTEXT_INIT_LOCK(spi_sam_dev_data_##n, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_sam_dev_data_##n, ctx), \
}; \
DEVICE_AND_API_INIT(spi_sam_##n, \
DT_SPI_##n##_NAME, \
DT_INST_##n##_ATMEL_SAM_SPI_LABEL, \
&spi_sam_init, &spi_sam_dev_data_##n, \
&spi_sam_config_##n, POST_KERNEL, \
CONFIG_SPI_INIT_PRIORITY, &spi_sam_driver_api)

#if DT_SPI_0_BASE_ADDRESS
SPI_SAM_DEVICE_INIT(0);
#if DT_INST_0_ATMEL_SAM_SPI
SPI_SAM_DEVICE_INIT(0, DT_INST_0_ATMEL_SAM_SPI_ID);
#endif

#if DT_SPI_1_BASE_ADDRESS
SPI_SAM_DEVICE_INIT(1);
#if DT_INST_1_ATMEL_SAM_SPI
SPI_SAM_DEVICE_INIT(1, DT_INST_0_ATMEL_SAM_SPI_ID);
#endif
6 changes: 0 additions & 6 deletions soc/arm/atmel_sam/sam4e/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
#define DT_I2C_1_IRQ_PRI DT_ATMEL_SAM_I2C_TWI_400AC000_IRQ_0_PRIORITY
#define DT_I2C_1_PERIPHERAL_ID DT_ATMEL_SAM_I2C_TWI_400AC000_PERIPHERAL_ID

#define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40088000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40088000_LABEL
#define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40088000_IRQ_0
#define DT_SPI_0_IRQ_PRI DT_ATMEL_SAM_SPI_40088000_IRQ_0_PRIORITY
#define DT_SPI_0_PERIPHERAL_ID DT_ATMEL_SAM_SPI_40088000_PERIPHERAL_ID

#define DT_UART_SAM_PORT_0_NAME DT_ATMEL_SAM_UART_400E0600_LABEL
#define DT_UART_SAM_PORT_0_BAUD_RATE DT_ATMEL_SAM_UART_400E0600_CURRENT_SPEED
#define DT_UART_SAM_PORT_0_IRQ DT_ATMEL_SAM_UART_400E0600_IRQ_0
Expand Down
6 changes: 0 additions & 6 deletions soc/arm/atmel_sam/sam4s/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
#define DT_I2C_1_IRQ_PRI DT_ATMEL_SAM_I2C_TWI_4001C000_IRQ_0_PRIORITY
#define DT_I2C_1_PERIPHERAL_ID DT_ATMEL_SAM_I2C_TWI_4001C000_PERIPHERAL_ID

#define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40008000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40008000_LABEL
#define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40008000_IRQ_0
#define DT_SPI_0_IRQ_PRI DT_ATMEL_SAM_SPI_40008000_IRQ_0_PRIORITY
#define DT_SPI_0_PERIPHERAL_ID DT_ATMEL_SAM_SPI_40008000_PERIPHERAL_ID

#define DT_UART_SAM_PORT_0_NAME DT_ATMEL_SAM_UART_400E0600_LABEL
#define DT_UART_SAM_PORT_0_BAUD_RATE DT_ATMEL_SAM_UART_400E0600_CURRENT_SPEED
#define DT_UART_SAM_PORT_0_IRQ DT_ATMEL_SAM_UART_400E0600_IRQ_0
Expand Down
12 changes: 0 additions & 12 deletions soc/arm/atmel_sam/same70/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@
#define DT_I2C_2_IRQ_PRI DT_ATMEL_SAM_I2C_TWIHS_40060000_IRQ_0_PRIORITY
#define DT_I2C_2_PERIPHERAL_ID DT_ATMEL_SAM_I2C_TWIHS_40060000_PERIPHERAL_ID

#define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40008000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40008000_LABEL
#define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40008000_IRQ_0
#define DT_SPI_0_IRQ_PRI DT_ATMEL_SAM_SPI_40008000_IRQ_0_PRIORITY
#define DT_SPI_0_PERIPHERAL_ID DT_ATMEL_SAM_SPI_40008000_PERIPHERAL_ID

#define DT_SPI_1_BASE_ADDRESS DT_ATMEL_SAM_SPI_40058000_BASE_ADDRESS
#define DT_SPI_1_NAME DT_ATMEL_SAM_SPI_40058000_LABEL
#define DT_SPI_1_IRQ DT_ATMEL_SAM_SPI_40058000_IRQ_0
#define DT_SPI_1_IRQ_PRI DT_ATMEL_SAM_SPI_40058000_IRQ_0_PRIORITY
#define DT_SPI_1_PERIPHERAL_ID DT_ATMEL_SAM_SPI_40058000_PERIPHERAL_ID

#define DT_UART_SAM_PORT_0_NAME DT_ATMEL_SAM_UART_400E0800_LABEL
#define DT_UART_SAM_PORT_0_BAUD_RATE DT_ATMEL_SAM_UART_400E0800_CURRENT_SPEED
#define DT_UART_SAM_PORT_0_IRQ DT_ATMEL_SAM_UART_400E0800_IRQ_0
Expand Down
12 changes: 0 additions & 12 deletions soc/arm/atmel_sam/samv71/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@
#define DT_I2C_2_IRQ_PRI DT_ATMEL_SAM_I2C_TWIHS_40060000_IRQ_0_PRIORITY
#define DT_I2C_2_PERIPHERAL_ID DT_ATMEL_SAM_I2C_TWIHS_40060000_PERIPHERAL_ID

#define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40008000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40008000_LABEL
#define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40008000_IRQ_0
#define DT_SPI_0_IRQ_PRI DT_ATMEL_SAM_SPI_40008000_IRQ_0_PRIORITY
#define DT_SPI_0_PERIPHERAL_ID DT_ATMEL_SAM_SPI_40008000_PERIPHERAL_ID

#define DT_SPI_1_BASE_ADDRESS DT_ATMEL_SAM_SPI_40058000_BASE_ADDRESS
#define DT_SPI_1_NAME DT_ATMEL_SAM_SPI_40058000_LABEL
#define DT_SPI_1_IRQ DT_ATMEL_SAM_SPI_40058000_IRQ_0
#define DT_SPI_1_IRQ_PRI DT_ATMEL_SAM_SPI_40058000_IRQ_0_PRIORITY
#define DT_SPI_1_PERIPHERAL_ID DT_ATMEL_SAM_SPI_40058000_PERIPHERAL_ID

#define DT_UART_SAM_PORT_0_NAME DT_ATMEL_SAM_UART_400E0800_LABEL
#define DT_UART_SAM_PORT_0_BAUD_RATE DT_ATMEL_SAM_UART_400E0800_CURRENT_SPEED
#define DT_UART_SAM_PORT_0_IRQ DT_ATMEL_SAM_UART_400E0800_IRQ_0
Expand Down

0 comments on commit b1782fb

Please sign in to comment.