Lines Matching +full:max +full:- +full:msgs

4  * SPDX-License-Identifier: Apache-2.0
20 void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs, in i3c_dump_msgs() argument
23 LOG_DBG("I3C msg: %s, addr=%x", name, target->dynamic_addr); in i3c_dump_msgs()
25 const struct i3c_msg *msg = &msgs[i]; in i3c_dump_msgs()
28 msg->flags & I3C_MSG_READ ? 'R' : 'W', msg->len); in i3c_dump_msgs()
29 if (!(msg->flags & I3C_MSG_READ)) { in i3c_dump_msgs()
30 LOG_HEXDUMP_DBG(msg->buf, msg->len, "contents:"); in i3c_dump_msgs()
53 slots->slots[idx] &= ~((unsigned long)I3C_ADDR_SLOT_STATUS_MASK << bitpos); in i3c_addr_slots_set()
54 slots->slots[idx] |= status << bitpos; in i3c_addr_slots_set()
79 status = slots->slots[idx] >> bitpos; in i3c_addr_slots_status()
89 (struct i3c_driver_data *)dev->data; in i3c_addr_slots_init()
91 (const struct i3c_driver_config *)dev->config; in i3c_addr_slots_init()
98 (void)memset(&data->attached_dev.addr_slots, 0, sizeof(data->attached_dev.addr_slots)); in i3c_addr_slots_init()
99 sys_slist_init(&data->attached_dev.devices.i3c); in i3c_addr_slots_init()
100 sys_slist_init(&data->attached_dev.devices.i2c); in i3c_addr_slots_init()
105 i3c_addr_slots_set(&data->attached_dev.addr_slots, i, I3C_ADDR_SLOT_STATUS_RSVD); in i3c_addr_slots_init()
111 i3c_addr_slots_set(&data->attached_dev.addr_slots, I3C_BROADCAST_ADDR ^ BIT(i), in i3c_addr_slots_init()
117 i3c_addr_slots_set(&data->attached_dev.addr_slots, I3C_BROADCAST_ADDR, in i3c_addr_slots_init()
123 for (i = 0; i < config->dev_list.num_i2c; i++) { in i3c_addr_slots_init()
124 i2c_dev = &config->dev_list.i2c[i]; in i3c_addr_slots_init()
128 ret = -EINVAL; in i3c_addr_slots_init()
136 * the same (pre-assigned) address on the bus. in i3c_addr_slots_init()
138 for (i = 0; i < config->dev_list.num_i3c; i++) { in i3c_addr_slots_init()
139 i3c_dev = &config->dev_list.i3c[i]; in i3c_addr_slots_init()
143 ret = -EINVAL; in i3c_addr_slots_init()
170 for (addr = MAX(start_addr, 8); addr < I3C_MAX_ADDR; addr++) { in i3c_addr_slots_next_free_find()
189 for (i = 0; i < dev_list->num_i3c; i++) { in i3c_dev_list_find()
190 struct i3c_device_desc *desc = &dev_list->i3c[i]; in i3c_dev_list_find()
192 if (desc->pid == id->pid) { in i3c_dev_list_find()
210 if (desc->dynamic_addr == addr) { in i3c_dev_list_i3c_addr_find()
228 if (desc->addr == addr) { in i3c_dev_list_i2c_addr_find()
239 struct i3c_driver_data *data = (struct i3c_driver_data *)target->bus->data; in i3c_attach_i3c_device()
240 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api; in i3c_attach_i3c_device()
246 I3C_BUS_FOR_EACH_I3CDEV(target->bus, i3c_desc) { in i3c_attach_i3c_device()
248 return -EINVAL; in i3c_attach_i3c_device()
252 addr = target->dynamic_addr ? target->dynamic_addr : target->static_addr; in i3c_attach_i3c_device()
258 if (!i3c_addr_slots_is_free(&data->attached_dev.addr_slots, addr)) { in i3c_attach_i3c_device()
259 return -EINVAL; in i3c_attach_i3c_device()
263 sys_slist_append(&data->attached_dev.devices.i3c, &target->node); in i3c_attach_i3c_device()
265 if (api->attach_i3c_device != NULL) { in i3c_attach_i3c_device()
266 status = api->attach_i3c_device(target->bus, target); in i3c_attach_i3c_device()
270 i3c_addr_slots_mark_i3c(&data->attached_dev.addr_slots, addr); in i3c_attach_i3c_device()
278 struct i3c_driver_data *data = (struct i3c_driver_data *)target->bus->data; in i3c_reattach_i3c_device()
279 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api; in i3c_reattach_i3c_device()
282 if (!i3c_addr_slots_is_free(&data->attached_dev.addr_slots, target->dynamic_addr)) { in i3c_reattach_i3c_device()
283 return -EINVAL; in i3c_reattach_i3c_device()
286 if (api->reattach_i3c_device != NULL) { in i3c_reattach_i3c_device()
287 status = api->reattach_i3c_device(target->bus, target, old_dyn_addr); in i3c_reattach_i3c_device()
292 i3c_addr_slots_mark_free(&data->attached_dev.addr_slots, old_dyn_addr); in i3c_reattach_i3c_device()
295 i3c_addr_slots_mark_i3c(&data->attached_dev.addr_slots, target->dynamic_addr); in i3c_reattach_i3c_device()
302 struct i3c_driver_data *data = (struct i3c_driver_data *)target->bus->data; in i3c_detach_i3c_device()
303 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api; in i3c_detach_i3c_device()
306 if (!sys_slist_is_empty(&data->attached_dev.devices.i3c)) { in i3c_detach_i3c_device()
307 if (!sys_slist_find_and_remove(&data->attached_dev.devices.i3c, &target->node)) { in i3c_detach_i3c_device()
308 return -EINVAL; in i3c_detach_i3c_device()
311 return -EINVAL; in i3c_detach_i3c_device()
314 if (api->detach_i3c_device != NULL) { in i3c_detach_i3c_device()
315 status = api->detach_i3c_device(target->bus, target); in i3c_detach_i3c_device()
318 i3c_addr_slots_mark_free(&data->attached_dev.addr_slots, in i3c_detach_i3c_device()
319 target->dynamic_addr ? target->dynamic_addr : target->static_addr); in i3c_detach_i3c_device()
326 struct i3c_driver_data *data = (struct i3c_driver_data *)target->bus->data; in i3c_attach_i2c_device()
327 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api; in i3c_attach_i2c_device()
332 I3C_BUS_FOR_EACH_I2CDEV(target->bus, i3c_i2c_desc) { in i3c_attach_i2c_device()
334 return -EINVAL; in i3c_attach_i2c_device()
338 if (!i3c_addr_slots_is_free(&data->attached_dev.addr_slots, target->addr)) { in i3c_attach_i2c_device()
339 return -EINVAL; in i3c_attach_i2c_device()
342 sys_slist_append(&data->attached_dev.devices.i2c, &target->node); in i3c_attach_i2c_device()
344 if (api->attach_i2c_device != NULL) { in i3c_attach_i2c_device()
345 status = api->attach_i2c_device(target->bus, target); in i3c_attach_i2c_device()
348 i3c_addr_slots_mark_i2c(&data->attached_dev.addr_slots, target->addr); in i3c_attach_i2c_device()
355 struct i3c_driver_data *data = (struct i3c_driver_data *)target->bus->data; in i3c_detach_i2c_device()
356 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api; in i3c_detach_i2c_device()
359 if (!sys_slist_is_empty(&data->attached_dev.devices.i2c)) { in i3c_detach_i2c_device()
360 if (!sys_slist_find_and_remove(&data->attached_dev.devices.i2c, &target->node)) { in i3c_detach_i2c_device()
361 return -EINVAL; in i3c_detach_i2c_device()
364 return -EINVAL; in i3c_detach_i2c_device()
367 if (api->detach_i2c_device != NULL) { in i3c_detach_i2c_device()
368 status = api->detach_i2c_device(target->bus, target); in i3c_detach_i2c_device()
371 i3c_addr_slots_mark_free(&data->attached_dev.addr_slots, target->addr); in i3c_detach_i2c_device()
396 ret = -ENODEV; in i3c_dev_list_daa_addr_helper()
404 if (desc != NULL && desc->dynamic_addr != 0U) { in i3c_dev_list_daa_addr_helper()
407 dyn_addr = desc->dynamic_addr; in i3c_dev_list_daa_addr_helper()
417 vendor_id, part_no, desc->dynamic_addr); in i3c_dev_list_daa_addr_helper()
418 ret = -EINVAL; in i3c_dev_list_daa_addr_helper()
427 if (desc != NULL && desc->init_dynamic_addr != 0U) { in i3c_dev_list_daa_addr_helper()
428 if (i3c_addr_slots_is_free(addr_slots, desc->init_dynamic_addr)) { in i3c_dev_list_daa_addr_helper()
429 dyn_addr = desc->init_dynamic_addr; in i3c_dev_list_daa_addr_helper()
442 ret = -ENOSPC; in i3c_dev_list_daa_addr_helper()
471 tmp_bcr = target->bcr; in i3c_device_basic_info_get()
479 target->bcr = bcr.bcr; in i3c_device_basic_info_get()
509 memcpy(&target->getcaps, &caps, sizeof(target->getcaps)); in i3c_device_basic_info_get()
510 } else if ((ret != 0) && (target->bcr & I3C_BCR_ADV_CAPABILITIES)) { in i3c_device_basic_info_get()
517 if (target->bcr & I3C_BCR_MAX_DATA_SPEED_LIMIT) { in i3c_device_basic_info_get()
523 target->data_speed.maxrd = mxds.fmt2.maxrd; in i3c_device_basic_info_get()
524 target->data_speed.maxwr = mxds.fmt2.maxwr; in i3c_device_basic_info_get()
525 target->data_speed.max_read_turnaround = sys_get_le24(mxds.fmt2.maxrdturn); in i3c_device_basic_info_get()
528 target->dcr = dcr.dcr; in i3c_device_basic_info_get()
529 target->data_length.mrl = mrl.len; in i3c_device_basic_info_get()
530 target->data_length.mwl = mwl.len; in i3c_device_basic_info_get()
531 target->data_length.max_ibi = mrl.ibi_len; in i3c_device_basic_info_get()
536 target->bcr = tmp_bcr; in i3c_device_basic_info_get()
560 for (i = 0; i < dev_list->num_i3c; i++) { in i3c_bus_setdasa()
561 struct i3c_device_desc *desc = &dev_list->i3c[i]; in i3c_bus_setdasa()
562 struct i3c_driver_data *bus_data = (struct i3c_driver_data *)dev->data; in i3c_bus_setdasa()
569 if (desc->static_addr == 0U) { in i3c_bus_setdasa()
579 if ((desc->supports_setaasa) && ((desc->init_dynamic_addr == 0) || in i3c_bus_setdasa()
580 desc->init_dynamic_addr == desc->static_addr)) { in i3c_bus_setdasa()
585 LOG_DBG("SETDASA for 0x%x", desc->static_addr); in i3c_bus_setdasa()
591 if ((desc->init_dynamic_addr != 0) && in i3c_bus_setdasa()
592 (desc->init_dynamic_addr != desc->static_addr)) { in i3c_bus_setdasa()
593 if (!i3c_addr_slots_is_free(&bus_data->attached_dev.addr_slots, in i3c_bus_setdasa()
594 desc->init_dynamic_addr)) { in i3c_bus_setdasa()
596 LOG_ERR("Failed to detach %s", desc->dev->name); in i3c_bus_setdasa()
603 * Note that the 7-bit address needs to start at bit 1 in i3c_bus_setdasa()
604 * (aka left-justified). So shift left by 1; in i3c_bus_setdasa()
606 dyn_addr.addr = (desc->init_dynamic_addr ? in i3c_bus_setdasa()
607 desc->init_dynamic_addr : desc->static_addr) << 1; in i3c_bus_setdasa()
611 desc->dynamic_addr = dyn_addr.addr >> 1; in i3c_bus_setdasa()
612 if (desc->dynamic_addr != desc->static_addr) { in i3c_bus_setdasa()
613 if (i3c_reattach_i3c_device(desc, desc->static_addr) != 0) { in i3c_bus_setdasa()
614 LOG_ERR("Failed to reattach %s (%d)", desc->dev->name, ret); in i3c_bus_setdasa()
620 LOG_ERR("Failed to detach %s (%d)", desc->dev->name, ret); in i3c_bus_setdasa()
623 desc->static_addr, ret); in i3c_bus_setdasa()
645 struct i3c_driver_data *data = (struct i3c_driver_data *)dev->data; in i3c_bus_deftgts()
652 size_t num_of_targets = sys_slist_len(&data->attached_dev.devices.i3c) + in i3c_bus_deftgts()
653 sys_slist_len(&data->attached_dev.devices.i2c); in i3c_bus_deftgts()
670 return -ENOMEM; in i3c_bus_deftgts()
676 deftgts->count = num_of_targets; in i3c_bus_deftgts()
681 deftgts->active_controller.addr = config_target.dynamic_addr << 1; in i3c_bus_deftgts()
682 deftgts->active_controller.dcr = config_target.dcr; in i3c_bus_deftgts()
683 deftgts->active_controller.bcr = config_target.bcr; in i3c_bus_deftgts()
684 deftgts->active_controller.static_addr = I3C_BROADCAST_ADDR << 1; in i3c_bus_deftgts()
690 deftgts->targets[n].addr = i3c_desc->dynamic_addr << 1; in i3c_bus_deftgts()
691 deftgts->targets[n].dcr = i3c_desc->dcr; in i3c_bus_deftgts()
692 deftgts->targets[n].bcr = i3c_desc->bcr; in i3c_bus_deftgts()
693 deftgts->targets[n].static_addr = i3c_desc->static_addr << 1; in i3c_bus_deftgts()
701 deftgts->targets[n].addr = 0; in i3c_bus_deftgts()
702 deftgts->targets[n].lvr = i3c_i2c_desc->lvr; in i3c_bus_deftgts()
703 deftgts->targets[n].bcr = 0; in i3c_bus_deftgts()
704 deftgts->targets[n].static_addr = (uint8_t)(i3c_i2c_desc->addr << 1); in i3c_bus_deftgts()
778 for (i = 0; i < dev_list->num_i3c; i++) { in i3c_bus_init()
779 struct i3c_device_desc *desc = &dev_list->i3c[i]; in i3c_bus_init()
784 if ((desc->supports_setaasa) && (desc->static_addr != 0) && in i3c_bus_init()
785 ((desc->init_dynamic_addr == 0) || in i3c_bus_init()
786 desc->init_dynamic_addr == desc->static_addr)) { in i3c_bus_init()
787 desc->dynamic_addr = desc->static_addr; in i3c_bus_init()
820 for (i = 0; i < dev_list->num_i3c; i++) { in i3c_bus_init()
821 struct i3c_device_desc *desc = &dev_list->i3c[i]; in i3c_bus_init()
823 if (desc->dynamic_addr == 0U) { in i3c_bus_init()
830 desc->static_addr); in i3c_bus_init()
833 desc->dynamic_addr, desc->bcr, desc->dcr, in i3c_bus_init()
834 desc->data_length.mrl, desc->data_length.mwl, in i3c_bus_init()
835 desc->data_length.max_ibi); in i3c_bus_init()
847 * Only re-enable Hot-Join from targets. in i3c_bus_init()