#include "tlv320adcx140.h"
+static const char *const adcx140_supply_names[] = {
+ "avdd",
+ "iovdd",
+};
+
+#define ADCX140_NUM_SUPPLIES ARRAY_SIZE(adcx140_supply_names)
+
struct adcx140_priv {
struct regulator *supply_areg;
+ struct regulator_bulk_data supplies[ADCX140_NUM_SUPPLIES];
struct gpio_desc *gpio_reset;
struct regmap *regmap;
struct device *dev;
static int adcx140_pwr_off(struct adcx140_priv *adcx140)
{
+ int ret;
+
regcache_cache_only(adcx140->regmap, true);
regcache_mark_dirty(adcx140->regmap);
*/
usleep_range(30000, 100000);
+ /* Power off the regulators, `avdd` and `iovdd` */
+ ret = regulator_bulk_disable(ARRAY_SIZE(adcx140->supplies),
+ adcx140->supplies);
+ if (ret) {
+ dev_err(adcx140->dev, "Failed to disable supplies: %d\n", ret);
+ return ret;
+ }
+
return 0;
}
{
int ret;
+ /* Power on the regulators, `avdd` and `iovdd` */
+ ret = regulator_bulk_enable(ARRAY_SIZE(adcx140->supplies),
+ adcx140->supplies);
+ if (ret) {
+ dev_err(adcx140->dev, "Failed to enable supplies: %d\n", ret);
+ return ret;
+ }
+
/* De-assert the reset GPIO */
gpiod_set_value_cansleep(adcx140->gpio_reset, 1);
adcx140->phase_calib_on = false;
adcx140->dev = &i2c->dev;
+ for (int i = 0; i < ADCX140_NUM_SUPPLIES; i++)
+ adcx140->supplies[i].supply = adcx140_supply_names[i];
+
+ ret = devm_regulator_bulk_get(&i2c->dev, ADCX140_NUM_SUPPLIES,
+ adcx140->supplies);
+ if (ret) {
+ dev_err_probe(&i2c->dev, ret, "Failed to request supplies\n");
+ return ret;
+ }
+
adcx140->gpio_reset = devm_gpiod_get_optional(adcx140->dev,
"reset", GPIOD_OUT_LOW);
if (IS_ERR(adcx140->gpio_reset))