blob: 1f31ea5421be2b2aa781f660d4ccfe0fb4087df0 [file] [log] [blame]
Michael Bohan0435bd62013-02-26 15:29:22 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Michael Bohan39d6fbd2012-01-05 14:32:59 -08002 *
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
18struct qpnp_irq_spec {
19 uint8_t slave; /* 0-15 */
20 uint8_t per; /* 0-255 */
21 uint8_t irq; /* 0-7 */
22};
23
24struct 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 */
46int __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 Bohanbb6b30f2012-06-01 13:33:51 -070055int qpnpint_register_controller(struct device_node *node,
56 struct spmi_controller *ctrl,
Michael Bohan39d6fbd2012-01-05 14:32:59 -080057 struct qpnp_local_int *li_cb);
58
59/**
Michael Bohan0435bd62013-02-26 15:29:22 -080060 * 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 */
65int qpnpint_unregister_controller(struct device_node *node);
66
67/**
Michael Bohan39d6fbd2012-01-05 14:32:59 -080068 * qpnpint_handle_irq - Main interrupt handling routine
69 *
70 * Pass a PMIC Arbiter interrupt to Linux.
71 */
72int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl,
73 struct qpnp_irq_spec *spec);
Abhijeet Dharmapurikared34f4b2013-08-09 18:44:13 -070074
75/**
76 * qpnpint_show_irq - Prints the Linux interrupt number
77 *
78 * Pass a PMIC Arbiter interrupt to Linux.
79 */
80int qpnpint_show_irq(struct spmi_controller *spmi_ctrl,
81 struct qpnp_irq_spec *spec);
82
83#ifdef CONFIG_MSM_SHOW_RESUME_IRQ
84extern int msm_show_resume_irq_mask;
85static inline bool qpnpint_show_resume_irq(void)
86{
87 return msm_show_resume_irq_mask;
88}
89#else
90static inline bool qpnpint_show_resume_irq(void)
91{
92 return false;
93}
94#endif
95
Michael Bohan39d6fbd2012-01-05 14:32:59 -080096#else
97static inline int __init qpnpint_of_init(struct device_node *node,
98 struct device_node *parent)
99{
100 return -ENXIO;
101}
Michael Bohanbb6b30f2012-06-01 13:33:51 -0700102
103static inline int qpnpint_register_controller(struct device_node *node,
104 struct spmi_controller *ctrl,
105 struct qpnp_local_int *li_cb)
106
Michael Bohan39d6fbd2012-01-05 14:32:59 -0800107{
108 return -ENXIO;
109}
110
Michael Bohan0435bd62013-02-26 15:29:22 -0800111static inline int qpnpint_unregister_controller(struct device_node *node)
112
113{
114 return -ENXIO;
115}
116
Michael Bohan39d6fbd2012-01-05 14:32:59 -0800117static inline int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl,
118 struct qpnp_irq_spec *spec)
119{
120 return -ENXIO;
121}
Abhijeet Dharmapurikared34f4b2013-08-09 18:44:13 -0700122int qpnpint_show_irq(struct spmi_controller *spmi_ctrl,
123 struct qpnp_irq_spec *spec)
124{
125 return -ENXIO;
126}
127
128static inline bool qpnpint_show_resume_irq(void)
129{
130 return false;
131}
Michael Bohan39d6fbd2012-01-05 14:32:59 -0800132#endif /* CONFIG_MSM_QPNP_INT */
133#endif /* QPNPINT_H */