Michael Bohan | 0435bd6 | 2013-02-26 15:29:22 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 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 | #ifndef QPNPINT_H |
| 14 | #define QPNPINT_H |
| 15 | |
| 16 | #include <linux/spmi.h> |
| 17 | |
| 18 | struct qpnp_irq_spec { |
| 19 | uint8_t slave; /* 0-15 */ |
| 20 | uint8_t per; /* 0-255 */ |
| 21 | uint8_t irq; /* 0-7 */ |
| 22 | }; |
| 23 | |
| 24 | struct qpnp_local_int { |
| 25 | /* mask - Invoke PMIC Arbiter local mask handler */ |
| 26 | int (*mask)(struct spmi_controller *spmi_ctrl, |
| 27 | struct qpnp_irq_spec *spec, |
| 28 | uint32_t priv_d); |
| 29 | /* unmask - Invoke PMIC Arbiter local unmask handler */ |
| 30 | int (*unmask)(struct spmi_controller *spmi_ctrl, |
| 31 | struct qpnp_irq_spec *spec, |
| 32 | uint32_t priv_d); |
| 33 | /* register_priv_data - Return per irq priv data */ |
| 34 | int (*register_priv_data)(struct spmi_controller *spmi_ctrl, |
| 35 | struct qpnp_irq_spec *spec, |
| 36 | uint32_t *priv_d); |
| 37 | }; |
| 38 | |
| 39 | #ifdef CONFIG_MSM_QPNP_INT |
| 40 | /** |
| 41 | * qpnpint_of_init() - Device Tree irq initialization |
| 42 | * |
| 43 | * Standard Device Tree init routine to be called from |
| 44 | * of_irq_init(). |
| 45 | */ |
| 46 | int __init qpnpint_of_init(struct device_node *node, |
| 47 | struct device_node *parent); |
| 48 | |
| 49 | /** |
| 50 | * qpnpint_register_controller() - Register local interrupt callbacks |
| 51 | * |
| 52 | * Used by the PMIC Arbiter driver or equivalent to register |
| 53 | * callbacks for interrupt events. |
| 54 | */ |
Michael Bohan | bb6b30f | 2012-06-01 13:33:51 -0700 | [diff] [blame] | 55 | int qpnpint_register_controller(struct device_node *node, |
| 56 | struct spmi_controller *ctrl, |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 57 | struct qpnp_local_int *li_cb); |
| 58 | |
| 59 | /** |
Michael Bohan | 0435bd6 | 2013-02-26 15:29:22 -0800 | [diff] [blame] | 60 | * qpnpint_unregister_controller() - Unregister local interrupt callbacks |
| 61 | * |
| 62 | * Used by the PMIC Arbiter driver or equivalent to unregister |
| 63 | * callbacks for interrupt events. |
| 64 | */ |
| 65 | int qpnpint_unregister_controller(struct device_node *node); |
| 66 | |
| 67 | /** |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 68 | * qpnpint_handle_irq - Main interrupt handling routine |
| 69 | * |
| 70 | * Pass a PMIC Arbiter interrupt to Linux. |
| 71 | */ |
| 72 | int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl, |
| 73 | struct qpnp_irq_spec *spec); |
Abhijeet Dharmapurikar | ed34f4b | 2013-08-09 18:44:13 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * qpnpint_show_irq - Prints the Linux interrupt number |
| 77 | * |
| 78 | * Pass a PMIC Arbiter interrupt to Linux. |
| 79 | */ |
| 80 | int qpnpint_show_irq(struct spmi_controller *spmi_ctrl, |
| 81 | struct qpnp_irq_spec *spec); |
| 82 | |
| 83 | #ifdef CONFIG_MSM_SHOW_RESUME_IRQ |
| 84 | extern int msm_show_resume_irq_mask; |
| 85 | static inline bool qpnpint_show_resume_irq(void) |
| 86 | { |
| 87 | return msm_show_resume_irq_mask; |
| 88 | } |
| 89 | #else |
| 90 | static inline bool qpnpint_show_resume_irq(void) |
| 91 | { |
| 92 | return false; |
| 93 | } |
| 94 | #endif |
| 95 | |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 96 | #else |
| 97 | static inline int __init qpnpint_of_init(struct device_node *node, |
| 98 | struct device_node *parent) |
| 99 | { |
| 100 | return -ENXIO; |
| 101 | } |
Michael Bohan | bb6b30f | 2012-06-01 13:33:51 -0700 | [diff] [blame] | 102 | |
| 103 | static inline int qpnpint_register_controller(struct device_node *node, |
| 104 | struct spmi_controller *ctrl, |
| 105 | struct qpnp_local_int *li_cb) |
| 106 | |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 107 | { |
| 108 | return -ENXIO; |
| 109 | } |
| 110 | |
Michael Bohan | 0435bd6 | 2013-02-26 15:29:22 -0800 | [diff] [blame] | 111 | static inline int qpnpint_unregister_controller(struct device_node *node) |
| 112 | |
| 113 | { |
| 114 | return -ENXIO; |
| 115 | } |
| 116 | |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 117 | static inline int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl, |
| 118 | struct qpnp_irq_spec *spec) |
| 119 | { |
| 120 | return -ENXIO; |
| 121 | } |
Abhijeet Dharmapurikar | ed34f4b | 2013-08-09 18:44:13 -0700 | [diff] [blame] | 122 | int qpnpint_show_irq(struct spmi_controller *spmi_ctrl, |
| 123 | struct qpnp_irq_spec *spec) |
| 124 | { |
| 125 | return -ENXIO; |
| 126 | } |
| 127 | |
| 128 | static inline bool qpnpint_show_resume_irq(void) |
| 129 | { |
| 130 | return false; |
| 131 | } |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 132 | #endif /* CONFIG_MSM_QPNP_INT */ |
| 133 | #endif /* QPNPINT_H */ |