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

x86/platform/intel/pmc_atom: Supply register mappings via PMC object

The patch converts the functions to use the register mappings
provided by PMC object. It would help in case of mappings on
different platforms.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Aubrey Li <aubrey.li@linux.intel.com>
Cc: Rafael J . Wysocki <rafael.j.wysocki@intel.com>
Cc: Kumar P Mahesh <mahesh.kumar.p@intel.com>
Link: http://lkml.kernel.org/r/1436192944-56496-4-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
940406d1 c3c65aa6

+32 -17
+32 -17
arch/x86/kernel/pmc_atom.c
··· 25 25 26 26 #include <asm/pmc_atom.h> 27 27 28 + struct pmc_bit_map { 29 + const char *name; 30 + u32 bit_mask; 31 + }; 32 + 33 + struct pmc_reg_map { 34 + const struct pmc_bit_map *dev; 35 + const struct pmc_bit_map *pss; 36 + }; 37 + 28 38 struct pmc_dev { 29 39 u32 base_addr; 30 40 void __iomem *regmap; 41 + const struct pmc_reg_map *map; 31 42 #ifdef CONFIG_DEBUG_FS 32 43 struct dentry *dbgfs_dir; 33 44 #endif /* CONFIG_DEBUG_FS */ ··· 47 36 48 37 static struct pmc_dev pmc_device; 49 38 static u32 acpi_base_addr; 50 - 51 - struct pmc_bit_map { 52 - const char *name; 53 - u32 bit_mask; 54 - }; 55 39 56 40 static const struct pmc_bit_map dev_map[] = { 57 41 {"LPSS1_F0_DMA", BIT_LPSS1_F0_DMA}, ··· 108 102 {"USB", PMC_PSS_BIT_USB}, 109 103 {"USB_SUS", PMC_PSS_BIT_USB_SUS}, 110 104 {}, 105 + }; 106 + 107 + static const struct pmc_reg_map reg_map = { 108 + .dev = dev_map, 109 + .pss = pss_map, 111 110 }; 112 111 113 112 static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset) ··· 183 172 static int pmc_dev_state_show(struct seq_file *s, void *unused) 184 173 { 185 174 struct pmc_dev *pmc = s->private; 175 + const struct pmc_bit_map *map = pmc->map->dev; 186 176 u32 func_dis, func_dis_2, func_dis_index; 187 177 u32 d3_sts_0, d3_sts_1, d3_sts_index; 188 - int dev_index, reg_index; 178 + int index, reg_index; 189 179 190 180 func_dis = pmc_reg_read(pmc, PMC_FUNC_DIS); 191 181 func_dis_2 = pmc_reg_read(pmc, PMC_FUNC_DIS_2); 192 182 d3_sts_0 = pmc_reg_read(pmc, PMC_D3_STS_0); 193 183 d3_sts_1 = pmc_reg_read(pmc, PMC_D3_STS_1); 194 184 195 - for (dev_index = 0; dev_map[dev_index].name; dev_index++) { 196 - reg_index = dev_index / PMC_REG_BIT_WIDTH; 185 + for (index = 0; map[index].name; index++) { 186 + reg_index = index / PMC_REG_BIT_WIDTH; 197 187 if (reg_index) { 198 188 func_dis_index = func_dis_2; 199 189 d3_sts_index = d3_sts_1; ··· 204 192 } 205 193 206 194 seq_printf(s, "Dev: %-2d - %-32s\tState: %s [%s]\n", 207 - dev_index, dev_map[dev_index].name, 208 - dev_map[dev_index].bit_mask & func_dis_index ? 195 + index, map[index].name, 196 + map[index].bit_mask & func_dis_index ? 209 197 "Disabled" : "Enabled ", 210 - dev_map[dev_index].bit_mask & d3_sts_index ? 198 + map[index].bit_mask & d3_sts_index ? 211 199 "D3" : "D0"); 212 200 } 213 201 return 0; ··· 228 216 static int pmc_pss_state_show(struct seq_file *s, void *unused) 229 217 { 230 218 struct pmc_dev *pmc = s->private; 219 + const struct pmc_bit_map *map = pmc->map->pss; 231 220 u32 pss = pmc_reg_read(pmc, PMC_PSS); 232 - int pss_index; 221 + int index; 233 222 234 - for (pss_index = 0; pss_map[pss_index].name; pss_index++) { 223 + for (index = 0; map[index].name; index++) { 235 224 seq_printf(s, "Island: %-2d - %-32s\tState: %s\n", 236 - pss_index, pss_map[pss_index].name, 237 - pss_map[pss_index].bit_mask & pss ? "Off" : "On"); 225 + index, map[index].name, 226 + map[index].bit_mask & pss ? "Off" : "On"); 238 227 } 239 228 return 0; 240 229 } ··· 325 312 } 326 313 #endif /* CONFIG_DEBUG_FS */ 327 314 328 - static int pmc_setup_dev(struct pci_dev *pdev) 315 + static int pmc_setup_dev(struct pci_dev *pdev, const struct pmc_reg_map *map) 329 316 { 330 317 struct pmc_dev *pmc = &pmc_device; 331 318 int ret; ··· 346 333 dev_err(&pdev->dev, "error: ioremap failed\n"); 347 334 return -ENOMEM; 348 335 } 336 + 337 + pmc->map = map; 349 338 350 339 /* PMC hardware registers setup */ 351 340 pmc_hw_reg_setup(pmc); ··· 391 376 for_each_pci_dev(pdev) { 392 377 ent = pci_match_id(pmc_pci_ids, pdev); 393 378 if (ent) 394 - return pmc_setup_dev(pdev); 379 + return pmc_setup_dev(pdev, &reg_map); 395 380 } 396 381 /* Device not found. */ 397 382 return -ENODEV;