2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-12-04 23:09:39 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief ARCv2 Interrupt Unit device driver
|
|
|
|
*
|
2015-04-11 07:44:37 +08:00
|
|
|
* The ARCv2 interrupt unit has 16 allocated exceptions associated with
|
|
|
|
* vectors 0 to 15 and 240 interrupts associated with vectors 16 to 255.
|
|
|
|
* The interrupt unit is optional in the ARCv2-based processors. When
|
|
|
|
* building a processor, you can configure the processor to include an
|
|
|
|
* interrupt unit. The ARCv2 interrupt unit is highly programmable.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <nanokernel.h>
|
2015-05-29 01:56:47 +08:00
|
|
|
#include <arch/cpu.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
#include <board.h>
|
2015-10-15 07:04:48 +08:00
|
|
|
extern void *_VectorTable;
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Initialize the interrupt unit device driver
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* Initializes the interrupt unit device driver and the device
|
|
|
|
* itself.
|
|
|
|
*
|
|
|
|
* Interrupts are still locked at this point, so there is no need to protect
|
|
|
|
* the window between a write to IRQ_SELECT and subsequent writes to the
|
|
|
|
* selected IRQ's registers.
|
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
void _arc_v2_irq_unit_init(void)
|
|
|
|
{
|
|
|
|
int irq; /* the interrupt index */
|
|
|
|
|
2016-04-27 06:41:13 +08:00
|
|
|
for (irq = 16; irq < CONFIG_NUM_IRQS; irq++) {
|
2015-04-11 07:44:37 +08:00
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_SELECT, irq);
|
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_PRIORITY, 1);
|
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_ENABLE, _ARC_V2_INT_DISABLE);
|
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_TRIGGER, _ARC_V2_INT_LEVEL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Send EOI signal to interrupt unit
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* This routine sends an EOI (End Of Interrupt) signal to the interrupt unit
|
|
|
|
* to clear a pulse-triggered interrupt.
|
|
|
|
*
|
|
|
|
* Interrupts must be locked or the ISR operating at P0 when invoking this
|
|
|
|
* function.
|
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
void _arc_v2_irq_unit_int_eoi(int irq)
|
|
|
|
{
|
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_SELECT, irq);
|
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_PULSE_CANCEL, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Sets an IRQ line to level/pulse trigger
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* Sets the IRQ line <irq> to trigger an interrupt based on the level or the
|
|
|
|
* edge of the signal. Valid values for <trigger> are _ARC_V2_INT_LEVEL and
|
|
|
|
* _ARC_V2_INT_PULSE.
|
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
void _arc_v2_irq_unit_trigger_set(int irq, unsigned int trigger)
|
|
|
|
{
|
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_SELECT, irq);
|
|
|
|
_arc_v2_aux_reg_write(_ARC_V2_IRQ_TRIGGER, trigger);
|
|
|
|
}
|