Skip to content

Commit 4cf2afd

Browse files
debox1andy-shev
authored andcommitted
platform/x86: intel_pmc_core: Add CNP SLPS0 debug registers
Adds debugfs access to registers in the Cannon Point PCH PMC that are useful for debugging #SLP_S0 signal assertion and other low power relate activities. Device pm states are latched in these registers whenever the package enters C10 and can be read from slp_s0_debug_status. The pm states may also be latched by writing 1 to slp_s0_dbg_latch which will immediately capture the current state on the next read of slp_s0_debug_status. Signed-off-by: Box, David E <david.e.box@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
1 parent 7442178 commit 4cf2afd

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

drivers/platform/x86/intel_pmc_core.c

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,67 @@ static const struct pmc_bit_map cnp_pfear_map[] = {
196196
{}
197197
};
198198

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+
199255
static const struct pmc_reg_map cnp_reg_map = {
200256
.pfear_sts = cnp_pfear_map,
201257
.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,
202260
.ltr_ignore_offset = CNP_PMC_LTR_IGNORE_OFFSET,
203261
.regmap_length = CNP_PMC_MMIO_REG_LEN,
204262
.ppfear0_offset = CNP_PMC_HOST_PPFEAR0A,
@@ -252,6 +310,8 @@ static int pmc_core_check_read_lock_bit(void)
252310
}
253311

254312
#if IS_ENABLED(CONFIG_DEBUG_FS)
313+
static bool slps0_dbg_latch;
314+
255315
static void pmc_core_display_map(struct seq_file *s, int index,
256316
u8 pf_reg, const struct pmc_bit_map *pf_map)
257317
{
@@ -481,6 +541,57 @@ static const struct file_operations pmc_core_ltr_ignore_ops = {
481541
.release = single_release,
482542
};
483543

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+
484595
static void pmc_core_dbgfs_unregister(struct pmc_dev *pmcdev)
485596
{
486597
debugfs_remove_recursive(pmcdev->dbgfs_dir);
@@ -514,6 +625,15 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)
514625
0444, dir, pmcdev,
515626
&pmc_core_mphy_pg_ops);
516627

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+
517637
return 0;
518638
}
519639
#else

drivers/platform/x86/intel_pmc_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ enum ppfear_regs {
127127
#define CNP_PMC_SLP_S0_RES_COUNTER_OFFSET 0x193C
128128
#define CNP_PMC_LTR_IGNORE_OFFSET 0x1B0C
129129
#define CNP_PMC_PM_CFG_OFFSET 0x1818
130+
#define CNP_PMC_SLPS0_DBG_OFFSET 0x10B4
130131
/* Cannonlake: PGD PFET Enable Ack Status Register(s) start */
131132
#define CNP_PMC_HOST_PPFEAR0A 0x1D90
132133

133134
#define CNP_PMC_MMIO_REG_LEN 0x2000
134135
#define CNP_PPFEAR_NUM_ENTRIES 8
135136
#define CNP_PMC_READ_DISABLE_BIT 22
137+
#define CNP_PMC_LATCH_SLPS0_EVENTS BIT(31)
136138

137139
struct pmc_bit_map {
138140
const char *name;
@@ -145,6 +147,7 @@ struct pmc_bit_map {
145147
* @pfear_sts: Maps name of IP block to PPFEAR* bit
146148
* @mphy_sts: Maps name of MPHY lane to MPHY status lane status bit
147149
* @pll_sts: Maps name of PLL to corresponding bit status
150+
* @slps0_dbg_maps: Array of SLP_S0_DBG* registers containing debug info
148151
* @slp_s0_offset: PWRMBASE offset to read SLP_S0 residency
149152
* @ltr_ignore_offset: PWRMBASE offset to read/write LTR ignore bit
150153
* @regmap_length: Length of memory to map from PWRMBASE address to access
@@ -153,6 +156,7 @@ struct pmc_bit_map {
153156
* PPFEAR
154157
* @pm_cfg_offset: PWRMBASE offset to PM_CFG register
155158
* @pm_read_disable_bit: Bit index to read PMC_READ_DISABLE
159+
* @slps0_dbg_offset: PWRMBASE offset to SLP_S0_DEBUG_REG*
156160
*
157161
* Each PCH has unique set of register offsets and bit indexes. This structure
158162
* captures them to have a common implementation.
@@ -161,13 +165,15 @@ struct pmc_reg_map {
161165
const struct pmc_bit_map *pfear_sts;
162166
const struct pmc_bit_map *mphy_sts;
163167
const struct pmc_bit_map *pll_sts;
168+
const struct pmc_bit_map **slps0_dbg_maps;
164169
const u32 slp_s0_offset;
165170
const u32 ltr_ignore_offset;
166171
const int regmap_length;
167172
const u32 ppfear0_offset;
168173
const int ppfear_buckets;
169174
const u32 pm_cfg_offset;
170175
const int pm_read_disable_bit;
176+
const u32 slps0_dbg_offset;
171177
};
172178

173179
/**

0 commit comments

Comments
 (0)