Lines Matching full:master

12 #include <linux/i3c/master.h>
422 to_cdns_i3c_master(struct i3c_master_controller *master) in to_cdns_i3c_master() argument
424 return container_of(master, struct cdns_i3c_master, base); in to_cdns_i3c_master()
427 static void cdns_i3c_master_wr_to_tx_fifo(struct cdns_i3c_master *master, in cdns_i3c_master_wr_to_tx_fifo() argument
430 writesl(master->regs + TX_FIFO, bytes, nbytes / 4); in cdns_i3c_master_wr_to_tx_fifo()
435 writesl(master->regs + TX_FIFO, &tmp, 1); in cdns_i3c_master_wr_to_tx_fifo()
439 static void cdns_i3c_master_rd_from_rx_fifo(struct cdns_i3c_master *master, in cdns_i3c_master_rd_from_rx_fifo() argument
442 readsl(master->regs + RX_FIFO, bytes, nbytes / 4); in cdns_i3c_master_rd_from_rx_fifo()
446 readsl(master->regs + RX_FIFO, &tmp, 1); in cdns_i3c_master_rd_from_rx_fifo()
492 static int cdns_i3c_master_disable(struct cdns_i3c_master *master) in cdns_i3c_master_disable() argument
496 writel(readl(master->regs + CTRL) & ~CTRL_DEV_EN, master->regs + CTRL); in cdns_i3c_master_disable()
498 return readl_poll_timeout(master->regs + MST_STATUS0, status, in cdns_i3c_master_disable()
502 static void cdns_i3c_master_enable(struct cdns_i3c_master *master) in cdns_i3c_master_enable() argument
504 writel(readl(master->regs + CTRL) | CTRL_DEV_EN, master->regs + CTRL); in cdns_i3c_master_enable()
508 cdns_i3c_master_alloc_xfer(struct cdns_i3c_master *master, unsigned int ncmds) in cdns_i3c_master_alloc_xfer() argument
528 static void cdns_i3c_master_start_xfer_locked(struct cdns_i3c_master *master) in cdns_i3c_master_start_xfer_locked() argument
530 struct cdns_i3c_xfer *xfer = master->xferqueue.cur; in cdns_i3c_master_start_xfer_locked()
536 writel(MST_INT_CMDD_EMP, master->regs + MST_ICR); in cdns_i3c_master_start_xfer_locked()
540 cdns_i3c_master_wr_to_tx_fifo(master, cmd->tx_buf, in cdns_i3c_master_start_xfer_locked()
548 master->regs + CMD1_FIFO); in cdns_i3c_master_start_xfer_locked()
549 writel(cmd->cmd0, master->regs + CMD0_FIFO); in cdns_i3c_master_start_xfer_locked()
552 writel(readl(master->regs + CTRL) | CTRL_MCS, in cdns_i3c_master_start_xfer_locked()
553 master->regs + CTRL); in cdns_i3c_master_start_xfer_locked()
554 writel(MST_INT_CMDD_EMP, master->regs + MST_IER); in cdns_i3c_master_start_xfer_locked()
557 static void cdns_i3c_master_end_xfer_locked(struct cdns_i3c_master *master, in cdns_i3c_master_end_xfer_locked() argument
560 struct cdns_i3c_xfer *xfer = master->xferqueue.cur; in cdns_i3c_master_end_xfer_locked()
570 writel(MST_INT_CMDD_EMP, master->regs + MST_IDR); in cdns_i3c_master_end_xfer_locked()
572 for (status0 = readl(master->regs + MST_STATUS0); in cdns_i3c_master_end_xfer_locked()
574 status0 = readl(master->regs + MST_STATUS0)) { in cdns_i3c_master_end_xfer_locked()
578 cmdr = readl(master->regs + CMDR); in cdns_i3c_master_end_xfer_locked()
587 cdns_i3c_master_rd_from_rx_fifo(master, cmd->rx_buf, rx_len); in cdns_i3c_master_end_xfer_locked()
622 xfer = list_first_entry_or_null(&master->xferqueue.list, in cdns_i3c_master_end_xfer_locked()
627 master->xferqueue.cur = xfer; in cdns_i3c_master_end_xfer_locked()
628 cdns_i3c_master_start_xfer_locked(master); in cdns_i3c_master_end_xfer_locked()
631 static void cdns_i3c_master_queue_xfer(struct cdns_i3c_master *master, in cdns_i3c_master_queue_xfer() argument
637 spin_lock_irqsave(&master->xferqueue.lock, flags); in cdns_i3c_master_queue_xfer()
638 if (master->xferqueue.cur) { in cdns_i3c_master_queue_xfer()
639 list_add_tail(&xfer->node, &master->xferqueue.list); in cdns_i3c_master_queue_xfer()
641 master->xferqueue.cur = xfer; in cdns_i3c_master_queue_xfer()
642 cdns_i3c_master_start_xfer_locked(master); in cdns_i3c_master_queue_xfer()
644 spin_unlock_irqrestore(&master->xferqueue.lock, flags); in cdns_i3c_master_queue_xfer()
647 static void cdns_i3c_master_unqueue_xfer(struct cdns_i3c_master *master, in cdns_i3c_master_unqueue_xfer() argument
652 spin_lock_irqsave(&master->xferqueue.lock, flags); in cdns_i3c_master_unqueue_xfer()
653 if (master->xferqueue.cur == xfer) { in cdns_i3c_master_unqueue_xfer()
656 writel(readl(master->regs + CTRL) & ~CTRL_DEV_EN, in cdns_i3c_master_unqueue_xfer()
657 master->regs + CTRL); in cdns_i3c_master_unqueue_xfer()
658 readl_poll_timeout_atomic(master->regs + MST_STATUS0, status, in cdns_i3c_master_unqueue_xfer()
661 master->xferqueue.cur = NULL; in cdns_i3c_master_unqueue_xfer()
664 master->regs + FLUSH_CTRL); in cdns_i3c_master_unqueue_xfer()
665 writel(MST_INT_CMDD_EMP, master->regs + MST_IDR); in cdns_i3c_master_unqueue_xfer()
666 writel(readl(master->regs + CTRL) | CTRL_DEV_EN, in cdns_i3c_master_unqueue_xfer()
667 master->regs + CTRL); in cdns_i3c_master_unqueue_xfer()
671 spin_unlock_irqrestore(&master->xferqueue.lock, flags); in cdns_i3c_master_unqueue_xfer()
697 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_send_ccc_cmd() local
702 xfer = cdns_i3c_master_alloc_xfer(master, 1); in cdns_i3c_master_send_ccc_cmd()
723 cdns_i3c_master_queue_xfer(master, xfer); in cdns_i3c_master_send_ccc_cmd()
725 cdns_i3c_master_unqueue_xfer(master, xfer); in cdns_i3c_master_send_ccc_cmd()
739 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_priv_xfers() local
751 if (nxfers > master->caps.cmdfifodepth || in cdns_i3c_master_priv_xfers()
752 nxfers > master->caps.cmdrfifodepth) in cdns_i3c_master_priv_xfers()
766 if (rxslots > master->caps.rxfifodepth || in cdns_i3c_master_priv_xfers()
767 txslots > master->caps.txfifodepth) in cdns_i3c_master_priv_xfers()
770 cdns_xfer = cdns_i3c_master_alloc_xfer(master, nxfers); in cdns_i3c_master_priv_xfers()
800 cdns_i3c_master_queue_xfer(master, cdns_xfer); in cdns_i3c_master_priv_xfers()
803 cdns_i3c_master_unqueue_xfer(master, cdns_xfer); in cdns_i3c_master_priv_xfers()
819 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_i2c_xfers() local
824 if (nxfers > master->caps.cmdfifodepth) in cdns_i3c_master_i2c_xfers()
837 if (ntxwords > master->caps.txfifodepth || in cdns_i3c_master_i2c_xfers()
838 nrxwords > master->caps.rxfifodepth) in cdns_i3c_master_i2c_xfers()
841 xfer = cdns_i3c_master_alloc_xfer(master, nxfers); in cdns_i3c_master_i2c_xfers()
865 cdns_i3c_master_queue_xfer(master, xfer); in cdns_i3c_master_i2c_xfers()
867 cdns_i3c_master_unqueue_xfer(master, xfer); in cdns_i3c_master_i2c_xfers()
901 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_upd_i3c_addr() local
908 writel(DEV_ID_RR0_IS_I3C | rr, master->regs + DEV_ID_RR0(data->id)); in cdns_i3c_master_upd_i3c_addr()
911 static int cdns_i3c_master_get_rr_slot(struct cdns_i3c_master *master, in cdns_i3c_master_get_rr_slot() argument
919 if (!master->free_rr_slots) in cdns_i3c_master_get_rr_slot()
922 return ffs(master->free_rr_slots) - 1; in cdns_i3c_master_get_rr_slot()
925 activedevs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK; in cdns_i3c_master_get_rr_slot()
928 for_each_set_bit(i, &activedevs, master->maxdevs + 1) { in cdns_i3c_master_get_rr_slot()
929 rr = readl(master->regs + DEV_ID_RR0(i)); in cdns_i3c_master_get_rr_slot()
951 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_attach_i3c_dev() local
959 slot = cdns_i3c_master_get_rr_slot(master, dev->info.dyn_addr); in cdns_i3c_master_attach_i3c_dev()
968 master->free_rr_slots &= ~BIT(slot); in cdns_i3c_master_attach_i3c_dev()
972 writel(readl(master->regs + DEVS_CTRL) | in cdns_i3c_master_attach_i3c_dev()
974 master->regs + DEVS_CTRL); in cdns_i3c_master_attach_i3c_dev()
983 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_detach_i3c_dev() local
986 writel(readl(master->regs + DEVS_CTRL) | in cdns_i3c_master_detach_i3c_dev()
988 master->regs + DEVS_CTRL); in cdns_i3c_master_detach_i3c_dev()
991 master->free_rr_slots |= BIT(data->id); in cdns_i3c_master_detach_i3c_dev()
998 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_attach_i2c_dev() local
1002 slot = cdns_i3c_master_get_rr_slot(master, 0); in cdns_i3c_master_attach_i2c_dev()
1011 master->free_rr_slots &= ~BIT(slot); in cdns_i3c_master_attach_i2c_dev()
1015 master->regs + DEV_ID_RR0(data->id)); in cdns_i3c_master_attach_i2c_dev()
1016 writel(dev->lvr, master->regs + DEV_ID_RR2(data->id)); in cdns_i3c_master_attach_i2c_dev()
1017 writel(readl(master->regs + DEVS_CTRL) | in cdns_i3c_master_attach_i2c_dev()
1019 master->regs + DEVS_CTRL); in cdns_i3c_master_attach_i2c_dev()
1027 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_detach_i2c_dev() local
1030 writel(readl(master->regs + DEVS_CTRL) | in cdns_i3c_master_detach_i2c_dev()
1032 master->regs + DEVS_CTRL); in cdns_i3c_master_detach_i2c_dev()
1033 master->free_rr_slots |= BIT(data->id); in cdns_i3c_master_detach_i2c_dev()
1041 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_bus_cleanup() local
1043 cdns_i3c_master_disable(master); in cdns_i3c_master_bus_cleanup()
1046 static void cdns_i3c_master_dev_rr_to_info(struct cdns_i3c_master *master, in cdns_i3c_master_dev_rr_to_info() argument
1053 rr = readl(master->regs + DEV_ID_RR0(slot)); in cdns_i3c_master_dev_rr_to_info()
1055 rr = readl(master->regs + DEV_ID_RR2(slot)); in cdns_i3c_master_dev_rr_to_info()
1059 info->pid |= (u64)readl(master->regs + DEV_ID_RR1(slot)) << 16; in cdns_i3c_master_dev_rr_to_info()
1062 static void cdns_i3c_master_upd_i3c_scl_lim(struct cdns_i3c_master *master) in cdns_i3c_master_upd_i3c_scl_lim() argument
1064 struct i3c_master_controller *m = &master->base; in cdns_i3c_master_upd_i3c_scl_lim()
1101 if (new_i3c_scl_lim == master->i3c_scl_lim) in cdns_i3c_master_upd_i3c_scl_lim()
1103 master->i3c_scl_lim = new_i3c_scl_lim; in cdns_i3c_master_upd_i3c_scl_lim()
1109 prescl1 = readl(master->regs + PRESCL_CTRL1) & in cdns_i3c_master_upd_i3c_scl_lim()
1111 ctrl = readl(master->regs + CTRL); in cdns_i3c_master_upd_i3c_scl_lim()
1113 i3c_lim_period = DIV_ROUND_UP(1000000000, master->i3c_scl_lim); in cdns_i3c_master_upd_i3c_scl_lim()
1122 /* Disable I3C master before updating PRESCL_CTRL1. */ in cdns_i3c_master_upd_i3c_scl_lim()
1124 cdns_i3c_master_disable(master); in cdns_i3c_master_upd_i3c_scl_lim()
1126 writel(prescl1, master->regs + PRESCL_CTRL1); in cdns_i3c_master_upd_i3c_scl_lim()
1129 cdns_i3c_master_enable(master); in cdns_i3c_master_upd_i3c_scl_lim()
1134 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_do_daa() local
1140 olddevs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK; in cdns_i3c_master_do_daa()
1144 for_each_clear_bit(slot, &olddevs, master->maxdevs + 1) { in cdns_i3c_master_do_daa()
1152 master->regs + DEV_ID_RR0(slot)); in cdns_i3c_master_do_daa()
1153 writel(0, master->regs + DEV_ID_RR1(slot)); in cdns_i3c_master_do_daa()
1154 writel(0, master->regs + DEV_ID_RR2(slot)); in cdns_i3c_master_do_daa()
1157 ret = i3c_master_entdaa_locked(&master->base); in cdns_i3c_master_do_daa()
1161 newdevs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK; in cdns_i3c_master_do_daa()
1168 for_each_set_bit(slot, &newdevs, master->maxdevs + 1) in cdns_i3c_master_do_daa()
1177 writel(readl(master->regs + DEVS_CTRL) | in cdns_i3c_master_do_daa()
1178 master->free_rr_slots << DEVS_CTRL_DEV_CLR_SHIFT, in cdns_i3c_master_do_daa()
1179 master->regs + DEVS_CTRL); in cdns_i3c_master_do_daa()
1181 i3c_master_defslvs_locked(&master->base); in cdns_i3c_master_do_daa()
1183 cdns_i3c_master_upd_i3c_scl_lim(master); in cdns_i3c_master_do_daa()
1192 static u8 cdns_i3c_master_calculate_thd_delay(struct cdns_i3c_master *master) in cdns_i3c_master_calculate_thd_delay() argument
1194 unsigned long sysclk_rate = clk_get_rate(master->sysclk); in cdns_i3c_master_calculate_thd_delay()
1195 u8 thd_delay = DIV_ROUND_UP(master->devdata->thd_delay_ns, in cdns_i3c_master_calculate_thd_delay()
1208 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_bus_init() local
1232 sysclk_rate = clk_get_rate(master->sysclk); in cdns_i3c_master_bus_init()
1256 writel(prescl0, master->regs + PRESCL_CTRL0); in cdns_i3c_master_bus_init()
1264 writel(prescl1, master->regs + PRESCL_CTRL1); in cdns_i3c_master_bus_init()
1266 /* Get an address for the master. */ in cdns_i3c_master_bus_init()
1272 master->regs + DEV_ID_RR0(0)); in cdns_i3c_master_bus_init()
1274 cdns_i3c_master_dev_rr_to_info(master, 0, &info); in cdns_i3c_master_bus_init()
1278 ret = i3c_master_set_info(&master->base, &info); in cdns_i3c_master_bus_init()
1294 * master output. This setting allows to meet this timing on master's in cdns_i3c_master_bus_init()
1297 ctrl |= CTRL_THD_DELAY(cdns_i3c_master_calculate_thd_delay(master)); in cdns_i3c_master_bus_init()
1298 writel(ctrl, master->regs + CTRL); in cdns_i3c_master_bus_init()
1300 cdns_i3c_master_enable(master); in cdns_i3c_master_bus_init()
1305 static void cdns_i3c_master_handle_ibi(struct cdns_i3c_master *master, in cdns_i3c_master_handle_ibi() argument
1320 if (id >= master->ibi.num_slots || (ibir & IBIR_ERROR)) in cdns_i3c_master_handle_ibi()
1323 dev = master->ibi.slots[id]; in cdns_i3c_master_handle_ibi()
1324 spin_lock(&master->ibi.lock); in cdns_i3c_master_handle_ibi()
1334 readsl(master->regs + IBI_DATA_FIFO, buf, nbytes / 4); in cdns_i3c_master_handle_ibi()
1336 u32 tmp = __raw_readl(master->regs + IBI_DATA_FIFO); in cdns_i3c_master_handle_ibi()
1347 spin_unlock(&master->ibi.lock); in cdns_i3c_master_handle_ibi()
1355 readl(master->regs + IBI_DATA_FIFO); in cdns_i3c_master_handle_ibi()
1359 static void cnds_i3c_master_demux_ibis(struct cdns_i3c_master *master) in cnds_i3c_master_demux_ibis() argument
1363 writel(MST_INT_IBIR_THR, master->regs + MST_ICR); in cnds_i3c_master_demux_ibis()
1365 for (status0 = readl(master->regs + MST_STATUS0); in cnds_i3c_master_demux_ibis()
1367 status0 = readl(master->regs + MST_STATUS0)) { in cnds_i3c_master_demux_ibis()
1368 u32 ibir = readl(master->regs + IBIR); in cnds_i3c_master_demux_ibis()
1372 cdns_i3c_master_handle_ibi(master, ibir); in cnds_i3c_master_demux_ibis()
1377 queue_work(master->base.wq, &master->hj_work); in cnds_i3c_master_demux_ibis()
1392 struct cdns_i3c_master *master = data; in cdns_i3c_master_interrupt() local
1395 status = readl(master->regs + MST_ISR); in cdns_i3c_master_interrupt()
1396 if (!(status & readl(master->regs + MST_IMR))) in cdns_i3c_master_interrupt()
1399 spin_lock(&master->xferqueue.lock); in cdns_i3c_master_interrupt()
1400 cdns_i3c_master_end_xfer_locked(master, status); in cdns_i3c_master_interrupt()
1401 spin_unlock(&master->xferqueue.lock); in cdns_i3c_master_interrupt()
1404 cnds_i3c_master_demux_ibis(master); in cdns_i3c_master_interrupt()
1412 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_disable_ibi() local
1423 spin_lock_irqsave(&master->ibi.lock, flags); in cdns_i3c_master_disable_ibi()
1424 sirmap = readl(master->regs + SIR_MAP_DEV_REG(data->ibi)); in cdns_i3c_master_disable_ibi()
1428 writel(sirmap, master->regs + SIR_MAP_DEV_REG(data->ibi)); in cdns_i3c_master_disable_ibi()
1429 spin_unlock_irqrestore(&master->ibi.lock, flags); in cdns_i3c_master_disable_ibi()
1437 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_enable_ibi() local
1443 spin_lock_irqsave(&master->ibi.lock, flags); in cdns_i3c_master_enable_ibi()
1444 sirmap = readl(master->regs + SIR_MAP_DEV_REG(data->ibi)); in cdns_i3c_master_enable_ibi()
1455 writel(sirmap, master->regs + SIR_MAP_DEV_REG(data->ibi)); in cdns_i3c_master_enable_ibi()
1456 spin_unlock_irqrestore(&master->ibi.lock, flags); in cdns_i3c_master_enable_ibi()
1461 spin_lock_irqsave(&master->ibi.lock, flags); in cdns_i3c_master_enable_ibi()
1462 sirmap = readl(master->regs + SIR_MAP_DEV_REG(data->ibi)); in cdns_i3c_master_enable_ibi()
1466 writel(sirmap, master->regs + SIR_MAP_DEV_REG(data->ibi)); in cdns_i3c_master_enable_ibi()
1467 spin_unlock_irqrestore(&master->ibi.lock, flags); in cdns_i3c_master_enable_ibi()
1477 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_request_ibi() local
1486 spin_lock_irqsave(&master->ibi.lock, flags); in cdns_i3c_master_request_ibi()
1487 for (i = 0; i < master->ibi.num_slots; i++) { in cdns_i3c_master_request_ibi()
1488 if (!master->ibi.slots[i]) { in cdns_i3c_master_request_ibi()
1490 master->ibi.slots[i] = dev; in cdns_i3c_master_request_ibi()
1494 spin_unlock_irqrestore(&master->ibi.lock, flags); in cdns_i3c_master_request_ibi()
1496 if (i < master->ibi.num_slots) in cdns_i3c_master_request_ibi()
1508 struct cdns_i3c_master *master = to_cdns_i3c_master(m); in cdns_i3c_master_free_ibi() local
1512 spin_lock_irqsave(&master->ibi.lock, flags); in cdns_i3c_master_free_ibi()
1513 master->ibi.slots[data->ibi] = NULL; in cdns_i3c_master_free_ibi()
1515 spin_unlock_irqrestore(&master->ibi.lock, flags); in cdns_i3c_master_free_ibi()
1550 struct cdns_i3c_master *master = container_of(work, in cdns_i3c_master_hj() local
1554 i3c_master_do_daa(&master->base); in cdns_i3c_master_hj()
1562 { .compatible = "cdns,i3c-master", .data = &cdns_i3c_devdata },
1569 struct cdns_i3c_master *master; in cdns_i3c_master_probe() local
1573 master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL); in cdns_i3c_master_probe()
1574 if (!master) in cdns_i3c_master_probe()
1577 master->devdata = of_device_get_match_data(&pdev->dev); in cdns_i3c_master_probe()
1578 if (!master->devdata) in cdns_i3c_master_probe()
1581 master->regs = devm_platform_ioremap_resource(pdev, 0); in cdns_i3c_master_probe()
1582 if (IS_ERR(master->regs)) in cdns_i3c_master_probe()
1583 return PTR_ERR(master->regs); in cdns_i3c_master_probe()
1585 master->pclk = devm_clk_get(&pdev->dev, "pclk"); in cdns_i3c_master_probe()
1586 if (IS_ERR(master->pclk)) in cdns_i3c_master_probe()
1587 return PTR_ERR(master->pclk); in cdns_i3c_master_probe()
1589 master->sysclk = devm_clk_get(&pdev->dev, "sysclk"); in cdns_i3c_master_probe()
1590 if (IS_ERR(master->sysclk)) in cdns_i3c_master_probe()
1591 return PTR_ERR(master->sysclk); in cdns_i3c_master_probe()
1597 ret = clk_prepare_enable(master->pclk); in cdns_i3c_master_probe()
1601 ret = clk_prepare_enable(master->sysclk); in cdns_i3c_master_probe()
1605 if (readl(master->regs + DEV_ID) != DEV_ID_I3C_MASTER) { in cdns_i3c_master_probe()
1610 spin_lock_init(&master->xferqueue.lock); in cdns_i3c_master_probe()
1611 INIT_LIST_HEAD(&master->xferqueue.list); in cdns_i3c_master_probe()
1613 INIT_WORK(&master->hj_work, cdns_i3c_master_hj); in cdns_i3c_master_probe()
1614 writel(0xffffffff, master->regs + MST_IDR); in cdns_i3c_master_probe()
1615 writel(0xffffffff, master->regs + SLV_IDR); in cdns_i3c_master_probe()
1617 dev_name(&pdev->dev), master); in cdns_i3c_master_probe()
1621 platform_set_drvdata(pdev, master); in cdns_i3c_master_probe()
1623 val = readl(master->regs + CONF_STATUS0); in cdns_i3c_master_probe()
1625 /* Device ID0 is reserved to describe this master. */ in cdns_i3c_master_probe()
1626 master->maxdevs = CONF_STATUS0_DEVS_NUM(val); in cdns_i3c_master_probe()
1627 master->free_rr_slots = GENMASK(master->maxdevs, 1); in cdns_i3c_master_probe()
1628 master->caps.ibirfifodepth = CONF_STATUS0_IBIR_DEPTH(val); in cdns_i3c_master_probe()
1629 master->caps.cmdrfifodepth = CONF_STATUS0_CMDR_DEPTH(val); in cdns_i3c_master_probe()
1631 val = readl(master->regs + CONF_STATUS1); in cdns_i3c_master_probe()
1632 master->caps.cmdfifodepth = CONF_STATUS1_CMD_DEPTH(val); in cdns_i3c_master_probe()
1633 master->caps.rxfifodepth = CONF_STATUS1_RX_DEPTH(val); in cdns_i3c_master_probe()
1634 master->caps.txfifodepth = CONF_STATUS1_TX_DEPTH(val); in cdns_i3c_master_probe()
1636 spin_lock_init(&master->ibi.lock); in cdns_i3c_master_probe()
1637 master->ibi.num_slots = CONF_STATUS1_IBI_HW_RES(val); in cdns_i3c_master_probe()
1638 master->ibi.slots = devm_kcalloc(&pdev->dev, master->ibi.num_slots, in cdns_i3c_master_probe()
1639 sizeof(*master->ibi.slots), in cdns_i3c_master_probe()
1641 if (!master->ibi.slots) { in cdns_i3c_master_probe()
1646 writel(IBIR_THR(1), master->regs + CMD_IBI_THR_CTRL); in cdns_i3c_master_probe()
1647 writel(MST_INT_IBIR_THR, master->regs + MST_IER); in cdns_i3c_master_probe()
1648 writel(DEVS_CTRL_DEV_CLR_ALL, master->regs + DEVS_CTRL); in cdns_i3c_master_probe()
1650 ret = i3c_master_register(&master->base, &pdev->dev, in cdns_i3c_master_probe()
1658 clk_disable_unprepare(master->sysclk); in cdns_i3c_master_probe()
1661 clk_disable_unprepare(master->pclk); in cdns_i3c_master_probe()
1668 struct cdns_i3c_master *master = platform_get_drvdata(pdev); in cdns_i3c_master_remove() local
1670 cancel_work_sync(&master->hj_work); in cdns_i3c_master_remove()
1671 i3c_master_unregister(&master->base); in cdns_i3c_master_remove()
1673 clk_disable_unprepare(master->sysclk); in cdns_i3c_master_remove()
1674 clk_disable_unprepare(master->pclk); in cdns_i3c_master_remove()
1681 .name = "cdns-i3c-master",
1688 MODULE_DESCRIPTION("Cadence I3C master driver");
1690 MODULE_ALIAS("platform:cdns-i3c-master");