foss-for-synopsys-dwc-arc-processors / embarc_osp

embARC Open Software Platform (OSP) - An embedded software distribution for IoT and other embedded applications for ARC
https://www.embarc.org/
BSD 3-Clause "New" or "Revised" License
70 stars 62 forks source link

enhancement: common IRQ priority control command for the Device HAL #106

Open alexeysmirnovspb opened 5 years ago

alexeysmirnovspb commented 5 years ago

Issue Summary


Complex use-case usually requires IRQ priorities tuning according to the specific time constraints. Since setting IRQ priority needs the knowledge of the particular device IRQ line numbers that is normally hidden by HAL, it is reasonable to add the new HAL API call to reuse the information from device description structure.

Please see code below, this is the example of the possible IRQ priority control command implementation for I2C driver:

1) the new command ID definition in device/ip/ip_hal/inc/dev_iic.h:

             /**
              * Set the required IRQ priority level
              * - Param type : int32_t
              * - Param usage :
              * - Return value explanation :
              */
             #define IIC_CMD_SET_IRQ_PRIO           DEV_SET_IIC_SYSCMD(18)

2) IRQ priority setting call (this call might be shared and declared outisde the I2C driver code, for example, as a macro) and the new command handler in device/ip/subsystem/iic/ss_i2c_master.c

             /* an inline procedure that sets the IRQ priority */
             Inline void ss_iic_set_irq_priority(uint32_t vector, uint32_t priority)
             {
                    _arc_aux_write(0x40b, vector);          /*IRQ_SELECT*/
                    _arc_aux_write(0x206, priority);        /*IRQ_LEVEL*/
             }

             <...>

             /* ...and finally adding the new command handler */
              int32_t ss_iic_master_close(SS_IIC_MASTER_DEV_CONTEXT *ctx)
              {
             <...>
                            case IIC_CMD_SET_IRQ_PRIO:
                                    val32 = (uint32_t)param;
                                    ss_iic_set_irq_priority(ctx->int_err, val32);
                                    ss_iic_set_irq_priority(ctx->int_rx_avail, val32);
                                    ss_iic_set_irq_priority(ctx->int_tx_req, val32);
                                    ss_iic_set_irq_priority(ctx->int_stop_det, val32);
                                    break;
             <...>
             }