blob: a79d2fc2b863f1e6199c0605b90e489e261c54d4 [file] [log] [blame]
Michael Bohan39d6fbd2012-01-05 14:32:59 -08001/* Copyright (c) 2012, Code Aurora Forum. 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#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 */
55int qpnpint_register_controller(unsigned int busno,
56 struct qpnp_local_int *li_cb);
57
58/**
59 * qpnpint_handle_irq - Main interrupt handling routine
60 *
61 * Pass a PMIC Arbiter interrupt to Linux.
62 */
63int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl,
64 struct qpnp_irq_spec *spec);
65#else
66static inline int __init qpnpint_of_init(struct device_node *node,
67 struct device_node *parent)
68{
69 return -ENXIO;
70}
71static inline int qpnpint_register_controller(unsigned int busno,
72 struct qpnp_local_int *li_cb)
73{
74 return -ENXIO;
75}
76
77static inline int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl,
78 struct qpnp_irq_spec *spec)
79{
80 return -ENXIO;
81}
82#endif /* CONFIG_MSM_QPNP_INT */
83#endif /* QPNPINT_H */