Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebc4768a authored by Jan Kandziora's avatar Jan Kandziora Committed by Greg Kroah-Hartman
Browse files

add w1_ds28e17 driver for the DS28E17 Onewire to I2C master bridge



This subpatch adds a driver for the DS28E17 Onewire to I2C master bridge.

Signed-off-by: default avatarJan Kandziora <jjj@gmx.de>
Acked-by: default avatarEvgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eb8470db
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
What:		/sys/bus/w1/devices/19-<id>/speed
Date:		Sep 2017
KernelVersion:	4.14
Contact:	Jan Kandziora <jjj@gmx.de>
Description:	When written, this file sets the I2C speed on the connected
		DS28E17 chip. When read, it reads the current setting from
		the DS28E17 chip.
		Valid values: 100, 400, 900 [kBaud].
		Default 100, can be set by w1_ds28e17.speed= module parameter.
Users:		w1_ds28e17 driver

What:		/sys/bus/w1/devices/19-<id>/stretch
Date:		Sep 2017
KernelVersion:	4.14
Contact:	Jan Kandziora <jjj@gmx.de>
Description:	When written, this file sets the multiplier used to calculate
		the busy timeout for I2C operations on the connected DS28E17
		chip. When read, returns the current setting.
		Valid values: 1 to 9.
		Default 1, can be set by w1_ds28e17.stretch= module parameter.
Users:		w1_ds28e17 driver
+2 −0
Original line number Diff line number Diff line
@@ -10,3 +10,5 @@ w1_ds2438
	- The Maxim/Dallas Semiconductor ds2438 smart battery monitor.
w1_ds28e04
	- The Maxim/Dallas Semiconductor ds28e04 eeprom.
w1_ds28e17
	- The Maxim/Dallas Semiconductor ds28e17 1-Wire-to-I2C Master Bridge.
+68 −0
Original line number Diff line number Diff line
Kernel driver w1_ds28e17
========================

Supported chips:
  * Maxim DS28E17 1-Wire-to-I2C Master Bridge

supported family codes:
	W1_FAMILY_DS28E17  0x19

Author: Jan Kandziora <jjj@gmx.de>


Description
-----------
The DS28E17 is a Onewire slave device which acts as an I2C bus master.

This driver creates a new I2C bus for any DS28E17 device detected. I2C buses
come and go as the DS28E17 devices come and go. I2C slave devices connected to
a DS28E17 can be accessed by the kernel or userspace tools as if they were
connected to a "native" I2C bus master.


An udev rule like the following
-------------------------------------------------------------------------------
SUBSYSTEM=="i2c-dev", KERNEL=="i2c-[0-9]*", ATTRS{name}=="w1-19-*", \
        SYMLINK+="i2c-$attr{name}"
-------------------------------------------------------------------------------
may be used to create stable /dev/i2c- entries based on the unique id of the
DS28E17 chip.


Driver parameters are:

speed:
	This sets up the default I2C speed a DS28E17 get configured for as soon
	it is connected. The power-on default	of the DS28E17 is 400kBaud, but
	chips may come and go on the Onewire bus without being de-powered and
	as soon the "w1_ds28e17" driver notices a freshly connected, or
	reconnected DS28E17 device on the Onewire bus, it will re-apply this
	setting.

	Valid values are 100, 400, 900 [kBaud]. Any other value means to leave
	alone the current DS28E17 setting on detect. The default value is 100.

stretch:
	This sets up the default stretch value used for freshly connected
	DS28E17 devices. It is a multiplier used on the calculation of the busy
	wait time for an I2C transfer. This is to account for I2C slave devices
	which make heavy use of the I2C clock stretching feature and thus, the
	needed timeout cannot be pre-calculated correctly. As the w1_ds28e17
	driver checks the DS28E17's busy flag in a loop after the precalculated
	wait time, it should be hardly needed to tweak this setting.

	Leave it at 1 unless you get ETIMEDOUT errors and a "w1_slave_driver
	19-00000002dbd8: busy timeout" in the kernel log.

	Valid values are 1 to 9. The default is 1.


The driver creates sysfs files /sys/bus/w1/devices/19-<id>/speed and
/sys/bus/w1/devices/19-<id>/stretch for each device, preloaded with the default
settings from the driver parameters. They may be changed anytime. In addition a
directory /sys/bus/w1/devices/19-<id>/i2c-<nnn> for the I2C bus master sysfs
structure is created.


See https://github.com/ianka/w1_ds28e17 for even more information.
+15 −0
Original line number Diff line number Diff line
@@ -148,4 +148,19 @@ config W1_SLAVE_DS28E04

	  If you are unsure, say N.

config W1_SLAVE_DS28E17
	tristate "1-wire-to-I2C master bridge (DS28E17)"
	select CRC16
	depends on I2C
	help
	  Say Y here if you want to use the DS28E17 1-wire-to-I2C master bridge.
	  For each DS28E17 detected, a new I2C adapter is created within the
	  kernel. I2C devices on that bus can be configured to be used by the
	  kernel and userspace tools as on any other "native" I2C bus.

	  This driver is also available as a module. If so, the module
	  will be called w1_ds28e17.

	  If you are unsure, say N.

endmenu
+1 −0
Original line number Diff line number Diff line
@@ -17,3 +17,4 @@ 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
obj-$(CONFIG_W1_SLAVE_DS28E17)	+= w1_ds28e17.o
Loading