Lines Matching full:master

74  * In other words, transfer requests passed to the I3C master can be submitted
75 * in parallel and I3C master drivers have to use their own locking to make
112 struct i3c_master_controller *master; in dev_to_i3cbus() local
117 master = dev_to_i3cmaster(dev); in dev_to_i3cbus()
119 return &master->bus; in dev_to_i3cbus()
124 struct i3c_master_controller *master; in dev_to_i3cdesc() local
129 master = dev_to_i3cmaster(dev); in dev_to_i3cdesc()
131 return master->this; in dev_to_i3cdesc()
562 static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable) in i3c_set_hotjoin() argument
566 if (!master || !master->ops) in i3c_set_hotjoin()
569 if (!master->ops->enable_hotjoin || !master->ops->disable_hotjoin) in i3c_set_hotjoin()
572 i3c_bus_normaluse_lock(&master->bus); in i3c_set_hotjoin()
575 ret = master->ops->enable_hotjoin(master); in i3c_set_hotjoin()
577 ret = master->ops->disable_hotjoin(master); in i3c_set_hotjoin()
579 master->hotjoin = enable; in i3c_set_hotjoin()
581 i3c_bus_normaluse_unlock(&master->bus); in i3c_set_hotjoin()
599 ret = i3c_set_hotjoin(i3cbus->cur_master->common.master, res); in hotjoin_store()
608 * @master: I3C master object
612 int i3c_master_enable_hotjoin(struct i3c_master_controller *master) in i3c_master_enable_hotjoin() argument
614 return i3c_set_hotjoin(master, true); in i3c_master_enable_hotjoin()
620 * @master: I3C master object
624 int i3c_master_disable_hotjoin(struct i3c_master_controller *master) in i3c_master_disable_hotjoin() argument
626 return i3c_set_hotjoin(master, false); in i3c_master_disable_hotjoin()
636 ret = sysfs_emit(buf, "%d\n", i3cbus->cur_master->common.master->hotjoin); in hotjoin_show()
661 struct i3c_master_controller *master = dev_to_i3cmaster(dev); in i3c_masterdev_release() local
664 if (master->wq) in i3c_masterdev_release()
665 destroy_workqueue(master->wq); in i3c_masterdev_release()
680 struct i3c_master_controller *master = i3c_bus_to_i3c_master(i3cbus); in i3c_bus_set_mode() local
707 dev_dbg(&master->dev, "i2c-scl = %ld Hz i3c-scl = %ld Hz\n", in i3c_bus_set_mode()
728 i3c_master_to_i2c_adapter(struct i3c_master_controller *master) in i3c_master_to_i2c_adapter() argument
730 return &master->i2c; in i3c_master_to_i2c_adapter()
739 i3c_master_alloc_i2c_dev(struct i3c_master_controller *master, in i3c_master_alloc_i2c_dev() argument
748 dev->common.master = master; in i3c_master_alloc_i2c_dev()
784 static int i3c_master_send_ccc_cmd_locked(struct i3c_master_controller *master, in i3c_master_send_ccc_cmd_locked() argument
789 if (!cmd || !master) in i3c_master_send_ccc_cmd_locked()
792 if (WARN_ON(master->init_done && in i3c_master_send_ccc_cmd_locked()
793 !rwsem_is_locked(&master->bus.lock))) in i3c_master_send_ccc_cmd_locked()
796 if (!master->ops->send_ccc_cmd) in i3c_master_send_ccc_cmd_locked()
802 if (master->ops->supports_ccc_cmd && in i3c_master_send_ccc_cmd_locked()
803 !master->ops->supports_ccc_cmd(master, cmd)) in i3c_master_send_ccc_cmd_locked()
806 ret = master->ops->send_ccc_cmd(master, cmd); in i3c_master_send_ccc_cmd_locked()
818 i3c_master_find_i2c_dev_by_addr(const struct i3c_master_controller *master, in i3c_master_find_i2c_dev_by_addr() argument
823 i3c_bus_for_each_i2cdev(&master->bus, dev) { in i3c_master_find_i2c_dev_by_addr()
833 * @master: I3C master object
841 int i3c_master_get_free_addr(struct i3c_master_controller *master, in i3c_master_get_free_addr() argument
844 return i3c_bus_get_free_addr(&master->bus, start_addr); in i3c_master_get_free_addr()
864 i3c_master_alloc_i3c_dev(struct i3c_master_controller *master, in i3c_master_alloc_i3c_dev() argument
873 dev->common.master = master; in i3c_master_alloc_i3c_dev()
880 static int i3c_master_rstdaa_locked(struct i3c_master_controller *master, in i3c_master_rstdaa_locked() argument
888 if (!master) in i3c_master_rstdaa_locked()
891 addrstat = i3c_bus_get_addr_slot_status(&master->bus, addr); in i3c_master_rstdaa_locked()
899 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_rstdaa_locked()
908 * @master: master used to send frames on the bus
913 * behind dynamic address assignment has to be handled in the I3C master
921 int i3c_master_entdaa_locked(struct i3c_master_controller *master) in i3c_master_entdaa_locked() argument
929 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_entdaa_locked()
936 static int i3c_master_enec_disec_locked(struct i3c_master_controller *master, in i3c_master_enec_disec_locked() argument
954 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_enec_disec_locked()
962 * @master: master used to send frames on the bus
974 int i3c_master_disec_locked(struct i3c_master_controller *master, u8 addr, in i3c_master_disec_locked() argument
977 return i3c_master_enec_disec_locked(master, addr, false, evts); in i3c_master_disec_locked()
983 * @master: master used to send frames on the bus
995 int i3c_master_enec_locked(struct i3c_master_controller *master, u8 addr, in i3c_master_enec_locked() argument
998 return i3c_master_enec_disec_locked(master, addr, true, evts); in i3c_master_enec_locked()
1004 * @master: master used to send frames on the bus
1006 * Send a DEFSLVS CCC command containing all the devices known to the @master.
1013 * It should also be called if a master ACKed an Hot-Join request and assigned
1021 int i3c_master_defslvs_locked(struct i3c_master_controller *master) in i3c_master_defslvs_locked() argument
1033 if (!master) in i3c_master_defslvs_locked()
1036 bus = i3c_master_get_bus(master); in i3c_master_defslvs_locked()
1040 if (i3cdev == master->this) in i3c_master_defslvs_locked()
1048 /* No other master on the bus, skip DEFSLVS. */ in i3c_master_defslvs_locked()
1062 defslvs->master.bcr = master->this->info.bcr; in i3c_master_defslvs_locked()
1063 defslvs->master.dcr = master->this->info.dcr; in i3c_master_defslvs_locked()
1064 defslvs->master.dyn_addr = master->this->info.dyn_addr << 1; in i3c_master_defslvs_locked()
1065 defslvs->master.static_addr = I3C_BROADCAST_ADDR << 1; in i3c_master_defslvs_locked()
1075 /* Skip the I3C dev representing this master. */ in i3c_master_defslvs_locked()
1076 if (i3cdev == master->this) in i3c_master_defslvs_locked()
1087 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_defslvs_locked()
1094 static int i3c_master_setda_locked(struct i3c_master_controller *master, in i3c_master_setda_locked() argument
1113 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_setda_locked()
1119 static int i3c_master_setdasa_locked(struct i3c_master_controller *master, in i3c_master_setdasa_locked() argument
1122 return i3c_master_setda_locked(master, static_addr, dyn_addr, true); in i3c_master_setdasa_locked()
1125 static int i3c_master_setnewda_locked(struct i3c_master_controller *master, in i3c_master_setnewda_locked() argument
1128 return i3c_master_setda_locked(master, oldaddr, newaddr, false); in i3c_master_setnewda_locked()
1131 static int i3c_master_getmrl_locked(struct i3c_master_controller *master, in i3c_master_getmrl_locked() argument
1151 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getmrl_locked()
1173 static int i3c_master_getmwl_locked(struct i3c_master_controller *master, in i3c_master_getmwl_locked() argument
1186 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getmwl_locked()
1203 static int i3c_master_getmxds_locked(struct i3c_master_controller *master, in i3c_master_getmxds_locked() argument
1217 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getmxds_locked()
1224 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getmxds_locked()
1247 static int i3c_master_gethdrcap_locked(struct i3c_master_controller *master, in i3c_master_gethdrcap_locked() argument
1261 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_gethdrcap_locked()
1278 static int i3c_master_getpid_locked(struct i3c_master_controller *master, in i3c_master_getpid_locked() argument
1291 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getpid_locked()
1308 static int i3c_master_getbcr_locked(struct i3c_master_controller *master, in i3c_master_getbcr_locked() argument
1321 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getbcr_locked()
1333 static int i3c_master_getdcr_locked(struct i3c_master_controller *master, in i3c_master_getdcr_locked() argument
1346 ret = i3c_master_send_ccc_cmd_locked(master, &cmd); in i3c_master_getdcr_locked()
1360 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_retrieve_dev_info() local
1367 slot_status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_retrieve_dev_info()
1373 ret = i3c_master_getpid_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1377 ret = i3c_master_getbcr_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1381 ret = i3c_master_getdcr_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1386 ret = i3c_master_getmxds_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1394 i3c_master_getmrl_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1395 i3c_master_getmwl_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1398 ret = i3c_master_gethdrcap_locked(master, &dev->info); in i3c_master_retrieve_dev_info()
1408 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_put_i3c_addrs() local
1411 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_put_i3c_addrs()
1416 i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, in i3c_master_put_i3c_addrs()
1420 i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, in i3c_master_put_i3c_addrs()
1426 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_get_i3c_addrs() local
1433 status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1442 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1455 status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1460 i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, in i3c_master_get_i3c_addrs()
1468 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_get_i3c_addrs()
1475 static int i3c_master_attach_i3c_dev(struct i3c_master_controller *master, in i3c_master_attach_i3c_dev() argument
1491 /* Do not attach the master device itself. */ in i3c_master_attach_i3c_dev()
1492 if (master->this != dev && master->ops->attach_i3c_dev) { in i3c_master_attach_i3c_dev()
1493 ret = master->ops->attach_i3c_dev(dev); in i3c_master_attach_i3c_dev()
1500 list_add_tail(&dev->common.node, &master->bus.devs.i3c); in i3c_master_attach_i3c_dev()
1508 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_reattach_i3c_dev() local
1515 status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_reattach_i3c_dev()
1519 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_reattach_i3c_dev()
1523 i3c_bus_set_addr_slot_status(&master->bus, old_dyn_addr, in i3c_master_reattach_i3c_dev()
1527 if (master->ops->reattach_i3c_dev) { in i3c_master_reattach_i3c_dev()
1528 ret = master->ops->reattach_i3c_dev(dev, old_dyn_addr); in i3c_master_reattach_i3c_dev()
1540 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_detach_i3c_dev() local
1542 /* Do not detach the master device itself. */ in i3c_master_detach_i3c_dev()
1543 if (master->this != dev && master->ops->detach_i3c_dev) in i3c_master_detach_i3c_dev()
1544 master->ops->detach_i3c_dev(dev); in i3c_master_detach_i3c_dev()
1550 static int i3c_master_attach_i2c_dev(struct i3c_master_controller *master, in i3c_master_attach_i2c_dev() argument
1555 if (master->ops->attach_i2c_dev) { in i3c_master_attach_i2c_dev()
1556 ret = master->ops->attach_i2c_dev(dev); in i3c_master_attach_i2c_dev()
1561 list_add_tail(&dev->common.node, &master->bus.devs.i2c); in i3c_master_attach_i2c_dev()
1568 struct i3c_master_controller *master = i2c_dev_get_master(dev); in i3c_master_detach_i2c_dev() local
1572 if (master->ops->detach_i2c_dev) in i3c_master_detach_i2c_dev()
1573 master->ops->detach_i2c_dev(dev); in i3c_master_detach_i2c_dev()
1576 static int i3c_master_early_i3c_dev_add(struct i3c_master_controller *master, in i3c_master_early_i3c_dev_add() argument
1586 i3cdev = i3c_master_alloc_i3c_dev(master, &info); in i3c_master_early_i3c_dev_add()
1592 ret = i3c_master_attach_i3c_dev(master, i3cdev); in i3c_master_early_i3c_dev_add()
1596 ret = i3c_master_setdasa_locked(master, i3cdev->info.static_addr, in i3c_master_early_i3c_dev_add()
1613 i3c_master_rstdaa_locked(master, i3cdev->boardinfo->init_dyn_addr); in i3c_master_early_i3c_dev_add()
1623 i3c_master_register_new_i3c_devs(struct i3c_master_controller *master) in i3c_master_register_new_i3c_devs() argument
1628 if (!master->init_done) in i3c_master_register_new_i3c_devs()
1631 i3c_bus_for_each_i3cdev(&master->bus, desc) { in i3c_master_register_new_i3c_devs()
1632 if (desc->dev || !desc->info.dyn_addr || desc == master->this) in i3c_master_register_new_i3c_devs()
1639 desc->dev->bus = &master->bus; in i3c_master_register_new_i3c_devs()
1641 desc->dev->dev.parent = &master->dev; in i3c_master_register_new_i3c_devs()
1645 dev_set_name(&desc->dev->dev, "%d-%llx", master->bus.id, in i3c_master_register_new_i3c_devs()
1653 dev_err(&master->dev, in i3c_master_register_new_i3c_devs()
1662 * @master: master doing the DAA
1668 * The I3C device object is returned in case the master wants to attach
1675 int i3c_master_do_daa(struct i3c_master_controller *master) in i3c_master_do_daa() argument
1679 i3c_bus_maintenance_lock(&master->bus); in i3c_master_do_daa()
1680 ret = master->ops->do_daa(master); in i3c_master_do_daa()
1681 i3c_bus_maintenance_unlock(&master->bus); in i3c_master_do_daa()
1686 i3c_bus_normaluse_lock(&master->bus); in i3c_master_do_daa()
1687 i3c_master_register_new_i3c_devs(master); in i3c_master_do_daa()
1688 i3c_bus_normaluse_unlock(&master->bus); in i3c_master_do_daa()
1695 * i3c_master_set_info() - set master device information
1696 * @master: master used to send frames on the bus
1699 * Set master device info. This should be called from
1702 * Not all &i3c_device_info fields are meaningful for a master device.
1718 int i3c_master_set_info(struct i3c_master_controller *master, in i3c_master_set_info() argument
1724 if (!i3c_bus_dev_addr_is_avail(&master->bus, info->dyn_addr)) in i3c_master_set_info()
1728 master->secondary) in i3c_master_set_info()
1731 if (master->this) in i3c_master_set_info()
1734 i3cdev = i3c_master_alloc_i3c_dev(master, info); in i3c_master_set_info()
1738 master->this = i3cdev; in i3c_master_set_info()
1739 master->bus.cur_master = master->this; in i3c_master_set_info()
1741 ret = i3c_master_attach_i3c_dev(master, i3cdev); in i3c_master_set_info()
1754 static void i3c_master_detach_free_devs(struct i3c_master_controller *master) in i3c_master_detach_free_devs() argument
1759 list_for_each_entry_safe(i3cdev, i3ctmp, &master->bus.devs.i3c, in i3c_master_detach_free_devs()
1764 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_detach_free_devs()
1771 list_for_each_entry_safe(i2cdev, i2ctmp, &master->bus.devs.i2c, in i3c_master_detach_free_devs()
1774 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_detach_free_devs()
1783 * @master: main master initializing the bus
1788 * 1. Attach I2C devs to the master so that the master can fill its internal
1792 * the master controller. That's usually where the bus mode is selected
1804 * devices to the master.
1813 static int i3c_master_bus_init(struct i3c_master_controller *master) in i3c_master_bus_init() argument
1825 list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node) { in i3c_master_bus_init()
1826 status = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_bus_init()
1833 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_bus_init()
1837 i2cdev = i3c_master_alloc_i2c_dev(master, in i3c_master_bus_init()
1845 ret = i3c_master_attach_i2c_dev(master, i2cdev); in i3c_master_bus_init()
1856 ret = master->ops->bus_init(master); in i3c_master_bus_init()
1861 * The master device should have been instantiated in ->bus_init(), in i3c_master_bus_init()
1864 if (!master->this) { in i3c_master_bus_init()
1865 dev_err(&master->dev, in i3c_master_bus_init()
1871 if (master->ops->set_speed) { in i3c_master_bus_init()
1872 ret = master->ops->set_speed(master, I3C_OPEN_DRAIN_SLOW_SPEED); in i3c_master_bus_init()
1881 ret = i3c_master_rstdaa_locked(master, I3C_BROADCAST_ADDR); in i3c_master_bus_init()
1885 if (master->ops->set_speed) { in i3c_master_bus_init()
1886 master->ops->set_speed(master, I3C_OPEN_DRAIN_NORMAL_SPEED); in i3c_master_bus_init()
1892 ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR, in i3c_master_bus_init()
1905 list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) { in i3c_master_bus_init()
1914 ret = i3c_bus_get_addr_slot_status(&master->bus, in i3c_master_bus_init()
1921 i3c_bus_set_addr_slot_status(&master->bus, in i3c_master_bus_init()
1934 i3c_master_early_i3c_dev_add(master, i3cboardinfo); in i3c_master_bus_init()
1937 ret = i3c_master_do_daa(master); in i3c_master_bus_init()
1944 i3c_master_rstdaa_locked(master, I3C_BROADCAST_ADDR); in i3c_master_bus_init()
1947 if (master->ops->bus_cleanup) in i3c_master_bus_init()
1948 master->ops->bus_cleanup(master); in i3c_master_bus_init()
1951 i3c_master_detach_free_devs(master); in i3c_master_bus_init()
1956 static void i3c_master_bus_cleanup(struct i3c_master_controller *master) in i3c_master_bus_cleanup() argument
1958 if (master->ops->bus_cleanup) in i3c_master_bus_cleanup()
1959 master->ops->bus_cleanup(master); in i3c_master_bus_cleanup()
1961 i3c_master_detach_free_devs(master); in i3c_master_bus_cleanup()
1966 struct i3c_master_controller *master = i3cdev->common.master; in i3c_master_attach_boardinfo() local
1969 list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) { in i3c_master_attach_boardinfo()
1982 struct i3c_master_controller *master = i3c_dev_get_master(refdev); in i3c_master_search_i3c_dev_duplicate() local
1985 i3c_bus_for_each_i3cdev(&master->bus, i3cdev) { in i3c_master_search_i3c_dev_duplicate()
1995 * @master: master used to send frames on the bus
2002 * The I3C device object is returned in case the master wants to attach
2009 int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, in i3c_master_add_i3c_dev_locked() argument
2019 if (!master) in i3c_master_add_i3c_dev_locked()
2022 newdev = i3c_master_alloc_i3c_dev(master, &info); in i3c_master_add_i3c_dev_locked()
2026 ret = i3c_master_attach_i3c_dev(master, newdev); in i3c_master_add_i3c_dev_locked()
2077 * master in i3c_master_add_i3c_dev_locked()
2089 * the address assigned by the master. in i3c_master_add_i3c_dev_locked()
2091 ret = i3c_master_setnewda_locked(master, in i3c_master_add_i3c_dev_locked()
2099 dev_err(&master->dev, in i3c_master_add_i3c_dev_locked()
2101 master->bus.id, newdev->info.pid); in i3c_master_add_i3c_dev_locked()
2116 dev_err(&master->dev, in i3c_master_add_i3c_dev_locked()
2118 master->bus.id, newdev->info.pid); in i3c_master_add_i3c_dev_locked()
2122 dev_err(&master->dev, in i3c_master_add_i3c_dev_locked()
2124 master->bus.id, newdev->info.pid); in i3c_master_add_i3c_dev_locked()
2147 of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master, in of_i3c_master_add_i2c_boardinfo() argument
2151 struct device *dev = &master->dev; in of_i3c_master_add_i2c_boardinfo()
2175 list_add_tail(&boardinfo->node, &master->boardinfo.i2c); in of_i3c_master_add_i2c_boardinfo()
2182 of_i3c_master_add_i3c_boardinfo(struct i3c_master_controller *master, in of_i3c_master_add_i3c_boardinfo() argument
2186 struct device *dev = &master->dev; in of_i3c_master_add_i3c_boardinfo()
2198 addrstatus = i3c_bus_get_addr_slot_status(&master->bus, in of_i3c_master_add_i3c_boardinfo()
2210 addrstatus = i3c_bus_get_addr_slot_status(&master->bus, in of_i3c_master_add_i3c_boardinfo()
2224 list_add_tail(&boardinfo->node, &master->boardinfo.i3c); in of_i3c_master_add_i3c_boardinfo()
2229 static int of_i3c_master_add_dev(struct i3c_master_controller *master, in of_i3c_master_add_dev() argument
2235 if (!master || !node) in of_i3c_master_add_dev()
2247 ret = of_i3c_master_add_i2c_boardinfo(master, node, reg); in of_i3c_master_add_dev()
2249 ret = of_i3c_master_add_i3c_boardinfo(master, node, reg); in of_i3c_master_add_dev()
2254 static int of_populate_i3c_bus(struct i3c_master_controller *master) in of_populate_i3c_bus() argument
2256 struct device *dev = &master->dev; in of_populate_i3c_bus()
2266 ret = of_i3c_master_add_dev(master, node); in of_populate_i3c_bus()
2279 master->bus.scl_rate.i2c = val; in of_populate_i3c_bus()
2282 master->bus.scl_rate.i3c = val; in of_populate_i3c_bus()
2290 struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap); in i3c_master_i2c_adapter_xfer() local
2295 if (!xfers || !master || nxfers <= 0) in i3c_master_i2c_adapter_xfer()
2298 if (!master->ops->i2c_xfers) in i3c_master_i2c_adapter_xfer()
2308 i3c_bus_normaluse_lock(&master->bus); in i3c_master_i2c_adapter_xfer()
2309 dev = i3c_master_find_i2c_dev_by_addr(master, addr); in i3c_master_i2c_adapter_xfer()
2313 ret = master->ops->i2c_xfers(dev, xfers, nxfers); in i3c_master_i2c_adapter_xfer()
2314 i3c_bus_normaluse_unlock(&master->bus); in i3c_master_i2c_adapter_xfer()
2342 struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap); in i3c_master_i2c_attach() local
2348 if (i3c_master_find_i2c_dev_by_addr(master, client->addr)) in i3c_master_i2c_attach()
2351 status = i3c_bus_get_addr_slot_status(&master->bus, client->addr); in i3c_master_i2c_attach()
2355 i3c_bus_set_addr_slot_status(&master->bus, client->addr, in i3c_master_i2c_attach()
2358 i2cdev = i3c_master_alloc_i2c_dev(master, client->addr, in i3c_master_i2c_attach()
2365 ret = i3c_master_attach_i2c_dev(master, i2cdev); in i3c_master_i2c_attach()
2374 i3c_bus_set_addr_slot_status(&master->bus, client->addr, in i3c_master_i2c_attach()
2382 struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap); in i3c_master_i2c_detach() local
2385 dev = i3c_master_find_i2c_dev_by_addr(master, client->addr); in i3c_master_i2c_detach()
2390 i3c_bus_set_addr_slot_status(&master->bus, dev->addr, in i3c_master_i2c_detach()
2408 struct i3c_master_controller *master; in i3c_i2c_notifier_call() local
2420 master = i2c_adapter_to_i3c_master(adap); in i3c_i2c_notifier_call()
2422 i3c_bus_maintenance_lock(&master->bus); in i3c_i2c_notifier_call()
2431 i3c_bus_maintenance_unlock(&master->bus); in i3c_i2c_notifier_call()
2440 static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master) in i3c_master_i2c_adapter_init() argument
2442 struct i2c_adapter *adap = i3c_master_to_i2c_adapter(master); in i3c_master_i2c_adapter_init()
2447 adap->dev.parent = master->dev.parent; in i3c_master_i2c_adapter_init()
2448 adap->owner = master->dev.parent->driver->owner; in i3c_master_i2c_adapter_init()
2450 strscpy(adap->name, dev_name(master->dev.parent), sizeof(adap->name)); in i3c_master_i2c_adapter_init()
2464 list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node) { in i3c_master_i2c_adapter_init()
2465 i2cdev = i3c_master_find_i2c_dev_by_addr(master, in i3c_master_i2c_adapter_init()
2475 static void i3c_master_i2c_adapter_cleanup(struct i3c_master_controller *master) in i3c_master_i2c_adapter_cleanup() argument
2479 i2c_del_adapter(&master->i2c); in i3c_master_i2c_adapter_cleanup()
2481 i3c_bus_for_each_i2cdev(&master->bus, i2cdev) in i3c_master_i2c_adapter_cleanup()
2485 static void i3c_master_unregister_i3c_devs(struct i3c_master_controller *master) in i3c_master_unregister_i3c_devs() argument
2489 i3c_bus_for_each_i3cdev(&master->bus, i3cdev) { in i3c_master_unregister_i3c_devs()
2522 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_master_handle_ibi() local
2531 master->ops->recycle_ibi_slot(dev, slot); in i3c_master_handle_ibi()
2681 * master driver struct_master_controller_ops->recycle_ibi() method.
2714 * i3c_master_register() - register an I3C master
2715 * @master: master used to send frames on the bus
2716 * @parent: the parent device (the one that provides this I3C master
2718 * @ops: the master controller operations
2719 * @secondary: true if you are registering a secondary master. Will return
2734 int i3c_master_register(struct i3c_master_controller *master, in i3c_master_register() argument
2740 struct i3c_bus *i3cbus = i3c_master_get_bus(master); in i3c_master_register()
2753 master->dev.parent = parent; in i3c_master_register()
2754 master->dev.of_node = of_node_get(parent->of_node); in i3c_master_register()
2755 master->dev.bus = &i3c_bus_type; in i3c_master_register()
2756 master->dev.type = &i3c_masterdev_type; in i3c_master_register()
2757 master->dev.release = i3c_masterdev_release; in i3c_master_register()
2758 master->ops = ops; in i3c_master_register()
2759 master->secondary = secondary; in i3c_master_register()
2760 INIT_LIST_HEAD(&master->boardinfo.i2c); in i3c_master_register()
2761 INIT_LIST_HEAD(&master->boardinfo.i3c); in i3c_master_register()
2763 ret = i3c_bus_init(i3cbus, master->dev.of_node); in i3c_master_register()
2767 device_initialize(&master->dev); in i3c_master_register()
2768 dev_set_name(&master->dev, "i3c-%d", i3cbus->id); in i3c_master_register()
2770 master->dev.dma_mask = parent->dma_mask; in i3c_master_register()
2771 master->dev.coherent_dma_mask = parent->coherent_dma_mask; in i3c_master_register()
2772 master->dev.dma_parms = parent->dma_parms; in i3c_master_register()
2774 ret = of_populate_i3c_bus(master); in i3c_master_register()
2778 list_for_each_entry(i2cbi, &master->boardinfo.i2c, node) { in i3c_master_register()
2805 master->wq = alloc_workqueue("%s", 0, 0, dev_name(parent)); in i3c_master_register()
2806 if (!master->wq) { in i3c_master_register()
2811 ret = i3c_master_bus_init(master); in i3c_master_register()
2815 ret = device_add(&master->dev); in i3c_master_register()
2823 ret = i3c_master_i2c_adapter_init(master); in i3c_master_register()
2829 pm_runtime_no_callbacks(&master->dev); in i3c_master_register()
2830 pm_suspend_ignore_children(&master->dev, true); in i3c_master_register()
2831 pm_runtime_enable(&master->dev); in i3c_master_register()
2837 master->init_done = true; in i3c_master_register()
2838 i3c_bus_normaluse_lock(&master->bus); in i3c_master_register()
2839 i3c_master_register_new_i3c_devs(master); in i3c_master_register()
2840 i3c_bus_normaluse_unlock(&master->bus); in i3c_master_register()
2845 device_del(&master->dev); in i3c_master_register()
2848 i3c_master_bus_cleanup(master); in i3c_master_register()
2851 put_device(&master->dev); in i3c_master_register()
2858 * i3c_master_unregister() - unregister an I3C master
2859 * @master: master used to send frames on the bus
2863 void i3c_master_unregister(struct i3c_master_controller *master) in i3c_master_unregister() argument
2865 i3c_bus_notify(&master->bus, I3C_NOTIFY_BUS_REMOVE); in i3c_master_unregister()
2867 i3c_master_i2c_adapter_cleanup(master); in i3c_master_unregister()
2868 i3c_master_unregister_i3c_devs(master); in i3c_master_unregister()
2869 i3c_master_bus_cleanup(master); in i3c_master_unregister()
2870 pm_runtime_disable(&master->dev); in i3c_master_unregister()
2871 device_unregister(&master->dev); in i3c_master_unregister()
2877 struct i3c_master_controller *master; in i3c_dev_setdasa_locked() local
2882 master = i3c_dev_get_master(dev); in i3c_dev_setdasa_locked()
2883 if (!master) in i3c_dev_setdasa_locked()
2890 return i3c_master_setdasa_locked(master, dev->info.static_addr, in i3c_dev_setdasa_locked()
2898 struct i3c_master_controller *master; in i3c_dev_do_priv_xfers_locked() local
2903 master = i3c_dev_get_master(dev); in i3c_dev_do_priv_xfers_locked()
2904 if (!master || !xfers) in i3c_dev_do_priv_xfers_locked()
2907 if (!master->ops->priv_xfers) in i3c_dev_do_priv_xfers_locked()
2910 return master->ops->priv_xfers(dev, xfers, nxfers); in i3c_dev_do_priv_xfers_locked()
2915 struct i3c_master_controller *master; in i3c_dev_disable_ibi_locked() local
2921 master = i3c_dev_get_master(dev); in i3c_dev_disable_ibi_locked()
2922 ret = master->ops->disable_ibi(dev); in i3c_dev_disable_ibi_locked()
2937 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_dev_enable_ibi_locked() local
2943 ret = master->ops->enable_ibi(dev); in i3c_dev_enable_ibi_locked()
2953 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_dev_request_ibi_locked() local
2957 if (!master->ops->request_ibi) in i3c_dev_request_ibi_locked()
2980 ret = master->ops->request_ibi(dev, req); in i3c_dev_request_ibi_locked()
2991 struct i3c_master_controller *master = i3c_dev_get_master(dev); in i3c_dev_free_ibi_locked() local
2999 master->ops->free_ibi(dev); in i3c_dev_free_ibi_locked()