aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-07-06 10:29:02 -0400
committerIngo Molnar <mingo@kernel.org>2015-07-06 11:42:46 -0400
commit940406d1cfb5b35cb9716d186fe3e6308f2700c5 (patch)
tree37a52d7a8377ee4131a834d49e051fd89d83083a
parentc3c65aa6d43f9e9f23f688848b08ffec97be893b (diff)
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>
-rw-r--r--arch/x86/kernel/pmc_atom.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/arch/x86/kernel/pmc_atom.c b/arch/x86/kernel/pmc_atom.c
index c7dca07d121c..4752b1a62910 100644
--- a/arch/x86/kernel/pmc_atom.c
+++ b/arch/x86/kernel/pmc_atom.c
@@ -25,9 +25,20 @@
25 25
26#include <asm/pmc_atom.h> 26#include <asm/pmc_atom.h>
27 27
28struct pmc_bit_map {
29 const char *name;
30 u32 bit_mask;
31};
32
33struct pmc_reg_map {
34 const struct pmc_bit_map *dev;
35 const struct pmc_bit_map *pss;
36};
37
28struct pmc_dev { 38struct pmc_dev {
29 u32 base_addr; 39 u32 base_addr;
30 void __iomem *regmap; 40 void __iomem *regmap;
41 const struct pmc_reg_map *map;
31#ifdef CONFIG_DEBUG_FS 42#ifdef CONFIG_DEBUG_FS
32 struct dentry *dbgfs_dir; 43 struct dentry *dbgfs_dir;
33#endif /* CONFIG_DEBUG_FS */ 44#endif /* CONFIG_DEBUG_FS */
@@ -37,11 +48,6 @@ struct pmc_dev {
37static struct pmc_dev pmc_device; 48static struct pmc_dev pmc_device;
38static u32 acpi_base_addr; 49static u32 acpi_base_addr;
39 50
40struct pmc_bit_map {
41 const char *name;
42 u32 bit_mask;
43};
44
45static const struct pmc_bit_map dev_map[] = { 51static const struct pmc_bit_map dev_map[] = {
46 {"LPSS1_F0_DMA", BIT_LPSS1_F0_DMA}, 52 {"LPSS1_F0_DMA", BIT_LPSS1_F0_DMA},
47 {"LPSS1_F1_PWM1", BIT_LPSS1_F1_PWM1}, 53 {"LPSS1_F1_PWM1", BIT_LPSS1_F1_PWM1},
@@ -104,6 +110,11 @@ static const struct pmc_bit_map pss_map[] = {
104 {}, 110 {},
105}; 111};
106 112
113static const struct pmc_reg_map reg_map = {
114 .dev = dev_map,
115 .pss = pss_map,
116};
117
107static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset) 118static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset)
108{ 119{
109 return readl(pmc->regmap + reg_offset); 120 return readl(pmc->regmap + reg_offset);
@@ -172,17 +183,18 @@ static void pmc_hw_reg_setup(struct pmc_dev *pmc)
172static int pmc_dev_state_show(struct seq_file *s, void *unused) 183static int pmc_dev_state_show(struct seq_file *s, void *unused)
173{ 184{
174 struct pmc_dev *pmc = s->private; 185 struct pmc_dev *pmc = s->private;
186 const struct pmc_bit_map *map = pmc->map->dev;
175 u32 func_dis, func_dis_2, func_dis_index; 187 u32 func_dis, func_dis_2, func_dis_index;
176 u32 d3_sts_0, d3_sts_1, d3_sts_index; 188 u32 d3_sts_0, d3_sts_1, d3_sts_index;
177 int dev_index, reg_index; 189 int index, reg_index;
178 190
179 func_dis = pmc_reg_read(pmc, PMC_FUNC_DIS); 191 func_dis = pmc_reg_read(pmc, PMC_FUNC_DIS);
180 func_dis_2 = pmc_reg_read(pmc, PMC_FUNC_DIS_2); 192 func_dis_2 = pmc_reg_read(pmc, PMC_FUNC_DIS_2);
181 d3_sts_0 = pmc_reg_read(pmc, PMC_D3_STS_0); 193 d3_sts_0 = pmc_reg_read(pmc, PMC_D3_STS_0);
182 d3_sts_1 = pmc_reg_read(pmc, PMC_D3_STS_1); 194 d3_sts_1 = pmc_reg_read(pmc, PMC_D3_STS_1);
183 195
184 for (dev_index = 0; dev_map[dev_index].name; dev_index++) { 196 for (index = 0; map[index].name; index++) {
185 reg_index = dev_index / PMC_REG_BIT_WIDTH; 197 reg_index = index / PMC_REG_BIT_WIDTH;
186 if (reg_index) { 198 if (reg_index) {
187 func_dis_index = func_dis_2; 199 func_dis_index = func_dis_2;
188 d3_sts_index = d3_sts_1; 200 d3_sts_index = d3_sts_1;
@@ -192,10 +204,10 @@ static int pmc_dev_state_show(struct seq_file *s, void *unused)
192 } 204 }
193 205
194 seq_printf(s, "Dev: %-2d - %-32s\tState: %s [%s]\n", 206 seq_printf(s, "Dev: %-2d - %-32s\tState: %s [%s]\n",
195 dev_index, dev_map[dev_index].name, 207 index, map[index].name,
196 dev_map[dev_index].bit_mask & func_dis_index ? 208 map[index].bit_mask & func_dis_index ?
197 "Disabled" : "Enabled ", 209 "Disabled" : "Enabled ",
198 dev_map[dev_index].bit_mask & d3_sts_index ? 210 map[index].bit_mask & d3_sts_index ?
199 "D3" : "D0"); 211 "D3" : "D0");
200 } 212 }
201 return 0; 213 return 0;
@@ -216,13 +228,14 @@ static const struct file_operations pmc_dev_state_ops = {
216static int pmc_pss_state_show(struct seq_file *s, void *unused) 228static int pmc_pss_state_show(struct seq_file *s, void *unused)
217{ 229{
218 struct pmc_dev *pmc = s->private; 230 struct pmc_dev *pmc = s->private;
231 const struct pmc_bit_map *map = pmc->map->pss;
219 u32 pss = pmc_reg_read(pmc, PMC_PSS); 232 u32 pss = pmc_reg_read(pmc, PMC_PSS);
220 int pss_index; 233 int index;
221 234
222 for (pss_index = 0; pss_map[pss_index].name; pss_index++) { 235 for (index = 0; map[index].name; index++) {
223 seq_printf(s, "Island: %-2d - %-32s\tState: %s\n", 236 seq_printf(s, "Island: %-2d - %-32s\tState: %s\n",
224 pss_index, pss_map[pss_index].name, 237 index, map[index].name,
225 pss_map[pss_index].bit_mask & pss ? "Off" : "On"); 238 map[index].bit_mask & pss ? "Off" : "On");
226 } 239 }
227 return 0; 240 return 0;
228} 241}
@@ -312,7 +325,7 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc)
312} 325}
313#endif /* CONFIG_DEBUG_FS */ 326#endif /* CONFIG_DEBUG_FS */
314 327
315static int pmc_setup_dev(struct pci_dev *pdev) 328static int pmc_setup_dev(struct pci_dev *pdev, const struct pmc_reg_map *map)
316{ 329{
317 struct pmc_dev *pmc = &pmc_device; 330 struct pmc_dev *pmc = &pmc_device;
318 int ret; 331 int ret;
@@ -334,6 +347,8 @@ static int pmc_setup_dev(struct pci_dev *pdev)
334 return -ENOMEM; 347 return -ENOMEM;
335 } 348 }
336 349
350 pmc->map = map;
351
337 /* PMC hardware registers setup */ 352 /* PMC hardware registers setup */
338 pmc_hw_reg_setup(pmc); 353 pmc_hw_reg_setup(pmc);
339 354
@@ -376,7 +391,7 @@ static int __init pmc_atom_init(void)
376 for_each_pci_dev(pdev) { 391 for_each_pci_dev(pdev) {
377 ent = pci_match_id(pmc_pci_ids, pdev); 392 ent = pci_match_id(pmc_pci_ids, pdev);
378 if (ent) 393 if (ent)
379 return pmc_setup_dev(pdev); 394 return pmc_setup_dev(pdev, &reg_map);
380 } 395 }
381 /* Device not found. */ 396 /* Device not found. */
382 return -ENODEV; 397 return -ENODEV;