summaryrefslogtreecommitdiff
path: root/components/drivers/ofw
diff options
context:
space:
mode:
authorzms123456 <[email protected]>2024-02-29 09:39:56 +0800
committerGitHub <[email protected]>2024-02-29 09:39:56 +0800
commit195f94ef1dc9ae48de16902e2ff1646ce0cffb57 (patch)
treefa8edaa56c1c8b25cb2ba5e350f02dd41e39647a /components/drivers/ofw
parent3816d9fba416338eb626c1d9a560c2a23391ba4b (diff)
[components][drivers]add pic-gic (#8388)
Diffstat (limited to 'components/drivers/ofw')
-rw-r--r--components/drivers/ofw/SConscript3
-rwxr-xr-xcomponents/drivers/ofw/irq.c26
2 files changed, 27 insertions, 2 deletions
diff --git a/components/drivers/ofw/SConscript b/components/drivers/ofw/SConscript
index d878c0c64a..9fb95643d0 100644
--- a/components/drivers/ofw/SConscript
+++ b/components/drivers/ofw/SConscript
@@ -11,6 +11,9 @@ CPPPATH = [cwd, cwd + '/../include']
src = Glob('*.c')
+if GetDepend('RT_USING_PIC') == False:
+ SrcRemove(src, ['irq.c'])
+
group = DefineGroup('DeviceDrivers', src, depend = [''], CPPPATH = CPPPATH)
for d in list:
diff --git a/components/drivers/ofw/irq.c b/components/drivers/ofw/irq.c
index 6460c5e19f..be843d6cb7 100755
--- a/components/drivers/ofw/irq.c
+++ b/components/drivers/ofw/irq.c
@@ -196,6 +196,9 @@ static rt_err_t ofw_parse_irq_map(struct rt_ofw_node *np, struct rt_ofw_cell_arg
break;
}
+ map_len = sizeof(fdt32_t);
+ map_mask_len = sizeof(fdt32_t);
+
err = -RT_EINVAL;
addr = irq_args->data;
@@ -491,7 +494,7 @@ rt_err_t rt_ofw_parse_irq_cells(struct rt_ofw_node *np, int index, struct rt_ofw
struct rt_ofw_node *rt_ofw_find_irq_parent(struct rt_ofw_node *np, int *out_interrupt_cells)
{
- rt_ofw_foreach_parent_node(np)
+ for (np = rt_ofw_node_get(np); np; np = rt_ofw_get_next_parent(np))
{
rt_phandle ic_phandle;
@@ -523,7 +526,7 @@ static int ofw_map_irq(struct rt_ofw_cell_args *irq_args)
{
int irq;
struct rt_ofw_node *ic_np = irq_args->data;
- struct rt_pic *pic = rt_ofw_data(ic_np);
+ struct rt_pic *pic = rt_pic_dynamic_cast(rt_ofw_data(ic_np));
/* args.data is "interrupt-controller" */
if (pic)
@@ -611,7 +614,26 @@ int rt_ofw_get_irq(struct rt_ofw_node *np, int index)
if (irq >= 0)
{
+ rt_phandle cpu_phandle;
+
irq = ofw_map_irq(&irq_args);
+
+ if (irq >= 0 && !rt_ofw_prop_read_u32_index(np, "interrupt-affinity", index, &cpu_phandle))
+ {
+ rt_uint64_t cpuid = rt_ofw_get_cpu_id(rt_ofw_find_node_by_phandle(cpu_phandle));
+
+ if ((rt_int64_t)cpuid >= 0)
+ {
+ RT_DECLARE_BITMAP(affinity, RT_CPUS_NR) = { 0 };
+
+ rt_bitmap_set_bit(affinity, cpuid);
+
+ if (rt_pic_irq_set_affinity(irq, affinity) == -RT_ENOSYS)
+ {
+ LOG_W("%s irq affinity init fail", np->full_name);
+ }
+ }
+ }
}
}
else