/*1* Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation; either version 2 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License along14* with this program; if not, write to the Free Software Foundation, Inc.,15* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.16*/1718#include <linux/kernel.h>19#include <linux/init.h>20#include <linux/irq.h>21#include <linux/io.h>2223#include <mach/mxs.h>24#include <mach/common.h>2526#define HW_ICOLL_VECTOR 0x000027#define HW_ICOLL_LEVELACK 0x001028#define HW_ICOLL_CTRL 0x002029#define HW_ICOLL_INTERRUPTn_SET(n) (0x0124 + (n) * 0x10)30#define HW_ICOLL_INTERRUPTn_CLR(n) (0x0128 + (n) * 0x10)31#define BM_ICOLL_INTERRUPTn_ENABLE 0x0000000432#define BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0 0x13334static void __iomem *icoll_base = MXS_IO_ADDRESS(MXS_ICOLL_BASE_ADDR);3536static void icoll_ack_irq(struct irq_data *d)37{38/*39* The Interrupt Collector is able to prioritize irqs.40* Currently only level 0 is used. So acking can use41* BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0 unconditionally.42*/43__raw_writel(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0,44icoll_base + HW_ICOLL_LEVELACK);45}4647static void icoll_mask_irq(struct irq_data *d)48{49__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,50icoll_base + HW_ICOLL_INTERRUPTn_CLR(d->irq));51}5253static void icoll_unmask_irq(struct irq_data *d)54{55__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,56icoll_base + HW_ICOLL_INTERRUPTn_SET(d->irq));57}5859static struct irq_chip mxs_icoll_chip = {60.irq_ack = icoll_ack_irq,61.irq_mask = icoll_mask_irq,62.irq_unmask = icoll_unmask_irq,63};6465void __init icoll_init_irq(void)66{67int i;6869/*70* Interrupt Collector reset, which initializes the priority71* for each irq to level 0.72*/73mxs_reset_block(icoll_base + HW_ICOLL_CTRL);7475for (i = 0; i < MXS_INTERNAL_IRQS; i++) {76irq_set_chip_and_handler(i, &mxs_icoll_chip, handle_level_irq);77set_irq_flags(i, IRQF_VALID);78}79}808182