1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Summit Microelectronics SMB347 Battery Charger Driver 4 * 5 * Copyright (C) 2011, Intel Corporation 6 * 7 * Authors: Bruce E. Robertson <bruce.e.robertson@intel.com> 8 * Mika Westerberg <mika.westerberg@linux.intel.com> 9 */ 10 11 #ifndef SMB347_CHARGER_H 12 #define SMB347_CHARGER_H 13 14 #include <linux/types.h> 15 #include <linux/power_supply.h> 16 17 enum { 18 /* use the default compensation method */ 19 SMB347_SOFT_TEMP_COMPENSATE_DEFAULT = -1, 20 21 SMB347_SOFT_TEMP_COMPENSATE_NONE, 22 SMB347_SOFT_TEMP_COMPENSATE_CURRENT, 23 SMB347_SOFT_TEMP_COMPENSATE_VOLTAGE, 24 }; 25 26 /* Use default factory programmed value for hard/soft temperature limit */ 27 #define SMB347_TEMP_USE_DEFAULT -273 28 29 /* 30 * Charging enable can be controlled by software (via i2c) by 31 * smb347-charger driver or by EN pin (active low/high). 32 */ 33 enum smb347_chg_enable { 34 SMB347_CHG_ENABLE_SW, 35 SMB347_CHG_ENABLE_PIN_ACTIVE_LOW, 36 SMB347_CHG_ENABLE_PIN_ACTIVE_HIGH, 37 }; 38 39 /** 40 * struct smb347_charger_platform_data - platform data for SMB347 charger 41 * @battery_info: Information about the battery 42 * @max_charge_current: maximum current (in uA) the battery can be charged 43 * @max_charge_voltage: maximum voltage (in uV) the battery can be charged 44 * @pre_charge_current: current (in uA) to use in pre-charging phase 45 * @termination_current: current (in uA) used to determine when the 46 * charging cycle terminates 47 * @pre_to_fast_voltage: voltage (in uV) treshold used for transitioning to 48 * pre-charge to fast charge mode 49 * @mains_current_limit: maximum input current drawn from AC/DC input (in uA) 50 * @usb_hc_current_limit: maximum input high current (in uA) drawn from USB 51 * input 52 * @chip_temp_threshold: die temperature where device starts limiting charge 53 * current [%100 - %130] (in degree C) 54 * @soft_cold_temp_limit: soft cold temperature limit [%0 - %15] (in degree C), 55 * granularity is 5 deg C. 56 * @soft_hot_temp_limit: soft hot temperature limit [%40 - %55] (in degree C), 57 * granularity is 5 deg C. 58 * @hard_cold_temp_limit: hard cold temperature limit [%-5 - %10] (in degree C), 59 * granularity is 5 deg C. 60 * @hard_hot_temp_limit: hard hot temperature limit [%50 - %65] (in degree C), 61 * granularity is 5 deg C. 62 * @suspend_on_hard_temp_limit: suspend charging when hard limit is hit 63 * @soft_temp_limit_compensation: compensation method when soft temperature 64 * limit is hit 65 * @charge_current_compensation: current (in uA) for charging compensation 66 * current when temperature hits soft limits 67 * @use_mains: AC/DC input can be used 68 * @use_usb: USB input can be used 69 * @use_usb_otg: USB OTG output can be used (not implemented yet) 70 * @irq_gpio: GPIO number used for interrupts (%-1 if not used) 71 * @enable_control: how charging enable/disable is controlled 72 * (driver/pin controls) 73 * 74 * @use_main, @use_usb, and @use_usb_otg are means to enable/disable 75 * hardware support for these. This is useful when we want to have for 76 * example OTG charging controlled via OTG transceiver driver and not by 77 * the SMB347 hardware. 78 * 79 * Hard and soft temperature limit values are given as described in the 80 * device data sheet and assuming NTC beta value is %3750. Even if this is 81 * not the case, these values should be used. They can be mapped to the 82 * corresponding NTC beta values with the help of table %2 in the data 83 * sheet. So for example if NTC beta is %3375 and we want to program hard 84 * hot limit to be %53 deg C, @hard_hot_temp_limit should be set to %50. 85 * 86 * If zero value is given in any of the current and voltage values, the 87 * factory programmed default will be used. For soft/hard temperature 88 * values, pass in %SMB347_TEMP_USE_DEFAULT instead. 89 */ 90 struct smb347_charger_platform_data { 91 struct power_supply_info battery_info; 92 unsigned int max_charge_current; 93 unsigned int max_charge_voltage; 94 unsigned int pre_charge_current; 95 unsigned int termination_current; 96 unsigned int pre_to_fast_voltage; 97 unsigned int mains_current_limit; 98 unsigned int usb_hc_current_limit; 99 unsigned int chip_temp_threshold; 100 int soft_cold_temp_limit; 101 int soft_hot_temp_limit; 102 int hard_cold_temp_limit; 103 int hard_hot_temp_limit; 104 bool suspend_on_hard_temp_limit; 105 unsigned int soft_temp_limit_compensation; 106 unsigned int charge_current_compensation; 107 bool use_mains; 108 bool use_usb; 109 bool use_usb_otg; 110 int irq_gpio; 111 enum smb347_chg_enable enable_control; 112 }; 113 114 #endif /* SMB347_CHARGER_H */ 115