Skip to contentSkip to conversation

add 1-wire support

PATCH Applied Jean-Christophe PLAGNIOL-VILLARD 2 participants 7 messages Oct 29, 2012 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

v2 cover add 1-wire support

Hi,

v2: use is_non_interruptible_timeout as name
use is_non_interruptible_timeout for ndelay as we will never call poller_cal anyway

The following changes since commit 72703410feff9ed44779b54a41ff30312e781279:

misc JTAG: include fixes (2012-10-26 09:08:51 +0200)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git tags/w1

for you to fetch changes up to acaa716bce8cd1373cb5dabff54332fb1da7355b:

1-wire: add ds2433 support (2012-10-29 04:46:21 +0800)

----------------------------------------------------------------
add 1-wire support

export for each device via param
the familly id (fid)
the id
the full reg_num

so for simple 64bit memory rom(ds2401/ds2411/ds1990*) no need driver.

with ds2431 and ds2433 eeprom support

Based on linux implementation, cleaned and re-implement the master/slave support to use the device/driver model correctly.

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (5):
clock: introduce non interruptible timeout
add 1-wire support
1-wire: add gpio bus
1-wire: add ds2431 support
1-wire: add ds2433 support

 common/clock.c                |   16 ++-
 drivers/Kconfig               |    1 +
 drivers/Makefile              |    1 +
 drivers/w1/Kconfig            |   14 +++
 drivers/w1/Makefile           |    6 +
 drivers/w1/masters/Kconfig    |   14 +++
 drivers/w1/masters/Makefile   |    5 +
 drivers/w1/masters/w1-gpio.c  |  116 ++++++++++++++++++++
 drivers/w1/slaves/Kconfig     |   27 +++++
 drivers/w1/slaves/Makefile    |    6 +
 drivers/w1/slaves/w1_ds2431.c |  294 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/w1/slaves/w1_ds2433.c |  196 +++++++++++++++++++++++++++++++++
 drivers/w1/w1.c               |  621 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/w1/w1.h               |  152 ++++++++++++++++++++++++++
 include/clock.h               |    1 +
 include/linux/w1-gpio.h       |   25 +++++
 16 files changed, 1490 insertions(+), 5 deletions(-)
 create mode 100644 drivers/w1/Kconfig
 create mode 100644 drivers/w1/Makefile
 create mode 100644 drivers/w1/masters/Kconfig
 create mode 100644 drivers/w1/masters/Makefile
 create mode 100644 drivers/w1/masters/w1-gpio.c
 create mode 100644 drivers/w1/slaves/Kconfig
 create mode 100644 drivers/w1/slaves/Makefile
 create mode 100644 drivers/w1/slaves/w1_ds2431.c
 create mode 100644 drivers/w1/slaves/w1_ds2433.c
 create mode 100644 drivers/w1/w1.c
 create mode 100644 drivers/w1/w1.h
 create mode 100644 include/linux/w1-gpio.h

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH v2 1/5 clock: introduce non interruptible timeout

is_timeout call poller_call if the timeout is >= 100us

but on 1-wire bus we need to wait 500us and not more than 930us for the bus reset. So if the poller_call is caller we can not guarantee it.

So for this introduce is_non_interruptible_timeout than we only wait.

Use it for ndelay too.

---
 common/clock.c  |   16 +++++++++++-----
 include/clock.h |    1 +
 2 files changed, 12 insertions(+), 5 deletions(-)
common/clock.c +11 -5
index 8adbeaf..9c7c1ba 100644
@@ -135,23 +135,29 @@ uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant)
         return (uint32_t)tmp;
 }
 
-int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns)
 {
-	if (time_offset_ns >= 100 * USECOND)
-		poller_call();
-
 	if ((int64_t)(start_ns + time_offset_ns - get_time_ns()) < 0)
 		return 1;
 	else
 		return 0;
 }
+EXPORT_SYMBOL(is_timeout_non_interruptible);
+
+int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+{
+	if (time_offset_ns >= 100 * USECOND)
+		poller_call();
+
+	return is_timeout_non_interruptible(start_ns, time_offset_ns);
+}
 EXPORT_SYMBOL(is_timeout);
 
 void ndelay(unsigned long nsecs)
 {
 	uint64_t start = get_time_ns();
 
-	while(!is_timeout(start, nsecs));
+	while(!is_timeout_non_interruptible(start, nsecs));
 }
 EXPORT_SYMBOL(ndelay);
 
