Move initialization of 'enabled' variable together with declaration.
This fixes the following compiler error:
error: 'enabled' may be used uninitialized [-Werror=maybe-uninitialized]
This is not really an error but the compiler is tricked by the
K_SPINLOCK() macro.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/88996
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
So far, it has been assumed that only level 2 interrupts can be shared
via the `CONFIG_SHARED_INTERRUPTS` option, but this is not true. In the
case of i.MX95, for instance, level 1 interrupt 143 is shared among EDMA
channels 30 and 31.
Due to the previous assumption, the irqsteer driver currently performs
reference counting for all level 2 interrupts aggregated by each
dispatcher and, of course, for the level 1 interrupts the dispatchers are
attached to. For instance, assuming a machine with 100 level 1 interrupts
and 1 irqsteer dispatcher attached to line 50 this would mean reference
counting is performed solely for line 50 (and the level 2 interrupts MUX'd
into this line).
Going back to i.MX95, since there's no dispatcher attached to IRQ line 143
that means there's no reference counting for it. In turn, this means that
the IRQ line can be disabled accidentally on a channel release() operation
while the other channel is active.
To protect against such cases, refactor the level1 interrupt reference
counting. Now, reference counting is performed for _all_ level 1
interrupts.
Additionally, simplify the locking logic. Ideally, there would be a lock
for each dispatcher protecting the level 2 interrupts and 1 global lock
protecting the level 1 interrupts. Instead of this approach (which is a
bit more complex), simply use a global lock for all interrupts. If finer
granularity is required then it can be added later on.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add the "_raw" suffix to the macros handling the level 1 IRQ enable and
disable operation to signify that these operations perform no refcounting.
Additionally, shorten some portions of the name.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Current system INTID calcualtion only worked for SoCs whose extended
interrupts started from IRQ 0.
Otherwise, FSL_FEATURE_IRQSTEER_IRQ_START_INDEX should be added for
system INTID.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Initialize the 'enabled' variable before using it.
This fixes the following compilation warning:
"warning: 'enabled' may be used uninitialized [-Wmaybe-uninitialized]"
issued when compiling with `CONFIG_DEBUG` enabled.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Tested-by: Daniel Baluta <daniel.baluta@nxp.com>
Add support for PM. The strategy is as follows:
1) For level 1 interrupts: don't care, these don't
require the PM domain of irqsteer to be turned on
since they are, well, direct.
2) For level 2 interrupts: use the reference count
of the dispatchers.
Upon doing a get() on a dispatcher with its reference count
set to 0, before enabling the IRQ (meaning accessing the
reg. space) increment the reference count of the irqstr device
(which will result in the PM domain being enabled if 0).
Upon doin a put() on a dispatcher with its reference count
set to 1, after disabling the IRQ (meaning accessing the
reg. space) decrement the reference count of the irqstr device
(which will result in the PM domain being disabled if 0).
In summary, the PM domain of the device will be enabled if
at least one dispatcher is in use. On the other hand, the
PM domain of the device will be disabled if there's no
dispatchers in use (assuming there's no other dependencies).
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Currently, all dispatcher interrupts are enabled during
the driver init() function, which will cause a bus fault
unless the PM domain associated with irqsteer is powered on.
Since PM will be done during irq_enable()/irq_disable(),
add support for dynamically enabling/disabling dispatchers.
This way, the reg. space of the dispatchers will be accessed
when the PM domain is powered on.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Currently, shared interrupts pose a big problem because
irq_disable() doesn't keep track of the number of clients
using that interrupt line. As such, add a reference count
mechanism which will stop the interrupt from being disabled
if there's still clients using it.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This gets rid of the z_ prefix.
Note that z_xt_*() are being used by the HAL so they cannot be
renamed.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit introduces a new interrupt controller driver used
for NXP's IRQ_STEER IP.
Apart from introducing the driver itself, this commit contains
the following changes:
1) Switch i.MX8MP to using the XTENSA core interrupt
controller instead of the dummy irqsteer one.
* this is required because the binding for the
irqsteer driver is no longer a dummy one
(since it's being used by the irqsteer driver).
As such, to avoid having problems, switch to
using another dummy binding.
2) Modify the irqsteer dummy binding such that it
serves the IRQ_STEER driver's needs.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>