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); |
| 74 | #else |
| 75 | static inline int __init qpnpint_of_init(struct device_node *node, |
| 76 | struct device_node *parent) |
| 77 | { |
| 78 | return -ENXIO; |
| 79 | } |
Michael Bohan | bb6b30f | 2012-06-01 13:33:51 -0700 | [diff] [blame] | 80 | |
| 81 | static inline int qpnpint_register_controller(struct device_node *node, |
| 82 | struct spmi_controller *ctrl, |
| 83 | struct qpnp_local_int *li_cb) |
| 84 | |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 85 | { |
| 86 | return -ENXIO; |
| 87 | } |
| 88 | |
Michael Bohan | 0435bd6 | 2013-02-26 15:29:22 -0800 | [diff] [blame^] | 89 | static inline int qpnpint_unregister_controller(struct device_node *node) |
| 90 | |
| 91 | { |
| 92 | return -ENXIO; |
| 93 | } |
| 94 | |
Michael Bohan | 39d6fbd | 2012-01-05 14:32:59 -0800 | [diff] [blame] | 95 | static inline int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl, |
| 96 | struct qpnp_irq_spec *spec) |
| 97 | { |
| 98 | return -ENXIO; |
| 99 | } |
| 100 | #endif /* CONFIG_MSM_QPNP_INT */ |
| 101 | #endif /* QPNPINT_H */ |