diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-21 18:06:27 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-21 18:06:27 -0700 |
commit | c1fecabecc352e40f99e6c5d7a74b8fcdfb38ae1 (patch) | |
tree | 9ba08f67988d1f45602ea0276555564ebce02b28 /drivers/w1 | |
parent | 99cc7ad46b62ef20b0478147677bebd1157bd9cf (diff) | |
parent | 5198a48381455969aa1053a0ca2e4ce409be2fc2 (diff) | |
download | linux-c1fecabecc352e40f99e6c5d7a74b8fcdfb38ae1.tar.bz2 |
Merge tag 'for-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel:
- Improve support for TI bq20z75 in sbs-battery
- Add Qualcomm PM8xxx reboot driver
- Add cros-ec USBPD charger driver
- Move ds2760 battery driver from w1 to power-supply and add DT support
- Misc fixes
* tag 'for-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (28 commits)
power: supply: bq27xxx: Update comments
power: supply: max77693_charger: fix unintentional fall-through
power: supply: mark expected switch fall-throughs
power: supply: lego_ev3_battery: fix Vce offset
power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value
power: supply: ds2760_battery: add devicetree probing
power: supply: ds2760_battery: merge ds2760 supply driver with its w1 slave companion
w1: core: match sub-nodes of bus masters in devicetree
dt-bindings: w1: document bindings for ds2760 battery monitor
dt-bindings: w1: document generic onewire bindings
power: supply: adp5061: Fix a couple off by ones
dt-bindings: power: reset: qcom: Add resin binding
adp5061: New driver for ADP5061 I2C battery charger
power: generic-adc-battery: check for duplicate properties copied from iio channels
power: generic-adc-battery: fix out-of-bounds write when copying channel properties
power: supply: axp288_charger: Fix initial constant_charge_current value
power: supply: ab8500: stop using getnstimeofday64()
power: gemini-poweroff: Avoid more spurious poweroffs
power: vexpress: fix corruption in notifier registration
power: remove possible deadlock when unregistering power_supply
...
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/slaves/Kconfig | 12 | ||||
-rw-r--r-- | drivers/w1/slaves/Makefile | 1 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_ds2760.c | 175 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_ds2760.h | 59 | ||||
-rw-r--r-- | drivers/w1/w1.c | 3 |
5 files changed, 3 insertions, 247 deletions
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index 7931231d8e80..e22fdeddada1 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig @@ -100,18 +100,6 @@ config W1_SLAVE_DS2438 Say Y here if you want to use a 1-wire DS2438 Smart Battery Monitor device support -config W1_SLAVE_DS2760 - tristate "Dallas 2760 battery monitor chip (HP iPAQ & others)" - help - If you enable this you will have the DS2760 battery monitor - chip support. - - The battery monitor chip is used in many batteries/devices - as the one who is responsible for charging/discharging/monitoring - Li+ batteries. - - If you are unsure, say N. - config W1_SLAVE_DS2780 tristate "Dallas 2780 battery monitor chip" help diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile index d5f4f4d5b9e5..eab29f151413 100644 --- a/drivers/w1/slaves/Makefile +++ b/drivers/w1/slaves/Makefile @@ -14,7 +14,6 @@ obj-$(CONFIG_W1_SLAVE_DS2431) += w1_ds2431.o obj-$(CONFIG_W1_SLAVE_DS2805) += w1_ds2805.o obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o obj-$(CONFIG_W1_SLAVE_DS2438) += w1_ds2438.o -obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o obj-$(CONFIG_W1_SLAVE_DS2780) += w1_ds2780.o obj-$(CONFIG_W1_SLAVE_DS2781) += w1_ds2781.o obj-$(CONFIG_W1_SLAVE_DS28E04) += w1_ds28e04.o diff --git a/drivers/w1/slaves/w1_ds2760.c b/drivers/w1/slaves/w1_ds2760.c deleted file mode 100644 index 26168abfb8b8..000000000000 --- a/drivers/w1/slaves/w1_ds2760.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 1-Wire implementation for the ds2760 chip - * - * Copyright © 2004-2005, Szabolcs Gyurko <szabolcs.gyurko@tlt.hu> - * - * Use consistent with the GNU GPL is permitted, - * provided that this copyright notice is - * preserved in its entirety in all copies and derived works. - * - */ - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/device.h> -#include <linux/types.h> -#include <linux/platform_device.h> -#include <linux/mutex.h> -#include <linux/idr.h> -#include <linux/gfp.h> - -#include <linux/w1.h> - -#include "w1_ds2760.h" - -#define W1_FAMILY_DS2760 0x30 - -static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count, - int io) -{ - struct w1_slave *sl = container_of(dev, struct w1_slave, dev); - - if (!dev) - return 0; - - mutex_lock(&sl->master->bus_mutex); - - if (addr > DS2760_DATA_SIZE || addr < 0) { - count = 0; - goto out; - } - if (addr + count > DS2760_DATA_SIZE) - count = DS2760_DATA_SIZE - addr; - - if (!w1_reset_select_slave(sl)) { - if (!io) { - w1_write_8(sl->master, W1_DS2760_READ_DATA); - w1_write_8(sl->master, addr); - count = w1_read_block(sl->master, buf, count); - } else { - w1_write_8(sl->master, W1_DS2760_WRITE_DATA); - w1_write_8(sl->master, addr); - w1_write_block(sl->master, buf, count); - /* XXX w1_write_block returns void, not n_written */ - } - } - -out: - mutex_unlock(&sl->master->bus_mutex); - - return count; -} - -int w1_ds2760_read(struct device *dev, char *buf, int addr, size_t count) -{ - return w1_ds2760_io(dev, buf, addr, count, 0); -} -EXPORT_SYMBOL(w1_ds2760_read); - -int w1_ds2760_write(struct device *dev, char *buf, int addr, size_t count) -{ - return w1_ds2760_io(dev, buf, addr, count, 1); -} -EXPORT_SYMBOL(w1_ds2760_write); - -static int w1_ds2760_eeprom_cmd(struct device *dev, int addr, int cmd) -{ - struct w1_slave *sl = container_of(dev, struct w1_slave, dev); - - if (!dev) - return -EINVAL; - - mutex_lock(&sl->master->bus_mutex); - - if (w1_reset_select_slave(sl) == 0) { - w1_write_8(sl->master, cmd); - w1_write_8(sl->master, addr); - } - - mutex_unlock(&sl->master->bus_mutex); - return 0; -} - -int w1_ds2760_store_eeprom(struct device *dev, int addr) -{ - return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_COPY_DATA); -} -EXPORT_SYMBOL(w1_ds2760_store_eeprom); - -int w1_ds2760_recall_eeprom(struct device *dev, int addr) -{ - return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_RECALL_DATA); -} -EXPORT_SYMBOL(w1_ds2760_recall_eeprom); - -static ssize_t w1_slave_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) -{ - struct device *dev = container_of(kobj, struct device, kobj); - return w1_ds2760_read(dev, buf, off, count); -} - -static BIN_ATTR_RO(w1_slave, DS2760_DATA_SIZE); - -static struct bin_attribute *w1_ds2760_bin_attrs[] = { - &bin_attr_w1_slave, - NULL, -}; - -static const struct attribute_group w1_ds2760_group = { - .bin_attrs = w1_ds2760_bin_attrs, -}; - -static const struct attribute_group *w1_ds2760_groups[] = { - &w1_ds2760_group, - NULL, -}; - -static int w1_ds2760_add_slave(struct w1_slave *sl) -{ - int ret; - struct platform_device *pdev; - - pdev = platform_device_alloc("ds2760-battery", PLATFORM_DEVID_AUTO); - if (!pdev) - return -ENOMEM; - pdev->dev.parent = &sl->dev; - - ret = platform_device_add(pdev); - if (ret) - goto pdev_add_failed; - - dev_set_drvdata(&sl->dev, pdev); - - return 0; - -pdev_add_failed: - platform_device_put(pdev); - - return ret; -} - -static void w1_ds2760_remove_slave(struct w1_slave *sl) -{ - struct platform_device *pdev = dev_get_drvdata(&sl->dev); - - platform_device_unregister(pdev); -} - -static struct w1_family_ops w1_ds2760_fops = { - .add_slave = w1_ds2760_add_slave, - .remove_slave = w1_ds2760_remove_slave, - .groups = w1_ds2760_groups, -}; - -static struct w1_family w1_ds2760_family = { - .fid = W1_FAMILY_DS2760, - .fops = &w1_ds2760_fops, -}; -module_w1_family(w1_ds2760_family); - -MODULE_AUTHOR("Szabolcs Gyurko <szabolcs.gyurko@tlt.hu>"); -MODULE_DESCRIPTION("1-wire Driver Dallas 2760 battery monitor chip"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_DS2760)); diff --git a/drivers/w1/slaves/w1_ds2760.h b/drivers/w1/slaves/w1_ds2760.h deleted file mode 100644 index 24168c94eeae..000000000000 --- a/drivers/w1/slaves/w1_ds2760.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 1-Wire implementation for the ds2760 chip - * - * Copyright © 2004-2005, Szabolcs Gyurko <szabolcs.gyurko@tlt.hu> - * - * Use consistent with the GNU GPL is permitted, - * provided that this copyright notice is - * preserved in its entirety in all copies and derived works. - * - */ - -#ifndef __w1_ds2760_h__ -#define __w1_ds2760_h__ - -/* Known commands to the DS2760 chip */ -#define W1_DS2760_SWAP 0xAA -#define W1_DS2760_READ_DATA 0x69 -#define W1_DS2760_WRITE_DATA 0x6C -#define W1_DS2760_COPY_DATA 0x48 -#define W1_DS2760_RECALL_DATA 0xB8 -#define W1_DS2760_LOCK 0x6A - -/* Number of valid register addresses */ -#define DS2760_DATA_SIZE 0x40 - -#define DS2760_PROTECTION_REG 0x00 - -#define DS2760_STATUS_REG 0x01 -#define DS2760_STATUS_IE (1 << 2) -#define DS2760_STATUS_SWEN (1 << 3) -#define DS2760_STATUS_RNAOP (1 << 4) -#define DS2760_STATUS_PMOD (1 << 5) - -#define DS2760_EEPROM_REG 0x07 -#define DS2760_SPECIAL_FEATURE_REG 0x08 -#define DS2760_VOLTAGE_MSB 0x0c -#define DS2760_VOLTAGE_LSB 0x0d -#define DS2760_CURRENT_MSB 0x0e -#define DS2760_CURRENT_LSB 0x0f -#define DS2760_CURRENT_ACCUM_MSB 0x10 -#define DS2760_CURRENT_ACCUM_LSB 0x11 -#define DS2760_TEMP_MSB 0x18 -#define DS2760_TEMP_LSB 0x19 -#define DS2760_EEPROM_BLOCK0 0x20 -#define DS2760_ACTIVE_FULL 0x20 -#define DS2760_EEPROM_BLOCK1 0x30 -#define DS2760_STATUS_WRITE_REG 0x31 -#define DS2760_RATED_CAPACITY 0x32 -#define DS2760_CURRENT_OFFSET_BIAS 0x33 -#define DS2760_ACTIVE_EMPTY 0x3b - -extern int w1_ds2760_read(struct device *dev, char *buf, int addr, - size_t count); -extern int w1_ds2760_write(struct device *dev, char *buf, int addr, - size_t count); -extern int w1_ds2760_store_eeprom(struct device *dev, int addr); -extern int w1_ds2760_recall_eeprom(struct device *dev, int addr); - -#endif /* !__w1_ds2760_h__ */ diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index caef0e0fd817..890c038c25f8 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -26,6 +26,7 @@ #include <linux/kthread.h> #include <linux/freezer.h> #include <linux/hwmon.h> +#include <linux/of.h> #include <linux/atomic.h> @@ -686,6 +687,8 @@ static int __w1_attach_slave_device(struct w1_slave *sl) sl->dev.bus = &w1_bus_type; sl->dev.release = &w1_slave_release; sl->dev.groups = w1_slave_groups; + sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node, + sl->family->of_match_table); dev_set_name(&sl->dev, "%02x-%012llx", (unsigned int) sl->reg_num.family, |