1 /*
2 * Switch class driver
3 *
4 * Copyright (C) 2008 Google, Inc.
5 * Author: Mike Lockwood <lockwood@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18 #ifndef __LINUX_SWITCH_H__
19 #define __LINUX_SWITCH_H__
20
21 struct switch_dev {
22 const char *name;
23 struct device *dev;
24 int index;
25 int state;
26
27 ssize_t (*print_name)(struct switch_dev *sdev, char *buf);
28 ssize_t (*print_state)(struct switch_dev *sdev, char *buf);
29 };
30
31 struct gpio_switch_platform_data {
32 const char *name;
33 unsigned gpio;
34
35 /* if NULL, switch_dev.name will be printed */
36 const char *name_on;
37 const char *name_off;
38 /* if NULL, "0" or "1" will be printed */
39 const char *state_on;
40 const char *state_off;
41 };
42
43 extern int switch_dev_register(struct switch_dev *sdev);
44 extern void switch_dev_unregister(struct switch_dev *sdev);
45
switch_get_state(struct switch_dev * sdev)46 static inline int switch_get_state(struct switch_dev *sdev)
47 {
48 return sdev->state;
49 }
50
51 extern void switch_set_state(struct switch_dev *sdev, int state);
52
53 #endif /* __LINUX_SWITCH_H__ */
54