-
Notifications
You must be signed in to change notification settings - Fork 0
/
axp-core.h
180 lines (159 loc) · 5.04 KB
/
axp-core.h
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* drivers/power/axp/axp-core.h
* (C) Copyright 2010-2016
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
* Pannan <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
*/
#ifndef AXP_CORE_H_
#define AXP_CORE_H_
#include <linux/interrupt.h>
//#include "aw_pm.h"
#include <linux/regulator/consumer.h>
#include <linux/module.h>
#include <linux/ctype.h>
#include "axp-charger.h"
#include "axp_depend.h"
#define AXP_REG_WIDTH (8)
#define AXP_ADD_WIDTH (8)
#define ABS(x) ((x) > 0 ? (x) : -(x))
#ifdef CONFIG_DUAL_AXP_USED
#define AXP_ONLINE_SUM (2)
#else
#define AXP_ONLINE_SUM (1)
#endif
enum AXP_REGMAP_TYPE {
AXP_REGMAP_I2C,
AXP_REGMAP_ARISC_RSB,
AXP_REGMAP_ARISC_TWI,
};
struct axp_regmap {
enum AXP_REGMAP_TYPE type;
struct i2c_client *client;
struct mutex lock;
#ifndef CONFIG_AXP_TWI_USED
spinlock_t spinlock;
#endif
u8 rsbaddr;
};
struct axp_regmap_irq {
irq_handler_t handler;
void *data;
};
struct axp_regmap_irq_chip {
const char *name;
unsigned int status_base;
unsigned int enable_base;
int num_regs;
};
struct axp_irq_chip_data {
struct mutex lock;
struct axp_regmap *map;
struct axp_regmap_irq_chip *chip;
struct axp_regmap_irq *irqs;
int num_irqs;
u64 irqs_enabled;
void (*wakeup_event)(void);
};
struct axp_dev {
struct device *dev;
struct axp_regmap *regmap;
int nr_cells;
struct mfd_cell *cells;
struct axp_irq_chip_data *irq_data;
int irq;
bool is_dummy;
bool is_slave;
struct list_head list;
int pmu_num;
};
struct axp_platform_ops {
s32 (*usb_det)(void);
s32 (*usb_vbus_output)(int);
//int (*cfg_pmux_para)(int, struct aw_pm_info *, int *);
const char * (*get_pmu_name)(void);
struct axp_dev * (*get_pmu_dev)(void);
int (*pmu_regulator_save)(void);
void (*pmu_regulator_restore)(void);
};
struct axp_interrupts {
char *name;
irq_handler_t isr;
};
struct axp_mfd_name_set {
char powerkey_name[32];
char charger_name[32];
char regulator_name[32];
char gpio_name[32];
};
struct axp_compatible_name_mapping {
char device_name[32];
struct axp_mfd_name_set mfd_name;
};
#define AXP_DUMP_ATTR(_name) \
{ \
.attr = { .name = #_name, .mode = 0644 }, \
.show = _name##_show, \
.store = _name##_store, \
}
enum {
AXP_SPLY = 1U << 0,
AXP_REGU = 1U << 1,
AXP_INT = 1U << 2,
AXP_CHG = 1U << 3,
AXP_MISC = 1U << 4,
};
enum {
AXP_NOT_SUSPEND = 1U << 0,
AXP_WAS_SUSPEND = 1U << 1,
AXP_SUSPEND_WITH_IRQ = 1U << 2,
};
#define AXP_DEBUG(level_mask, pmu_num, fmt, arg...) \
{ if (unlikely(axp_debug_mask & level_mask)) { \
printk("[%s] ", get_pmu_cur_name(pmu_num)); \
printk(fmt, ##arg); \
} \
}
struct axp_regmap *axp_regmap_init_i2c(struct device *dev);
struct axp_irq_chip_data *axp_irq_chip_register(struct axp_regmap *map,
int irq, int irq_flags, struct axp_regmap_irq_chip *irq_chip,
void (*wakeup_event)(void));
void axp_irq_chip_unregister(int irq, struct axp_irq_chip_data *irq_data);
int axp_regmap_write(struct axp_regmap *map, s32 reg, u8 val);
int axp_regmap_writes(struct axp_regmap *map, s32 reg, s32 len, u8 *val);
int axp_regmap_read(struct axp_regmap *map, s32 reg, u8 *val);
int axp_regmap_reads(struct axp_regmap *map, s32 reg, s32 len, u8 *val);
int axp_regmap_update(struct axp_regmap *map, s32 reg, u8 val, u8 mask);
int axp_regmap_set_bits(struct axp_regmap *map, s32 reg, u8 bit_mask);
int axp_regmap_clr_bits(struct axp_regmap *map, s32 reg, u8 bit_mask);
int axp_regmap_update_sync(struct axp_regmap *map, s32 reg, u8 val, u8 mask);
int axp_regmap_set_bits_sync(struct axp_regmap *map, s32 reg, u8 bit_mask);
int axp_regmap_clr_bits_sync(struct axp_regmap *map, s32 reg, u8 bit_mask);
int axp_mfd_add_devices(struct axp_dev *axp_dev);
int axp_mfd_remove_devices(struct axp_dev *axp_dev);
int axp_request_irq(struct axp_dev *adev, int irq_no,
irq_handler_t handler, void *data);
int axp_free_irq(struct axp_dev *adev, int irq_no);
int axp_dt_parse(struct device_node *node, int pmu_num,
struct axp_config_info *axp_config);
void axp_platform_ops_set(int pmu_num, struct axp_platform_ops *ops);
void axp_dev_set(struct axp_dev *axpdev);
int axp_gpio_irq_register(struct axp_dev *adev, int irq_no,
irq_handler_t handler, void *data);
struct axp_dev *get_pmu_cur_dev(int pmu_num);
int axp_mfd_cell_name_init(const struct axp_compatible_name_mapping *mapping,
int count, int pmu_num,
int size, struct mfd_cell *cells);
int axp_get_pmu_num(const struct axp_compatible_name_mapping *mapping,
int size);
extern int axp_suspend_flag;
extern int axp_debug_mask;
extern int axp_usb_connect;
extern const char *axp_name[AXP_ONLINE_SUM];
extern const char *get_pmu_cur_name(int pmu_num);
#endif /* AXP_CORE_H_ */