summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2018-09-18 10:35:24 +0300
committerTom Rini <trini@konsulko.com>2018-09-28 20:22:34 -0400
commitd3e19cf9195e7308c6333bbbbc12f8db8fa2d079 (patch)
tree96c9b9583e2c5f2b59bd142e89f7fb9e73702196 /include
parent620300043c95cc695585748ba6ef79da8b8095eb (diff)
w1: Add 1-Wire uclass
We might want to use 1-Wire devices connected on boards such as EEPROMs in U-Boot. Provide a framework to be able to do that. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> [eugen.hristev@microchip.com: reworked] Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Diffstat (limited to 'include')
-rw-r--r--include/dm/uclass-id.h1
-rw-r--r--include/w1.h36
2 files changed, 37 insertions, 0 deletions
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 10d29901e0..fcfc120351 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -93,6 +93,7 @@ enum uclass_id {
UCLASS_VIDEO, /* Video or LCD device */
UCLASS_VIDEO_BRIDGE, /* Video bridge, e.g. DisplayPort to LVDS */
UCLASS_VIDEO_CONSOLE, /* Text console driver for video device */
+ UCLASS_W1, /* Dallas 1-Wire bus */
UCLASS_WDT, /* Watchdot Timer driver */
UCLASS_COUNT,
diff --git a/include/w1.h b/include/w1.h
new file mode 100644
index 0000000000..b36e0f8d5d
--- /dev/null
+++ b/include/w1.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Copyright (c) 2015 Free Electrons
+ * Copyright (c) 2015 NextThing Co
+ *
+ */
+
+#ifndef __W1_H
+#define __W1_H
+
+#include <dm.h>
+
+#define W1_FAMILY_DS24B33 0x23
+#define W1_FAMILY_DS2431 0x2d
+
+struct w1_device {
+ u64 id;
+};
+
+struct w1_ops {
+ u8 (*read_byte)(struct udevice *dev);
+ bool (*reset)(struct udevice *dev);
+ u8 (*triplet)(struct udevice *dev, bool bdir);
+ void (*write_byte)(struct udevice *dev, u8 byte);
+};
+
+int w1_get_bus(int busnum, struct udevice **busp);
+u8 w1_get_device_family(struct udevice *dev);
+
+int w1_read_buf(struct udevice *dev, u8 *buf, unsigned int count);
+int w1_read_byte(struct udevice *dev);
+int w1_reset_select(struct udevice *dev);
+int w1_write_buf(struct udevice *dev, u8 *buf, unsigned int count);
+int w1_write_byte(struct udevice *dev, u8 byte);
+
+#endif