Re: [PATCH] bsp/raspberry: Add a bsp_fdt_map_intr().

2020-04-04 Thread Gedare Bloom
On Sat, Apr 4, 2020 at 9:14 AM Christian Mauderer  wrote:
>
> On 04/04/2020 17:04, Gedare Bloom wrote:
> > On Sat, Apr 4, 2020 at 4:57 AM Christian Mauderer  
> > wrote:
> >>
> >> From: Christian Mauderer 
> >>
> >> Fixes #3903
> >> ---
> >>  bsps/arm/raspberrypi/include/bsp/irq.h |  2 ++
> >>  bsps/arm/raspberrypi/start/bspstart.c  | 23 +++
> >>  2 files changed, 25 insertions(+)
> >>
> >> diff --git a/bsps/arm/raspberrypi/include/bsp/irq.h 
> >> b/bsps/arm/raspberrypi/include/bsp/irq.h
> >> index 6a9d05cba6..6758094519 100644
> >> --- a/bsps/arm/raspberrypi/include/bsp/irq.h
> >> +++ b/bsps/arm/raspberrypi/include/bsp/irq.h
> >> @@ -35,6 +35,8 @@
> >>
> >>  #define BCM2835_INTC_TOTAL_IRQ   64 + 8
> >>
> >> +#define BCM2835_IRQ_SET1_MIN 0
> >> +#define BCM2835_IRQ_SET2_MIN 32
> >>
> >>  #define BCM2835_IRQ_ID_GPU_TIMER_M0  0
> >>  #define BCM2835_IRQ_ID_GPU_TIMER_M1  1
> >> diff --git a/bsps/arm/raspberrypi/start/bspstart.c 
> >> b/bsps/arm/raspberrypi/start/bspstart.c
> >> index 49896e4d47..89fe8707f1 100644
> >> --- a/bsps/arm/raspberrypi/start/bspstart.c
> >> +++ b/bsps/arm/raspberrypi/start/bspstart.c
> >> @@ -101,6 +101,29 @@ void *raspberrypi_get_reg_of_node(const void *fdt, 
> >> int node)
> >>return (BUS_TO_PHY((void *) fdt32_to_cpu(val[0])));
> >>  }
> >>
> >> +#ifdef BSP_FDT_IS_SUPPORTED
> >> +uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
> >> +{
> >> +  uint32_t controller = intr[0];
> >> +  uint32_t source = intr[1];
> >> +
> >> +  switch(controller) {
> > should have spaces here:
> >   switch ( controller ) {
>
> I'll fix that before pushing.
>
> >
> >> +case 0:
> >> +return source + BCM2835_IRQ_ID_BASIC_BASE_ID;
> >> +break;
> >> +case 1:
> >> +return source + BCM2835_IRQ_SET1_MIN;
> >> +break;
> >> +case 2:
> >> +return source + BCM2835_IRQ_SET2_MIN;
> >> +break;
> >> +default:
> >> +return (uint32_t)(-1);
> > Not my favorite thing to see. Is 0 an ok error condition?
> >
> > It can be pushed either way
>
> 0 is a valid interrupt. I wanted one that isn't valid as an error value
> so that some function throws an error (for example there are some checks
> during bsp_interrupt_vector_enable / _disable for this BSP).
>
> If you prefer, I could use one of the following:
>
> * (BSP_INTERRUPT_VECTOR_MAX + 1)
> * BSP_IRQ_COUNT
> * UINT32_MAX
> * BSP_INTERRUPT_VECTOR_INVALID and set that define to for example UINT32_MAX
>
It would be nice to have something that could be used consistently,
since this is a shared low-level interface. I like
BSP_INTERRUPT_VECTOR_INVALID idea.

> Best regards
>
> Christian
>
> >
> >> +break;
> >> +  }
> >> +}
> >> +#endif /* BSP_FDT_IS_SUPPORTED */
> >> +
> >>  void bsp_start(void)
> >>  {
> >>  bcm2835_get_board_spec_entries spec = { 0 };
> >> --
> >> 2.25.1
> >>
> >> ___
> >> devel mailing list
> >> devel@rtems.org
> >> http://lists.rtems.org/mailman/listinfo/devel
> >
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] bsp/raspberry: Add a bsp_fdt_map_intr().

2020-04-04 Thread Christian Mauderer
On 04/04/2020 17:04, Gedare Bloom wrote:
> On Sat, Apr 4, 2020 at 4:57 AM Christian Mauderer  wrote:
>>
>> From: Christian Mauderer 
>>
>> Fixes #3903
>> ---
>>  bsps/arm/raspberrypi/include/bsp/irq.h |  2 ++
>>  bsps/arm/raspberrypi/start/bspstart.c  | 23 +++
>>  2 files changed, 25 insertions(+)
>>
>> diff --git a/bsps/arm/raspberrypi/include/bsp/irq.h 
>> b/bsps/arm/raspberrypi/include/bsp/irq.h
>> index 6a9d05cba6..6758094519 100644
>> --- a/bsps/arm/raspberrypi/include/bsp/irq.h
>> +++ b/bsps/arm/raspberrypi/include/bsp/irq.h
>> @@ -35,6 +35,8 @@
>>
>>  #define BCM2835_INTC_TOTAL_IRQ   64 + 8
>>
>> +#define BCM2835_IRQ_SET1_MIN 0
>> +#define BCM2835_IRQ_SET2_MIN 32
>>
>>  #define BCM2835_IRQ_ID_GPU_TIMER_M0  0
>>  #define BCM2835_IRQ_ID_GPU_TIMER_M1  1
>> diff --git a/bsps/arm/raspberrypi/start/bspstart.c 
>> b/bsps/arm/raspberrypi/start/bspstart.c
>> index 49896e4d47..89fe8707f1 100644
>> --- a/bsps/arm/raspberrypi/start/bspstart.c
>> +++ b/bsps/arm/raspberrypi/start/bspstart.c
>> @@ -101,6 +101,29 @@ void *raspberrypi_get_reg_of_node(const void *fdt, int 
>> node)
>>return (BUS_TO_PHY((void *) fdt32_to_cpu(val[0])));
>>  }
>>
>> +#ifdef BSP_FDT_IS_SUPPORTED
>> +uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
>> +{
>> +  uint32_t controller = intr[0];
>> +  uint32_t source = intr[1];
>> +
>> +  switch(controller) {
> should have spaces here:
>   switch ( controller ) {

I'll fix that before pushing.

> 
>> +case 0:
>> +return source + BCM2835_IRQ_ID_BASIC_BASE_ID;
>> +break;
>> +case 1:
>> +return source + BCM2835_IRQ_SET1_MIN;
>> +break;
>> +case 2:
>> +return source + BCM2835_IRQ_SET2_MIN;
>> +break;
>> +default:
>> +return (uint32_t)(-1);
> Not my favorite thing to see. Is 0 an ok error condition?
> 
> It can be pushed either way

0 is a valid interrupt. I wanted one that isn't valid as an error value
so that some function throws an error (for example there are some checks
during bsp_interrupt_vector_enable / _disable for this BSP).

If you prefer, I could use one of the following:

* (BSP_INTERRUPT_VECTOR_MAX + 1)
* BSP_IRQ_COUNT
* UINT32_MAX
* BSP_INTERRUPT_VECTOR_INVALID and set that define to for example UINT32_MAX

Best regards

Christian

> 
>> +break;
>> +  }
>> +}
>> +#endif /* BSP_FDT_IS_SUPPORTED */
>> +
>>  void bsp_start(void)
>>  {
>>  bcm2835_get_board_spec_entries spec = { 0 };
>> --
>> 2.25.1
>>
>> ___
>> devel mailing list
>> devel@rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] bsp/raspberry: Add a bsp_fdt_map_intr().

2020-04-04 Thread Gedare Bloom
On Sat, Apr 4, 2020 at 4:57 AM Christian Mauderer  wrote:
>
> From: Christian Mauderer 
>
> Fixes #3903
> ---
>  bsps/arm/raspberrypi/include/bsp/irq.h |  2 ++
>  bsps/arm/raspberrypi/start/bspstart.c  | 23 +++
>  2 files changed, 25 insertions(+)
>
> diff --git a/bsps/arm/raspberrypi/include/bsp/irq.h 
> b/bsps/arm/raspberrypi/include/bsp/irq.h
> index 6a9d05cba6..6758094519 100644
> --- a/bsps/arm/raspberrypi/include/bsp/irq.h
> +++ b/bsps/arm/raspberrypi/include/bsp/irq.h
> @@ -35,6 +35,8 @@
>
>  #define BCM2835_INTC_TOTAL_IRQ   64 + 8
>
> +#define BCM2835_IRQ_SET1_MIN 0
> +#define BCM2835_IRQ_SET2_MIN 32
>
>  #define BCM2835_IRQ_ID_GPU_TIMER_M0  0
>  #define BCM2835_IRQ_ID_GPU_TIMER_M1  1
> diff --git a/bsps/arm/raspberrypi/start/bspstart.c 
> b/bsps/arm/raspberrypi/start/bspstart.c
> index 49896e4d47..89fe8707f1 100644
> --- a/bsps/arm/raspberrypi/start/bspstart.c
> +++ b/bsps/arm/raspberrypi/start/bspstart.c
> @@ -101,6 +101,29 @@ void *raspberrypi_get_reg_of_node(const void *fdt, int 
> node)
>return (BUS_TO_PHY((void *) fdt32_to_cpu(val[0])));
>  }
>
> +#ifdef BSP_FDT_IS_SUPPORTED
> +uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
> +{
> +  uint32_t controller = intr[0];
> +  uint32_t source = intr[1];
> +
> +  switch(controller) {
should have spaces here:
  switch ( controller ) {

> +case 0:
> +return source + BCM2835_IRQ_ID_BASIC_BASE_ID;
> +break;
> +case 1:
> +return source + BCM2835_IRQ_SET1_MIN;
> +break;
> +case 2:
> +return source + BCM2835_IRQ_SET2_MIN;
> +break;
> +default:
> +return (uint32_t)(-1);
Not my favorite thing to see. Is 0 an ok error condition?

It can be pushed either way

> +break;
> +  }
> +}
> +#endif /* BSP_FDT_IS_SUPPORTED */
> +
>  void bsp_start(void)
>  {
>  bcm2835_get_board_spec_entries spec = { 0 };
> --
> 2.25.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] bsp/raspberry: Add a bsp_fdt_map_intr().

2020-04-04 Thread Christian Mauderer
From: Christian Mauderer 

Fixes #3903
---
 bsps/arm/raspberrypi/include/bsp/irq.h |  2 ++
 bsps/arm/raspberrypi/start/bspstart.c  | 23 +++
 2 files changed, 25 insertions(+)

diff --git a/bsps/arm/raspberrypi/include/bsp/irq.h 
b/bsps/arm/raspberrypi/include/bsp/irq.h
index 6a9d05cba6..6758094519 100644
--- a/bsps/arm/raspberrypi/include/bsp/irq.h
+++ b/bsps/arm/raspberrypi/include/bsp/irq.h
@@ -35,6 +35,8 @@
 
 #define BCM2835_INTC_TOTAL_IRQ   64 + 8
 
+#define BCM2835_IRQ_SET1_MIN 0
+#define BCM2835_IRQ_SET2_MIN 32
 
 #define BCM2835_IRQ_ID_GPU_TIMER_M0  0
 #define BCM2835_IRQ_ID_GPU_TIMER_M1  1
diff --git a/bsps/arm/raspberrypi/start/bspstart.c 
b/bsps/arm/raspberrypi/start/bspstart.c
index 49896e4d47..89fe8707f1 100644
--- a/bsps/arm/raspberrypi/start/bspstart.c
+++ b/bsps/arm/raspberrypi/start/bspstart.c
@@ -101,6 +101,29 @@ void *raspberrypi_get_reg_of_node(const void *fdt, int 
node)
   return (BUS_TO_PHY((void *) fdt32_to_cpu(val[0])));
 }
 
+#ifdef BSP_FDT_IS_SUPPORTED
+uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
+{
+  uint32_t controller = intr[0];
+  uint32_t source = intr[1];
+
+  switch(controller) {
+case 0:
+return source + BCM2835_IRQ_ID_BASIC_BASE_ID;
+break;
+case 1:
+return source + BCM2835_IRQ_SET1_MIN;
+break;
+case 2:
+return source + BCM2835_IRQ_SET2_MIN;
+break;
+default:
+return (uint32_t)(-1);
+break;
+  }
+}
+#endif /* BSP_FDT_IS_SUPPORTED */
+
 void bsp_start(void)
 {
 bcm2835_get_board_spec_entries spec = { 0 };
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel