From 567ec716efab543c55a0d1abf2303f193ea9d544 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 19 Dec 2019 11:55:58 +0100 Subject: eeprom: at24: update the license tag The current GPL v2.0 or later SPDX tag is 'GPL-2.0-or-later' as defined at https://spdx.org/licenses/. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/misc') diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 0681d5fdd538..1d7270bbf29f 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +// SPDX-License-Identifier: GPL-2.0-or-later /* * at24.c - handle most I2C EEPROMs * -- cgit From 69afc4b623088665677be09ea59627aaf080bff7 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 2 Jan 2020 17:56:32 +0100 Subject: eeprom: at24: sort headers alphabetically For consistency and easier maintenance: sort the headers alphabetically. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/misc') diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 1d7270bbf29f..ffecabd5d527 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -6,23 +6,23 @@ * Copyright (C) 2008 Wolfram Sang, Pengutronix */ -#include +#include +#include +#include +#include +#include #include +#include +#include +#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include -#include +#include #include -#include +#include +#include +#include /* Address pointer is 16 bit. */ #define AT24_FLAG_ADDR16 BIT(7) -- cgit From 1c89074bf85068d1b86f2e0f0c2110fdd9b83c9f Mon Sep 17 00:00:00 2001 From: Khouloud Touil Date: Thu, 9 Jan 2020 10:51:13 +0100 Subject: eeprom: at24: remove the write-protect pin support NVMEM framework is an interface for the at24 EEPROMs as well as for other drivers, instead of passing the wp-gpios over the different drivers each time, it would be better to pass it over the NVMEM subsystem once and for all. Removing the support for the write-protect pin after adding it to the NVMEM subsystem. Signed-off-by: Khouloud Touil Reviewed-by: Linus Walleij Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'drivers/misc') diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index ffecabd5d527..896c1fe3c44b 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -89,8 +88,6 @@ struct at24_data { struct nvmem_device *nvmem; - struct gpio_desc *wp_gpio; - /* * Some chips tie up multiple I2C addresses; dummy devices reserve * them for us, and we'll use them with SMBus calls. @@ -457,12 +454,10 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) * from this host, but not from other I2C masters. */ mutex_lock(&at24->lock); - gpiod_set_value_cansleep(at24->wp_gpio, 0); while (count) { ret = at24_regmap_write(at24, buf, off, count); if (ret < 0) { - gpiod_set_value_cansleep(at24->wp_gpio, 1); mutex_unlock(&at24->lock); pm_runtime_put(dev); return ret; @@ -472,7 +467,6 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) count -= ret; } - gpiod_set_value_cansleep(at24->wp_gpio, 1); mutex_unlock(&at24->lock); pm_runtime_put(dev); @@ -662,9 +656,6 @@ static int at24_probe(struct i2c_client *client) at24->client[0].client = client; at24->client[0].regmap = regmap; - at24->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH); - if (IS_ERR(at24->wp_gpio)) - return PTR_ERR(at24->wp_gpio); writable = !(flags & AT24_FLAG_READONLY); if (writable) { -- cgit From cd5676db0574cc1c0b234bc3b17565b07290aa72 Mon Sep 17 00:00:00 2001 From: Bibby Hsieh Date: Thu, 23 Jan 2020 12:52:57 +0100 Subject: misc: eeprom: at24: support pm_runtime control Although in the most platforms, the power of eeprom are alway on, some platforms disable the eeprom power in order to meet low power request. This patch add the pm_runtime ops to control power to support all platforms. Signed-off-by: Bibby Hsieh [Bartosz: rebased on top of current at24/for-next] Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'drivers/misc') diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 896c1fe3c44b..031eb64549af 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -21,6 +21,7 @@ #include #include #include +#include #include /* Address pointer is 16 bit. */ @@ -87,6 +88,7 @@ struct at24_data { u8 flags; struct nvmem_device *nvmem; + struct regulator *vcc_reg; /* * Some chips tie up multiple I2C addresses; dummy devices reserve @@ -656,6 +658,9 @@ static int at24_probe(struct i2c_client *client) at24->client[0].client = client; at24->client[0].regmap = regmap; + at24->vcc_reg = devm_regulator_get(dev, "vcc"); + if (IS_ERR(at24->vcc_reg)) + return PTR_ERR(at24->vcc_reg); writable = !(flags & AT24_FLAG_READONLY); if (writable) { @@ -692,6 +697,12 @@ static int at24_probe(struct i2c_client *client) i2c_set_clientdata(client, at24); + err = regulator_enable(at24->vcc_reg); + if (err) { + dev_err(dev, "Failed to enable vcc regulator\n"); + return err; + } + /* enable runtime pm */ pm_runtime_set_active(dev); pm_runtime_enable(dev); @@ -704,6 +715,7 @@ static int at24_probe(struct i2c_client *client) pm_runtime_idle(dev); if (err) { pm_runtime_disable(dev); + regulator_disable(at24->vcc_reg); return -ENODEV; } @@ -719,15 +731,42 @@ static int at24_probe(struct i2c_client *client) static int at24_remove(struct i2c_client *client) { + struct at24_data *at24 = i2c_get_clientdata(client); + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + regulator_disable(at24->vcc_reg); pm_runtime_set_suspended(&client->dev); return 0; } +static int __maybe_unused at24_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct at24_data *at24 = i2c_get_clientdata(client); + + return regulator_disable(at24->vcc_reg); +} + +static int __maybe_unused at24_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct at24_data *at24 = i2c_get_clientdata(client); + + return regulator_enable(at24->vcc_reg); +} + +static const struct dev_pm_ops at24_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(at24_suspend, at24_resume, NULL) +}; + static struct i2c_driver at24_driver = { .driver = { .name = "at24", + .pm = &at24_pm_ops, .of_match_table = at24_of_match, .acpi_match_table = ACPI_PTR(at24_acpi_ids), }, -- cgit