Lines Matching +full:eeprom +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0-only
3 * max6875.c - driver for MAX6874/MAX6875
7 * Based on eeprom.c
9 * The MAX6875 has a bank of registers and two banks of EEPROM.
11 * * 0x0000 - 0x0046 = configuration registers
12 * * 0x8000 - 0x8046 = configuration EEPROM
13 * * 0x8100 - 0x82FF = user EEPROM
15 * This driver makes the user EEPROM available for read.
17 * The registers & config EEPROM should be accessed via i2c-dev.
20 * two addresses - 0x50/0x51 and 0x52/0x53.
23 * address, so this driver is destructive if loaded for the wrong EEPROM chip.
36 /* USER EEPROM is at addresses 0x8100 - 0x82FF */
44 /* Each client has this additional data */
50 u8 data[USER_EEPROM_SIZE]; member
56 struct max6875_data *data = i2c_get_clientdata(client); in max6875_update_slice() local
63 mutex_lock(&data->update_lock); in max6875_update_slice()
65 buf = &data->data[slice << SLICE_BITS]; in max6875_update_slice()
67 if (!(data->valid & (1 << slice)) || in max6875_update_slice()
68 time_after(jiffies, data->last_updated[slice])) { in max6875_update_slice()
70 dev_dbg(&client->dev, "Starting update of slice %u\n", slice); in max6875_update_slice()
72 data->valid &= ~(1 << slice); in max6875_update_slice()
76 /* select the eeprom address */ in max6875_update_slice()
78 dev_err(&client->dev, "address set failed\n"); in max6875_update_slice()
82 if (i2c_check_functionality(client->adapter, in max6875_update_slice()
99 data->last_updated[slice] = jiffies; in max6875_update_slice()
100 data->valid |= (1 << slice); in max6875_update_slice()
103 mutex_unlock(&data->update_lock); in max6875_update_slice()
111 struct max6875_data *data = i2c_get_clientdata(client); in max6875_read() local
115 max_slice = (off + count - 1) >> SLICE_BITS; in max6875_read()
119 memcpy(buf, &data->data[off], count); in max6875_read()
126 .name = "eeprom",
135 struct i2c_adapter *adapter = client->adapter; in max6875_probe()
136 struct max6875_data *data; in max6875_probe() local
141 return -ENODEV; in max6875_probe()
144 if (client->addr & 1) in max6875_probe()
145 return -ENODEV; in max6875_probe()
147 data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL); in max6875_probe()
148 if (!data) in max6875_probe()
149 return -ENOMEM; in max6875_probe()
152 data->fake_client = i2c_new_dummy_device(client->adapter, client->addr + 1); in max6875_probe()
153 if (IS_ERR(data->fake_client)) { in max6875_probe()
154 err = PTR_ERR(data->fake_client); in max6875_probe()
159 i2c_set_clientdata(client, data); in max6875_probe()
160 mutex_init(&data->update_lock); in max6875_probe()
162 err = sysfs_create_bin_file(&client->dev.kobj, &user_eeprom_attr); in max6875_probe()
169 i2c_unregister_device(data->fake_client); in max6875_probe()
171 kfree(data); in max6875_probe()
177 struct max6875_data *data = i2c_get_clientdata(client); in max6875_remove() local
179 i2c_unregister_device(data->fake_client); in max6875_remove()
181 sysfs_remove_bin_file(&client->dev.kobj, &user_eeprom_attr); in max6875_remove()
182 kfree(data); in max6875_remove()