Changeset 1b421585 in rtems


Ignore:
Timestamp:
Aug 3, 2020, 7:42:25 AM (7 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
d2c98c1
Parents:
81631de
git-author:
Sebastian Huber <sebastian.huber@…> (08/03/20 07:42:25)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/05/20 05:00:36)
Message:

arm/atsam: Make interrupt server configurable

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 #4039.

Location:
bsps/arm/atsam
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/atsam/include/bsp/sc16is752.h

    r81631de r1b421585  
    2525#endif /* __cplusplus */
    2626
     27/**
     28 * @brief The SC16IS752 device context.
     29 *
     30 * All members are private to the device driver.
     31 */
    2732typedef struct {
    2833  sc16is752_spi_context base;
    2934  Pin irq_pin;
    30   rtems_interrupt_server_entry irqs_entry; /* Internal. Don't touch. */
    31   rtems_interrupt_server_action irqs_action; /* Internal. Don't touch. */
     35  rtems_interrupt_server_entry irqs_entry;
     36  rtems_interrupt_server_action irqs_action;
     37  uint32_t irqs_index;
    3238} atsam_sc16is752_spi_context;
     39
     40/**
     41 * @brief The SC16IS752 device configuration.
     42 *
     43 * @see atsam_sc16is752_spi_create().
     44 */
     45typedef struct {
     46  /**
     47   * @brief The device file path for the new device.
     48   */
     49  const char *device_path;
     50
     51  /**
     52   * @brief The SC16IS752 mode.
     53   */
     54  sc16is752_mode mode;
     55
     56  /**
     57   * @brief The input frequency in Hertz of the SC16IS752 chip.  See XTAL1 and
     58   * XTAL2 pins.
     59   */
     60  uint32_t input_frequency;
     61
     62  /**
     63   * @brief The SPI bus device path.
     64   */
     65  const char *spi_path;
     66
     67  /**
     68   * @brief The SPI chip select (starts with 0, the SPI driver uses
     69   * SPI_ChipSelect(1 << spi_chip_select)).
     70   */
     71  uint8_t spi_chip_select;
     72
     73  /**
     74   * @brief The SPI bus speed in Hertz.
     75   */
     76  uint32_t spi_speed_hz;
     77
     78  /**
     79   * @brief The interrupt pin, e.g. { PIO_PD28, PIOD, ID_PIOD, PIO_INPUT,
     80   * PIO_IT_LOW_LEVEL }.
     81   */
     82  const Pin irq_pin;
     83
     84  /**
     85   * @brief The index to identify the interrupt server used for interrupt
     86   * processing.
     87   */
     88  uint32_t server_index;
     89} atsam_sc16is752_spi_config;
    3390
    3491/**
    3592 * @brief Creates an SPI connected SC16IS752 device.
    3693 *
    37  * This devices uses the interrupt server, see
    38  * rtems_interrupt_server_initialize().
     94 * This devices uses the interrupt server, see rtems_interrupt_server_create().
    3995 *
    4096 * The device claims the interrupt of the PIO block.
    4197 *
    42  * @param[in] ctx The device context.  May have an arbitrary content.
    43  * @param[in] device_path The device file path for the new device.
    44  * @param[in] mode The SC16IS752 mode.
    45  * @param[in] input_frequency The input frequency in Hertz of the SC16IS752
    46  *   chip.  See XTAL1 and XTAL2 pins.
    47  * @param[in] spi_path The SPI bus device path.
    48  * @param[in] spi_chip_select The SPI chip select (starts with 0, the SPI
    49  *   driver uses SPI_ChipSelect(1 << spi_chip_select)).
    50  * @param[in] spi_speed_hz The SPI bus speed in Hertz.
    51  * @param[in] irq_pin The interrupt pin, e.g. { PIO_PD28, PIOD, ID_PIOD,
    52  *   PIO_INPUT, PIO_IT_LOW_LEVEL }.
     98 * @param[out] ctx is the device context.  It may have an arbitrary content.
     99 * @param config is the device configuration.
    53100 *
    54101 * @return See sc16is752_spi_create().
    55102 */
    56103int atsam_sc16is752_spi_create(
    57   atsam_sc16is752_spi_context *ctx,
    58   const char                  *device_path,
    59   sc16is752_mode               mode,
    60   uint32_t                     input_frequency,
    61   const char                  *spi_path,
    62   uint8_t                      spi_chip_select,
    63   uint32_t                     spi_speed_hz,
    64   const Pin                    *irq_pin
     104  atsam_sc16is752_spi_context      *ctx,
     105  const atsam_sc16is752_spi_config *config
    65106);
    66107
  • bsps/arm/atsam/spi/sc16is752.c

    r81631de r1b421585  
    4242  uint8_t rv;
    4343
    44   sc = rtems_interrupt_server_entry_initialize(RTEMS_INTERRUPT_SERVER_DEFAULT,
     44  sc = rtems_interrupt_server_entry_initialize(ctx->irqs_index,
    4545    &ctx->irqs_entry);
    4646  rtems_interrupt_server_action_prepend(&ctx->irqs_entry,
     
    6565
    6666int atsam_sc16is752_spi_create(
    67   atsam_sc16is752_spi_context *ctx,
    68   const char *device_path,
    69   sc16is752_mode mode,
    70   uint32_t input_frequency,
    71   const char *spi_path,
    72   uint8_t spi_chip_select,
    73   uint32_t spi_speed_hz,
    74   const Pin *irq_pin
     67  atsam_sc16is752_spi_context      *ctx,
     68  const atsam_sc16is752_spi_config *config
    7569)
    7670{
    77   ctx->base.base.mode = mode;
    78   ctx->base.base.input_frequency = input_frequency;
     71  ctx->base.base.mode = config->mode;
     72  ctx->base.base.input_frequency = config->input_frequency;
    7973  ctx->base.base.install_irq = atsam_sc16is752_install_interrupt;
    8074  ctx->base.base.remove_irq = atsam_sc16is752_remove_interrupt;
    81   ctx->base.spi_path = spi_path;
    82   ctx->base.cs = spi_chip_select;
    83   ctx->base.speed_hz = spi_speed_hz;
    84   ctx->irq_pin = *irq_pin;
     75  ctx->base.spi_path = config->spi_path;
     76  ctx->base.cs = config->spi_chip_select;
     77  ctx->base.speed_hz = config->spi_speed_hz;
     78  ctx->irq_pin = config->irq_pin;
     79  ctx->irqs_index = config->server_index;
    8580
    86   return sc16is752_spi_create(&ctx->base, device_path);
     81  return sc16is752_spi_create(&ctx->base, config->device_path);
    8782}
Note: See TracChangeset for help on using the changeset viewer.