• Home
  • Raw
  • Download

Lines Matching full:cell

339 static void nvmem_cell_drop(struct nvmem_cell *cell)  in nvmem_cell_drop()  argument
341 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_REMOVE, cell); in nvmem_cell_drop()
343 list_del(&cell->node); in nvmem_cell_drop()
345 of_node_put(cell->np); in nvmem_cell_drop()
346 kfree_const(cell->name); in nvmem_cell_drop()
347 kfree(cell); in nvmem_cell_drop()
352 struct nvmem_cell *cell, *p; in nvmem_device_remove_all_cells() local
354 list_for_each_entry_safe(cell, p, &nvmem->cells, node) in nvmem_device_remove_all_cells()
355 nvmem_cell_drop(cell); in nvmem_device_remove_all_cells()
358 static void nvmem_cell_add(struct nvmem_cell *cell) in nvmem_cell_add() argument
361 list_add_tail(&cell->node, &cell->nvmem->cells); in nvmem_cell_add()
363 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell); in nvmem_cell_add()
368 struct nvmem_cell *cell) in nvmem_cell_info_to_nvmem_cell_nodup() argument
370 cell->nvmem = nvmem; in nvmem_cell_info_to_nvmem_cell_nodup()
371 cell->offset = info->offset; in nvmem_cell_info_to_nvmem_cell_nodup()
372 cell->bytes = info->bytes; in nvmem_cell_info_to_nvmem_cell_nodup()
373 cell->name = info->name; in nvmem_cell_info_to_nvmem_cell_nodup()
375 cell->bit_offset = info->bit_offset; in nvmem_cell_info_to_nvmem_cell_nodup()
376 cell->nbits = info->nbits; in nvmem_cell_info_to_nvmem_cell_nodup()
378 if (cell->nbits) in nvmem_cell_info_to_nvmem_cell_nodup()
379 cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, in nvmem_cell_info_to_nvmem_cell_nodup()
382 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in nvmem_cell_info_to_nvmem_cell_nodup()
384 "cell %s unaligned to nvmem stride %d\n", in nvmem_cell_info_to_nvmem_cell_nodup()
385 cell->name ?: "<unknown>", nvmem->stride); in nvmem_cell_info_to_nvmem_cell_nodup()
394 struct nvmem_cell *cell) in nvmem_cell_info_to_nvmem_cell() argument
398 err = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, cell); in nvmem_cell_info_to_nvmem_cell()
402 cell->name = kstrdup_const(info->name, GFP_KERNEL); in nvmem_cell_info_to_nvmem_cell()
403 if (!cell->name) in nvmem_cell_info_to_nvmem_cell()
410 * nvmem_add_cells() - Add cell information to an nvmem device
413 * @info: nvmem cell info to add to the device
488 struct nvmem_cell *cell; in nvmem_add_cells_from_table() local
497 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_cells_from_table()
498 if (!cell) { in nvmem_add_cells_from_table()
505 cell); in nvmem_add_cells_from_table()
507 kfree(cell); in nvmem_add_cells_from_table()
511 nvmem_cell_add(cell); in nvmem_add_cells_from_table()
524 struct nvmem_cell *iter, *cell = NULL; in nvmem_find_cell_by_name() local
529 cell = iter; in nvmem_find_cell_by_name()
535 return cell; in nvmem_find_cell_by_name()
542 struct nvmem_cell *cell; in nvmem_add_cells_from_of() local
558 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_cells_from_of()
559 if (!cell) { in nvmem_add_cells_from_of()
564 cell->nvmem = nvmem; in nvmem_add_cells_from_of()
565 cell->offset = be32_to_cpup(addr++); in nvmem_add_cells_from_of()
566 cell->bytes = be32_to_cpup(addr); in nvmem_add_cells_from_of()
567 cell->name = kasprintf(GFP_KERNEL, "%pOFn", child); in nvmem_add_cells_from_of()
571 cell->bit_offset = be32_to_cpup(addr++); in nvmem_add_cells_from_of()
572 cell->nbits = be32_to_cpup(addr); in nvmem_add_cells_from_of()
575 if (cell->nbits) in nvmem_add_cells_from_of()
576 cell->bytes = DIV_ROUND_UP( in nvmem_add_cells_from_of()
577 cell->nbits + cell->bit_offset, in nvmem_add_cells_from_of()
580 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in nvmem_add_cells_from_of()
581 dev_err(dev, "cell %s unaligned to nvmem stride %d\n", in nvmem_add_cells_from_of()
582 cell->name, nvmem->stride); in nvmem_add_cells_from_of()
584 kfree_const(cell->name); in nvmem_add_cells_from_of()
585 kfree(cell); in nvmem_add_cells_from_of()
590 cell->np = of_node_get(child); in nvmem_add_cells_from_of()
591 nvmem_cell_add(cell); in nvmem_add_cells_from_of()
828 "could not increase module refcount for cell %s\n", in __nvmem_device_get()
964 * devm_nvmem_device_get() - Get nvmem cell of device form a given id
996 struct nvmem_cell *cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup() local
1016 cell = ERR_CAST(nvmem); in nvmem_cell_get_from_lookup()
1020 cell = nvmem_find_cell_by_name(nvmem, in nvmem_cell_get_from_lookup()
1022 if (!cell) { in nvmem_cell_get_from_lookup()
1024 cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup()
1031 return cell; in nvmem_cell_get_from_lookup()
1038 struct nvmem_cell *iter, *cell = NULL; in nvmem_find_cell_by_node() local
1043 cell = iter; in nvmem_find_cell_by_node()
1049 return cell; in nvmem_find_cell_by_node()
1053 * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
1055 * @np: Device tree node that uses the nvmem cell.
1056 * @id: nvmem cell name from nvmem-cell-names property, or NULL
1057 * for the cell at index 0 (the lone cell with no accompanying
1058 * nvmem-cell-names property).
1068 struct nvmem_cell *cell; in of_nvmem_cell_get() local
1071 /* if cell name exists, find index to the name */ in of_nvmem_cell_get()
1073 index = of_property_match_string(np, "nvmem-cell-names", id); in of_nvmem_cell_get()
1088 cell = nvmem_find_cell_by_node(nvmem, cell_np); in of_nvmem_cell_get()
1089 if (!cell) { in of_nvmem_cell_get()
1094 return cell; in of_nvmem_cell_get()
1100 * nvmem_cell_get() - Get nvmem cell of device form a given cell name
1102 * @dev: Device that requests the nvmem cell.
1103 * @id: nvmem cell name to get (this corresponds with the name from the
1104 * nvmem-cell-names property for DT systems and with the con_id from
1113 struct nvmem_cell *cell; in nvmem_cell_get() local
1116 cell = of_nvmem_cell_get(dev->of_node, id); in nvmem_cell_get()
1117 if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER) in nvmem_cell_get()
1118 return cell; in nvmem_cell_get()
1121 /* NULL cell id only allowed for device tree; invalid otherwise */ in nvmem_cell_get()
1135 * devm_nvmem_cell_get() - Get nvmem cell of device form a given id
1137 * @dev: Device that requests the nvmem cell.
1138 * @id: nvmem cell name id to get.
1146 struct nvmem_cell **ptr, *cell; in devm_nvmem_cell_get() local
1152 cell = nvmem_cell_get(dev, id); in devm_nvmem_cell_get()
1153 if (!IS_ERR(cell)) { in devm_nvmem_cell_get()
1154 *ptr = cell; in devm_nvmem_cell_get()
1160 return cell; in devm_nvmem_cell_get()
1175 * devm_nvmem_cell_put() - Release previously allocated nvmem cell
1178 * @dev: Device that requests the nvmem cell.
1179 * @cell: Previously allocated nvmem cell by devm_nvmem_cell_get().
1181 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell) in devm_nvmem_cell_put() argument
1186 devm_nvmem_cell_match, cell); in devm_nvmem_cell_put()
1193 * nvmem_cell_put() - Release previously allocated nvmem cell.
1195 * @cell: Previously allocated nvmem cell by nvmem_cell_get().
1197 void nvmem_cell_put(struct nvmem_cell *cell) in nvmem_cell_put() argument
1199 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_put()
1205 static void nvmem_shift_read_buffer_in_place(struct nvmem_cell *cell, void *buf) in nvmem_shift_read_buffer_in_place() argument
1208 int i, extra, bit_offset = cell->bit_offset; in nvmem_shift_read_buffer_in_place()
1216 for (i = 1; i < cell->bytes; i++) { in nvmem_shift_read_buffer_in_place()
1225 p += cell->bytes - 1; in nvmem_shift_read_buffer_in_place()
1229 extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE); in nvmem_shift_read_buffer_in_place()
1234 if (cell->nbits % BITS_PER_BYTE) in nvmem_shift_read_buffer_in_place()
1235 *p &= GENMASK((cell->nbits % BITS_PER_BYTE) - 1, 0); in nvmem_shift_read_buffer_in_place()
1239 struct nvmem_cell *cell, in __nvmem_cell_read() argument
1244 rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes); in __nvmem_cell_read()
1250 if (cell->bit_offset || cell->nbits) in __nvmem_cell_read()
1251 nvmem_shift_read_buffer_in_place(cell, buf); in __nvmem_cell_read()
1254 *len = cell->bytes; in __nvmem_cell_read()
1260 * nvmem_cell_read() - Read a given nvmem cell
1262 * @cell: nvmem cell to be read.
1263 * @len: pointer to length of cell which will be populated on successful read;
1269 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) in nvmem_cell_read() argument
1271 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_read()
1278 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_read()
1282 rc = __nvmem_cell_read(nvmem, cell, buf, len); in nvmem_cell_read()
1292 static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, in nvmem_cell_prepare_write_buffer() argument
1295 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_prepare_write_buffer()
1296 int i, rc, nbits, bit_offset = cell->bit_offset; in nvmem_cell_prepare_write_buffer()
1299 nbits = cell->nbits; in nvmem_cell_prepare_write_buffer()
1300 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_prepare_write_buffer()
1312 rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); in nvmem_cell_prepare_write_buffer()
1318 for (i = 1; i < cell->bytes; i++) { in nvmem_cell_prepare_write_buffer()
1332 cell->offset + cell->bytes - 1, &v, 1); in nvmem_cell_prepare_write_buffer()
1346 * nvmem_cell_write() - Write to a given nvmem cell
1348 * @cell: nvmem cell to be written.
1350 * @len: length of buffer to be written to nvmem cell.
1354 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len) in nvmem_cell_write() argument
1356 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_write()
1360 (cell->bit_offset == 0 && len != cell->bytes)) in nvmem_cell_write()
1363 if (cell->bit_offset || cell->nbits) { in nvmem_cell_write()
1364 buf = nvmem_cell_prepare_write_buffer(cell, buf, len); in nvmem_cell_write()
1369 rc = nvmem_reg_write(nvmem, cell->offset, buf, cell->bytes); in nvmem_cell_write()
1372 if (cell->bit_offset || cell->nbits) in nvmem_cell_write()
1385 struct nvmem_cell *cell; in nvmem_cell_read_common() local
1389 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_common()
1390 if (IS_ERR(cell)) in nvmem_cell_read_common()
1391 return PTR_ERR(cell); in nvmem_cell_read_common()
1393 buf = nvmem_cell_read(cell, &len); in nvmem_cell_read_common()
1395 nvmem_cell_put(cell); in nvmem_cell_read_common()
1400 nvmem_cell_put(cell); in nvmem_cell_read_common()
1405 nvmem_cell_put(cell); in nvmem_cell_read_common()
1411 * nvmem_cell_read_u8() - Read a cell value as a u8
1413 * @dev: Device that requests the nvmem cell.
1414 * @cell_id: Name of nvmem cell to read.
1426 * nvmem_cell_read_u16() - Read a cell value as a u16
1428 * @dev: Device that requests the nvmem cell.
1429 * @cell_id: Name of nvmem cell to read.
1441 * nvmem_cell_read_u32() - Read a cell value as a u32
1443 * @dev: Device that requests the nvmem cell.
1444 * @cell_id: Name of nvmem cell to read.
1456 * nvmem_cell_read_u64() - Read a cell value as a u64
1458 * @dev: Device that requests the nvmem cell.
1459 * @cell_id: Name of nvmem cell to read.
1471 * nvmem_device_cell_read() - Read a given nvmem device and cell
1474 * @info: nvmem cell info to be read.
1483 struct nvmem_cell cell; in nvmem_device_cell_read() local
1490 rc = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, &cell); in nvmem_device_cell_read()
1494 rc = __nvmem_cell_read(nvmem, &cell, buf, &len); in nvmem_device_cell_read()
1503 * nvmem_device_cell_write() - Write cell to a given nvmem device
1506 * @info: nvmem cell info to be written.
1507 * @buf: buffer to be written to cell.
1514 struct nvmem_cell cell; in nvmem_device_cell_write() local
1520 rc = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, &cell); in nvmem_device_cell_write()
1524 return nvmem_cell_write(&cell, buf, cell.bytes); in nvmem_device_cell_write()
1558 * nvmem_device_write() - Write cell to a given nvmem device
1587 * nvmem_add_cell_table() - register a table of cell info entries
1589 * @table: table of cell info entries
1600 * nvmem_del_cell_table() - remove a previously registered cell info table
1602 * @table: table of cell info entries
1613 * nvmem_add_cell_lookups() - register a list of cell lookup entries
1615 * @entries: array of cell lookup entries
1616 * @nentries: number of cell lookup entries in the array
1630 * nvmem_del_cell_lookups() - remove a list of previously added cell lookup
1633 * @entries: array of cell lookup entries
1634 * @nentries: number of cell lookup entries in the array