include/clock.h +1 -0
index c01a8d0..a169790 100644
@@ -32,6 +32,7 @@ void clocks_calc_mult_shift(uint32_t *mult, uint32_t *shift, uint32_t from, uint
 uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant);
 
 int is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
+int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns);
 
 // void udelay(unsigned long usecs);
 
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 2/5 add 1-wire support

export for each device via param
the familly id (fid)
the id
the full reg_num

so for simple 64bit memory rom(ds2401/ds2411/ds1990*) no need driver.

Based on linux implementation, cleaned and re-implement the master/slave support to use the device/driver model correctly.

---
 drivers/Kconfig             |    1 +
 drivers/Makefile            |    1 +
 drivers/w1/Kconfig          |   14 +
 drivers/w1/Makefile         |    6 +
 drivers/w1/masters/Kconfig  |    7 +
 drivers/w1/masters/Makefile |    4 +
 drivers/w1/slaves/Kconfig   |    7 +
 drivers/w1/slaves/Makefile  |    4 +
 drivers/w1/w1.c             |  621 +++++++++++++++++++++++++++++++++++++++++++
 drivers/w1/w1.h             |  152 +++++++++++
 10 files changed, 817 insertions(+)
 create mode 100644 drivers/w1/Kconfig
 create mode 100644 drivers/w1/Makefile
 create mode 100644 drivers/w1/masters/Kconfig
 create mode 100644 drivers/w1/masters/Makefile
 create mode 100644 drivers/w1/slaves/Kconfig
 create mode 100644 drivers/w1/slaves/Makefile
 create mode 100644 drivers/w1/w1.c
 create mode 100644 drivers/w1/w1.h
drivers/Kconfig +1 -0
index d0b5e3a..945fe02 100644
@@ -21,5 +21,6 @@ source "drivers/pwm/Kconfig"
 source "drivers/dma/Kconfig"
 source "drivers/gpio/Kconfig"
 source "drivers/of/Kconfig"
+source "drivers/w1/Kconfig"
 
 endmenu
drivers/Makefile +1 -0
index 2a1f8b0..e6cdf39 100644
@@ -21,3 +21,4 @@ obj-y	+= dma/
 obj-y  += watchdog/
 obj-y	+= gpio/
 obj-$(CONFIG_OFDEVICE) += of/
+obj-$(CONFIG_W1) += w1/
drivers/w1/Kconfig new file +14 -0
new file mode 100644
index 0000000..ab34997
@@ -0,0 +1,14 @@
+menuconfig W1
+	bool "Dallas's 1-wire support"
+	---help---
+	  Dallas' 1-wire bus is useful to connect slow 1-pin devices
+	  such as iButtons and thermal sensors.
+
+	  If you want W1 support, you should say Y here.
+
+if W1
+
+source drivers/w1/masters/Kconfig
+source drivers/w1/slaves/Kconfig
+
+endif # W1
drivers/w1/Makefile new file +6 -0
new file mode 100644
index 0000000..3e36d2f
@@ -0,0 +1,6 @@
+#
+# Makefile for the Dallas's 1-wire bus.
+#
+
+obj-$(CONFIG_W1)	+= w1.o
+obj-y			+= masters/ slaves/
drivers/w1/masters/Kconfig new file +7 -0
new file mode 100644
index 0000000..86aa8df
@@ -0,0 +1,7 @@
+#
+# 1-wire bus master configuration
+#
+
+menu "1-wire Bus Masters"
+
+endmenu
drivers/w1/masters/Makefile new file +4 -0
new file mode 100644
index 0000000..ed1b9d9
@@ -0,0 +1,4 @@
+#
+# Makefile for 1-wire bus master drivers.
+#
+
drivers/w1/slaves/Kconfig new file +7 -0
new file mode 100644
index 0000000..f35eedf
@@ -0,0 +1,7 @@
+#
+# 1-wire slaves configuration
+#
+
+menu "1-wire Slaves"
+
+endmenu
drivers/w1/slaves/Makefile new file +4 -0
new file mode 100644
index 0000000..ac9a5a7
@@ -0,0 +1,4 @@
+#
+# Makefile for the Dallas's 1-wire slaves.
+#
+
drivers/w1/w1.c new file +621 -0

