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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Battery and Power Management code for the Sharp SL-Cxx00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2005 Richard Purdie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/gpio-pxa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/apm-emulation.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <mach/hardware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <mach/spitz.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "pxa27x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "sharpsl_pm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include "generic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define SHARPSL_CHARGE_ON_VOLT         0x99  /* 2.9V */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define SHARPSL_CHARGE_ON_TEMP         0xe0  /* 2.9V */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define SHARPSL_CHARGE_ON_ACIN_HIGH    0x9b  /* 6V */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define SHARPSL_CHARGE_ON_ACIN_LOW     0x34  /* 2V */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define SHARPSL_FATAL_ACIN_VOLT        182   /* 3.45V */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define SHARPSL_FATAL_NOACIN_VOLT      170   /* 3.40V */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static int spitz_last_ac_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static struct gpio spitz_charger_gpios[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	{ SPITZ_GPIO_KEY_INT,	GPIOF_IN, "Keyboard Interrupt" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	{ SPITZ_GPIO_SYNC,	GPIOF_IN, "Sync" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	{ SPITZ_GPIO_AC_IN,     GPIOF_IN, "Charger Detection" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	{ SPITZ_GPIO_ADC_TEMP_ON, GPIOF_OUT_INIT_LOW, "ADC Temp On" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	{ SPITZ_GPIO_JK_B,	  GPIOF_OUT_INIT_LOW, "JK B" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	{ SPITZ_GPIO_CHRG_ON,	  GPIOF_OUT_INIT_LOW, "Charger On" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static void spitz_charger_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	gpio_request_array(ARRAY_AND_SIZE(spitz_charger_gpios));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static void spitz_measure_temp(int on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	gpio_set_value(SPITZ_GPIO_ADC_TEMP_ON, on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static void spitz_charge(int on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	if (on) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		if (sharpsl_pm.flags & SHARPSL_SUSPENDED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			gpio_set_value(SPITZ_GPIO_JK_B, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			gpio_set_value(SPITZ_GPIO_JK_B, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		gpio_set_value(SPITZ_GPIO_JK_B, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		gpio_set_value(SPITZ_GPIO_CHRG_ON, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static void spitz_discharge(int on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	gpio_set_value(SPITZ_GPIO_JK_A, on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) /* HACK - For unknown reasons, accurate voltage readings are only made with a load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)    on the power bus which the green led on spitz provides */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static void spitz_discharge1(int on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	gpio_set_value(SPITZ_GPIO_LED_GREEN, on);
^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) static unsigned long gpio18_config = GPIO18_GPIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static void spitz_presuspend(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	spitz_last_ac_status = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* GPIO Sleep Register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	PGSR0 = 0x00144018;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	PGSR1 = 0x00EF0000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	if (machine_is_akita()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		PGSR2 = 0x2121C000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		PGSR3 = 0x00600400;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		PGSR2 = 0x0121C000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		PGSR3 = 0x00600000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	PGSR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	PGSR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	PGSR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	pxa2xx_mfp_config(&gpio18_config, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	gpio_request_one(18, GPIOF_OUT_INIT_HIGH, "Unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	gpio_free(18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	PRER = GPIO_bit(SPITZ_GPIO_KEY_INT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	PFER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	PWER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET) | PWER_RTC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	PKWR = GPIO_bit(SPITZ_GPIO_SYNC) | GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	PKSR = 0xffffffff; /* clear */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	/* nRESET_OUT Disable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	PSLR |= PSLR_SL_ROD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	/* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	PCFR = PCFR_GPR_EN | PCFR_OPDE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static void spitz_postsuspend(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static int spitz_should_wakeup(unsigned int resume_on_alarm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int is_resume = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	if (spitz_last_ac_status != acin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		if (acin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			/* charge on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			dev_dbg(sharpsl_pm.dev, "AC Inserted\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			/* charge off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			dev_dbg(sharpsl_pm.dev, "AC Removed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			sharpsl_pm_led(SHARPSL_LED_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			sharpsl_pm.machinfo->charge(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			sharpsl_pm.charge_mode = CHRG_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		spitz_last_ac_status = acin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		/* Return to suspend as this must be what we were woken for */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (PEDR & GPIO_bit(SPITZ_GPIO_KEY_INT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		is_resume |= GPIO_bit(SPITZ_GPIO_KEY_INT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (PKSR & GPIO_bit(SPITZ_GPIO_SYNC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		is_resume |= GPIO_bit(SPITZ_GPIO_SYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (resume_on_alarm && (PEDR & PWER_RTC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		is_resume |= PWER_RTC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	dev_dbg(sharpsl_pm.dev, "is_resume: %x\n", is_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	return is_resume;
^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 bool spitz_charger_wakeup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	return !gpio_get_value(SPITZ_GPIO_KEY_INT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		gpio_get_value(SPITZ_GPIO_SYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) unsigned long spitzpm_read_devdata(int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	case SHARPSL_STATUS_ACIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return !gpio_get_value(SPITZ_GPIO_AC_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	case SHARPSL_STATUS_LOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		return gpio_get_value(sharpsl_pm.machinfo->gpio_batlock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	case SHARPSL_STATUS_CHRGFULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		return gpio_get_value(sharpsl_pm.machinfo->gpio_batfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	case SHARPSL_STATUS_FATAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		return gpio_get_value(sharpsl_pm.machinfo->gpio_fatal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	case SHARPSL_ACIN_VOLT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	case SHARPSL_BATT_TEMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	case SHARPSL_BATT_VOLT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct sharpsl_charger_machinfo spitz_pm_machinfo = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	.init             = spitz_charger_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	.exit             = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	.gpio_batlock     = SPITZ_GPIO_BAT_COVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	.gpio_acin        = SPITZ_GPIO_AC_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	.gpio_batfull     = SPITZ_GPIO_CHRG_FULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	.batfull_irq	  = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	.gpio_fatal       = SPITZ_GPIO_FATAL_BAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	.discharge        = spitz_discharge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	.discharge1       = spitz_discharge1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	.charge           = spitz_charge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	.measure_temp     = spitz_measure_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	.presuspend       = spitz_presuspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	.postsuspend      = spitz_postsuspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	.read_devdata     = spitzpm_read_devdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	.charger_wakeup   = spitz_charger_wakeup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	.should_wakeup    = spitz_should_wakeup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #if defined(CONFIG_LCD_CORGI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	.backlight_limit = corgi_lcd_limit_intensity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	.charge_on_volt	  = SHARPSL_CHARGE_ON_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	.charge_on_temp	  = SHARPSL_CHARGE_ON_TEMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	.charge_acin_high = SHARPSL_CHARGE_ON_ACIN_HIGH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	.charge_acin_low  = SHARPSL_CHARGE_ON_ACIN_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	.fatal_acin_volt  = SHARPSL_FATAL_ACIN_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	.fatal_noacin_volt= SHARPSL_FATAL_NOACIN_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.bat_levels       = 40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.bat_levels_noac  = sharpsl_battery_levels_noac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.bat_levels_acin  = sharpsl_battery_levels_acin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.status_high_acin = 188,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.status_low_acin  = 178,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	.status_high_noac = 185,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	.status_low_noac  = 175,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static struct platform_device *spitzpm_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static int spitzpm_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	if (!machine_is_spitz() && !machine_is_akita()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 			&& !machine_is_borzoi())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	spitzpm_device = platform_device_alloc("sharpsl-pm", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if (!spitzpm_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	spitzpm_device->dev.platform_data = &spitz_pm_machinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	ret = platform_device_add(spitzpm_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		platform_device_put(spitzpm_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static void spitzpm_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	platform_device_unregister(spitzpm_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) module_init(spitzpm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) module_exit(spitzpm_exit);