blob: 2b862160e9fec93737635173ed599ca3200f3257 [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);
74#else
75static inline int __init qpnpint_of_init(struct device_node *node,
76 struct device_node *parent)
77{
78 return -ENXIO;
79}
Michael Bohanbb6b30f2012-06-01 13:33:51 -070080
81static inline int qpnpint_register_controller(struct device_node *node,
82 struct spmi_controller *ctrl,
83 struct qpnp_local_int *li_cb)
84
Michael Bohan39d6fbd2012-01-05 14:32:59 -080085{
86 return -ENXIO;
87}
88
Michael Bohan0435bd62013-02-26 15:29:22 -080089static inline int qpnpint_unregister_controller(struct device_node *node)
90
91{
92 return -ENXIO;
93}
94
Michael Bohan39d6fbd2012-01-05 14:32:59 -080095static 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 */