Lines Matching +full:trickle +full:- +full:resistor +full:- +full:ohms
1 // SPDX-License-Identifier: GPL-2.0-only
33 #define BQ32K_TCH2 0x08 /* Trickle charge enable */
34 #define BQ32K_CFG2 0x09 /* Trickle charger control */
35 #define BQ32K_TCFE BIT(6) /* Trickle charge FET bypass */
58 .addr = client->addr, in bq32k_read()
63 .addr = client->addr, in bq32k_read()
70 if (i2c_transfer(client->adapter, msgs, 2) == 2) in bq32k_read()
73 return -EIO; in bq32k_read()
87 return -EIO; in bq32k_write()
104 return -EINVAL; in bq32k_rtc_read_time()
106 tm->tm_sec = bcd2bin(regs.seconds & BQ32K_SECONDS_MASK); in bq32k_rtc_read_time()
107 tm->tm_min = bcd2bin(regs.minutes & BQ32K_MINUTES_MASK); in bq32k_rtc_read_time()
108 tm->tm_hour = bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK); in bq32k_rtc_read_time()
109 tm->tm_mday = bcd2bin(regs.date); in bq32k_rtc_read_time()
110 tm->tm_wday = bcd2bin(regs.day) - 1; in bq32k_rtc_read_time()
111 tm->tm_mon = bcd2bin(regs.month) - 1; in bq32k_rtc_read_time()
112 tm->tm_year = bcd2bin(regs.years) + in bq32k_rtc_read_time()
122 regs.seconds = bin2bcd(tm->tm_sec); in bq32k_rtc_set_time()
123 regs.minutes = bin2bcd(tm->tm_min); in bq32k_rtc_set_time()
124 regs.cent_hours = bin2bcd(tm->tm_hour) | BQ32K_CENT_EN; in bq32k_rtc_set_time()
125 regs.day = bin2bcd(tm->tm_wday + 1); in bq32k_rtc_set_time()
126 regs.date = bin2bcd(tm->tm_mday); in bq32k_rtc_set_time()
127 regs.month = bin2bcd(tm->tm_mon + 1); in bq32k_rtc_set_time()
129 if (tm->tm_year >= 100) { in bq32k_rtc_set_time()
131 regs.years = bin2bcd(tm->tm_year - 100); in bq32k_rtc_set_time()
133 regs.years = bin2bcd(tm->tm_year); in bq32k_rtc_set_time()
147 u32 ohms = 0; in trickle_charger_of_init() local
149 if (of_property_read_u32(node, "trickle-resistor-ohms" , &ohms)) in trickle_charger_of_init()
152 switch (ohms) { in trickle_charger_of_init()
156 * over diode and 940ohm resistor) in trickle_charger_of_init()
159 if (of_property_read_bool(node, "trickle-diode-disable")) { in trickle_charger_of_init()
160 dev_err(dev, "diode and resistor mismatch\n"); in trickle_charger_of_init()
161 return -EINVAL; in trickle_charger_of_init()
169 if (!of_property_read_bool(node, "trickle-diode-disable")) { in trickle_charger_of_init()
170 dev_err(dev, "bq32k: diode and resistor mismatch\n"); in trickle_charger_of_init()
171 return -EINVAL; in trickle_charger_of_init()
177 dev_err(dev, "invalid resistor value (%d)\n", ohms); in trickle_charger_of_init()
178 return -EINVAL; in trickle_charger_of_init()
190 dev_info(dev, "Enabled trickle RTC battery charge.\n"); in trickle_charger_of_init()
214 return -EINVAL; in bq32k_sysfs_store_tricklecharge_bypass()
226 dev_info(dev, "Enabled trickle charge FET bypass.\n"); in bq32k_sysfs_store_tricklecharge_bypass()
233 dev_info(dev, "Disabled trickle charge FET bypass.\n"); in bq32k_sysfs_store_tricklecharge_bypass()
255 struct device *dev = &client->dev; in bq32k_probe()
260 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) in bq32k_probe()
261 return -ENODEV; in bq32k_probe()
280 if (client->dev.of_node) in bq32k_probe()
281 trickle_charger_of_init(dev, client->dev.of_node); in bq32k_probe()
283 rtc = devm_rtc_device_register(&client->dev, bq32k_driver.driver.name, in bq32k_probe()
288 error = bq32k_sysfs_register(&client->dev); in bq32k_probe()
290 dev_err(&client->dev, in bq32k_probe()
303 bq32k_sysfs_unregister(&client->dev); in bq32k_remove()