@@ -300,7 +300,14 @@ static void dw_i3c_master_disable(struct dw_i3c_master *master)
300
300
301
301
static void dw_i3c_master_enable (struct dw_i3c_master * master )
302
302
{
303
- writel (readl (master -> regs + DEVICE_CTRL ) | DEV_CTRL_ENABLE ,
303
+ u32 dev_ctrl ;
304
+
305
+ dev_ctrl = readl (master -> regs + DEVICE_CTRL );
306
+ /* For now don't support Hot-Join */
307
+ dev_ctrl |= DEV_CTRL_HOT_JOIN_NACK ;
308
+ if (master -> i2c_slv_prsnt )
309
+ dev_ctrl |= DEV_CTRL_I2C_SLAVE_PRESENT ;
310
+ writel (dev_ctrl | DEV_CTRL_ENABLE ,
304
311
master -> regs + DEVICE_CTRL );
305
312
}
306
313
@@ -521,6 +528,32 @@ static void dw_i3c_master_end_xfer_locked(struct dw_i3c_master *master, u32 isr)
521
528
dw_i3c_master_start_xfer_locked (master );
522
529
}
523
530
531
+ static void dw_i3c_master_set_intr_regs (struct dw_i3c_master * master )
532
+ {
533
+ u32 thld_ctrl ;
534
+
535
+ thld_ctrl = readl (master -> regs + QUEUE_THLD_CTRL );
536
+ thld_ctrl &= ~(QUEUE_THLD_CTRL_RESP_BUF_MASK |
537
+ QUEUE_THLD_CTRL_IBI_STAT_MASK |
538
+ QUEUE_THLD_CTRL_IBI_DATA_MASK );
539
+ thld_ctrl |= QUEUE_THLD_CTRL_IBI_STAT (1 ) |
540
+ QUEUE_THLD_CTRL_IBI_DATA (31 );
541
+ writel (thld_ctrl , master -> regs + QUEUE_THLD_CTRL );
542
+
543
+ thld_ctrl = readl (master -> regs + DATA_BUFFER_THLD_CTRL );
544
+ thld_ctrl &= ~DATA_BUFFER_THLD_CTRL_RX_BUF ;
545
+ writel (thld_ctrl , master -> regs + DATA_BUFFER_THLD_CTRL );
546
+
547
+ writel (INTR_ALL , master -> regs + INTR_STATUS );
548
+ writel (INTR_MASTER_MASK , master -> regs + INTR_STATUS_EN );
549
+ writel (INTR_MASTER_MASK , master -> regs + INTR_SIGNAL_EN );
550
+
551
+ master -> sir_rej_mask = IBI_REQ_REJECT_ALL ;
552
+ writel (master -> sir_rej_mask , master -> regs + IBI_SIR_REQ_REJECT );
553
+
554
+ writel (IBI_REQ_REJECT_ALL , master -> regs + IBI_MR_REQ_REJECT );
555
+ }
556
+
524
557
static int dw_i3c_clk_cfg (struct dw_i3c_master * master )
525
558
{
526
559
unsigned long core_rate , core_period ;
@@ -615,7 +648,6 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m)
615
648
struct dw_i3c_master * master = to_dw_i3c_master (m );
616
649
struct i3c_bus * bus = i3c_master_get_bus (m );
617
650
struct i3c_device_info info = { };
618
- u32 thld_ctrl ;
619
651
int ret ;
620
652
621
653
ret = master -> platform_ops -> init (master );
@@ -638,22 +670,6 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m)
638
670
return - EINVAL ;
639
671
}
640
672
641
- thld_ctrl = readl (master -> regs + QUEUE_THLD_CTRL );
642
- thld_ctrl &= ~(QUEUE_THLD_CTRL_RESP_BUF_MASK |
643
- QUEUE_THLD_CTRL_IBI_STAT_MASK |
644
- QUEUE_THLD_CTRL_IBI_DATA_MASK );
645
- thld_ctrl |= QUEUE_THLD_CTRL_IBI_STAT (1 ) |
646
- QUEUE_THLD_CTRL_IBI_DATA (31 );
647
- writel (thld_ctrl , master -> regs + QUEUE_THLD_CTRL );
648
-
649
- thld_ctrl = readl (master -> regs + DATA_BUFFER_THLD_CTRL );
650
- thld_ctrl &= ~DATA_BUFFER_THLD_CTRL_RX_BUF ;
651
- writel (thld_ctrl , master -> regs + DATA_BUFFER_THLD_CTRL );
652
-
653
- writel (INTR_ALL , master -> regs + INTR_STATUS );
654
- writel (INTR_MASTER_MASK , master -> regs + INTR_STATUS_EN );
655
- writel (INTR_MASTER_MASK , master -> regs + INTR_SIGNAL_EN );
656
-
657
673
ret = i3c_master_get_free_addr (m , 0 );
658
674
if (ret < 0 )
659
675
return ret ;
@@ -668,15 +684,7 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m)
668
684
if (ret )
669
685
return ret ;
670
686
671
- master -> sir_rej_mask = IBI_REQ_REJECT_ALL ;
672
- writel (master -> sir_rej_mask , master -> regs + IBI_SIR_REQ_REJECT );
673
-
674
- writel (IBI_REQ_REJECT_ALL , master -> regs + IBI_MR_REQ_REJECT );
675
-
676
- /* For now don't support Hot-Join */
677
- writel (readl (master -> regs + DEVICE_CTRL ) | DEV_CTRL_HOT_JOIN_NACK ,
678
- master -> regs + DEVICE_CTRL );
679
-
687
+ dw_i3c_master_set_intr_regs (master );
680
688
dw_i3c_master_enable (master );
681
689
682
690
return 0 ;
0 commit comments