621 lines not on this page · raw message

drivers/w1/w1.h new file +152 -0

152 lines not on this page · raw message

Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v2 3/5 1-wire: add gpio bus

In reply to Jean-Christophe PLAGNIOL-VILLARD

Based on linux implementation.

---
 drivers/w1/masters/Kconfig   |    7 +++
 drivers/w1/masters/Makefile  |    1 +
 drivers/w1/masters/w1-gpio.c |  116 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/w1-gpio.h      |   25 +++++++++
 4 files changed, 149 insertions(+)
 create mode 100644 drivers/w1/masters/w1-gpio.c
 create mode 100644 include/linux/w1-gpio.h
drivers/w1/masters/Kconfig +7 -0
index 86aa8df..e429c14 100644
@@ -4,4 +4,11 @@
 
 menu "1-wire Bus Masters"
 
+config W1_MASTER_GPIO
+	bool "GPIO 1-wire busmaster"
+	depends on GENERIC_GPIO
+	help
+	  Say Y here if you want to communicate with your 1-wire devices using
+	  GPIO pins. This driver uses the GPIO API to control the wire.
+
 endmenu
drivers/w1/masters/Makefile +1 -0
index ed1b9d9..84b35bb 100644
@@ -2,3 +2,4 @@
 # Makefile for 1-wire bus master drivers.
 #
 
+obj-$(CONFIG_W1_MASTER_GPIO)		+= w1-gpio.o
drivers/w1/masters/w1-gpio.c new file +116 -0

116 lines not on this page · raw message

include/linux/w1-gpio.h new file +25 -0
new file mode 100644
index 0000000..065e3ae
@@ -0,0 +1,25 @@
+/*
+ * w1-gpio interface to platform code
+ *
+ * Copyright (C) 2007 Ville Syrjala <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ */
+#ifndef _LINUX_W1_GPIO_H
+#define _LINUX_W1_GPIO_H
+
+/**
+ * struct w1_gpio_platform_data - Platform-dependent data for w1-gpio
+ * @pin: GPIO pin to use
+ * @is_open_drain: GPIO pin is configured as open drain
+ */
+struct w1_gpio_platform_data {
+	unsigned int pin;
+	unsigned int is_open_drain:1;
+	void (*enable_external_pullup)(int enable);
+	unsigned int ext_pullup_enable_pin;
+};
+
+#endif /* _LINUX_W1_GPIO_H */
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH v2 4/5 1-wire: add ds2431 support

In reply to Jean-Christophe PLAGNIOL-VILLARD

Based on linux implementation.

---
 drivers/w1/slaves/Kconfig     |   10 ++
 drivers/w1/slaves/Makefile    |    1 +
 drivers/w1/slaves/w1_ds2431.c |  294 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 305 insertions(+)
 create mode 100644 drivers/w1/slaves/w1_ds2431.c
drivers/w1/slaves/Kconfig +10 -0
index f35eedf..26150a2 100644
@@ -4,4 +4,14 @@
 
 menu "1-wire Slaves"
 
+config W1_SLAVE_DS2431
+	bool "1kb EEPROM family support (DS2431)"
+	help
+	  Say Y here if you want to use a 1-wire
+	  1kb EEPROM family device (DS2431)
+
+config W1_SLAVE_DS2431_WRITE
+	bool "write support"
+	depends on W1_SLAVE_DS2431
+
 endmenu
drivers/w1/slaves/Makefile +1 -0
index ac9a5a7..65804e0 100644
@@ -2,3 +2,4 @@
 # Makefile for the Dallas's 1-wire slaves.
 #
 
+obj-$(CONFIG_W1_SLAVE_DS2431)	+= w1_ds2431.o
drivers/w1/slaves/w1_ds2431.c new file +294 -0

294 lines not on this page · raw message

Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH v2 5/5 1-wire: add ds2433 support

