Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/platform/intel/pmc_atom: Add Cherrytrail PMC interface

The patch adds CHT PMC interface. This exposes all the South IP
device power states and S0ix states for CHT. The bit map of
FUNC_DIS and D3_STS_0 registers for SoCs are consistent. The
D3_STS_1 and FUNC_DIS_2 registers, however, are not aligned.
This is fixed by splitting a common mapping on per register basis.

(Originally based on code from Kumar P Mahesh.)

Originally-from: Kumar P Mahesh <mahesh.kumar.p@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Aubrey Li <aubrey.li@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J . Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1436192944-56496-5-git-send-email-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Shevchenko and committed by
Ingo Molnar
2b8f8edd 940406d1

+114 -29
+25
arch/x86/include/asm/pmc_atom.h
··· 18 18 19 19 /* ValleyView Power Control Unit PCI Device ID */ 20 20 #define PCI_DEVICE_ID_VLV_PMC 0x0F1C 21 + /* CherryTrail Power Control Unit PCI Device ID */ 22 + #define PCI_DEVICE_ID_CHT_PMC 0x229C 21 23 22 24 /* PMC Memory mapped IO registers */ 23 25 #define PMC_BASE_ADDR_OFFSET 0x44 ··· 30 28 /* BIOS uses FUNC_DIS to disable specific function */ 31 29 #define PMC_FUNC_DIS 0x34 32 30 #define PMC_FUNC_DIS_2 0x38 31 + 32 + /* CHT specific bits in FUNC_DIS2 register */ 33 + #define BIT_FD_GMM BIT(3) 34 + #define BIT_FD_ISH BIT(4) 33 35 34 36 /* S0ix wake event control */ 35 37 #define PMC_S0IX_WAKE_EN 0x3C ··· 81 75 #define PMC_PSS_BIT_USB BIT(16) 82 76 #define PMC_PSS_BIT_USB_SUS BIT(17) 83 77 78 + /* CHT specific bits in PSS register */ 79 + #define PMC_PSS_BIT_CHT_UFS BIT(7) 80 + #define PMC_PSS_BIT_CHT_UXD BIT(11) 81 + #define PMC_PSS_BIT_CHT_UXD_FD BIT(12) 82 + #define PMC_PSS_BIT_CHT_UX_ENG BIT(15) 83 + #define PMC_PSS_BIT_CHT_USB_SUS BIT(16) 84 + #define PMC_PSS_BIT_CHT_GMM BIT(17) 85 + #define PMC_PSS_BIT_CHT_ISH BIT(18) 86 + #define PMC_PSS_BIT_CHT_DFX_MASTER BIT(26) 87 + #define PMC_PSS_BIT_CHT_DFX_CLUSTER1 BIT(27) 88 + #define PMC_PSS_BIT_CHT_DFX_CLUSTER2 BIT(28) 89 + #define PMC_PSS_BIT_CHT_DFX_CLUSTER3 BIT(29) 90 + #define PMC_PSS_BIT_CHT_DFX_CLUSTER4 BIT(30) 91 + #define PMC_PSS_BIT_CHT_DFX_CLUSTER5 BIT(31) 92 + 84 93 /* These registers reflect D3 status of functions */ 85 94 #define PMC_D3_STS_0 0xA0 86 95 ··· 137 116 #define BIT_OTG_SS_PHY BIT(1) 138 117 #define BIT_USH_SS_PHY BIT(2) 139 118 #define BIT_DFX BIT(3) 119 + 120 + /* CHT specific bits in PMC_D3_STS_1 register */ 121 + #define BIT_STS_GMM BIT(1) 122 + #define BIT_STS_ISH BIT(2) 140 123 141 124 /* PMC I/O Registers */ 142 125 #define ACPI_BASE_ADDR_OFFSET 0x40
+89 -29
arch/x86/kernel/pmc_atom.c
··· 31 31 }; 32 32 33 33 struct pmc_reg_map { 34 - const struct pmc_bit_map *dev; 34 + const struct pmc_bit_map *d3_sts_0; 35 + const struct pmc_bit_map *d3_sts_1; 36 + const struct pmc_bit_map *func_dis; 37 + const struct pmc_bit_map *func_dis_2; 35 38 const struct pmc_bit_map *pss; 36 39 }; 37 40 ··· 51 48 static struct pmc_dev pmc_device; 52 49 static u32 acpi_base_addr; 53 50 54 - static const struct pmc_bit_map dev_map[] = { 51 + static const struct pmc_bit_map d3_sts_0_map[] = { 55 52 {"LPSS1_F0_DMA", BIT_LPSS1_F0_DMA}, 56 53 {"LPSS1_F1_PWM1", BIT_LPSS1_F1_PWM1}, 57 54 {"LPSS1_F2_PWM2", BIT_LPSS1_F2_PWM2}, ··· 84 81 {"LPSS2_F5_I2C5", BIT_LPSS2_F5_I2C5}, 85 82 {"LPSS2_F6_I2C6", BIT_LPSS2_F6_I2C6}, 86 83 {"LPSS2_F7_I2C7", BIT_LPSS2_F7_I2C7}, 84 + {}, 85 + }; 86 + 87 + static struct pmc_bit_map byt_d3_sts_1_map[] = { 87 88 {"SMB", BIT_SMB}, 88 89 {"OTG_SS_PHY", BIT_OTG_SS_PHY}, 89 90 {"USH_SS_PHY", BIT_USH_SS_PHY}, ··· 95 88 {}, 96 89 }; 97 90 98 - static const struct pmc_bit_map pss_map[] = { 91 + static struct pmc_bit_map cht_d3_sts_1_map[] = { 92 + {"SMB", BIT_SMB}, 93 + {"GMM", BIT_STS_GMM}, 94 + {"ISH", BIT_STS_ISH}, 95 + {}, 96 + }; 97 + 98 + static struct pmc_bit_map cht_func_dis_2_map[] = { 99 + {"SMB", BIT_SMB}, 100 + {"GMM", BIT_FD_GMM}, 101 + {"ISH", BIT_FD_ISH}, 102 + {}, 103 + }; 104 + 105 + static const struct pmc_bit_map byt_pss_map[] = { 99 106 {"GBE", PMC_PSS_BIT_GBE}, 100 107 {"SATA", PMC_PSS_BIT_SATA}, 101 108 {"HDA", PMC_PSS_BIT_HDA}, ··· 131 110 {}, 132 111 }; 133 112 134 - static const struct pmc_reg_map reg_map = { 135 - .dev = dev_map, 136 - .pss = pss_map, 113 + static const struct pmc_bit_map cht_pss_map[] = { 114 + {"SATA", PMC_PSS_BIT_SATA}, 115 + {"HDA", PMC_PSS_BIT_HDA}, 116 + {"SEC", PMC_PSS_BIT_SEC}, 117 + {"PCIE", PMC_PSS_BIT_PCIE}, 118 + {"LPSS", PMC_PSS_BIT_LPSS}, 119 + {"LPE", PMC_PSS_BIT_LPE}, 120 + {"UFS", PMC_PSS_BIT_CHT_UFS}, 121 + {"UXD", PMC_PSS_BIT_CHT_UXD}, 122 + {"UXD_FD", PMC_PSS_BIT_CHT_UXD_FD}, 123 + {"UX_ENG", PMC_PSS_BIT_CHT_UX_ENG}, 124 + {"USB_SUS", PMC_PSS_BIT_CHT_USB_SUS}, 125 + {"GMM", PMC_PSS_BIT_CHT_GMM}, 126 + {"ISH", PMC_PSS_BIT_CHT_ISH}, 127 + {"DFX_MASTER", PMC_PSS_BIT_CHT_DFX_MASTER}, 128 + {"DFX_CLUSTER1", PMC_PSS_BIT_CHT_DFX_CLUSTER1}, 129 + {"DFX_CLUSTER2", PMC_PSS_BIT_CHT_DFX_CLUSTER2}, 130 + {"DFX_CLUSTER3", PMC_PSS_BIT_CHT_DFX_CLUSTER3}, 131 + {"DFX_CLUSTER4", PMC_PSS_BIT_CHT_DFX_CLUSTER4}, 132 + {"DFX_CLUSTER5", PMC_PSS_BIT_CHT_DFX_CLUSTER5}, 133 + {}, 134 + }; 135 + 136 + static const struct pmc_reg_map byt_reg_map = { 137 + .d3_sts_0 = d3_sts_0_map, 138 + .d3_sts_1 = byt_d3_sts_1_map, 139 + .func_dis = d3_sts_0_map, 140 + .func_dis_2 = byt_d3_sts_1_map, 141 + .pss = byt_pss_map, 142 + }; 143 + 144 + static const struct pmc_reg_map cht_reg_map = { 145 + .d3_sts_0 = d3_sts_0_map, 146 + .d3_sts_1 = cht_d3_sts_1_map, 147 + .func_dis = d3_sts_0_map, 148 + .func_dis_2 = cht_func_dis_2_map, 149 + .pss = cht_pss_map, 137 150 }; 138 151 139 152 static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset) ··· 235 180 } 236 181 237 182 #ifdef CONFIG_DEBUG_FS 183 + static void pmc_dev_state_print(struct seq_file *s, int reg_index, 184 + u32 sts, const struct pmc_bit_map *sts_map, 185 + u32 fd, const struct pmc_bit_map *fd_map) 186 + { 187 + int offset = PMC_REG_BIT_WIDTH * reg_index; 188 + int index; 189 + 190 + for (index = 0; sts_map[index].name; index++) { 191 + seq_printf(s, "Dev: %-2d - %-32s\tState: %s [%s]\n", 192 + offset + index, sts_map[index].name, 193 + fd_map[index].bit_mask & fd ? "Disabled" : "Enabled ", 194 + sts_map[index].bit_mask & sts ? "D3" : "D0"); 195 + } 196 + } 197 + 238 198 static int pmc_dev_state_show(struct seq_file *s, void *unused) 239 199 { 240 200 struct pmc_dev *pmc = s->private; 241 - const struct pmc_bit_map *map = pmc->map->dev; 242 - u32 func_dis, func_dis_2, func_dis_index; 243 - u32 d3_sts_0, d3_sts_1, d3_sts_index; 244 - int index, reg_index; 201 + const struct pmc_reg_map *m = pmc->map; 202 + u32 func_dis, func_dis_2; 203 + u32 d3_sts_0, d3_sts_1; 245 204 246 205 func_dis = pmc_reg_read(pmc, PMC_FUNC_DIS); 247 206 func_dis_2 = pmc_reg_read(pmc, PMC_FUNC_DIS_2); 248 207 d3_sts_0 = pmc_reg_read(pmc, PMC_D3_STS_0); 249 208 d3_sts_1 = pmc_reg_read(pmc, PMC_D3_STS_1); 250 209 251 - for (index = 0; map[index].name; index++) { 252 - reg_index = index / PMC_REG_BIT_WIDTH; 253 - if (reg_index) { 254 - func_dis_index = func_dis_2; 255 - d3_sts_index = d3_sts_1; 256 - } else { 257 - func_dis_index = func_dis; 258 - d3_sts_index = d3_sts_0; 259 - } 210 + /* Low part */ 211 + pmc_dev_state_print(s, 0, d3_sts_0, m->d3_sts_0, func_dis, m->func_dis); 260 212 261 - seq_printf(s, "Dev: %-2d - %-32s\tState: %s [%s]\n", 262 - index, map[index].name, 263 - map[index].bit_mask & func_dis_index ? 264 - "Disabled" : "Enabled ", 265 - map[index].bit_mask & d3_sts_index ? 266 - "D3" : "D0"); 267 - } 213 + /* High part */ 214 + pmc_dev_state_print(s, 1, d3_sts_1, m->d3_sts_1, func_dis_2, m->func_dis_2); 215 + 268 216 return 0; 269 217 } 270 218 ··· 383 325 } 384 326 #endif /* CONFIG_DEBUG_FS */ 385 327 386 - static int pmc_setup_dev(struct pci_dev *pdev, const struct pmc_reg_map *map) 328 + static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent) 387 329 { 388 330 struct pmc_dev *pmc = &pmc_device; 331 + const struct pmc_reg_map *map = (struct pmc_reg_map *)ent->driver_data; 389 332 int ret; 390 333 391 334 /* Obtain ACPI base address */ ··· 428 369 * a driver on the same PCI id. 429 370 */ 430 371 static const struct pci_device_id pmc_pci_ids[] = { 431 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_VLV_PMC) }, 372 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_VLV_PMC), (kernel_ulong_t)&byt_reg_map }, 373 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_CHT_PMC), (kernel_ulong_t)&cht_reg_map }, 432 374 { 0, }, 433 375 }; 434 376 ··· 451 391 for_each_pci_dev(pdev) { 452 392 ent = pci_match_id(pmc_pci_ids, pdev); 453 393 if (ent) 454 - return pmc_setup_dev(pdev, &reg_map); 394 + return pmc_setup_dev(pdev, ent); 455 395 } 456 396 /* Device not found. */ 457 397 return -ENODEV;