Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * tps65010 - driver for tps6501x power management chips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Copyright (C) 2004 Texas Instruments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Copyright (C) 2004-2005 David Brownell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/mfd/tps65010.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/gpio/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #define	DRIVER_VERSION	"2 May 2005"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #define	DRIVER_NAME	(tps65010_driver.driver.name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) MODULE_DESCRIPTION("TPS6501x Power Management Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) static struct i2c_driver tps65010_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) /* This driver handles a family of multipurpose chips, which incorporate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40)  * voltage regulators, lithium ion/polymer battery charging, GPIOs, LEDs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41)  * and other features often needed in portable devices like cell phones
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42)  * or digital cameras.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44)  * The tps65011 and tps65013 have different voltage settings compared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45)  * to tps65010 and tps65012.  The tps65013 has a NO_CHG status/irq.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46)  * All except tps65010 have "wait" mode, possibly defaulted so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47)  * battery-insert != device-on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49)  * We could distinguish between some models by checking VDCDC1.UVLO or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50)  * other registers, unless they've been changed already after powerup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51)  * as part of board setup by a bootloader.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) enum tps_model {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	TPS65010,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 	TPS65011,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	TPS65012,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	TPS65013,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) struct tps65010 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	struct i2c_client	*client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 	struct mutex		lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	struct delayed_work	work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	struct dentry		*file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	unsigned		charging:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 	unsigned		por:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	unsigned		model:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	u16			vbus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	unsigned long		flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) #define	FLAG_VBUS_CHANGED	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) #define	FLAG_IRQ_ENABLE		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	/* copies of last register state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	u8			chgstatus, regstatus, chgconf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	u8			nmask1, nmask2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	u8			outmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	struct gpio_chip	chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	struct platform_device	*leds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) #define	POWER_POLL_DELAY	msecs_to_jiffies(5000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) #if	defined(DEBUG) || defined(CONFIG_DEBUG_FS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) static void dbg_chgstat(char *buf, size_t len, u8 chgstatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 	snprintf(buf, len, "%02x%s%s%s%s%s%s%s%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 		chgstatus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 		(chgstatus & TPS_CHG_USB) ? " USB" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 		(chgstatus & TPS_CHG_AC) ? " AC" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 		(chgstatus & TPS_CHG_THERM) ? " therm" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 		(chgstatus & TPS_CHG_TERM) ? " done" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 			((chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 				? " (charging)" : ""),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 		(chgstatus & TPS_CHG_TAPER_TMO) ? " taper_tmo" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 		(chgstatus & TPS_CHG_CHG_TMO) ? " charge_tmo" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 		(chgstatus & TPS_CHG_PRECHG_TMO) ? " prechg_tmo" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 		(chgstatus & TPS_CHG_TEMP_ERR) ? " temp_err" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) static void dbg_regstat(char *buf, size_t len, u8 regstatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	snprintf(buf, len, "%02x %s%s%s%s%s%s%s%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 		regstatus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 		(regstatus & TPS_REG_ONOFF) ? "off" : "(on)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 		(regstatus & TPS_REG_COVER) ? " uncover" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 		(regstatus & TPS_REG_UVLO) ? " UVLO" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 		(regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 		(regstatus & TPS_REG_PG_LD02) ? " ld02_bad" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 		(regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 		(regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 		(regstatus & TPS_REG_PG_CORE) ? " core_bad" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	const char *hibit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	if (por)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 		hibit = (chgconfig & TPS_CHARGE_POR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 				? "POR=69ms" : "POR=1sec";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 		hibit = (chgconfig & TPS65013_AUA) ? "AUA" : "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 	snprintf(buf, len, "%02x %s%s%s AC=%d%% USB=%dmA %sCharge\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 		chgconfig, hibit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 		(chgconfig & TPS_CHARGE_RESET) ? " reset" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 		(chgconfig & TPS_CHARGE_FAST) ? " fast" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 		({int p; switch ((chgconfig >> 3) & 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 		case 3:		p = 100; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 		case 2:		p = 75; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 		case 1:		p = 50; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 		default:	p = 25; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 		}; p; }),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		(chgconfig & TPS_VBUS_CHARGING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 			? ((chgconfig & TPS_VBUS_500MA) ? 500 : 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 			: 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 		(chgconfig & TPS_CHARGE_ENABLE) ? "" : "No");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) #ifdef	DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) static void show_chgstatus(const char *label, u8 chgstatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	char buf [100];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	dbg_chgstat(buf, sizeof buf, chgstatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	pr_debug("%s: %s %s", DRIVER_NAME, label, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) static void show_regstatus(const char *label, u8 regstatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	char buf [100];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	dbg_regstat(buf, sizeof buf, regstatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	pr_debug("%s: %s %s", DRIVER_NAME, label, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) static void show_chgconfig(int por, const char *label, u8 chgconfig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	char buf [100];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	dbg_chgconf(por, buf, sizeof buf, chgconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	pr_debug("%s: %s %s", DRIVER_NAME, label, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) static inline void show_chgstatus(const char *label, u8 chgstatus) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) static inline void show_regstatus(const char *label, u8 chgstatus) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) #ifdef	CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) static int dbg_show(struct seq_file *s, void *_)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	struct tps65010	*tps = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	u8		value, v2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	unsigned	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	char		buf[100];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	const char	*chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	switch (tps->model) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	case TPS65010:	chip = "tps65010"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	case TPS65011:	chip = "tps65011"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	case TPS65012:	chip = "tps65012"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	case TPS65013:	chip = "tps65013"; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	default:	chip = NULL; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	seq_printf(s, "driver  %s\nversion %s\nchip    %s\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 			DRIVER_NAME, DRIVER_VERSION, chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 	mutex_lock(&tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	/* FIXME how can we tell whether a battery is present?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	 * likely involves a charge gauging chip (like BQ26501).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	seq_printf(s, "%scharging\n\n", tps->charging ? "" : "(not) ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	/* registers for monitoring battery charging and status; note
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	 * that reading chgstat and regstat may ack IRQs...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	value = i2c_smbus_read_byte_data(tps->client, TPS_CHGCONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	dbg_chgconf(tps->por, buf, sizeof buf, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	seq_printf(s, "chgconfig %s", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	value = i2c_smbus_read_byte_data(tps->client, TPS_CHGSTATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	dbg_chgstat(buf, sizeof buf, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 	seq_printf(s, "chgstat   %s", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	value = i2c_smbus_read_byte_data(tps->client, TPS_MASK1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	dbg_chgstat(buf, sizeof buf, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	seq_printf(s, "mask1     %s", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	/* ignore ackint1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	value = i2c_smbus_read_byte_data(tps->client, TPS_REGSTATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	dbg_regstat(buf, sizeof buf, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	seq_printf(s, "regstat   %s", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	value = i2c_smbus_read_byte_data(tps->client, TPS_MASK2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	dbg_regstat(buf, sizeof buf, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	seq_printf(s, "mask2     %s\n", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	/* ignore ackint2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	queue_delayed_work(system_power_efficient_wq, &tps->work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 			   POWER_POLL_DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	/* VMAIN voltage, enable lowpower, etc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	value = i2c_smbus_read_byte_data(tps->client, TPS_VDCDC1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 	seq_printf(s, "vdcdc1    %02x\n", value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	/* VCORE voltage, vibrator on/off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	value = i2c_smbus_read_byte_data(tps->client, TPS_VDCDC2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	seq_printf(s, "vdcdc2    %02x\n", value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	/* both LD0s, and their lowpower behavior */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	value = i2c_smbus_read_byte_data(tps->client, TPS_VREGS1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	seq_printf(s, "vregs1    %02x\n\n", value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	/* LEDs and GPIOs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	value = i2c_smbus_read_byte_data(tps->client, TPS_LED1_ON);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	v2 = i2c_smbus_read_byte_data(tps->client, TPS_LED1_PER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 		(value & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 			? ((v2 & 0x80) ? "on" : "off")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 			: ((v2 & 0x80) ? "blink" : "(nPG)"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 		value, v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 		(value & 0x7f) * 10, (v2 & 0x7f) * 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	value = i2c_smbus_read_byte_data(tps->client, TPS_LED2_ON);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	v2 = i2c_smbus_read_byte_data(tps->client, TPS_LED2_PER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 		(value & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 			? ((v2 & 0x80) ? "on" : "off")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 			: ((v2 & 0x80) ? "blink" : "off"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 		value, v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 		(value & 0x7f) * 10, (v2 & 0x7f) * 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	value = i2c_smbus_read_byte_data(tps->client, TPS_DEFGPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	v2 = i2c_smbus_read_byte_data(tps->client, TPS_MASK3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 		if (value & (1 << (4 + i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 			seq_printf(s, "  gpio%d-out %s\n", i + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 				(value & (1 << i)) ? "low" : "hi ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 			seq_printf(s, "  gpio%d-in  %s %s %s\n", i + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 				(value & (1 << i)) ? "hi " : "low",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 				(v2 & (1 << i)) ? "no-irq" : "irq",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 				(v2 & (1 << (4 + i))) ? "rising" : "falling");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	mutex_unlock(&tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) static int dbg_tps_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	return single_open(file, dbg_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) static const struct file_operations debug_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	.open		= dbg_tps_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	.read		= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	.llseek		= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	.release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) #define	DEBUG_FOPS	&debug_fops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) #define	DEBUG_FOPS	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) /* handle IRQS in a task context, so we can use I2C calls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) static void tps65010_interrupt(struct tps65010 *tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	u8 tmp = 0, mask, poll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	/* IRQs won't trigger for certain events, but we can get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	 * others by polling (normally, with external power applied).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	poll = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	/* regstatus irqs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	if (tps->nmask2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		tmp = i2c_smbus_read_byte_data(tps->client, TPS_REGSTATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 		mask = tmp ^ tps->regstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 		tps->regstatus = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		mask &= tps->nmask2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 		mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	if (mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 		tps->regstatus =  tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 		/* may need to shut something down ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 		/* "off" usually means deep sleep */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 		if (tmp & TPS_REG_ONOFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 			pr_info("%s: power off button\n", DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 			/* REVISIT:  this might need its own workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 			 * plus tweaks including deadlock avoidance ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 			 * also needs to get error handling and probably
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 			 * an #ifdef CONFIG_HIBERNATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 			hibernate();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 			poll = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	/* chgstatus irqs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	if (tps->nmask1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		tmp = i2c_smbus_read_byte_data(tps->client, TPS_CHGSTATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		mask = tmp ^ tps->chgstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 		tps->chgstatus = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 		mask &= tps->nmask1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 		mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	if (mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		unsigned	charging = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 		show_chgstatus("chg/irq", tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 		if (tmp & (TPS_CHG_USB|TPS_CHG_AC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 			show_chgconfig(tps->por, "conf", tps->chgconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 		/* Unless it was turned off or disabled, we charge any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 		 * battery whenever there's power available for it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 		 * and the charger hasn't been disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 		if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 				&& (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 				&& (tps->chgconf & TPS_CHARGE_ENABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 				) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 			if (tps->chgstatus & TPS_CHG_USB) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 				/* VBUS options are readonly until reconnect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 				if (mask & TPS_CHG_USB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 					set_bit(FLAG_VBUS_CHANGED, &tps->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 				charging = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 			} else if (tps->chgstatus & TPS_CHG_AC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 				charging = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 		if (charging != tps->charging) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 			tps->charging = charging;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 			pr_info("%s: battery %scharging\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 				DRIVER_NAME, charging ? "" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 				((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 					? "NOT " : "dis"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	/* always poll to detect (a) power removal, without tps65013
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	 * NO_CHG IRQ; or (b) restart of charging after stop.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 	if ((tps->model != TPS65013 || !tps->charging)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 			&& (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 		poll = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 	if (poll)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 		queue_delayed_work(system_power_efficient_wq, &tps->work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 				   POWER_POLL_DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	/* also potentially gpio-in rise or fall */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) /* handle IRQs and polling using keventd for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) static void tps65010_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	struct tps65010		*tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	tps = container_of(to_delayed_work(work), struct tps65010, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	mutex_lock(&tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	tps65010_interrupt(tps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 		u8	chgconfig, tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 		chgconfig = i2c_smbus_read_byte_data(tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 					TPS_CHGCONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 		chgconfig &= ~(TPS_VBUS_500MA | TPS_VBUS_CHARGING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		if (tps->vbus == 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 			chgconfig |= TPS_VBUS_500MA | TPS_VBUS_CHARGING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 		else if (tps->vbus >= 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 			chgconfig |= TPS_VBUS_CHARGING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		i2c_smbus_write_byte_data(tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 					  TPS_CHGCONFIG, chgconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		/* vbus update fails unless VBUS is connected! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 		tmp = i2c_smbus_read_byte_data(tps->client, TPS_CHGCONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		tps->chgconf = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 		show_chgconfig(tps->por, "update vbus", tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 		enable_irq(tps->client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	mutex_unlock(&tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) static irqreturn_t tps65010_irq(int irq, void *_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	struct tps65010		*tps = _tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	disable_irq_nosync(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	set_bit(FLAG_IRQ_ENABLE, &tps->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 	queue_delayed_work(system_power_efficient_wq, &tps->work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) /* offsets 0..3 == GPIO1..GPIO4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445)  * offsets 4..5 == LED1/nPG, LED2 (we set one of the non-BLINK modes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446)  * offset 6 == vibrator motor driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) tps65010_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	if (offset < 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 		tps65010_set_gpio_out_value(offset + 1, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	else if (offset < 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 		tps65010_set_led(offset - 3, value ? ON : OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 		tps65010_set_vib(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) tps65010_output(struct gpio_chip *chip, unsigned offset, int value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	/* GPIOs may be input-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	if (offset < 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 		struct tps65010		*tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 		tps = gpiochip_get_data(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 		if (!(tps->outmask & (1 << offset)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 		tps65010_set_gpio_out_value(offset + 1, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	} else if (offset < 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 		tps65010_set_led(offset - 3, value ? ON : OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 		tps65010_set_vib(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) static int tps65010_gpio_get(struct gpio_chip *chip, unsigned offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	int			value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	struct tps65010		*tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	tps = gpiochip_get_data(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	if (offset < 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 		value = i2c_smbus_read_byte_data(tps->client, TPS_DEFGPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 		if (value < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 			return value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 		if (value & (1 << (offset + 4)))	/* output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 			return !(value & (1 << offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 		else					/* input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 			return !!(value & (1 << offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	/* REVISIT we *could* report LED1/nPG and LED2 state ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) static struct tps65010 *the_tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) static int tps65010_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	struct tps65010		*tps = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	struct tps65010_board	*board = dev_get_platdata(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	if (board && board->teardown) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 		int status = board->teardown(client, board->context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 		if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 			dev_dbg(&client->dev, "board %s %s err %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 				"teardown", client->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	if (client->irq > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 		free_irq(client->irq, tps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	cancel_delayed_work_sync(&tps->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	debugfs_remove(tps->file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	the_tps = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) static int tps65010_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 			  const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	struct tps65010		*tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 	struct tps65010_board	*board = dev_get_platdata(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 	if (the_tps) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 		dev_dbg(&client->dev, "only one tps6501x chip allowed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	if (!tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	mutex_init(&tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	INIT_DELAYED_WORK(&tps->work, tps65010_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	tps->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	tps->model = id->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 	/* the IRQ is active low, but many gpio lines can't support that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	 * so this driver uses falling-edge triggers instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	if (client->irq > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 		status = request_irq(client->irq, tps65010_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 				     IRQF_TRIGGER_FALLING, DRIVER_NAME, tps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 		if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 			dev_dbg(&client->dev, "can't get IRQ %d, err %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 					client->irq, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 		/* annoying race here, ideally we'd have an option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 		 * to claim the irq now and enable it later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 		 * FIXME genirq IRQF_NOAUTOEN now solves that ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		disable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 		set_bit(FLAG_IRQ_ENABLE, &tps->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 		dev_warn(&client->dev, "IRQ not configured!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	switch (tps->model) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	case TPS65010:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	case TPS65012:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 		tps->por = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	/* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	tps->chgconf = i2c_smbus_read_byte_data(client, TPS_CHGCONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	show_chgconfig(tps->por, "conf/init", tps->chgconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	show_chgstatus("chg/init",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 		i2c_smbus_read_byte_data(client, TPS_CHGSTATUS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	show_regstatus("reg/init",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 		i2c_smbus_read_byte_data(client, TPS_REGSTATUS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	pr_debug("%s: vdcdc1 0x%02x, vdcdc2 %02x, vregs1 %02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 		i2c_smbus_read_byte_data(client, TPS_VDCDC1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 		i2c_smbus_read_byte_data(client, TPS_VDCDC2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 		i2c_smbus_read_byte_data(client, TPS_VREGS1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	pr_debug("%s: defgpio 0x%02x, mask3 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 		i2c_smbus_read_byte_data(client, TPS_DEFGPIO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 		i2c_smbus_read_byte_data(client, TPS_MASK3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	i2c_set_clientdata(client, tps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	the_tps = tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) #if	defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	/* USB hosts can't draw VBUS.  OTG devices could, later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	 * when OTG infrastructure enables it.  USB peripherals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	 * could be relying on VBUS while booting, though.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	tps->vbus = 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	/* unmask the "interesting" irqs, then poll once to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	 * kickstart monitoring, initialize shadowed status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 	 * registers, and maybe disable VBUS draw.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	tps->nmask1 = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	(void) i2c_smbus_write_byte_data(client, TPS_MASK1, ~tps->nmask1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	tps->nmask2 = TPS_REG_ONOFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	if (tps->model == TPS65013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		tps->nmask2 |= TPS_REG_NO_CHG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	(void) i2c_smbus_write_byte_data(client, TPS_MASK2, ~tps->nmask2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	(void) i2c_smbus_write_byte_data(client, TPS_MASK3, 0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 		| i2c_smbus_read_byte_data(client, TPS_MASK3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	tps65010_work(&tps->work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 				tps, DEBUG_FOPS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	/* optionally register GPIOs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	if (board && board->base != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 		tps->outmask = board->outmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 		tps->chip.label = client->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		tps->chip.parent = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 		tps->chip.owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 		tps->chip.set = tps65010_gpio_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		tps->chip.direction_output = tps65010_output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 		/* NOTE:  only partial support for inputs; nyet IRQs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 		tps->chip.get = tps65010_gpio_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 		tps->chip.base = board->base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 		tps->chip.ngpio = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 		tps->chip.can_sleep = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 		status = gpiochip_add_data(&tps->chip, tps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 		if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 			dev_err(&client->dev, "can't add gpiochip, err %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 					status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 		else if (board->setup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 			status = board->setup(client, board->context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 			if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 				dev_dbg(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 					"board %s %s err %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 					"setup", client->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 				status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) static const struct i2c_device_id tps65010_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	{ "tps65010", TPS65010 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	{ "tps65011", TPS65011 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	{ "tps65012", TPS65012 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	{ "tps65013", TPS65013 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	{ "tps65014", TPS65011 },	/* tps65011 charging at 6.5V max */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) MODULE_DEVICE_TABLE(i2c, tps65010_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) static struct i2c_driver tps65010_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 		.name	= "tps65010",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	.probe	= tps65010_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	.remove	= tps65010_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	.id_table = tps65010_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) /* Draw from VBUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680)  *   0 mA -- DON'T DRAW (might supply power instead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681)  * 100 mA -- usb unit load (slowest charge rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682)  * 500 mA -- usb high power (fast battery charge)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) int tps65010_set_vbus_draw(unsigned mA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	unsigned long	flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	if (!the_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	/* assumes non-SMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	if (mA >= 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 		mA = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	else if (mA >= 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 		mA = 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 		mA = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 	the_tps->vbus = mA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	if ((the_tps->chgstatus & TPS_CHG_USB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 			&& test_and_set_bit(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 				FLAG_VBUS_CHANGED, &the_tps->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 		/* gadget drivers call this in_irq() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 		queue_delayed_work(system_power_efficient_wq, &the_tps->work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 				   0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) EXPORT_SYMBOL(tps65010_set_vbus_draw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) /* tps65010_set_gpio_out_value parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715)  * gpio:  GPIO1, GPIO2, GPIO3 or GPIO4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716)  * value: LOW or HIGH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	int	 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	unsigned defgpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 	if (!the_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	if ((gpio < GPIO1) || (gpio > GPIO4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	mutex_lock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	defgpio = i2c_smbus_read_byte_data(the_tps->client, TPS_DEFGPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 	/* Configure GPIO for output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	defgpio |= 1 << (gpio + 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	/* Writing 1 forces a logic 0 on that GPIO and vice versa */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	switch (value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	case LOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 		defgpio |= 1 << (gpio - 1);    /* set GPIO low by writing 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	/* case HIGH: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 		defgpio &= ~(1 << (gpio - 1)); /* set GPIO high by writing 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 		TPS_DEFGPIO, defgpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 		gpio, value ? "high" : "low",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 		i2c_smbus_read_byte_data(the_tps->client, TPS_DEFGPIO));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 	mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) EXPORT_SYMBOL(tps65010_set_gpio_out_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) /* tps65010_set_led parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760)  * led:  LED1 or LED2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761)  * mode: ON, OFF or BLINK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) int tps65010_set_led(unsigned led, unsigned mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	int	 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	unsigned led_on, led_per, offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	if (!the_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	if (led == LED1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 		offs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 		offs = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 		led = LED2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	mutex_lock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	pr_debug("%s: led%i_on   0x%02x\n", DRIVER_NAME, led,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 		i2c_smbus_read_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 				TPS_LED1_ON + offs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	pr_debug("%s: led%i_per  0x%02x\n", DRIVER_NAME, led,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 		i2c_smbus_read_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 				TPS_LED1_PER + offs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	switch (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	case OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 		led_on  = 1 << 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 		led_per = 0 << 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	case ON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 		led_on  = 1 << 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		led_per = 1 << 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	case BLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 		led_on  = 0x30 | (0 << 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 		led_per = 0x08 | (1 << 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 		printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 		       DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 		mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 			TPS_LED1_ON + offs, led_on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	if (status != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 		printk(KERN_ERR "%s: Failed to write led%i_on register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		       DRIVER_NAME, led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 		mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	pr_debug("%s: led%i_on   0x%02x\n", DRIVER_NAME, led,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 		i2c_smbus_read_byte_data(the_tps->client, TPS_LED1_ON + offs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 			TPS_LED1_PER + offs, led_per);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	if (status != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 		printk(KERN_ERR "%s: Failed to write led%i_per register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 		       DRIVER_NAME, led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 		mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	pr_debug("%s: led%i_per  0x%02x\n", DRIVER_NAME, led,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 		i2c_smbus_read_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 				TPS_LED1_PER + offs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) EXPORT_SYMBOL(tps65010_set_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) /* tps65010_set_vib parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843)  * value: ON or OFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) int tps65010_set_vib(unsigned value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	int	 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	unsigned vdcdc2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	if (!the_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	mutex_lock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	vdcdc2 = i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	vdcdc2 &= ~(1 << 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 	if (value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 		vdcdc2 |= (1 << 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 		TPS_VDCDC2, vdcdc2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) EXPORT_SYMBOL(tps65010_set_vib);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) /* tps65010_set_low_pwr parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871)  * mode: ON or OFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) int tps65010_set_low_pwr(unsigned mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	int	 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	unsigned vdcdc1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	if (!the_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	mutex_lock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 	pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 		mode ? "enable" : "disable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 		i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	vdcdc1 = i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	switch (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	case OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 		vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	/* case ON: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 		vdcdc1 |= TPS_ENABLE_LP;  /* enable ENABLE_LP bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 			TPS_VDCDC1, vdcdc1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 			DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 			i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 	mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) EXPORT_SYMBOL(tps65010_set_low_pwr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) /* tps65010_config_vregs1 parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917)  * value to be written to VREGS1 register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918)  * Note: The complete register is written, set all bits you need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) int tps65010_config_vregs1(unsigned value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	int	 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 	if (!the_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	mutex_lock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 			i2c_smbus_read_byte_data(the_tps->client, TPS_VREGS1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 			TPS_VREGS1, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 		printk(KERN_ERR "%s: Failed to write vregs1 register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 			DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 		pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 			i2c_smbus_read_byte_data(the_tps->client, TPS_VREGS1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) EXPORT_SYMBOL(tps65010_config_vregs1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) int tps65010_config_vdcdc2(unsigned value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	struct i2c_client *c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	int	 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	if (!the_tps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	c = the_tps->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	mutex_lock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	pr_debug("%s: vdcdc2 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 		 i2c_smbus_read_byte_data(c, TPS_VDCDC2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	status = i2c_smbus_write_byte_data(c, TPS_VDCDC2, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		printk(KERN_ERR "%s: Failed to write vdcdc2 register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 			DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 		pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 			 i2c_smbus_read_byte_data(c, TPS_VDCDC2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) EXPORT_SYMBOL(tps65010_config_vdcdc2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) /* tps65013_set_low_pwr parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978)  * mode: ON or OFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) /* FIXME: Assumes AC or USB power is present. Setting AUA bit is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	required if power supply is through a battery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) int tps65013_set_low_pwr(unsigned mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	int	 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	unsigned vdcdc1, chgconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	if (!the_tps || the_tps->por)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	mutex_lock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 		DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		mode ? "enable" : "disable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 		i2c_smbus_read_byte_data(the_tps->client, TPS_CHGCONFIG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 		i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	chgconfig = i2c_smbus_read_byte_data(the_tps->client, TPS_CHGCONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	vdcdc1 = i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	switch (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	case OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 		chgconfig &= ~TPS65013_AUA; /* disable AUA bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 		vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	/* case ON: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 		chgconfig |= TPS65013_AUA;  /* enable AUA bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 		vdcdc1 |= TPS_ENABLE_LP;  /* enable ENABLE_LP bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 			TPS_CHGCONFIG, chgconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	if (status != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 		printk(KERN_ERR "%s: Failed to write chconfig register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	 DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 		mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	chgconfig = i2c_smbus_read_byte_data(the_tps->client, TPS_CHGCONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	the_tps->chgconf = chgconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	show_chgconfig(0, "chgconf", chgconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	status = i2c_smbus_write_byte_data(the_tps->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 			TPS_VDCDC1, vdcdc1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 		printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	 DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 			i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	mutex_unlock(&the_tps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) EXPORT_SYMBOL(tps65013_set_low_pwr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) static int __init tps_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	return i2c_add_driver(&tps65010_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) /* NOTE:  this MUST be initialized before the other parts of the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)  * that rely on it ... but after the i2c bus on which this relies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052)  * That is, much earlier than on PC-type systems, which don't often use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)  * I2C as a core system bus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) subsys_initcall(tps_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) static void __exit tps_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	i2c_del_driver(&tps65010_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) module_exit(tps_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)