In reply to Jean-Christophe PLAGNIOL-VILLARD

Based on linux implementation.

---
 drivers/w1/slaves/Kconfig     |   10 +++
 drivers/w1/slaves/Makefile    |    1 +
 drivers/w1/slaves/w1_ds2433.c |  196 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 207 insertions(+)
 create mode 100644 drivers/w1/slaves/w1_ds2433.c
drivers/w1/slaves/Kconfig +10 -0
index 26150a2..946a0b3 100644
@@ -14,4 +14,14 @@ config W1_SLAVE_DS2431_WRITE
 	bool "write support"
 	depends on W1_SLAVE_DS2431
 
+config W1_SLAVE_DS2433
+	bool "4kb EEPROM family support (DS2433)"
+	help
+	  Say Y here if you want to use a 1-wire
+	  4kb EEPROM family device (DS2433).
+
+config W1_SLAVE_DS2433_WRITE
+	bool "write support"
+	depends on W1_SLAVE_DS2433
+
 endmenu
drivers/w1/slaves/Makefile +1 -0
index 65804e0..dd7160a 100644
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_W1_SLAVE_DS2431)	+= w1_ds2431.o
+obj-$(CONFIG_W1_SLAVE_DS2433)	+= w1_ds2433.o
drivers/w1/slaves/w1_ds2433.c new file +196 -0

196 lines not on this page · raw message

Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#6 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Hi,

v2: use is_non_interruptible_timeout as name
use is_non_interruptible_timeout for ndelay as we will never call poller_cal anyway

Quoted 8 lines

The following changes since commit 72703410feff9ed44779b54a41ff30312e781279:

misc JTAG: include fixes (2012-10-26 09:08:51 +0200)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git tags/w1

Applied, thanks

Sascha

Quoted 67 lines

for you to fetch changes up to acaa716bce8cd1373cb5dabff54332fb1da7355b:

1-wire: add ds2433 support (2012-10-29 04:46:21 +0800)

----------------------------------------------------------------
add 1-wire support

export for each device via param
the familly id (fid)
the id
the full reg_num

so for simple 64bit memory rom(ds2401/ds2411/ds1990*) no need driver.

with ds2431 and ds2433 eeprom support

Based on linux implementation, cleaned and re-implement the master/slave support to use the device/driver model correctly.

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (5):
clock: introduce non interruptible timeout
add 1-wire support
1-wire: add gpio bus
1-wire: add ds2431 support
1-wire: add ds2433 support

 common/clock.c                |   16 ++-
 drivers/Kconfig               |    1 +
 drivers/Makefile              |    1 +
 drivers/w1/Kconfig            |   14 +++
 drivers/w1/Makefile           |    6 +
 drivers/w1/masters/Kconfig    |   14 +++
 drivers/w1/masters/Makefile   |    5 +
 drivers/w1/masters/w1-gpio.c  |  116 ++++++++++++++++++++
 drivers/w1/slaves/Kconfig     |   27 +++++
 drivers/w1/slaves/Makefile    |    6 +
 drivers/w1/slaves/w1_ds2431.c |  294 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/w1/slaves/w1_ds2433.c |  196 +++++++++++++++++++++++++++++++++
 drivers/w1/w1.c               |  621 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/w1/w1.h               |  152 ++++++++++++++++++++++++++
 include/clock.h               |    1 +
 include/linux/w1-gpio.h       |   25 +++++
 16 files changed, 1490 insertions(+), 5 deletions(-)
 create mode 100644 drivers/w1/Kconfig
 create mode 100644 drivers/w1/Makefile
 create mode 100644 drivers/w1/masters/Kconfig
 create mode 100644 drivers/w1/masters/Makefile
 create mode 100644 drivers/w1/masters/w1-gpio.c
 create mode 100644 drivers/w1/slaves/Kconfig
 create mode 100644 drivers/w1/slaves/Makefile
 create mode 100644 drivers/w1/slaves/w1_ds2431.c
 create mode 100644 drivers/w1/slaves/w1_ds2433.c
 create mode 100644 drivers/w1/w1.c
 create mode 100644 drivers/w1/w1.h
 create mode 100644 include/linux/w1-gpio.h

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox