Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: lp87565: Handle optional reset pin

Optionally handle the NRST pin (active low reset) in order to start from a
known state during boot and to shut down the chip when rebooting.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Luca Ceresoli and committed by
Lee Jones
50e4d7a2 4700ef32

+28
+27
drivers/mfd/lp87565.c
··· 5 5 * Author: Keerthy <j-keerthy@ti.com> 6 6 */ 7 7 8 + #include <linux/gpio/consumer.h> 8 9 #include <linux/interrupt.h> 9 10 #include <linux/mfd/core.h> 10 11 #include <linux/module.h> ··· 65 64 return ret; 66 65 } 67 66 67 + lp87565->reset_gpio = devm_gpiod_get_optional(lp87565->dev, "reset", 68 + GPIOD_OUT_LOW); 69 + if (IS_ERR(lp87565->reset_gpio)) { 70 + ret = PTR_ERR(lp87565->reset_gpio); 71 + if (ret == -EPROBE_DEFER) 72 + return ret; 73 + } 74 + 75 + if (lp87565->reset_gpio) { 76 + gpiod_set_value_cansleep(lp87565->reset_gpio, 1); 77 + /* The minimum assertion time is undocumented, just guess */ 78 + usleep_range(2000, 4000); 79 + 80 + gpiod_set_value_cansleep(lp87565->reset_gpio, 0); 81 + /* Min 1.2 ms before first I2C transaction */ 82 + usleep_range(1500, 3000); 83 + } 84 + 68 85 ret = regmap_read(lp87565->regmap, LP87565_REG_OTP_REV, &otpid); 69 86 if (ret) { 70 87 dev_err(lp87565->dev, "Failed to read OTP ID\n"); ··· 102 83 NULL, 0, NULL); 103 84 } 104 85 86 + static void lp87565_shutdown(struct i2c_client *client) 87 + { 88 + struct lp87565 *lp87565 = i2c_get_clientdata(client); 89 + 90 + gpiod_set_value_cansleep(lp87565->reset_gpio, 1); 91 + } 92 + 105 93 static const struct i2c_device_id lp87565_id_table[] = { 106 94 { "lp87565-q1", 0 }, 107 95 { }, ··· 121 95 .of_match_table = of_lp87565_match_table, 122 96 }, 123 97 .probe = lp87565_probe, 98 + .shutdown = lp87565_shutdown, 124 99 .id_table = lp87565_id_table, 125 100 }; 126 101 module_i2c_driver(lp87565_driver);
+1
include/linux/mfd/lp87565.h
··· 252 252 u8 rev; 253 253 u8 dev_type; 254 254 struct regmap *regmap; 255 + struct gpio_desc *reset_gpio; 255 256 }; 256 257 #endif /* __LINUX_MFD_LP87565_H */