[PATCH 1/1] arm/atsam: Make interrupt server configurable
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Aug 3 07:45:08 UTC 2020
The external UART over SPI device SC16IS752 uses the interrupt server
for interrupt processing. The interrupt server is also heavily used by
libbsd. The interrupt processing for the SC16IS752 is time critical and
doesn't work if network traffic is processed at the same priority.
With #4033 custom interrupt servers are available. Change
atsam_sc16is752_spi_create() to support user-defined interrupt servers.
Introduced atsam_sc16is752_spi_config to cut down the argument count of
this function.
Close #4038.
---
bsps/arm/atsam/include/bsp/sc16is752.h | 87 +++++++++++++++++++-------
bsps/arm/atsam/spi/sc16is752.c | 27 ++++----
2 files changed, 75 insertions(+), 39 deletions(-)
diff --git a/bsps/arm/atsam/include/bsp/sc16is752.h b/bsps/arm/atsam/include/bsp/sc16is752.h
index e8973efc46..e27f80bf97 100644
--- a/bsps/arm/atsam/include/bsp/sc16is752.h
+++ b/bsps/arm/atsam/include/bsp/sc16is752.h
@@ -24,44 +24,85 @@
extern "C" {
#endif /* __cplusplus */
+/**
+ * @brief The SC16IS752 device context.
+ *
+ * All members are private to the device driver.
+ */
typedef struct {
sc16is752_spi_context base;
Pin irq_pin;
- rtems_interrupt_server_entry irqs_entry; /* Internal. Don't touch. */
- rtems_interrupt_server_action irqs_action; /* Internal. Don't touch. */
+ rtems_interrupt_server_entry irqs_entry;
+ rtems_interrupt_server_action irqs_action;
+ uint32_t irqs_index;
} atsam_sc16is752_spi_context;
+/**
+ * @brief The SC16IS752 device configuration.
+ *
+ * @see atsam_sc16is752_spi_create().
+ */
+typedef struct {
+ /**
+ * @brief The device file path for the new device.
+ */
+ const char *device_path;
+
+ /**
+ * @brief The SC16IS752 mode.
+ */
+ sc16is752_mode mode;
+
+ /**
+ * @brief The input frequency in Hertz of the SC16IS752 chip. See XTAL1 and
+ * XTAL2 pins.
+ */
+ uint32_t input_frequency;
+
+ /**
+ * @brief The SPI bus device path.
+ */
+ const char *spi_path;
+
+ /**
+ * @brief The SPI chip select (starts with 0, the SPI driver uses
+ * SPI_ChipSelect(1 << spi_chip_select)).
+ */
+ uint8_t spi_chip_select;
+
+ /**
+ * @brief The SPI bus speed in Hertz.
+ */
+ uint32_t spi_speed_hz;
+
+ /**
+ * @brief The interrupt pin, e.g. { PIO_PD28, PIOD, ID_PIOD, PIO_INPUT,
+ * PIO_IT_LOW_LEVEL }.
+ */
+ const Pin irq_pin;
+
+ /**
+ * @brief The index to identify the interrupt server used for interrupt
+ * processing.
+ */
+ uint32_t server_index;
+} atsam_sc16is752_spi_config;
+
/**
* @brief Creates an SPI connected SC16IS752 device.
*
- * This devices uses the interrupt server, see
- * rtems_interrupt_server_initialize().
+ * This devices uses the interrupt server, see rtems_interrupt_server_create().
*
* The device claims the interrupt of the PIO block.
*
- * @param[in] ctx The device context. May have an arbitrary content.
- * @param[in] device_path The device file path for the new device.
- * @param[in] mode The SC16IS752 mode.
- * @param[in] input_frequency The input frequency in Hertz of the SC16IS752
- * chip. See XTAL1 and XTAL2 pins.
- * @param[in] spi_path The SPI bus device path.
- * @param[in] spi_chip_select The SPI chip select (starts with 0, the SPI
- * driver uses SPI_ChipSelect(1 << spi_chip_select)).
- * @param[in] spi_speed_hz The SPI bus speed in Hertz.
- * @param[in] irq_pin The interrupt pin, e.g. { PIO_PD28, PIOD, ID_PIOD,
- * PIO_INPUT, PIO_IT_LOW_LEVEL }.
+ * @param[out] ctx is the device context. It may have an arbitrary content.
+ * @param config is the device configuration.
*
* @return See sc16is752_spi_create().
*/
int atsam_sc16is752_spi_create(
- atsam_sc16is752_spi_context *ctx,
- const char *device_path,
- sc16is752_mode mode,
- uint32_t input_frequency,
- const char *spi_path,
- uint8_t spi_chip_select,
- uint32_t spi_speed_hz,
- const Pin *irq_pin
+ atsam_sc16is752_spi_context *ctx,
+ const atsam_sc16is752_spi_config *config
);
#ifdef __cplusplus
diff --git a/bsps/arm/atsam/spi/sc16is752.c b/bsps/arm/atsam/spi/sc16is752.c
index 8d38fe92d6..59380d5057 100644
--- a/bsps/arm/atsam/spi/sc16is752.c
+++ b/bsps/arm/atsam/spi/sc16is752.c
@@ -41,7 +41,7 @@ static bool atsam_sc16is752_install_interrupt(sc16is752_context *base)
rtems_status_code sc;
uint8_t rv;
- sc = rtems_interrupt_server_entry_initialize(RTEMS_INTERRUPT_SERVER_DEFAULT,
+ sc = rtems_interrupt_server_entry_initialize(ctx->irqs_index,
&ctx->irqs_entry);
rtems_interrupt_server_action_prepend(&ctx->irqs_entry,
&ctx->irqs_action, atsam_sc16i752_irqs_handler, ctx);
@@ -64,24 +64,19 @@ static void atsam_sc16is752_remove_interrupt(sc16is752_context *base)
}
int atsam_sc16is752_spi_create(
- atsam_sc16is752_spi_context *ctx,
- const char *device_path,
- sc16is752_mode mode,
- uint32_t input_frequency,
- const char *spi_path,
- uint8_t spi_chip_select,
- uint32_t spi_speed_hz,
- const Pin *irq_pin
+ atsam_sc16is752_spi_context *ctx,
+ const atsam_sc16is752_spi_config *config
)
{
- ctx->base.base.mode = mode;
- ctx->base.base.input_frequency = input_frequency;
+ ctx->base.base.mode = config->mode;
+ ctx->base.base.input_frequency = config->input_frequency;
ctx->base.base.install_irq = atsam_sc16is752_install_interrupt;
ctx->base.base.remove_irq = atsam_sc16is752_remove_interrupt;
- ctx->base.spi_path = spi_path;
- ctx->base.cs = spi_chip_select;
- ctx->base.speed_hz = spi_speed_hz;
- ctx->irq_pin = *irq_pin;
+ ctx->base.spi_path = config->spi_path;
+ ctx->base.cs = config->spi_chip_select;
+ ctx->base.speed_hz = config->spi_speed_hz;
+ ctx->irq_pin = config->irq_pin;
+ ctx->irqs_index = config->server_index;
- return sc16is752_spi_create(&ctx->base, device_path);
+ return sc16is752_spi_create(&ctx->base, config->device_path);
}
--
2.26.2
More information about the devel
mailing list