Lines Matching +full:bd +full:- +full:address
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ee1004 - driver for DDR4 SPD EEPROMs
5 * Copyright (C) 2017-2019 Jean Delvare
8 * Copyright (C) 2005-2007 David Brownell
19 #include <linux/nvmem-provider.h>
23 * specification. These are 512-byte EEPROMs using a single I2C address
24 * in the 0x50-0x57 range for data. One of two 256-byte page is selected
25 * by writing a command to I2C address 0x36 or 0x37 on the same I2C bus.
62 /*-------------------------------------------------------------------------*/
82 static int ee1004_get_current_page(struct ee1004_bus_data *bd) in ee1004_get_current_page() argument
86 err = i2c_smbus_read_byte(bd->set_page[0]); in ee1004_get_current_page()
87 if (err == -ENXIO) { in ee1004_get_current_page()
102 struct ee1004_bus_data *bd = i2c_get_clientdata(client); in ee1004_set_current_page() local
105 if (page == bd->current_page) in ee1004_set_current_page()
109 ret = i2c_smbus_write_byte(bd->set_page[page], 0x00); in ee1004_set_current_page()
114 if (ret == -ENXIO && ee1004_get_current_page(bd) == page) in ee1004_set_current_page()
117 dev_err(&client->dev, "Failed to select page %d (%d)\n", page, ret); in ee1004_set_current_page()
121 dev_dbg(&client->dev, "Selected page %d\n", page); in ee1004_set_current_page()
122 bd->current_page = page; in ee1004_set_current_page()
133 offset &= (1 << EE1004_PAGE_SHIFT) - 1; in ee1004_eeprom_read()
141 count = EE1004_PAGE_SIZE - offset; in ee1004_eeprom_read()
159 return -EINVAL; in ee1004_read()
176 count -= ret; in ee1004_read()
187 unsigned short addr = 0x18 | (client->addr & 7); in ee1004_probe_temp_sensor()
203 * with SPD revision 1.0, check the thermal sensor address in ee1004_probe_temp_sensor()
205 * that address. in ee1004_probe_temp_sensor()
207 * temperature sensor address since i2c_new_scanned_device() in ee1004_probe_temp_sensor()
214 i2c_new_scanned_device(client->adapter, &info, addr_list, NULL); in ee1004_probe_temp_sensor()
217 static void ee1004_cleanup(int idx, struct ee1004_bus_data *bd) in ee1004_cleanup() argument
219 if (--bd->dev_count == 0) { in ee1004_cleanup()
220 while (--idx >= 0) in ee1004_cleanup()
221 i2c_unregister_device(bd->set_page[idx]); in ee1004_cleanup()
222 memset(bd, 0, sizeof(struct ee1004_bus_data)); in ee1004_cleanup()
228 struct ee1004_bus_data *bd = data; in ee1004_cleanup_bus_data() local
232 ee1004_cleanup(EE1004_NUM_PAGES, bd); in ee1004_cleanup_bus_data()
238 struct ee1004_bus_data *bd; in ee1004_init_bus_data() local
241 bd = ee1004_get_bus_data(client->adapter); in ee1004_init_bus_data()
242 if (!bd) in ee1004_init_bus_data()
243 return dev_err_probe(&client->dev, -ENOSPC, "Only %d busses supported", in ee1004_init_bus_data()
246 i2c_set_clientdata(client, bd); in ee1004_init_bus_data()
248 if (++bd->dev_count == 1) { in ee1004_init_bus_data()
253 cl = i2c_new_dummy_device(client->adapter, EE1004_ADDR_SET_PAGE + cnr); in ee1004_init_bus_data()
259 bd->set_page[cnr] = cl; in ee1004_init_bus_data()
263 err = ee1004_get_current_page(bd); in ee1004_init_bus_data()
267 dev_dbg(&client->dev, "Currently selected page: %d\n", err); in ee1004_init_bus_data()
268 bd->current_page = err; in ee1004_init_bus_data()
274 ee1004_cleanup(cnr, bd); in ee1004_init_bus_data()
282 .dev = &client->dev, in ee1004_probe()
283 .name = dev_name(&client->dev), in ee1004_probe()
295 .base_dev = &client->dev, in ee1004_probe()
301 if (!i2c_check_functionality(client->adapter, in ee1004_probe()
303 !i2c_check_functionality(client->adapter, in ee1004_probe()
305 return -EPFNOSUPPORT; in ee1004_probe()
319 err = devm_add_action_or_reset(&client->dev, ee1004_cleanup_bus_data, in ee1004_probe()
324 ndev = devm_nvmem_register(&client->dev, &config); in ee1004_probe()
328 dev_info(&client->dev, in ee1004_probe()
329 "%u byte EE1004-compliant SPD EEPROM, read-only\n", in ee1004_probe()
335 /*-------------------------------------------------------------------------*/
346 MODULE_DESCRIPTION("Driver for EE1004-compliant DDR4 SPD EEPROMs");