Lines Matching full:slave

128 	 * Create Slave devices based on Slaves described in  in sdw_bus_master_add()
168 struct sdw_slave *slave = dev_to_sdw_dev(dev); in sdw_delete_slave() local
169 struct sdw_bus *bus = slave->bus; in sdw_delete_slave()
173 sdw_slave_debugfs_exit(slave); in sdw_delete_slave()
177 if (slave->dev_num) { /* clear dev_num if assigned */ in sdw_delete_slave()
178 clear_bit(slave->dev_num, bus->assigned); in sdw_delete_slave()
180 bus->ops->put_device_num(bus, slave); in sdw_delete_slave()
182 list_del_init(&slave->node); in sdw_delete_slave()
278 dev_err(bus->dev, "trf on Slave %d failed:%d %s addr %x count %d\n", in sdw_transfer_unlocked()
287 * sdw_transfer() - Synchronous transfer message to a SDW Slave device
337 * sdw_transfer_defer() - Asynchronously transfer message to a SDW Slave device
352 dev_err(bus->dev, "Defer trf on Slave %d failed:%d\n", in sdw_transfer_defer()
358 int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave, in sdw_fill_msg() argument
377 if (slave && !slave->prop.paging_support) in sdw_fill_msg()
388 if (!slave) { in sdw_fill_msg()
389 pr_err("SDW: No slave for paging addr\n"); in sdw_fill_msg()
393 if (!slave->prop.paging_support) { in sdw_fill_msg()
394 dev_err(&slave->dev, in sdw_fill_msg()
411 static int sdw_ntransfer_no_pm(struct sdw_slave *slave, u32 addr, u8 flags, in sdw_ntransfer_no_pm() argument
422 ret = sdw_fill_msg(&msg, slave, addr, size, slave->dev_num, flags, val); in sdw_ntransfer_no_pm()
426 ret = sdw_transfer(slave->bus, &msg); in sdw_ntransfer_no_pm()
427 if (ret < 0 && !slave->is_mockup_device) in sdw_ntransfer_no_pm()
439 * sdw_nread_no_pm() - Read "n" contiguous SDW Slave registers with no PM
440 * @slave: SDW Slave
448 int sdw_nread_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val) in sdw_nread_no_pm() argument
450 return sdw_ntransfer_no_pm(slave, addr, SDW_MSG_FLAG_READ, count, val); in sdw_nread_no_pm()
455 * sdw_nwrite_no_pm() - Write "n" contiguous SDW Slave registers with no PM
456 * @slave: SDW Slave
464 int sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val) in sdw_nwrite_no_pm() argument
466 return sdw_ntransfer_no_pm(slave, addr, SDW_MSG_FLAG_WRITE, count, (u8 *)val); in sdw_nwrite_no_pm()
471 * sdw_write_no_pm() - Write a SDW Slave register with no PM
472 * @slave: SDW Slave
476 int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value) in sdw_write_no_pm() argument
478 return sdw_nwrite_no_pm(slave, addr, 1, &value); in sdw_write_no_pm()
549 * sdw_read_no_pm() - Read a SDW Slave register with no PM
550 * @slave: SDW Slave
553 int sdw_read_no_pm(struct sdw_slave *slave, u32 addr) in sdw_read_no_pm() argument
558 ret = sdw_nread_no_pm(slave, addr, 1, &buf); in sdw_read_no_pm()
566 int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val) in sdw_update_no_pm() argument
570 tmp = sdw_read_no_pm(slave, addr); in sdw_update_no_pm()
575 return sdw_write_no_pm(slave, addr, tmp); in sdw_update_no_pm()
579 /* Read-Modify-Write Slave register */
580 int sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val) in sdw_update() argument
584 tmp = sdw_read(slave, addr); in sdw_update()
589 return sdw_write(slave, addr, tmp); in sdw_update()
594 * sdw_nread() - Read "n" contiguous SDW Slave registers
595 * @slave: SDW Slave
600 * This version of the function will take a PM reference to the slave
605 int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val) in sdw_nread() argument
609 ret = pm_runtime_get_sync(&slave->dev); in sdw_nread()
611 pm_runtime_put_noidle(&slave->dev); in sdw_nread()
615 ret = sdw_nread_no_pm(slave, addr, count, val); in sdw_nread()
617 pm_runtime_mark_last_busy(&slave->dev); in sdw_nread()
618 pm_runtime_put(&slave->dev); in sdw_nread()
625 * sdw_nwrite() - Write "n" contiguous SDW Slave registers
626 * @slave: SDW Slave
631 * This version of the function will take a PM reference to the slave
636 int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val) in sdw_nwrite() argument
640 ret = pm_runtime_get_sync(&slave->dev); in sdw_nwrite()
642 pm_runtime_put_noidle(&slave->dev); in sdw_nwrite()
646 ret = sdw_nwrite_no_pm(slave, addr, count, val); in sdw_nwrite()
648 pm_runtime_mark_last_busy(&slave->dev); in sdw_nwrite()
649 pm_runtime_put(&slave->dev); in sdw_nwrite()
656 * sdw_read() - Read a SDW Slave register
657 * @slave: SDW Slave
660 * This version of the function will take a PM reference to the slave
663 int sdw_read(struct sdw_slave *slave, u32 addr) in sdw_read() argument
668 ret = sdw_nread(slave, addr, 1, &buf); in sdw_read()
677 * sdw_write() - Write a SDW Slave register
678 * @slave: SDW Slave
682 * This version of the function will take a PM reference to the slave
685 int sdw_write(struct sdw_slave *slave, u32 addr, u8 value) in sdw_write() argument
687 return sdw_nwrite(slave, addr, 1, &value); in sdw_write()
698 struct sdw_slave *slave; in sdw_get_slave() local
700 list_for_each_entry(slave, &bus->slaves, node) { in sdw_get_slave()
701 if (slave->dev_num == i) in sdw_get_slave()
702 return slave; in sdw_get_slave()
708 int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id) in sdw_compare_devid() argument
710 if (slave->id.mfg_id != id.mfg_id || in sdw_compare_devid()
711 slave->id.part_id != id.part_id || in sdw_compare_devid()
712 slave->id.class_id != id.class_id || in sdw_compare_devid()
713 (slave->id.unique_id != SDW_IGNORED_UNIQUE_ID && in sdw_compare_devid()
714 slave->id.unique_id != id.unique_id)) in sdw_compare_devid()
722 static int sdw_get_device_num(struct sdw_slave *slave) in sdw_get_device_num() argument
724 struct sdw_bus *bus = slave->bus; in sdw_get_device_num()
728 bit = bus->ops->get_device_num(bus, slave); in sdw_get_device_num()
740 * Do not update dev_num in Slave data structure here, in sdw_get_device_num()
749 static int sdw_assign_device_num(struct sdw_slave *slave) in sdw_assign_device_num() argument
751 struct sdw_bus *bus = slave->bus; in sdw_assign_device_num()
756 if (!slave->dev_num) { in sdw_assign_device_num()
757 if (!slave->dev_num_sticky) { in sdw_assign_device_num()
758 mutex_lock(&slave->bus->bus_lock); in sdw_assign_device_num()
759 dev_num = sdw_get_device_num(slave); in sdw_assign_device_num()
760 mutex_unlock(&slave->bus->bus_lock); in sdw_assign_device_num()
766 slave->dev_num = dev_num; in sdw_assign_device_num()
767 slave->dev_num_sticky = dev_num; in sdw_assign_device_num()
770 slave->dev_num = slave->dev_num_sticky; in sdw_assign_device_num()
776 "Slave already registered, reusing dev_num:%d\n", in sdw_assign_device_num()
777 slave->dev_num); in sdw_assign_device_num()
779 /* Clear the slave->dev_num to transfer message on device 0 */ in sdw_assign_device_num()
780 dev_num = slave->dev_num; in sdw_assign_device_num()
781 slave->dev_num = 0; in sdw_assign_device_num()
783 ret = sdw_write_no_pm(slave, SDW_SCP_DEVNUMBER, dev_num); in sdw_assign_device_num()
791 slave->dev_num = slave->dev_num_sticky; in sdw_assign_device_num()
794 bus->ops->new_peripheral_assigned(bus, slave, dev_num); in sdw_assign_device_num()
802 dev_dbg(bus->dev, "SDW Slave Addr: %llx\n", addr); in sdw_extract_slave_id()
811 "SDW Slave class_id 0x%02x, mfg_id 0x%04x, part_id 0x%04x, unique_id 0x%x, version 0x%x\n", in sdw_extract_slave_id()
819 struct sdw_slave *slave, *_s; in sdw_program_device_num() local
828 /* No Slave, so use raw xfer api */ in sdw_program_device_num()
858 list_for_each_entry_safe(slave, _s, &bus->slaves, node) { in sdw_program_device_num()
859 if (sdw_compare_devid(slave, id) == 0) { in sdw_program_device_num()
869 if (slave->status != SDW_SLAVE_UNATTACHED) in sdw_program_device_num()
873 * Assign a new dev_num to this Slave and in sdw_program_device_num()
878 ret = sdw_assign_device_num(slave); in sdw_program_device_num()
896 * add Slave device even if there is no platform in sdw_program_device_num()
903 dev_err(bus->dev, "Slave Entry not found\n"); in sdw_program_device_num()
919 static void sdw_modify_slave_status(struct sdw_slave *slave, in sdw_modify_slave_status() argument
922 struct sdw_bus *bus = slave->bus; in sdw_modify_slave_status()
927 "changing status slave %d status %d new status %d\n", in sdw_modify_slave_status()
928 slave->dev_num, slave->status, status); in sdw_modify_slave_status()
931 dev_dbg(&slave->dev, in sdw_modify_slave_status()
932 "initializing enumeration and init completion for Slave %d\n", in sdw_modify_slave_status()
933 slave->dev_num); in sdw_modify_slave_status()
935 reinit_completion(&slave->enumeration_complete); in sdw_modify_slave_status()
936 reinit_completion(&slave->initialization_complete); in sdw_modify_slave_status()
939 (slave->status == SDW_SLAVE_UNATTACHED)) { in sdw_modify_slave_status()
940 dev_dbg(&slave->dev, in sdw_modify_slave_status()
941 "signaling enumeration completion for Slave %d\n", in sdw_modify_slave_status()
942 slave->dev_num); in sdw_modify_slave_status()
944 complete_all(&slave->enumeration_complete); in sdw_modify_slave_status()
946 slave->status = status; in sdw_modify_slave_status()
950 static int sdw_slave_clk_stop_callback(struct sdw_slave *slave, in sdw_slave_clk_stop_callback() argument
956 mutex_lock(&slave->sdw_dev_lock); in sdw_slave_clk_stop_callback()
958 if (slave->probed) { in sdw_slave_clk_stop_callback()
959 struct device *dev = &slave->dev; in sdw_slave_clk_stop_callback()
963 ret = drv->ops->clk_stop(slave, mode, type); in sdw_slave_clk_stop_callback()
966 mutex_unlock(&slave->sdw_dev_lock); in sdw_slave_clk_stop_callback()
971 static int sdw_slave_clk_stop_prepare(struct sdw_slave *slave, in sdw_slave_clk_stop_prepare() argument
979 wake_en = slave->prop.wake_capable; in sdw_slave_clk_stop_prepare()
990 ret = sdw_read_no_pm(slave, SDW_SCP_SYSTEMCTRL); in sdw_slave_clk_stop_prepare()
993 dev_err(&slave->dev, "SDW_SCP_SYSTEMCTRL read failed:%d\n", ret); in sdw_slave_clk_stop_prepare()
1000 ret = sdw_write_no_pm(slave, SDW_SCP_SYSTEMCTRL, val); in sdw_slave_clk_stop_prepare()
1003 dev_err(&slave->dev, "SDW_SCP_SYSTEMCTRL write failed:%d\n", ret); in sdw_slave_clk_stop_prepare()
1022 dev_dbg(bus->dev, "clock stop %s done slave:%d\n", in sdw_bus_wait_for_clk_prep_deprep()
1032 dev_dbg(bus->dev, "clock stop %s did not complete for slave:%d\n", in sdw_bus_wait_for_clk_prep_deprep()
1040 * sdw_bus_prep_clk_stop: prepare Slave(s) for clock stop
1044 * Query Slave for clock stop mode and prepare for that mode.
1049 struct sdw_slave *slave; in sdw_bus_prep_clk_stop() local
1055 * each Slave and then wait for all Slave(s) to be in sdw_bus_prep_clk_stop()
1057 * If one of the Slave devices has lost sync and in sdw_bus_prep_clk_stop()
1061 list_for_each_entry(slave, &bus->slaves, node) { in sdw_bus_prep_clk_stop()
1062 if (!slave->dev_num) in sdw_bus_prep_clk_stop()
1065 if (slave->status != SDW_SLAVE_ATTACHED && in sdw_bus_prep_clk_stop()
1066 slave->status != SDW_SLAVE_ALERT) in sdw_bus_prep_clk_stop()
1069 /* Identify if Slave(s) are available on Bus */ in sdw_bus_prep_clk_stop()
1072 ret = sdw_slave_clk_stop_callback(slave, in sdw_bus_prep_clk_stop()
1076 dev_err(&slave->dev, "clock stop pre-prepare cb failed:%d\n", ret); in sdw_bus_prep_clk_stop()
1080 /* Only prepare a Slave device if needed */ in sdw_bus_prep_clk_stop()
1081 if (!slave->prop.simple_clk_stop_capable) { in sdw_bus_prep_clk_stop()
1084 ret = sdw_slave_clk_stop_prepare(slave, in sdw_bus_prep_clk_stop()
1088 dev_err(&slave->dev, "clock stop prepare failed:%d\n", ret); in sdw_bus_prep_clk_stop()
1094 /* Skip remaining clock stop preparation if no Slave is attached */ in sdw_bus_prep_clk_stop()
1106 * if there are no Slave devices present and the reply is in sdw_bus_prep_clk_stop()
1116 list_for_each_entry(slave, &bus->slaves, node) { in sdw_bus_prep_clk_stop()
1117 if (!slave->dev_num) in sdw_bus_prep_clk_stop()
1120 if (slave->status != SDW_SLAVE_ATTACHED && in sdw_bus_prep_clk_stop()
1121 slave->status != SDW_SLAVE_ALERT) in sdw_bus_prep_clk_stop()
1124 ret = sdw_slave_clk_stop_callback(slave, in sdw_bus_prep_clk_stop()
1129 dev_err(&slave->dev, "clock stop post-prepare cb failed:%d\n", ret); in sdw_bus_prep_clk_stop()
1178 struct sdw_slave *slave; in sdw_bus_exit_clk_stop() local
1184 * each Slave and then wait for all Slave(s) to be in sdw_bus_exit_clk_stop()
1187 list_for_each_entry(slave, &bus->slaves, node) { in sdw_bus_exit_clk_stop()
1188 if (!slave->dev_num) in sdw_bus_exit_clk_stop()
1191 if (slave->status != SDW_SLAVE_ATTACHED && in sdw_bus_exit_clk_stop()
1192 slave->status != SDW_SLAVE_ALERT) in sdw_bus_exit_clk_stop()
1195 /* Identify if Slave(s) are available on Bus */ in sdw_bus_exit_clk_stop()
1198 ret = sdw_slave_clk_stop_callback(slave, SDW_CLK_STOP_MODE0, in sdw_bus_exit_clk_stop()
1201 dev_warn(&slave->dev, "clock stop pre-deprepare cb failed:%d\n", ret); in sdw_bus_exit_clk_stop()
1203 /* Only de-prepare a Slave device if needed */ in sdw_bus_exit_clk_stop()
1204 if (!slave->prop.simple_clk_stop_capable) { in sdw_bus_exit_clk_stop()
1207 ret = sdw_slave_clk_stop_prepare(slave, SDW_CLK_STOP_MODE0, in sdw_bus_exit_clk_stop()
1211 dev_warn(&slave->dev, "clock stop deprepare failed:%d\n", ret); in sdw_bus_exit_clk_stop()
1215 /* Skip remaining clock stop de-preparation if no Slave is attached */ in sdw_bus_exit_clk_stop()
1229 list_for_each_entry(slave, &bus->slaves, node) { in sdw_bus_exit_clk_stop()
1230 if (!slave->dev_num) in sdw_bus_exit_clk_stop()
1233 if (slave->status != SDW_SLAVE_ATTACHED && in sdw_bus_exit_clk_stop()
1234 slave->status != SDW_SLAVE_ALERT) in sdw_bus_exit_clk_stop()
1237 ret = sdw_slave_clk_stop_callback(slave, SDW_CLK_STOP_MODE0, in sdw_bus_exit_clk_stop()
1240 dev_warn(&slave->dev, "clock stop post-deprepare cb failed:%d\n", ret); in sdw_bus_exit_clk_stop()
1247 int sdw_configure_dpn_intr(struct sdw_slave *slave, in sdw_configure_dpn_intr() argument
1254 if (slave->bus->params.s_data_mode != SDW_PORT_DATA_MODE_NORMAL) { in sdw_configure_dpn_intr()
1255 dev_dbg(&slave->dev, "TEST FAIL interrupt %s\n", in sdw_configure_dpn_intr()
1271 ret = sdw_update_no_pm(slave, addr, (mask | SDW_DPN_INT_PORT_READY), val); in sdw_configure_dpn_intr()
1273 dev_err(&slave->dev, in sdw_configure_dpn_intr()
1279 static int sdw_slave_set_frequency(struct sdw_slave *slave) in sdw_slave_set_frequency() argument
1281 u32 mclk_freq = slave->bus->prop.mclk_freq; in sdw_slave_set_frequency()
1282 u32 curr_freq = slave->bus->params.curr_dr_freq >> 1; in sdw_slave_set_frequency()
1294 if (!slave->id.class_id && !slave->prop.clock_reg_supported) in sdw_slave_set_frequency()
1298 dev_err(&slave->dev, in sdw_slave_set_frequency()
1328 dev_err(&slave->dev, in sdw_slave_set_frequency()
1335 dev_err(&slave->dev, in sdw_slave_set_frequency()
1350 dev_err(&slave->dev, in sdw_slave_set_frequency()
1357 ret = sdw_write_no_pm(slave, SDW_SCP_BUS_CLOCK_BASE, base); in sdw_slave_set_frequency()
1359 dev_err(&slave->dev, in sdw_slave_set_frequency()
1365 ret = sdw_write_no_pm(slave, SDW_SCP_BUSCLOCK_SCALE_B0, scale_index); in sdw_slave_set_frequency()
1367 dev_err(&slave->dev, in sdw_slave_set_frequency()
1371 ret = sdw_write_no_pm(slave, SDW_SCP_BUSCLOCK_SCALE_B1, scale_index); in sdw_slave_set_frequency()
1373 dev_err(&slave->dev, in sdw_slave_set_frequency()
1376 dev_dbg(&slave->dev, in sdw_slave_set_frequency()
1383 static int sdw_initialize_slave(struct sdw_slave *slave) in sdw_initialize_slave() argument
1385 struct sdw_slave_prop *prop = &slave->prop; in sdw_initialize_slave()
1390 ret = sdw_slave_set_frequency(slave); in sdw_initialize_slave()
1394 if (slave->bus->prop.quirks & SDW_MASTER_QUIRKS_CLEAR_INITIAL_CLASH) { in sdw_initialize_slave()
1396 status = sdw_read_no_pm(slave, SDW_SCP_INT1); in sdw_initialize_slave()
1398 dev_err(&slave->dev, in sdw_initialize_slave()
1403 dev_warn(&slave->dev, "Bus clash detected before INT mask is enabled\n"); in sdw_initialize_slave()
1404 ret = sdw_write_no_pm(slave, SDW_SCP_INT1, SDW_SCP_INT1_BUS_CLASH); in sdw_initialize_slave()
1406 dev_err(&slave->dev, in sdw_initialize_slave()
1412 if ((slave->bus->prop.quirks & SDW_MASTER_QUIRKS_CLEAR_INITIAL_PARITY) && in sdw_initialize_slave()
1415 status = sdw_read_no_pm(slave, SDW_SCP_INT1); in sdw_initialize_slave()
1417 dev_err(&slave->dev, in sdw_initialize_slave()
1422 dev_warn(&slave->dev, "PARITY error detected before INT mask is enabled\n"); in sdw_initialize_slave()
1423 ret = sdw_write_no_pm(slave, SDW_SCP_INT1, SDW_SCP_INT1_PARITY); in sdw_initialize_slave()
1425 dev_err(&slave->dev, in sdw_initialize_slave()
1442 ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1, val, val); in sdw_initialize_slave()
1444 dev_err(&slave->dev, in sdw_initialize_slave()
1457 ret = sdw_update_no_pm(slave, SDW_DP0_INTMASK, val, val); in sdw_initialize_slave()
1459 dev_err(&slave->dev, in sdw_initialize_slave()
1464 static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status) in sdw_handle_dp0_interrupt() argument
1469 status = sdw_read_no_pm(slave, SDW_DP0_INT); in sdw_handle_dp0_interrupt()
1471 dev_err(&slave->dev, in sdw_handle_dp0_interrupt()
1480 dev_err(&slave->dev, "Test fail for port 0\n"); in sdw_handle_dp0_interrupt()
1490 complete(&slave->port_ready[0]); in sdw_handle_dp0_interrupt()
1495 dev_err(&slave->dev, "BRA failed\n"); in sdw_handle_dp0_interrupt()
1508 ret = sdw_write_no_pm(slave, SDW_DP0_INT, clear); in sdw_handle_dp0_interrupt()
1510 dev_err(&slave->dev, in sdw_handle_dp0_interrupt()
1516 status2 = sdw_read_no_pm(slave, SDW_DP0_INT); in sdw_handle_dp0_interrupt()
1518 dev_err(&slave->dev, in sdw_handle_dp0_interrupt()
1531 dev_warn(&slave->dev, "Reached MAX_RETRY on DP0 read\n"); in sdw_handle_dp0_interrupt()
1536 static int sdw_handle_port_interrupt(struct sdw_slave *slave, in sdw_handle_port_interrupt() argument
1544 return sdw_handle_dp0_interrupt(slave, slave_status); in sdw_handle_port_interrupt()
1547 status = sdw_read_no_pm(slave, addr); in sdw_handle_port_interrupt()
1549 dev_err(&slave->dev, in sdw_handle_port_interrupt()
1559 dev_err(&slave->dev, "Test fail for port:%d\n", port); in sdw_handle_port_interrupt()
1568 complete(&slave->port_ready[port]); in sdw_handle_port_interrupt()
1581 ret = sdw_write_no_pm(slave, addr, clear); in sdw_handle_port_interrupt()
1583 dev_err(&slave->dev, in sdw_handle_port_interrupt()
1589 status2 = sdw_read_no_pm(slave, addr); in sdw_handle_port_interrupt()
1591 dev_err(&slave->dev, in sdw_handle_port_interrupt()
1604 dev_warn(&slave->dev, "Reached MAX_RETRY on port read"); in sdw_handle_port_interrupt()
1609 static int sdw_handle_slave_alerts(struct sdw_slave *slave) in sdw_handle_slave_alerts() argument
1621 sdw_modify_slave_status(slave, SDW_SLAVE_ALERT); in sdw_handle_slave_alerts()
1623 ret = pm_runtime_get_sync(&slave->dev); in sdw_handle_slave_alerts()
1625 dev_err(&slave->dev, "Failed to resume device: %d\n", ret); in sdw_handle_slave_alerts()
1626 pm_runtime_put_noidle(&slave->dev); in sdw_handle_slave_alerts()
1631 ret = sdw_read_no_pm(slave, SDW_SCP_INT1); in sdw_handle_slave_alerts()
1633 dev_err(&slave->dev, in sdw_handle_slave_alerts()
1639 ret = sdw_nread_no_pm(slave, SDW_SCP_INTSTAT2, 2, buf2); in sdw_handle_slave_alerts()
1641 dev_err(&slave->dev, in sdw_handle_slave_alerts()
1646 if (slave->id.class_id) { in sdw_handle_slave_alerts()
1647 ret = sdw_read_no_pm(slave, SDW_DP0_INT); in sdw_handle_slave_alerts()
1649 dev_err(&slave->dev, in sdw_handle_slave_alerts()
1660 * Check parity, bus clash and Slave (impl defined) in sdw_handle_slave_alerts()
1664 parity_check = slave->prop.scp_int1_mask & SDW_SCP_INT1_PARITY; in sdw_handle_slave_alerts()
1665 parity_quirk = !slave->first_interrupt_done && in sdw_handle_slave_alerts()
1666 (slave->prop.quirks & SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY); in sdw_handle_slave_alerts()
1669 dev_err(&slave->dev, "Parity error detected\n"); in sdw_handle_slave_alerts()
1674 if (slave->prop.scp_int1_mask & SDW_SCP_INT1_BUS_CLASH) in sdw_handle_slave_alerts()
1675 dev_err(&slave->dev, "Bus clash detected\n"); in sdw_handle_slave_alerts()
1687 if (slave->prop.scp_int1_mask & SDW_SCP_INT1_IMPL_DEF) { in sdw_handle_slave_alerts()
1688 dev_dbg(&slave->dev, "Slave impl defined interrupt\n"); in sdw_handle_slave_alerts()
1704 sdw_handle_port_interrupt(slave, bit, in sdw_handle_slave_alerts()
1714 sdw_handle_port_interrupt(slave, in sdw_handle_slave_alerts()
1726 sdw_handle_port_interrupt(slave, in sdw_handle_slave_alerts()
1732 /* Update the Slave driver */ in sdw_handle_slave_alerts()
1734 mutex_lock(&slave->sdw_dev_lock); in sdw_handle_slave_alerts()
1736 if (slave->probed) { in sdw_handle_slave_alerts()
1737 struct device *dev = &slave->dev; in sdw_handle_slave_alerts()
1740 if (slave->prop.use_domain_irq && slave->irq) in sdw_handle_slave_alerts()
1741 handle_nested_irq(slave->irq); in sdw_handle_slave_alerts()
1749 drv->ops->interrupt_callback(slave, &slave_intr); in sdw_handle_slave_alerts()
1753 mutex_unlock(&slave->sdw_dev_lock); in sdw_handle_slave_alerts()
1757 ret = sdw_write_no_pm(slave, SDW_SCP_INT1, clear); in sdw_handle_slave_alerts()
1759 dev_err(&slave->dev, in sdw_handle_slave_alerts()
1765 slave->first_interrupt_done = true; in sdw_handle_slave_alerts()
1771 ret = sdw_read_no_pm(slave, SDW_SCP_INT1); in sdw_handle_slave_alerts()
1773 dev_err(&slave->dev, in sdw_handle_slave_alerts()
1779 ret = sdw_nread_no_pm(slave, SDW_SCP_INTSTAT2, 2, buf2); in sdw_handle_slave_alerts()
1781 dev_err(&slave->dev, in sdw_handle_slave_alerts()
1786 if (slave->id.class_id) { in sdw_handle_slave_alerts()
1787 ret = sdw_read_no_pm(slave, SDW_DP0_INT); in sdw_handle_slave_alerts()
1789 dev_err(&slave->dev, in sdw_handle_slave_alerts()
1802 * Exit loop if Slave is continuously in ALERT state even in sdw_handle_slave_alerts()
1811 dev_warn(&slave->dev, "Reached MAX_RETRY on alert read\n"); in sdw_handle_slave_alerts()
1814 pm_runtime_mark_last_busy(&slave->dev); in sdw_handle_slave_alerts()
1815 pm_runtime_put_autosuspend(&slave->dev); in sdw_handle_slave_alerts()
1820 static int sdw_update_slave_status(struct sdw_slave *slave, in sdw_update_slave_status() argument
1825 mutex_lock(&slave->sdw_dev_lock); in sdw_update_slave_status()
1827 if (slave->probed) { in sdw_update_slave_status()
1828 struct device *dev = &slave->dev; in sdw_update_slave_status()
1832 ret = drv->ops->update_status(slave, status); in sdw_update_slave_status()
1835 mutex_unlock(&slave->sdw_dev_lock); in sdw_update_slave_status()
1841 * sdw_handle_slave_status() - Handle Slave status
1843 * @status: Status for all Slave(s)
1849 struct sdw_slave *slave; in sdw_handle_slave_status() local
1862 slave = sdw_get_slave(bus, i); in sdw_handle_slave_status()
1863 if (!slave) in sdw_handle_slave_status()
1867 slave->status != SDW_SLAVE_UNATTACHED) { in sdw_handle_slave_status()
1868 dev_warn(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n", in sdw_handle_slave_status()
1869 i, slave->status); in sdw_handle_slave_status()
1870 sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED); in sdw_handle_slave_status()
1873 ret = sdw_update_slave_status(slave, status[i]); in sdw_handle_slave_status()
1875 dev_warn(&slave->dev, "Update Slave status failed:%d\n", ret); in sdw_handle_slave_status()
1880 dev_dbg(bus->dev, "Slave attached, programming device number\n"); in sdw_handle_slave_status()
1900 /* Continue to check other slave statuses */ in sdw_handle_slave_status()
1909 slave = sdw_get_slave(bus, i); in sdw_handle_slave_status()
1910 if (!slave) in sdw_handle_slave_status()
1917 if (slave->status == SDW_SLAVE_UNATTACHED) in sdw_handle_slave_status()
1920 dev_warn(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n", in sdw_handle_slave_status()
1921 i, slave->status); in sdw_handle_slave_status()
1923 sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED); in sdw_handle_slave_status()
1927 ret = sdw_handle_slave_alerts(slave); in sdw_handle_slave_status()
1929 dev_err(&slave->dev, in sdw_handle_slave_status()
1930 "Slave %d alert handling failed: %d\n", in sdw_handle_slave_status()
1935 if (slave->status == SDW_SLAVE_ATTACHED) in sdw_handle_slave_status()
1938 prev_status = slave->status; in sdw_handle_slave_status()
1939 sdw_modify_slave_status(slave, SDW_SLAVE_ATTACHED); in sdw_handle_slave_status()
1946 ret = sdw_initialize_slave(slave); in sdw_handle_slave_status()
1948 dev_err(&slave->dev, in sdw_handle_slave_status()
1949 "Slave %d initialization failed: %d\n", in sdw_handle_slave_status()
1955 dev_err(&slave->dev, "Invalid slave %d status:%d\n", in sdw_handle_slave_status()
1960 ret = sdw_update_slave_status(slave, status[i]); in sdw_handle_slave_status()
1962 dev_err(&slave->dev, in sdw_handle_slave_status()
1963 "Update Slave status failed:%d\n", ret); in sdw_handle_slave_status()
1965 dev_dbg(&slave->dev, in sdw_handle_slave_status()
1966 "signaling initialization completion for Slave %d\n", in sdw_handle_slave_status()
1967 slave->dev_num); in sdw_handle_slave_status()
1969 complete_all(&slave->initialization_complete); in sdw_handle_slave_status()
1981 pm_request_resume(&slave->dev); in sdw_handle_slave_status()
1991 struct sdw_slave *slave; in sdw_clear_slave_status() local
2003 slave = sdw_get_slave(bus, i); in sdw_clear_slave_status()
2004 if (!slave) in sdw_clear_slave_status()
2007 if (slave->status != SDW_SLAVE_UNATTACHED) { in sdw_clear_slave_status()
2008 sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED); in sdw_clear_slave_status()
2009 slave->first_interrupt_done = false; in sdw_clear_slave_status()
2010 sdw_update_slave_status(slave, SDW_SLAVE_UNATTACHED); in sdw_clear_slave_status()
2014 slave->unattach_request = request; in sdw_clear_slave_status()