aboutsummaryrefslogtreecommitdiff
path: root/include/linux/irqchip/qpnp-int.h
blob: 614165ebf8b374d5e0ced134f2acfe3c3673c874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef QPNPINT_H
#define QPNPINT_H

#include <linux/spmi.h>

struct qpnp_irq_spec {
	uint8_t slave; /* 0-15 */
	uint8_t per; /* 0-255 */
	uint8_t irq; /* 0-7 */
};

struct qpnp_local_int {
	 /* mask - Invoke PMIC Arbiter local mask handler */
	int (*mask)(struct spmi_controller *spmi_ctrl,
		    struct qpnp_irq_spec *spec,
		    uint32_t priv_d);
	 /* unmask - Invoke PMIC Arbiter local unmask handler */
	int (*unmask)(struct spmi_controller *spmi_ctrl,
		      struct qpnp_irq_spec *spec,
		      uint32_t priv_d);
	/* register_priv_data - Return per irq priv data */
	int (*register_priv_data)(struct spmi_controller *spmi_ctrl,
				  struct qpnp_irq_spec *spec,
				  uint32_t *priv_d);
};

#ifdef CONFIG_MSM_QPNP_INT
/**
 * qpnpint_of_init() - Device Tree irq initialization
 *
 * Standard Device Tree init routine to be called from
 * of_irq_init().
 */
int __init qpnpint_of_init(struct device_node *node,
			   struct device_node *parent);

/**
 * qpnpint_register_controller() - Register local interrupt callbacks
 *
 * Used by the PMIC Arbiter driver or equivalent to register
 * callbacks for interrupt events.
 */
int qpnpint_register_controller(struct device_node *node,
				struct spmi_controller *ctrl,
				struct qpnp_local_int *li_cb);

/**
 * qpnpint_unregister_controller() - Unregister local interrupt callbacks
 *
 * Used by the PMIC Arbiter driver or equivalent to unregister
 * callbacks for interrupt events.
 */
int qpnpint_unregister_controller(struct device_node *node);

/**
 * qpnpint_handle_irq - Main interrupt handling routine
 *
 * Pass a PMIC Arbiter interrupt to Linux.
 */
int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl,
		       struct qpnp_irq_spec *spec);

/**
 * qpnpint_show_irq - Prints the Linux interrupt number
 *
 * Pass a PMIC Arbiter interrupt to Linux.
 */
int qpnpint_show_irq(struct spmi_controller *spmi_ctrl,
		       struct qpnp_irq_spec *spec);

#ifdef CONFIG_MSM_SHOW_RESUME_IRQ
extern int msm_show_resume_irq_mask;
static inline bool qpnpint_show_resume_irq(void)
{
	return msm_show_resume_irq_mask;
}
#else
static inline bool qpnpint_show_resume_irq(void)
{
	return false;
}
#endif

#else
static inline int __init qpnpint_of_init(struct device_node *node,
				  struct device_node *parent)
{
	return -ENXIO;
}

static inline int qpnpint_register_controller(struct device_node *node,
					      struct spmi_controller *ctrl,
					      struct qpnp_local_int *li_cb)
{
	return -ENXIO;
}

static inline int qpnpint_unregister_controller(struct device_node *node)
{
	return -ENXIO;
}

static inline int qpnpint_handle_irq(struct spmi_controller *spmi_ctrl,
		       struct qpnp_irq_spec *spec)
{
	return -ENXIO;
}
int qpnpint_show_irq(struct spmi_controller *spmi_ctrl,
		       struct qpnp_irq_spec *spec)
{
	return -ENXIO;
}

static inline bool qpnpint_show_resume_irq(void)
{
	return false;
}
#endif /* CONFIG_MSM_QPNP_INT */
#endif /* QPNPINT_H */