bsp/imx: Add imx_get_irq_of_node()

Update #3090.
This commit is contained in:
Sebastian Huber
2017-09-28 09:29:38 +02:00
parent 4cfce5cb64
commit 7e195e66c7
4 changed files with 30 additions and 16 deletions

View File

@@ -84,12 +84,7 @@ static void imx_uart_init_context(
}
#ifdef CONSOLE_USE_INTERRUPTS
val = fdt_getprop(fdt, node, "interrupts", &len);
if (val != NULL && len >= 8) {
uint32_t cpu_val[2];
cpu_val[1] = fdt32_to_cpu(val[1]);
ctx->irq = bsp_fdt_map_intr(cpu_val, 2);
}
ctx->irq = imx_get_irq_of_node(fdt, node, 0);
#endif
}

View File

@@ -41,6 +41,12 @@ extern "C" {
void arm_generic_timer_get_config(uint32_t *frequency, uint32_t *irq);
rtems_vector_number imx_get_irq_of_node(
const void *fdt,
int node,
size_t index
);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@@ -21,9 +21,28 @@
#include <libfdt.h>
#define MAGIC_IRQ_OFFSET 32
rtems_vector_number imx_get_irq_of_node(
const void *fdt,
int node,
size_t index
)
{
int len;
const uint32_t *val;
val = fdt_getprop(fdt, node, "interrupts", &len);
if (val == NULL || len < (int) ((index + 1) * 12)) {
return UINT32_MAX;
}
return fdt32_to_cpu(val[index * 3 + 1]) + MAGIC_IRQ_OFFSET;
}
uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
{
return intr[1] + 32;
return intr[1] + MAGIC_IRQ_OFFSET;
}
void arm_generic_timer_get_config(
@@ -46,13 +65,8 @@ void arm_generic_timer_get_config(
bsp_fatal(IMX_FATAL_GENERIC_TIMER_FREQUENCY);
}
val = fdt_getprop(fdt, node, "interrupts", &len);
if (val != NULL && len >= 8) {
/* FIXME: Figure out how Linux gets a proper IRQ number */
*irq = 16 + fdt32_to_cpu(val[1]);
} else {
bsp_fatal(IMX_FATAL_GENERIC_TIMER_IRQ);
}
/* FIXME: Figure out how Linux gets a proper IRQ number */
*irq = imx_get_irq_of_node(fdt, node, 0) - 16;
}
void bsp_start(void)

View File

@@ -137,8 +137,7 @@ typedef enum {
ATSAM_FATAL_PIO_CONFIGURE_IT,
/* i.MX fatal codes */
IMX_FATAL_GENERIC_TIMER_FREQUENCY = BSP_FATAL_CODE_BLOCK(12),
IMX_FATAL_GENERIC_TIMER_IRQ
IMX_FATAL_GENERIC_TIMER_FREQUENCY = BSP_FATAL_CODE_BLOCK(12)
} bsp_fatal_code;
RTEMS_NO_RETURN static inline void