Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0f5bb9b authored by Mike Lockwood's avatar Mike Lockwood Committed by Greg Kroah-Hartman
Browse files

staging: android: switch: switch class and GPIO drivers.



This adds the Android switch driver code to the staging tree.

[Note, this code was located in drivers/switch/ in the Android kernel
releases, but as that api wasn't generally accepted, and the interface
is working toward changing to the newly proposed extcon inteface, this
driver was placed here until the extcon code is merged into mainline and
the Android userspace code is converted over to using it. - gregkh]

Signed-off-by: default avatarArve Hjønnevåg <arve@android.com>
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Donggeun Kim <dg77.kim@samsung.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: MyungJoo Ham <myungjoo.ham@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: NeilBrown <neilb@suse.de>
Cc: Morten CHRISTIANSEN <morten.christiansen@stericsson.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: John Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6169a148
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -90,6 +90,8 @@ config ANDROID_LOW_MEMORY_KILLER
	---help---
	  Register processes to be killed when memory is low

source "drivers/staging/android/switch/Kconfig"

endif # if ANDROID

endmenu
+1 −0
Original line number Diff line number Diff line
@@ -4,3 +4,4 @@ obj-$(CONFIG_ANDROID_RAM_CONSOLE) += ram_console.o
obj-$(CONFIG_ANDROID_TIMED_OUTPUT)	+= timed_output.o
obj-$(CONFIG_ANDROID_TIMED_GPIO)	+= timed_gpio.o
obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER)	+= lowmemorykiller.o
obj-$(CONFIG_ANDROID_SWITCH)		+= switch/
+11 −0
Original line number Diff line number Diff line
menuconfig ANDROID_SWITCH
	tristate "Android Switch class support"
	help
	  Say Y here to enable Android switch class support. This allows
	  monitoring switches by userspace via sysfs and uevent.

config ANDROID_SWITCH_GPIO
	tristate "Android GPIO Switch support"
	depends on GENERIC_GPIO && ANDROID_SWITCH
	help
	  Say Y here to enable GPIO based switch support.
+4 −0
Original line number Diff line number Diff line
# Android Switch Class Driver
obj-$(CONFIG_ANDROID_SWITCH)		+= switch_class.o
obj-$(CONFIG_ANDROID_SWITCH_GPIO)	+= switch_gpio.o
+53 −0
Original line number Diff line number Diff line
/*
 *  Switch class driver
 *
 * Copyright (C) 2008 Google, Inc.
 * Author: Mike Lockwood <lockwood@android.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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 __LINUX_SWITCH_H__
#define __LINUX_SWITCH_H__

struct switch_dev {
	const char	*name;
	struct device	*dev;
	int		index;
	int		state;

	ssize_t	(*print_name)(struct switch_dev *sdev, char *buf);
	ssize_t	(*print_state)(struct switch_dev *sdev, char *buf);
};

struct gpio_switch_platform_data {
	const char *name;
	unsigned 	gpio;

	/* if NULL, switch_dev.name will be printed */
	const char *name_on;
	const char *name_off;
	/* if NULL, "0" or "1" will be printed */
	const char *state_on;
	const char *state_off;
};

extern int switch_dev_register(struct switch_dev *sdev);
extern void switch_dev_unregister(struct switch_dev *sdev);

static inline int switch_get_state(struct switch_dev *sdev)
{
	return sdev->state;
}

extern void switch_set_state(struct switch_dev *sdev, int state);

#endif /* __LINUX_SWITCH_H__ */
Loading