Prasad Sodagudi | ed8df5b | 2012-09-28 13:49:59 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2012, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/slab.h> |
| 16 | #include <linux/irq.h> |
| 17 | #include <asm/fiq.h> |
| 18 | #include <asm/hardware/gic.h> |
| 19 | #include <asm/cacheflush.h> |
| 20 | #include <mach/irqs-8625.h> |
Taniya Das | ebc6a79 | 2012-10-18 14:57:29 +0530 | [diff] [blame] | 21 | #include <mach/socinfo.h> |
Prasad Sodagudi | ed8df5b | 2012-09-28 13:49:59 +0530 | [diff] [blame] | 22 | |
| 23 | #include "msm_watchdog.h" |
| 24 | |
| 25 | #define MODULE_NAME "MSM7K_FIQ" |
| 26 | |
| 27 | struct msm_watchdog_dump msm_dump_cpu_ctx; |
| 28 | static int fiq_counter; |
| 29 | void *msm7k_fiq_stack; |
| 30 | |
| 31 | /* Called from the FIQ asm handler */ |
| 32 | void msm7k_fiq_handler(void) |
| 33 | { |
| 34 | struct irq_data *d; |
| 35 | struct irq_chip *c; |
| 36 | |
| 37 | pr_info("Fiq is received %s\n", __func__); |
| 38 | fiq_counter++; |
| 39 | d = irq_get_irq_data(MSM8625_INT_A9_M2A_2); |
| 40 | c = irq_data_get_irq_chip(d); |
| 41 | c->irq_mask(d); |
| 42 | local_irq_disable(); |
| 43 | |
| 44 | /* Clear the IRQ from the ENABLE_SET */ |
| 45 | gic_clear_irq_pending(MSM8625_INT_A9_M2A_2); |
| 46 | local_irq_enable(); |
| 47 | flush_cache_all(); |
| 48 | outer_flush_all(); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | struct fiq_handler msm7k_fh = { |
| 53 | .name = MODULE_NAME, |
| 54 | }; |
| 55 | |
| 56 | static int __init msm_setup_fiq_handler(void) |
| 57 | { |
| 58 | int ret = 0; |
| 59 | |
| 60 | claim_fiq(&msm7k_fh); |
| 61 | set_fiq_handler(&msm7k_fiq_start, msm7k_fiq_length); |
| 62 | msm7k_fiq_stack = (void *)__get_free_pages(GFP_KERNEL, |
| 63 | THREAD_SIZE_ORDER); |
| 64 | if (msm7k_fiq_stack == NULL) { |
| 65 | pr_err("FIQ STACK SETUP IS NOT SUCCESSFUL\n"); |
| 66 | return -ENOMEM; |
| 67 | } |
| 68 | |
| 69 | fiq_set_type(MSM8625_INT_A9_M2A_2, IRQF_TRIGGER_RISING); |
| 70 | gic_set_irq_secure(MSM8625_INT_A9_M2A_2); |
| 71 | enable_irq(MSM8625_INT_A9_M2A_2); |
| 72 | pr_info("%s : msm7k fiq setup--done\n", __func__); |
| 73 | return ret; |
| 74 | } |
| 75 | |
| 76 | static int __init init7k_fiq(void) |
| 77 | { |
Utsab Bose | 4ed4ba1 | 2012-11-08 18:52:38 +0530 | [diff] [blame] | 78 | if (!cpu_is_msm8625() && !cpu_is_msm8625q()) |
Taniya Das | ebc6a79 | 2012-10-18 14:57:29 +0530 | [diff] [blame] | 79 | return 0; |
| 80 | |
Prasad Sodagudi | ed8df5b | 2012-09-28 13:49:59 +0530 | [diff] [blame] | 81 | if (msm_setup_fiq_handler()) |
| 82 | pr_err("MSM7K FIQ INIT FAILED\n"); |
| 83 | |
| 84 | return 0; |
| 85 | } |
| 86 | late_initcall(init7k_fiq); |