Lines Matching full:master
73 * In other words, transfer requests passed to the I3C master can be submitted
74 * in parallel and I3C master drivers have to use their own locking to make
111 struct i3c_master_controller *master; in dev_to_i3cbus() local
116 master = dev_to_i3cmaster(dev); in dev_to_i3cbus()
118 return &master->bus; in dev_to_i3cbus()
123 struct i3c_master_controller *master; in dev_to_i3cdesc() local
128 master = dev_to_i3cmaster(dev); in dev_to_i3cdesc()
130 return master->this; in dev_to_i3cdesc()
404 * Some master controllers (such as HCI) need to prepare the entire above transaction before
603 static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable) in i3c_set_hotjoin() argument
607 if (!master || !master->ops) in i3c_set_hotjoin()
610 if (!master->ops->enable_hotjoin || !master->ops->disable_hotjoin) in i3c_set_hotjoin()
613 i3c_bus_normaluse_lock(&master->bus); in i3c_set_hotjoin()
616 ret = master->ops->enable_hotjoin(master); in i3c_set_hotjoin()
618 ret = master->ops->disable_hotjoin(master); in i3c_set_hotjoin()
620 master->hotjoin = enable; in i3c_set_hotjoin()
622 i3c_bus_normaluse_unlock(&master->bus); in i3c_set_hotjoin()
640 ret = i3c_set_hotjoin(i3cbus->cur_master->common.master, res); in hotjoin_store()
649 * @master: I3C master object
653 int i3c_master_enable_hotjoin(struct i3c_master_controller *master) in i3c_master_enable_hotjoin() argument
655 return i3c_set_hotjoin(master, true); in i3c_master_enable_hotjoin()
661 * @master: I3C master object
665 int i3c_master_disable_hotjoin(struct i3c_master_controller *master) in i3c_master_disable_hotjoin() argument
667 return i3c_set_hotjoin(master, false); in i3c_master_disable_hotjoin()
677 ret = sysfs_emit(buf, "%d\n", i3cbus->cur_master->common.master->hotjoin); in hotjoin_show()
702 struct i3c_master_controller *master = dev_to_i3cmaster(dev); in i3c_masterdev_release() local
705 if (master->wq) in i3c_masterdev_release()
706 destroy_workqueue(master->wq); in i3c_masterdev_release()
721 struct i3c_master_controller *master = i3c_bus_to_i3c_master(i3cbus); in i3c_bus_set_mode() local
748 dev_dbg(&master->dev, "i2c-scl = %ld Hz i3c-scl = %ld Hz\n", in i3c_bus_set_mode()
769 i3c_master_to_i2c_adapter(struct i3c_master_controller *master) in i3c_master_to_i2c_adapter() argument
771 return &master->i2c; in i3c_master_to_i2c_adapter()
780 i3c_master_alloc_i2c_dev(struct i3c_master_controller *master, in i3c_master_alloc_i2c_dev() argument
789 dev->common.master = master; in i3c_master_alloc_i2c_dev()
825 static int i3c_master_send_ccc_cmd_locked(struct i3c_master_controller *master, in i3c_master_send_ccc_cmd_locked() argument
830 if (!cmd || !master) in i3c_master_send_ccc_cmd_locked()
833 if (WARN_ON(master->init_done && in i3c_master_send_ccc_cmd_locked()
834 !rwsem_is_locked(&master->bus.lock))) in i3c_master_send_ccc_cmd_locked()
837 if (!master->ops->send_ccc_cmd) in i3c_master_send_ccc_cmd_locked()
843 if (master->ops->supports_ccc_cmd && in i3c_master_send_ccc_cmd_locked()
844 !master->ops->supports_ccc_cmd(master, cmd)) in i3c_master_send_ccc_cmd_locked()
847 ret = master->ops->send_ccc_cmd(master, cmd); in i3c_master_send_ccc_cmd_locked()
859 i3c_master_find_i2c_dev_by_addr(const struct i3c_master_controller *master, in i3c_master_find_i2c_dev_by_addr() argument
864 i3c_bus_for_each_i2cdev(&master->bus, dev) { in i3c_master_find_i2c_dev_by_addr()
874 * @master: I3C master object
882 int i3c_master_get_free_addr(struct i3c_master_controller *master, in i3c_master_get_free_addr() argument
885 return i3c_bus_get_free_addr(&master->bus, start_addr); in i3c_master_get_free_addr()
905 i3c_master_alloc_i3c_dev(struct i3c_master_controller *master, in i3c_master_alloc_i3c_dev() argument
914 dev->common.master = master; in i3c_master_alloc_i3c_dev()
921 static int i3c_master_rstdaa_locked(struct i3c_master_controller *master, in i3c_master_rstdaa_locked() argument
929 if (!master) in i3c_master_rstdaa_locked()
932 addrstat = i3c_bus_get_addr_slot_status(&master->bus, addr); in i3c_master_rstdaa_locked()
940 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_rstdaa_locked()
949 * @master: master used to send frames on the bus
954 * behind dynamic address assignment has to be handled in the I3C master
962 int i3c_master_entdaa_locked(struct i3c_master_controller *master) in i3c_master_entdaa_locked() argument
970 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_entdaa_locked()
977 static int i3c_master_enec_disec_locked(struct i3c_master_controller *master, in i3c_master_enec_disec_locked() argument
995 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_enec_disec_locked()
1003 * @master: master used to send frames on the bus
1015 int i3c_master_disec_locked(struct i3c_master_controller *master, u8 addr, in i3c_master_disec_locked() argument
1018 return i3c_master_enec_disec_locked(master, addr, false, evts); in i3c_master_disec_locked()
1024 * @master: master used to send frames on the bus
1036 int i3c_master_enec_locked(struct i3c_master_controller *master, u8 addr, in i3c_master_enec_locked() argument
1039 return i3c_master_enec_disec_locked(master, addr, true, evts); in i3c_master_enec_locked()
1045 * @master: master used to send frames on the bus
1047 * Send a DEFSLVS CCC command containing all the devices known to the @master.
1054 * It should also be called if a master ACKed an Hot-Join request and assigned
1062 int i3c_master_defslvs_locked(struct i3c_master_controller *master) in i3c_master_defslvs_locked() argument
1074 if (!master) in i3c_master_defslvs_locked()
1077 bus = i3c_master_get_bus(master); in i3c_master_defslvs_locked()
1081 if (i3cdev == master->this) in i3c_master_defslvs_locked()
1089 /* No other master on the bus, skip DEFSLVS. */ in i3c_master_defslvs_locked()
1103 defslvs->master.bcr = master->this->info.bcr; in i3c_master_defslvs_locked()
1104 defslvs->master.dcr = master->this->info.dcr; in i3c_master_defslvs_locked()
1105 defslvs->master.dyn_addr = master->this->info.dyn_addr << 1; in i3c_master_defslvs_locked()
1106 defslvs->master.static_addr = I3C_BROADCAST_ADDR << 1; in i3c_master_defslvs_locked()
1116 /* Skip the I3C dev representing this master. */ in i3c_master_defslvs_locked()
1117 if (i3cdev == master->this) in i3c_master_defslvs_locked()
1128 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_defslvs_locked()
1135 static int i3c_master_setda_locked(struct i3c_master_controller *master, in i3c_master_setda_locked() argument
1154 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_setda_locked()
1160 static int i3c_master_setdasa_locked(struct i3c_master_controller *master, in i3c_master_setdasa_locked() argument
1163 return i3c_master_setda_locked(master, static_addr, dyn_addr, true); in i3c_master_setdasa_locked()
1166 static int i3c_master_setnewda_locked(struct i3c_master_controller *master, in i3c_master_setnewda_locked() argument
1169 return i3c_master_setda_locked(master, oldaddr, newaddr, false); in i3c_master_setnewda_locked()
1172 static int i3c_master_getmrl_locked(struct i3c_master_controller *master, in i3c_master_getmrl_locked() argument
1192 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getmrl_locked()
1214 static int i3c_master_getmwl_locked(struct i3c_master_controller *master, in i3c_master_getmwl_locked() argument
1227 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getmwl_locked()
1244 static int i3c_master_getmxds_locked(struct i3c_master_controller *master, in i3c_master_getmxds_locked() argument
1258 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getmxds_locked()
1280 static int i3c_master_gethdrcap_locked(struct i3c_master_controller *master, in i3c_master_gethdrcap_locked() argument
1294 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_gethdrcap_locked()
1311 static int i3c_master_getpid_locked(struct i3c_master_controller *master, in i3c_master_getpid_locked() argument
1324 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getpid_locked()
1341 static int i3c_master_getbcr_locked(struct i3c_master_controller *master, in i3c_master_getbcr_locked() argument
1354 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getbcr_locked()
1366 static int i3c_master_getdcr_locked(struct i3c_master_controller *master, in i3c_master_getdcr_locked() argument
1379 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getdcr_locked()
1393 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_retrieve_dev_info() local
1400 slot_status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_retrieve_dev_info()
1406 ret = i3c_master_getpid_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1410 ret = i3c_master_getbcr_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1414 ret = i3c_master_getdcr_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1419 ret = i3c_master_getmxds_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1427 i3c_master_getmrl_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1428 i3c_master_getmwl_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1431 ret = i3c_master_gethdrcap_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1441 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_put_i3c_addrs() local
1444 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_put_i3c_addrs()
1449 i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, in i3c_master_put_i3c_addrs()
1453 i3c_bus_set_addr_slot_status(&master->bus, dev->boardinfo->init_dyn_addr, in i3c_master_put_i3c_addrs()
1459 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_get_i3c_addrs() local
1466 status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1475 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1488 status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1493 i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, in i3c_master_get_i3c_addrs()
1501 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1508 static int i3c_master_attach_i3c_dev(struct i3c_master_controller *master, in i3c_master_attach_i3c_dev() argument
1524 /* Do not attach the master device itself. */ in i3c_master_attach_i3c_dev()
1525 if (master->this != dev && master->ops->attach_i3c_dev) { in i3c_master_attach_i3c_dev()
1526 ret = master->ops->attach_i3c_dev(dev); in i3c_master_attach_i3c_dev()
1533 list_add_tail(&dev->common.node, &master->bus.devs.i3c); in i3c_master_attach_i3c_dev()
1541 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_reattach_i3c_dev() local
1545 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_reattach_i3c_dev()
1549 i3c_bus_set_addr_slot_status(&master->bus, old_dyn_addr, in i3c_master_reattach_i3c_dev()
1553 if (master->ops->reattach_i3c_dev) { in i3c_master_reattach_i3c_dev()
1554 ret = master->ops->reattach_i3c_dev(dev, old_dyn_addr); in i3c_master_reattach_i3c_dev()
1566 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_detach_i3c_dev() local
1568 /* Do not detach the master device itself. */ in i3c_master_detach_i3c_dev()
1569 if (master->this != dev && master->ops->detach_i3c_dev) in i3c_master_detach_i3c_dev()
1570 master->ops->detach_i3c_dev(dev); in i3c_master_detach_i3c_dev()
1576 static int i3c_master_attach_i2c_dev(struct i3c_master_controller *master, in i3c_master_attach_i2c_dev() argument
1581 if (master->ops->attach_i2c_dev) { in i3c_master_attach_i2c_dev()
1582 ret = master->ops->attach_i2c_dev(dev); in i3c_master_attach_i2c_dev()
1587 list_add_tail(&dev->common.node, &master->bus.devs.i2c); in i3c_master_attach_i2c_dev()
1594 struct i3c_master_controller *master = i2c_dev_get_master(dev); in i3c_master_detach_i2c_dev() local
1598 if (master->ops->detach_i2c_dev) in i3c_master_detach_i2c_dev()
1599 master->ops->detach_i2c_dev(dev); in i3c_master_detach_i2c_dev()
1602 static int i3c_master_early_i3c_dev_add(struct i3c_master_controller *master, in i3c_master_early_i3c_dev_add() argument
1612 i3cdev = i3c_master_alloc_i3c_dev(master, &info); in i3c_master_early_i3c_dev_add()
1618 ret = i3c_master_attach_i3c_dev(master, i3cdev); in i3c_master_early_i3c_dev_add()
1622 ret = i3c_master_setdasa_locked(master, i3cdev->info.static_addr, in i3c_master_early_i3c_dev_add()
1639 i3c_master_rstdaa_locked(master, i3cdev->boardinfo->init_dyn_addr); in i3c_master_early_i3c_dev_add()
1649 i3c_master_register_new_i3c_devs(struct i3c_master_controller *master) in i3c_master_register_new_i3c_devs() argument
1654 if (!master->init_done) in i3c_master_register_new_i3c_devs()
1657 i3c_bus_for_each_i3cdev(&master->bus, desc) { in i3c_master_register_new_i3c_devs()
1658 if (desc->dev || !desc->info.dyn_addr || desc == master->this) in i3c_master_register_new_i3c_devs()
1665 desc->dev->bus = &master->bus; in i3c_master_register_new_i3c_devs()
1667 desc->dev->dev.parent = &master->dev; in i3c_master_register_new_i3c_devs()
1671 dev_set_name(&desc->dev->dev, "%d-%llx", master->bus.id, in i3c_master_register_new_i3c_devs()
1679 dev_err(&master->dev, in i3c_master_register_new_i3c_devs()
1688 * @master: master doing the DAA
1694 * The I3C device object is returned in case the master wants to attach
1701 int i3c_master_do_daa(struct i3c_master_controller *master) in i3c_master_do_daa() argument
1705 i3c_bus_maintenance_lock(&master->bus); in i3c_master_do_daa()
1706 ret = master->ops->do_daa(master); in i3c_master_do_daa()
1707 i3c_bus_maintenance_unlock(&master->bus); in i3c_master_do_daa()
1712 i3c_bus_normaluse_lock(&master->bus); in i3c_master_do_daa()
1713 i3c_master_register_new_i3c_devs(master); in i3c_master_do_daa()
1714 i3c_bus_normaluse_unlock(&master->bus); in i3c_master_do_daa()
1721 * i3c_master_set_info() - set master device information
1722 * @master: master used to send frames on the bus
1725 * Set master device info. This should be called from
1728 * Not all &i3c_device_info fields are meaningful for a master device.
1744 int i3c_master_set_info(struct i3c_master_controller *master, in i3c_master_set_info() argument
1750 if (!i3c_bus_dev_addr_is_avail(&master->bus, info->dyn_addr)) in i3c_master_set_info()
1754 master->secondary) in i3c_master_set_info()
1757 if (master->this) in i3c_master_set_info()
1760 i3cdev = i3c_master_alloc_i3c_dev(master, info); in i3c_master_set_info()
1764 master->this = i3cdev; in i3c_master_set_info()
1765 master->bus.cur_master = master->this; in i3c_master_set_info()
1767 ret = i3c_master_attach_i3c_dev(master, i3cdev); in i3c_master_set_info()
1780 static void i3c_master_detach_free_devs(struct i3c_master_controller *master) in i3c_master_detach_free_devs() argument
1785 list_for_each_entry_safe(i3cdev, i3ctmp, &master->bus.devs.i3c, in i3c_master_detach_free_devs()
1790 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_detach_free_devs()
1797 list_for_each_entry_safe(i2cdev, i2ctmp, &master->bus.devs.i2c, in i3c_master_detach_free_devs()
1800 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_detach_free_devs()
1809 * @master: main master initializing the bus
1814 * 1. Attach I2C devs to the master so that the master can fill its internal
1818 * the master controller. That's usually where the bus mode is selected
1830 * devices to the master.
1839 static int i3c_master_bus_init(struct i3c_master_controller *master) in i3c_master_bus_init() argument
1851 list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node) { in i3c_master_bus_init()
1852 status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_bus_init()
1859 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_bus_init()
1863 i2cdev = i3c_master_alloc_i2c_dev(master, in i3c_master_bus_init()
1871 ret = i3c_master_attach_i2c_dev(master, i2cdev); in i3c_master_bus_init()
1882 ret = master->ops->bus_init(master); in i3c_master_bus_init()
1887 * The master device should have been instantiated in ->bus_init(), in i3c_master_bus_init()
1890 if (!master->this) { in i3c_master_bus_init()
1891 dev_err(&master->dev, in i3c_master_bus_init()
1897 if (master->ops->set_speed) { in i3c_master_bus_init()
1898 ret = master->ops->set_speed(master, I3C_OPEN_DRAIN_SLOW_SPEED); in i3c_master_bus_init()
1907 ret = i3c_master_rstdaa_locked(master, I3C_BROADCAST_ADDR); in i3c_master_bus_init()
1911 if (master->ops->set_speed) { in i3c_master_bus_init()
1912 master->ops->set_speed(master, I3C_OPEN_DRAIN_NORMAL_SPEED); in i3c_master_bus_init()
1918 ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR, in i3c_master_bus_init()
1931 list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) { in i3c_master_bus_init()
1940 ret = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_bus_init()
1948 i3c_bus_set_addr_slot_status_mask(&master->bus, in i3c_master_bus_init()
1962 i3c_master_early_i3c_dev_add(master, i3cboardinfo); in i3c_master_bus_init()
1965 ret = i3c_master_do_daa(master); in i3c_master_bus_init()
1972 i3c_master_rstdaa_locked(master, I3C_BROADCAST_ADDR); in i3c_master_bus_init()
1975 if (master->ops->bus_cleanup) in i3c_master_bus_init()
1976 master->ops->bus_cleanup(master); in i3c_master_bus_init()
1979 i3c_master_detach_free_devs(master); in i3c_master_bus_init()
1984 static void i3c_master_bus_cleanup(struct i3c_master_controller *master) in i3c_master_bus_cleanup() argument
1986 if (master->ops->bus_cleanup) in i3c_master_bus_cleanup()
1987 master->ops->bus_cleanup(master); in i3c_master_bus_cleanup()
1989 i3c_master_detach_free_devs(master); in i3c_master_bus_cleanup()
1994 struct i3c_master_controller *master = i3cdev->common.master; in i3c_master_attach_boardinfo() local
1997 list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) { in i3c_master_attach_boardinfo()
2010 struct i3c_master_controller *master = i3c_dev_get_master(refdev); in i3c_master_search_i3c_dev_duplicate() local
2013 i3c_bus_for_each_i3cdev(&master->bus, i3cdev) { in i3c_master_search_i3c_dev_duplicate()
2023 * @master: master used to send frames on the bus
2030 * The I3C device object is returned in case the master wants to attach
2037 int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, in i3c_master_add_i3c_dev_locked() argument
2047 if (!master) in i3c_master_add_i3c_dev_locked()
2050 newdev = i3c_master_alloc_i3c_dev(master, &info); in i3c_master_add_i3c_dev_locked()
2054 ret = i3c_master_attach_i3c_dev(master, newdev); in i3c_master_add_i3c_dev_locked()
2110 * master in i3c_master_add_i3c_dev_locked()
2120 i3c_bus_get_addr_slot_status(&master->bus, expected_dyn_addr) == I3C_ADDR_SLOT_FREE) { in i3c_master_add_i3c_dev_locked()
2123 * the address assigned by the master. in i3c_master_add_i3c_dev_locked()
2125 ret = i3c_master_setnewda_locked(master, in i3c_master_add_i3c_dev_locked()
2133 dev_err(&master->dev, in i3c_master_add_i3c_dev_locked()
2135 master->bus.id, newdev->info.pid); in i3c_master_add_i3c_dev_locked()
2150 dev_err(&master->dev, in i3c_master_add_i3c_dev_locked()
2152 master->bus.id, newdev->info.pid); in i3c_master_add_i3c_dev_locked()
2156 dev_err(&master->dev, in i3c_master_add_i3c_dev_locked()
2158 master->bus.id, newdev->info.pid); in i3c_master_add_i3c_dev_locked()
2181 of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master, in of_i3c_master_add_i2c_boardinfo() argument
2185 struct device *dev = &master->dev; in of_i3c_master_add_i2c_boardinfo()
2209 list_add_tail(&boardinfo->node, &master->boardinfo.i2c); in of_i3c_master_add_i2c_boardinfo()
2216 of_i3c_master_add_i3c_boardinfo(struct i3c_master_controller *master, in of_i3c_master_add_i3c_boardinfo() argument
2220 struct device *dev = &master->dev; in of_i3c_master_add_i3c_boardinfo()
2232 addrstatus = i3c_bus_get_addr_slot_status(&master->bus, in of_i3c_master_add_i3c_boardinfo()
2244 addrstatus = i3c_bus_get_addr_slot_status(&master->bus, in of_i3c_master_add_i3c_boardinfo()
2258 list_add_tail(&boardinfo->node, &master->boardinfo.i3c); in of_i3c_master_add_i3c_boardinfo()
2263 static int of_i3c_master_add_dev(struct i3c_master_controller *master, in of_i3c_master_add_dev() argument
2269 if (!master || !node) in of_i3c_master_add_dev()
2281 ret = of_i3c_master_add_i2c_boardinfo(master, node, reg); in of_i3c_master_add_dev()
2283 ret = of_i3c_master_add_i3c_boardinfo(master, node, reg); in of_i3c_master_add_dev()
2288 static int of_populate_i3c_bus(struct i3c_master_controller *master) in of_populate_i3c_bus() argument
2290 struct device *dev = &master->dev; in of_populate_i3c_bus()
2300 ret = of_i3c_master_add_dev(master, node); in of_populate_i3c_bus()
2313 master->bus.scl_rate.i2c = val; in of_populate_i3c_bus()
2316 master->bus.scl_rate.i3c = val; in of_populate_i3c_bus()
2324 struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap); in i3c_master_i2c_adapter_xfer() local
2329 if (!xfers || !master || nxfers <= 0) in i3c_master_i2c_adapter_xfer()
2332 if (!master->ops->i2c_xfers) in i3c_master_i2c_adapter_xfer()
2342 i3c_bus_normaluse_lock(&master->bus); in i3c_master_i2c_adapter_xfer()
2343 dev = i3c_master_find_i2c_dev_by_addr(master, addr); in i3c_master_i2c_adapter_xfer()
2347 ret = master->ops->i2c_xfers(dev, xfers, nxfers); in i3c_master_i2c_adapter_xfer()
2348 i3c_bus_normaluse_unlock(&master->bus); in i3c_master_i2c_adapter_xfer()
2376 struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap); in i3c_master_i2c_attach() local
2382 if (i3c_master_find_i2c_dev_by_addr(master, client->addr)) in i3c_master_i2c_attach()
2385 status = i3c_bus_get_addr_slot_status(&master->bus, client->addr); in i3c_master_i2c_attach()
2389 i3c_bus_set_addr_slot_status(&master->bus, client->addr, in i3c_master_i2c_attach()
2392 i2cdev = i3c_master_alloc_i2c_dev(master, client->addr, in i3c_master_i2c_attach()
2399 ret = i3c_master_attach_i2c_dev(master, i2cdev); in i3c_master_i2c_attach()
2408 i3c_bus_set_addr_slot_status(&master->bus, client->addr, in i3c_master_i2c_attach()
2416 struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap); in i3c_master_i2c_detach() local
2419 dev = i3c_master_find_i2c_dev_by_addr(master, client->addr); in i3c_master_i2c_detach()
2424 i3c_bus_set_addr_slot_status(&master->bus, dev->addr, in i3c_master_i2c_detach()
2442 struct i3c_master_controller *master; in i3c_i2c_notifier_call() local
2454 master = i2c_adapter_to_i3c_master(adap); in i3c_i2c_notifier_call()
2456 i3c_bus_maintenance_lock(&master->bus); in i3c_i2c_notifier_call()
2465 i3c_bus_maintenance_unlock(&master->bus); in i3c_i2c_notifier_call()
2474 static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master) in i3c_master_i2c_adapter_init() argument
2476 struct i2c_adapter *adap = i3c_master_to_i2c_adapter(master); in i3c_master_i2c_adapter_init()
2481 adap->dev.parent = master->dev.parent; in i3c_master_i2c_adapter_init()
2482 adap->owner = master->dev.parent->driver->owner; in i3c_master_i2c_adapter_init()
2484 strncpy(adap->name, dev_name(master->dev.parent), sizeof(adap->name)); in i3c_master_i2c_adapter_init()
2498 list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node) { in i3c_master_i2c_adapter_init()
2499 i2cdev = i3c_master_find_i2c_dev_by_addr(master, in i3c_master_i2c_adapter_init()
2509 static void i3c_master_i2c_adapter_cleanup(struct i3c_master_controller *master) in i3c_master_i2c_adapter_cleanup() argument
2513 i2c_del_adapter(&master->i2c); in i3c_master_i2c_adapter_cleanup()
2515 i3c_bus_for_each_i2cdev(&master->bus, i2cdev) in i3c_master_i2c_adapter_cleanup()
2519 static void i3c_master_unregister_i3c_devs(struct i3c_master_controller *master) in i3c_master_unregister_i3c_devs() argument
2523 i3c_bus_for_each_i3cdev(&master->bus, i3cdev) { in i3c_master_unregister_i3c_devs()
2547 queue_work(dev->common.master->wq, &slot->work); in i3c_master_queue_ibi()
2556 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_handle_ibi() local
2565 master->ops->recycle_ibi_slot(dev, slot); in i3c_master_handle_ibi()
2715 * master driver struct_master_controller_ops->recycle_ibi() method.
2748 * i3c_master_register() - register an I3C master
2749 * @master: master used to send frames on the bus
2750 * @parent: the parent device (the one that provides this I3C master
2752 * @ops: the master controller operations
2753 * @secondary: true if you are registering a secondary master. Will return
2768 int i3c_master_register(struct i3c_master_controller *master, in i3c_master_register() argument
2774 struct i3c_bus *i3cbus = i3c_master_get_bus(master); in i3c_master_register()
2787 master->dev.parent = parent; in i3c_master_register()
2788 master->dev.of_node = of_node_get(parent->of_node); in i3c_master_register()
2789 master->dev.bus = &i3c_bus_type; in i3c_master_register()
2790 master->dev.type = &i3c_masterdev_type; in i3c_master_register()
2791 master->dev.release = i3c_masterdev_release; in i3c_master_register()
2792 master->ops = ops; in i3c_master_register()
2793 master->secondary = secondary; in i3c_master_register()
2794 INIT_LIST_HEAD(&master->boardinfo.i2c); in i3c_master_register()
2795 INIT_LIST_HEAD(&master->boardinfo.i3c); in i3c_master_register()
2797 ret = i3c_bus_init(i3cbus, master->dev.of_node); in i3c_master_register()
2801 device_initialize(&master->dev); in i3c_master_register()
2802 dev_set_name(&master->dev, "i3c-%d", i3cbus->id); in i3c_master_register()
2804 ret = of_populate_i3c_bus(master); in i3c_master_register()
2808 list_for_each_entry(i2cbi, &master->boardinfo.i2c, node) { in i3c_master_register()
2835 master->wq = alloc_workqueue("%s", 0, 0, dev_name(parent)); in i3c_master_register()
2836 if (!master->wq) { in i3c_master_register()
2841 ret = i3c_master_bus_init(master); in i3c_master_register()
2845 ret = device_add(&master->dev); in i3c_master_register()
2853 ret = i3c_master_i2c_adapter_init(master); in i3c_master_register()
2863 master->init_done = true; in i3c_master_register()
2864 i3c_bus_normaluse_lock(&master->bus); in i3c_master_register()
2865 i3c_master_register_new_i3c_devs(master); in i3c_master_register()
2866 i3c_bus_normaluse_unlock(&master->bus); in i3c_master_register()
2871 device_del(&master->dev); in i3c_master_register()
2874 i3c_master_bus_cleanup(master); in i3c_master_register()
2877 put_device(&master->dev); in i3c_master_register()
2884 * i3c_master_unregister() - unregister an I3C master
2885 * @master: master used to send frames on the bus
2889 void i3c_master_unregister(struct i3c_master_controller *master) in i3c_master_unregister() argument
2891 i3c_bus_notify(&master->bus, I3C_NOTIFY_BUS_REMOVE); in i3c_master_unregister()
2893 i3c_master_i2c_adapter_cleanup(master); in i3c_master_unregister()
2894 i3c_master_unregister_i3c_devs(master); in i3c_master_unregister()
2895 i3c_master_bus_cleanup(master); in i3c_master_unregister()
2896 device_unregister(&master->dev); in i3c_master_unregister()
2902 struct i3c_master_controller *master; in i3c_dev_setdasa_locked() local
2907 master = i3c_dev_get_master(dev); in i3c_dev_setdasa_locked()
2908 if (!master) in i3c_dev_setdasa_locked()
2915 return i3c_master_setdasa_locked(master, dev->info.static_addr, in i3c_dev_setdasa_locked()
2923 struct i3c_master_controller *master; in i3c_dev_do_priv_xfers_locked() local
2928 master = i3c_dev_get_master(dev); in i3c_dev_do_priv_xfers_locked()
2929 if (!master || !xfers) in i3c_dev_do_priv_xfers_locked()
2932 if (!master->ops->priv_xfers) in i3c_dev_do_priv_xfers_locked()
2935 return master->ops->priv_xfers(dev, xfers, nxfers); in i3c_dev_do_priv_xfers_locked()
2940 struct i3c_master_controller *master; in i3c_dev_disable_ibi_locked() local
2946 master = i3c_dev_get_master(dev); in i3c_dev_disable_ibi_locked()
2947 ret = master->ops->disable_ibi(dev); in i3c_dev_disable_ibi_locked()
2962 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_dev_enable_ibi_locked() local
2968 ret = master->ops->enable_ibi(dev); in i3c_dev_enable_ibi_locked()
2978 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_dev_request_ibi_locked() local
2982 if (!master->ops->request_ibi) in i3c_dev_request_ibi_locked()
2999 ret = master->ops->request_ibi(dev, req); in i3c_dev_request_ibi_locked()
3010 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_dev_free_ibi_locked() local
3018 master->ops->free_ibi(dev); in i3c_dev_free_ibi_locked()