1 // SPDX-License-Identifier: GPL-2.0+
4 * Copyright (c) 2015 Free Electrons
5 * Copyright (c) 2015 NextThing Co.
6 * Copyright (c) 2018 Microchip Technology, Inc.
8 * Maxime Ripard <maxime.ripard@free-electrons.com>
9 * Eugen Hristev <eugen.hristev@microchip.com>
13 #define LOG_CATEGORY UCLASS_W1_EEPROM
19 #include <w1-eeprom.h>
21 #include <dm/device-internal.h>
23 int w1_eeprom_read_buf(struct udevice *dev, unsigned int offset,
24 u8 *buf, unsigned int count)
26 const struct w1_eeprom_ops *ops = device_get_ops(dev);
33 ret = w1_eeprom_get_id(dev, &id);
39 return ops->read_buf(dev, offset, buf, count);
42 int w1_eeprom_get_id(struct udevice *dev, u64 *id)
44 struct w1_device *w1 = dev_get_parent_plat(dev);
53 UCLASS_DRIVER(w1_eeprom) = {
55 .id = UCLASS_W1_EEPROM,
56 .flags = DM_UC_FLAG_SEQ_ALIAS,
57 #if CONFIG_IS_ENABLED(OF_CONTROL)
58 .post_bind = dm_scan_fdt_dev,
62 int w1_eeprom_dm_init(void)
68 ret = uclass_get(UCLASS_W1_EEPROM, &uc);
70 debug("W1_EEPROM uclass not available\n");
74 uclass_foreach_dev(dev, uc) {
75 ret = device_probe(dev);
76 if (ret == -ENODEV) { /* No such device. */
77 debug("W1_EEPROM not available.\n");
81 if (ret) { /* Other error. */
82 printf("W1_EEPROM probe failed, error %d\n", ret);