From: tip-bot for Andy Shevchenko <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mahesh.kumar.p@intel.com, torvalds@linux-foundation.org,
linux-kernel@vger.kernel.org, hpa@zytor.com,
rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com,
tglx@linutronix.de, mingo@kernel.org, aubrey.li@linux.intel.com,
peterz@infradead.org
Subject: [tip:x86/platform] x86/platform/intel/pmc_atom: Export accessors to PMC registers
Date: Mon, 6 Jul 2015 09:34:32 -0700 [thread overview]
Message-ID: <tip-68872eb9b19bbd85883262a4e0927b487653816c@git.kernel.org> (raw)
In-Reply-To: <1436192944-56496-2-git-send-email-andriy.shevchenko@linux.intel.com>
Commit-ID: 68872eb9b19bbd85883262a4e0927b487653816c
Gitweb: http://git.kernel.org/tip/68872eb9b19bbd85883262a4e0927b487653816c
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Mon, 6 Jul 2015 17:29:00 +0300
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 6 Jul 2015 17:42:45 +0200
x86/platform/intel/pmc_atom: Export accessors to PMC registers
Export the pmc_atom_read() and pmc_atom_write() accessors to the PMC
registers. On early initcall stages the functions will return
-ENODEV, and caller has to wait when it will be available.
Additionally make absence of debugfs a non-fatal error.
The patch will be useful for the upcoming fixes regarding to the
LPSS block found on Intel BayTrail-T and Braswell.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Aubrey Li <aubrey.li@linux.intel.com>
Cc: Kumar P Mahesh <mahesh.kumar.p@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-2-git-send-email-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/pmc_atom.h | 4 ++++
arch/x86/kernel/pmc_atom.c | 49 ++++++++++++++++++++++++++++-------------
2 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/arch/x86/include/asm/pmc_atom.h b/arch/x86/include/asm/pmc_atom.h
index bc0fc08..6ee2200 100644
--- a/arch/x86/include/asm/pmc_atom.h
+++ b/arch/x86/include/asm/pmc_atom.h
@@ -126,4 +126,8 @@
#define SLEEP_TYPE_MASK 0xFFFFECFF
#define SLEEP_TYPE_S5 0x1C00
#define SLEEP_ENABLE 0x2000
+
+extern int pmc_atom_read(int offset, u32 *value);
+extern int pmc_atom_write(int offset, u32 value);
+
#endif /* PMC_ATOM_H */
diff --git a/arch/x86/kernel/pmc_atom.c b/arch/x86/kernel/pmc_atom.c
index d66a4fe..4e1242e 100644
--- a/arch/x86/kernel/pmc_atom.c
+++ b/arch/x86/kernel/pmc_atom.c
@@ -31,6 +31,7 @@ struct pmc_dev {
#ifdef CONFIG_DEBUG_FS
struct dentry *dbgfs_dir;
#endif /* CONFIG_DEBUG_FS */
+ bool init;
};
static struct pmc_dev pmc_device;
@@ -111,6 +112,30 @@ static inline void pmc_reg_write(struct pmc_dev *pmc, int reg_offset, u32 val)
writel(val, pmc->regmap + reg_offset);
}
+int pmc_atom_read(int offset, u32 *value)
+{
+ struct pmc_dev *pmc = &pmc_device;
+
+ if (!pmc->init)
+ return -ENODEV;
+
+ *value = pmc_reg_read(pmc, offset);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pmc_atom_read);
+
+int pmc_atom_write(int offset, u32 value)
+{
+ struct pmc_dev *pmc = &pmc_device;
+
+ if (!pmc->init)
+ return -ENODEV;
+
+ pmc_reg_write(pmc, offset, value);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pmc_atom_write);
+
static void pmc_power_off(void)
{
u16 pm1_cnt_port;
@@ -250,7 +275,7 @@ static void pmc_dbgfs_unregister(struct pmc_dev *pmc)
debugfs_remove_recursive(pmc->dbgfs_dir);
}
-static int pmc_dbgfs_register(struct pmc_dev *pmc, struct pci_dev *pdev)
+static int pmc_dbgfs_register(struct pmc_dev *pmc)
{
struct dentry *dir, *f;
@@ -262,24 +287,18 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc, struct pci_dev *pdev)
f = debugfs_create_file("dev_state", S_IFREG | S_IRUGO,
dir, pmc, &pmc_dev_state_ops);
- if (!f) {
- dev_err(&pdev->dev, "dev_state register failed\n");
+ if (!f)
goto err;
- }
f = debugfs_create_file("pss_state", S_IFREG | S_IRUGO,
dir, pmc, &pmc_pss_state_ops);
- if (!f) {
- dev_err(&pdev->dev, "pss_state register failed\n");
+ if (!f)
goto err;
- }
f = debugfs_create_file("sleep_state", S_IFREG | S_IRUGO,
dir, pmc, &pmc_sleep_tmr_ops);
- if (!f) {
- dev_err(&pdev->dev, "sleep_state register failed\n");
+ if (!f)
goto err;
- }
return 0;
err:
@@ -287,7 +306,7 @@ err:
return -ENODEV;
}
#else
-static int pmc_dbgfs_register(struct pmc_dev *pmc, struct pci_dev *pdev)
+static int pmc_dbgfs_register(struct pmc_dev *pmc)
{
return 0;
}
@@ -318,11 +337,11 @@ static int pmc_setup_dev(struct pci_dev *pdev)
/* PMC hardware registers setup */
pmc_hw_reg_setup(pmc);
- ret = pmc_dbgfs_register(pmc, pdev);
- if (ret) {
- iounmap(pmc->regmap);
- }
+ ret = pmc_dbgfs_register(pmc);
+ if (ret)
+ dev_warn(&pdev->dev, "debugfs register failed\n");
+ pmc->init = true;
return ret;
}
next prev parent reply other threads:[~2015-07-06 16:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 14:28 [PATCH v3 0/5] x86: pmc_atom: Add Cherrytrail support Andy Shevchenko
2015-07-06 14:29 ` [PATCH v3 1/5] x86: pmc_atom: export accessors to PMC registers Andy Shevchenko
2015-07-06 16:34 ` tip-bot for Andy Shevchenko [this message]
2015-07-06 14:29 ` [PATCH v3 2/5] x86: pmc_atom: print index of device in loop Andy Shevchenko
2015-07-06 16:34 ` [tip:x86/platform] x86/platform/intel/pmc_atom: Print " tip-bot for Andy Shevchenko
2015-07-06 14:29 ` [PATCH v3 3/5] x86: pmc_atom: supply register mappings via pmc object Andy Shevchenko
2015-07-06 16:35 ` [tip:x86/platform] x86/platform/intel/pmc_atom: Supply register mappings via PMC object tip-bot for Andy Shevchenko
2015-07-06 14:29 ` [PATCH v3 4/5] x86: pmc_atom: Add Cherrytrail PMC interface Andy Shevchenko
2015-07-06 15:44 ` Ingo Molnar
2015-07-06 15:47 ` Thomas Gleixner
2015-07-06 15:50 ` Ingo Molnar
2015-07-06 16:37 ` Andy Shevchenko
2015-07-06 16:39 ` Ingo Molnar
2015-07-06 16:35 ` [tip:x86/platform] x86/platform/intel/pmc_atom: " tip-bot for Kumar P Mahesh
2015-07-06 19:09 ` Peter Zijlstra
2015-07-07 6:55 ` Ingo Molnar
2015-07-06 16:51 ` tip-bot for Andy Shevchenko
2015-07-06 14:29 ` [PATCH v3 5/5] x86: pmc_atom: place it under arch/x86/platform/atom Andy Shevchenko
2015-07-06 16:35 ` [tip:x86/platform] x86/platform/intel/pmc_atom: Move the PMC-Atom code to arch/x86/platform/atom tip-bot for Andy Shevchenko
2015-07-06 16:51 ` tip-bot for Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-68872eb9b19bbd85883262a4e0927b487653816c@git.kernel.org \
--to=tipbot@zytor.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=aubrey.li@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mahesh.kumar.p@intel.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox