source: rtems/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c @ d548318

5
Last change on this file since d548318 was d548318, checked in by Pavel Pisa <pisa@…>, on 07/23/16 at 10:07:10

arm/raspberrypi: remove duplicate setup of IRQ handler in the main ARM exception table.

Exception table setup is processed by common CPU architecture support.
For ARM architecture, it can be found in the file

rtems/c/src/lib/libbsp/arm/shared/start/start.S

and ends by bsp_vector_table_copy_done label.
The actual tabel content can be found at

bsp_start_vector_table_begin

For ARMv7-A and even other variant with hypervisor mode support,
it is even not necessary to copy table to address 0 at all
because CP15 register can be used to specify alternative
table start address

arm_cp15_set_vector_base_address(&)bsp_start_vector_table_begin;

ARMv7-M have register to set exception table base as well.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/**
2 * @file irq.c
3 *
4 * @ingroup raspberrypi_interrupt
5 *
6 * @brief Interrupt support.
7 */
8
9/*
10 * Copyright (c) 2014 Andre Marques <andre.lousa.marques at gmail.com>
11 *
12 * Copyright (c) 2009
13 * embedded brains GmbH
14 * Obere Lagerstr. 30
15 * D-82178 Puchheim
16 * Germany
17 * <rtems@embedded-brains.de>
18 *
19 * The license and distribution terms for this file may be
20 * found in the file LICENSE in this distribution or at
21 * http://www.rtems.org/license/LICENSE.
22 */
23
24#include <rtems/score/armv4.h>
25
26#include <bsp.h>
27#include <bsp/irq.h>
28#include <bsp/irq-generic.h>
29#include <bsp/raspberrypi.h>
30#include <bsp/linker-symbols.h>
31#include <bsp/mmu.h>
32#include <rtems/bspIo.h>
33
34/*
35** Determine the source of the interrupt and dispatch the correct handler.
36*/
37void bsp_interrupt_dispatch(void)
38{
39  rtems_vector_number vector = 255;
40
41  /* ARM timer */
42  if ( BCM2835_REG(BCM2835_IRQ_BASIC) & 0x1 )
43  {
44      vector = BCM2835_IRQ_ID_TIMER_0;
45  }
46  /* UART 0 */
47  else if ( BCM2835_REG(BCM2835_IRQ_BASIC) & BCM2835_BIT(19) )
48  {
49      vector = BCM2835_IRQ_ID_UART;
50  }
51  /* GPIO 0*/
52  else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(17) )
53  {
54      vector = BCM2835_IRQ_ID_GPIO_0;
55  }
56  else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(18) )
57  {
58      vector = BCM2835_IRQ_ID_GPIO_1;
59  }
60  else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(19) )
61  {
62      vector = BCM2835_IRQ_ID_GPIO_2;
63  }
64  else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(20) )
65  {
66      vector = BCM2835_IRQ_ID_GPIO_3;
67  }
68  /* I2C */
69  else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(21) )
70  {
71      vector = BCM2835_IRQ_ID_I2C;
72  }
73  /* SPI */
74  else if ( BCM2835_REG(BCM2835_IRQ_PENDING2) & BCM2835_BIT(22) )
75  {
76      vector = BCM2835_IRQ_ID_SPI;
77  }
78  /* USB */
79  else if ( BCM2835_REG(BCM2835_IRQ_PENDING1) & BCM2835_BIT(9) )
80  {
81      vector = BCM2835_IRQ_ID_USB;
82  }
83
84  if ( vector < 255 )
85  {
86      bsp_interrupt_handler_dispatch(vector);
87  }
88}
89
90rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
91{
92  rtems_interrupt_level  level;
93
94  rtems_interrupt_disable(level);
95 
96  /* ARM Timer */
97  if ( vector == BCM2835_IRQ_ID_TIMER_0 )
98  {
99      BCM2835_REG(BCM2835_IRQ_ENABLE_BASIC) = 0x1;
100  }
101  /* UART 0 */
102  else if ( vector == BCM2835_IRQ_ID_UART )
103  {
104      BCM2835_REG(BCM2835_IRQ_ENABLE2) =  BCM2835_BIT(25);
105  }
106  /* GPIO 0 */
107  else if ( vector == BCM2835_IRQ_ID_GPIO_0 )
108  {
109      BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(17);
110  }
111  /* GPIO 1 */
112  else if ( vector == BCM2835_IRQ_ID_GPIO_1 )
113  {
114      BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(18);
115  }
116  /* GPIO 2 */
117  else if ( vector == BCM2835_IRQ_ID_GPIO_2 )
118  {
119      BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(19);
120  }
121  /* GPIO 3 */
122  else if ( vector == BCM2835_IRQ_ID_GPIO_3 )
123  {
124      BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(20);
125  }
126  /* I2C */
127  else if ( vector == BCM2835_IRQ_ID_I2C )
128  {
129      BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(21);
130  }
131  /* SPI */
132  else if ( vector == BCM2835_IRQ_ID_SPI )
133  {
134      BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(22);
135  }
136  /* USB */
137  else if ( vector == BCM2835_IRQ_ID_USB )
138  {
139      BCM2835_REG(BCM2835_IRQ_ENABLE1) = BCM2835_BIT(9);
140  }
141 
142  rtems_interrupt_enable(level);
143
144  return RTEMS_SUCCESSFUL;
145}
146
147rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
148{
149  rtems_interrupt_level level;
150
151  rtems_interrupt_disable(level);
152
153  if ( vector == BCM2835_IRQ_ID_TIMER_0 )
154  {
155      BCM2835_REG(BCM2835_IRQ_DISABLE_BASIC) = 0x1;
156  }
157  else if ( vector == BCM2835_IRQ_ID_UART )
158  {
159      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(25);
160  }
161  /* GPIO 0 */
162  else if ( vector == BCM2835_IRQ_ID_GPIO_0 )
163  {
164      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(17);
165  }
166  /* GPIO 1 */
167  else if ( vector == BCM2835_IRQ_ID_GPIO_1 )
168  {
169      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(18);
170  }
171  /* GPIO 2 */
172  else if ( vector == BCM2835_IRQ_ID_GPIO_2 )
173  {
174      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(19);
175  }
176  /* GPIO 3 */
177  else if ( vector == BCM2835_IRQ_ID_GPIO_3 )
178  {
179      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(20);
180  }
181  /* I2C */
182  else if ( vector == BCM2835_IRQ_ID_I2C )
183  {
184      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(21);
185  }
186  /* SPI */
187  else if ( vector == BCM2835_IRQ_ID_SPI )
188  {
189      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(22);
190  }
191  /* USB */
192  else if ( vector == BCM2835_IRQ_ID_USB )
193  {
194      BCM2835_REG(BCM2835_IRQ_DISABLE1) = BCM2835_BIT(9);
195  }
196
197  rtems_interrupt_enable(level);
198
199  return RTEMS_SUCCESSFUL;
200}
201
202void bsp_interrupt_handler_default(rtems_vector_number vector)
203{
204    printk("spurious interrupt: %lu\n", vector);
205}
206
207rtems_status_code bsp_interrupt_facility_initialize(void)
208{
209   BCM2835_REG(BCM2835_IRQ_DISABLE1) = 0xffffffff;
210   BCM2835_REG(BCM2835_IRQ_DISABLE2) = 0xffffffff;
211   BCM2835_REG(BCM2835_IRQ_DISABLE_BASIC) = 0xffffffff;
212   BCM2835_REG(BCM2835_IRQ_FIQ_CTRL) = 0;
213   return RTEMS_SUCCESSFUL;
214}
Note: See TracBrowser for help on using the repository browser.