@@ -196,9 +196,67 @@ static const struct pmc_bit_map cnp_pfear_map[] = {
196
196
{}
197
197
};
198
198
199
+ static const struct pmc_bit_map cnp_slps0_dbg0_map [] = {
200
+ {"AUDIO_D3" , BIT (0 )},
201
+ {"OTG_D3" , BIT (1 )},
202
+ {"XHCI_D3" , BIT (2 )},
203
+ {"LPIO_D3" , BIT (3 )},
204
+ {"SDX_D3" , BIT (4 )},
205
+ {"SATA_D3" , BIT (5 )},
206
+ {"UFS0_D3" , BIT (6 )},
207
+ {"UFS1_D3" , BIT (7 )},
208
+ {"EMMC_D3" , BIT (8 )},
209
+ {}
210
+ };
211
+
212
+ static const struct pmc_bit_map cnp_slps0_dbg1_map [] = {
213
+ {"SDIO_PLL_OFF" , BIT (0 )},
214
+ {"USB2_PLL_OFF" , BIT (1 )},
215
+ {"AUDIO_PLL_OFF" , BIT (2 )},
216
+ {"OC_PLL_OFF" , BIT (3 )},
217
+ {"MAIN_PLL_OFF" , BIT (4 )},
218
+ {"XOSC_OFF" , BIT (5 )},
219
+ {"LPC_CLKS_GATED" , BIT (6 )},
220
+ {"PCIE_CLKREQS_IDLE" , BIT (7 )},
221
+ {"AUDIO_ROSC_OFF" , BIT (8 )},
222
+ {"HPET_XOSC_CLK_REQ" , BIT (9 )},
223
+ {"PMC_ROSC_SLOW_CLK" , BIT (10 )},
224
+ {"AON2_ROSC_GATED" , BIT (11 )},
225
+ {"CLKACKS_DEASSERTED" , BIT (12 )},
226
+ {}
227
+ };
228
+
229
+ static const struct pmc_bit_map cnp_slps0_dbg2_map [] = {
230
+ {"MPHY_CORE_GATED" , BIT (0 )},
231
+ {"CSME_GATED" , BIT (1 )},
232
+ {"USB2_SUS_GATED" , BIT (2 )},
233
+ {"DYN_FLEX_IO_IDLE" , BIT (3 )},
234
+ {"GBE_NO_LINK" , BIT (4 )},
235
+ {"THERM_SEN_DISABLED" , BIT (5 )},
236
+ {"PCIE_LOW_POWER" , BIT (6 )},
237
+ {"ISH_VNNAON_REQ_ACT" , BIT (7 )},
238
+ {"ISH_VNN_REQ_ACT" , BIT (8 )},
239
+ {"CNV_VNNAON_REQ_ACT" , BIT (9 )},
240
+ {"CNV_VNN_REQ_ACT" , BIT (10 )},
241
+ {"NPK_VNNON_REQ_ACT" , BIT (11 )},
242
+ {"PMSYNC_STATE_IDLE" , BIT (12 )},
243
+ {"ALST_GT_THRES" , BIT (13 )},
244
+ {"PMC_ARC_PG_READY" , BIT (14 )},
245
+ {}
246
+ };
247
+
248
+ static const struct pmc_bit_map * cnp_slps0_dbg_maps [] = {
249
+ cnp_slps0_dbg0_map ,
250
+ cnp_slps0_dbg1_map ,
251
+ cnp_slps0_dbg2_map ,
252
+ NULL ,
253
+ };
254
+
199
255
static const struct pmc_reg_map cnp_reg_map = {
200
256
.pfear_sts = cnp_pfear_map ,
201
257
.slp_s0_offset = CNP_PMC_SLP_S0_RES_COUNTER_OFFSET ,
258
+ .slps0_dbg_maps = cnp_slps0_dbg_maps ,
259
+ .slps0_dbg_offset = CNP_PMC_SLPS0_DBG_OFFSET ,
202
260
.ltr_ignore_offset = CNP_PMC_LTR_IGNORE_OFFSET ,
203
261
.regmap_length = CNP_PMC_MMIO_REG_LEN ,
204
262
.ppfear0_offset = CNP_PMC_HOST_PPFEAR0A ,
@@ -252,6 +310,8 @@ static int pmc_core_check_read_lock_bit(void)
252
310
}
253
311
254
312
#if IS_ENABLED (CONFIG_DEBUG_FS )
313
+ static bool slps0_dbg_latch ;
314
+
255
315
static void pmc_core_display_map (struct seq_file * s , int index ,
256
316
u8 pf_reg , const struct pmc_bit_map * pf_map )
257
317
{
@@ -481,6 +541,57 @@ static const struct file_operations pmc_core_ltr_ignore_ops = {
481
541
.release = single_release ,
482
542
};
483
543
544
+ static void pmc_core_slps0_dbg_latch (struct pmc_dev * pmcdev , bool reset )
545
+ {
546
+ const struct pmc_reg_map * map = pmcdev -> map ;
547
+ u32 fd ;
548
+
549
+ mutex_lock (& pmcdev -> lock );
550
+
551
+ if (!reset && !slps0_dbg_latch )
552
+ goto out_unlock ;
553
+
554
+ fd = pmc_core_reg_read (pmcdev , map -> slps0_dbg_offset );
555
+ if (reset )
556
+ fd &= ~CNP_PMC_LATCH_SLPS0_EVENTS ;
557
+ else
558
+ fd |= CNP_PMC_LATCH_SLPS0_EVENTS ;
559
+ pmc_core_reg_write (pmcdev , map -> slps0_dbg_offset , fd );
560
+
561
+ slps0_dbg_latch = 0 ;
562
+
563
+ out_unlock :
564
+ mutex_unlock (& pmcdev -> lock );
565
+ }
566
+
567
+ static int pmc_core_slps0_dbg_show (struct seq_file * s , void * unused )
568
+ {
569
+ struct pmc_dev * pmcdev = s -> private ;
570
+ const struct pmc_bit_map * * maps = pmcdev -> map -> slps0_dbg_maps ;
571
+ const struct pmc_bit_map * map ;
572
+ int offset ;
573
+ u32 data ;
574
+
575
+ pmc_core_slps0_dbg_latch (pmcdev , false);
576
+ offset = pmcdev -> map -> slps0_dbg_offset ;
577
+ while (* maps ) {
578
+ map = * maps ;
579
+ data = pmc_core_reg_read (pmcdev , offset );
580
+ offset += 4 ;
581
+ while (map -> name ) {
582
+ seq_printf (s , "SLP_S0_DBG: %-32s\tState: %s\n" ,
583
+ map -> name ,
584
+ data & map -> bit_mask ?
585
+ "Yes" : "No" );
586
+ ++ map ;
587
+ }
588
+ ++ maps ;
589
+ }
590
+ pmc_core_slps0_dbg_latch (pmcdev , true);
591
+ return 0 ;
592
+ }
593
+ DEFINE_SHOW_ATTRIBUTE (pmc_core_slps0_dbg );
594
+
484
595
static void pmc_core_dbgfs_unregister (struct pmc_dev * pmcdev )
485
596
{
486
597
debugfs_remove_recursive (pmcdev -> dbgfs_dir );
@@ -514,6 +625,15 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)
514
625
0444 , dir , pmcdev ,
515
626
& pmc_core_mphy_pg_ops );
516
627
628
+ if (pmcdev -> map -> slps0_dbg_maps ) {
629
+ debugfs_create_file ("slp_s0_debug_status" , 0444 ,
630
+ dir , pmcdev ,
631
+ & pmc_core_slps0_dbg_fops );
632
+
633
+ debugfs_create_bool ("slp_s0_dbg_latch" , 0644 ,
634
+ dir , & slps0_dbg_latch );
635
+ }
636
+
517
637
return 0 ;
518
638
}
519
639
#else
0 commit comments