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.
11 #include <linux/err.h>
13 #include <w1-eeprom.h>
16 #define W1_F2D_READ_EEPROM 0xf0
18 static int ds24xxx_read_buf(struct udevice
*dev
, unsigned int offset
,
19 u8
*buf
, unsigned int count
)
23 w1_write_byte(dev
, W1_F2D_READ_EEPROM
);
24 w1_write_byte(dev
, offset
& 0xff);
25 w1_write_byte(dev
, offset
>> 8);
27 return w1_read_buf(dev
, buf
, count
);
30 static int ds24xxx_probe(struct udevice
*dev
)
34 w1
= dev_get_parent_platdata(dev
);
39 static const struct w1_eeprom_ops ds24xxx_ops
= {
40 .read_buf
= ds24xxx_read_buf
,
43 static const struct udevice_id ds24xxx_id
[] = {
44 { .compatible
= "maxim,ds24b33", .data
= W1_FAMILY_DS24B33
},
45 { .compatible
= "maxim,ds2431", .data
= W1_FAMILY_DS2431
},
49 U_BOOT_DRIVER(ds24xxx
) = {
51 .id
= UCLASS_W1_EEPROM
,
52 .of_match
= ds24xxx_id
,
54 .probe
= ds24xxx_probe
,