From: Andres Salomon <dilinger@queued.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Fox <pgf@laptop.org>, Daniel Drake <dsd@laptop.org>,
"Richard A. Smith" <richard@laptop.org>,
linux-kernel@vger.kernel.org, libertas-dev@lists.infradead.org,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
platform-driver-x86@vger.kernel.org, devel@driverdev.osuosl.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Dan Williams <dcbw@redhat.com>,
"John W. Linville" <linville@tuxdriver.com>,
Matthew Garrett <mjg@redhat.com>, Anton Vorontsov <cbou@mail.ru>,
David Woodhouse <dwmw2@infradead.org>,
Chris Ball <cjb@laptop.org>,
Jon Nettleton <jon.nettleton@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH RESEND 6/9] x86: OLPC: switch over to using new EC driver on x86
Date: Wed, 18 Jul 2012 21:42:11 -0700 [thread overview]
Message-ID: <20120718214211.67cff1f3@dev.queued.net> (raw)
In-Reply-To: <20120718213713.232e4161@dev.queued.net>
This uses the new EC driver framework in drivers/platform/olpc. The
XO-1 and XO-1.5-specific code is still in arch/x86, but the generic stuff
(including a new workqueue; no more running EC commands with IRQs disabled!)
can be shared with other architectures.
Signed-off-by: Andres Salomon <dilinger@queued.net>
---
arch/x86/include/asm/olpc.h | 5 ---
arch/x86/platform/olpc/olpc.c | 53 ++++++++++++++++++++-------------------
drivers/platform/olpc/olpc-ec.c | 5 ---
3 files changed, 27 insertions(+), 36 deletions(-)
diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 5b28f3e..72f9adf6 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -100,11 +100,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value);
extern int pci_olpc_init(void);
-/* EC related functions */
-
-extern int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf,
- size_t inlen, unsigned char *outbuf, size_t outlen);
-
/* SCI source values */
#define EC_SCI_SRC_EMPTY 0x00
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index a3fa180..4590096 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -14,7 +14,6 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/delay.h>
-#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/string.h>
#include <linux/platform_device.h>
@@ -32,8 +31,6 @@
struct olpc_platform_t olpc_platform_info;
EXPORT_SYMBOL_GPL(olpc_platform_info);
-static DEFINE_SPINLOCK(ec_lock);
-
/* debugfs interface to EC commands */
#define EC_MAX_CMD_ARGS (5 + 1) /* cmd byte + 5 args */
#define EC_MAX_CMD_REPLY (8)
@@ -126,16 +123,13 @@ static int __wait_on_obf(unsigned int line, unsigned int port, int desired)
* <http://wiki.laptop.org/go/Ec_specification>. Unfortunately, while
* OpenFirmware's source is available, the EC's is not.
*/
-int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
- unsigned char *outbuf, size_t outlen)
+static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+ size_t outlen, void *arg)
{
- unsigned long flags;
int ret = -EIO;
int i;
int restarts = 0;
- spin_lock_irqsave(&ec_lock, flags);
-
/* Clear OBF */
for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++)
inb(0x68);
@@ -199,10 +193,8 @@ restart:
ret = 0;
err:
- spin_unlock_irqrestore(&ec_lock, flags);
return ret;
}
-EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
void olpc_ec_wakeup_set(u16 value)
{
@@ -366,7 +358,7 @@ static void setup_debugfs(void)
&ec_debugfs_genops);
}
-static int olpc_ec_suspend(void)
+static int olpc_ec_suspend(struct platform_device *pdev)
{
return olpc_ec_mask_write(ec_wakeup_mask);
}
@@ -425,8 +417,28 @@ static int __init add_xo1_platform_devices(void)
return 0;
}
-static struct syscore_ops olpc_syscore_ops = {
+static int olpc_xo1_ec_probe(struct platform_device *pdev)
+{
+ /* get the EC revision */
+ olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
+ (unsigned char *) &olpc_platform_info.ecver, 1);
+
+ /* EC version 0x5f adds support for wide SCI mask */
+ if (olpc_platform_info.ecver >= 0x5f)
+ olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
+
+ pr_info("OLPC board revision %s%X (EC=%x)\n",
+ ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
+ olpc_platform_info.boardrev >> 4,
+ olpc_platform_info.ecver);
+
+ return 0;
+}
+
+static struct olpc_ec_driver ec_xo1_driver = {
.suspend = olpc_ec_suspend,
+ .probe = olpc_xo1_ec_probe,
+ .ec_cmd = olpc_xo1_ec_cmd,
};
static int __init olpc_init(void)
@@ -436,16 +448,14 @@ static int __init olpc_init(void)
if (!olpc_ofw_present() || !platform_detect())
return 0;
- spin_lock_init(&ec_lock);
+ /* register the XO-1 and 1.5-specific EC handler */
+ olpc_ec_driver_register(&ec_xo1_driver, NULL);
+ platform_device_register_simple("olpc-ec", -1, NULL, 0);
/* assume B1 and above models always have a DCON */
if (olpc_board_at_least(olpc_board(0xb1)))
olpc_platform_info.flags |= OLPC_F_DCON;
- /* get the EC revision */
- olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
- (unsigned char *) &olpc_platform_info.ecver, 1);
-
#ifdef CONFIG_PCI_OLPC
/* If the VSA exists let it emulate PCI, if not emulate in kernel.
* XO-1 only. */
@@ -453,14 +463,6 @@ static int __init olpc_init(void)
!cs5535_has_vsa2())
x86_init.pci.arch_init = pci_olpc_init;
#endif
- /* EC version 0x5f adds support for wide SCI mask */
- if (olpc_platform_info.ecver >= 0x5f)
- olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
-
- printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n",
- ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
- olpc_platform_info.boardrev >> 4,
- olpc_platform_info.ecver);
if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) { /* XO-1 */
r = add_xo1_platform_devices();
@@ -468,7 +470,6 @@ static int __init olpc_init(void)
return r;
}
- register_syscore_ops(&olpc_syscore_ops);
setup_debugfs();
return 0;
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index cfba41f..a3d32c2 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -113,11 +113,6 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
struct olpc_ec_priv *ec = ec_priv;
struct ec_cmd_desc desc;
- /* XXX: this will be removed in later patches */
- /* Are we using old-style callers? */
- if (!ec_driver || !ec_driver->ec_cmd)
- return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
-
/* Ensure a driver and ec hook have been registered */
if (WARN_ON(!ec_driver || !ec_driver->ec_cmd))
return -ENODEV;
--
1.7.2.5
next prev parent reply other threads:[~2012-07-19 4:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 4:37 [PATCH RESEND 0/9] OLPC: create a generic OLPC EC driver Andres Salomon
2012-07-19 4:38 ` [PATCH RESEND 1/9] Platform: OLPC: add a stub to drivers/platform/ for the " Andres Salomon
2012-07-19 4:38 ` [PATCH RESEND 2/9] drivers: OLPC: update various drivers to include olpc-ec.h Andres Salomon
2012-07-19 4:39 ` [PATCH RESEND 3/9] Platform: OLPC: allow EC cmd to be overridden, and create a workqueue to call it Andres Salomon
2012-07-19 4:40 ` [PATCH RESEND 4/9] Platform: OLPC: turn EC driver into a platform_driver Andres Salomon
2012-07-19 4:40 ` [PATCH RESEND 5/9] Platform: OLPC: add a suspended flag to the EC driver Andres Salomon
2012-07-19 4:42 ` Andres Salomon [this message]
2012-07-19 4:43 ` [PATCH RESEND 7/9] Platform: OLPC: move debugfs support from x86 " Andres Salomon
2012-07-19 4:44 ` [PATCH RESEND 8/9] Platform: OLPC: move global variables into priv struct Andres Salomon
2012-07-19 4:44 ` [PATCH RESEND 9/9] x86: OLPC: move s/r-related EC cmds to EC driver Andres Salomon
2012-07-26 13:51 ` [PATCH RESEND 0/9] OLPC: create a generic OLPC " Thomas Gleixner
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=20120718214211.67cff1f3@dev.queued.net \
--to=dilinger@queued.net \
--cc=akpm@linux-foundation.org \
--cc=cbou@mail.ru \
--cc=cjb@laptop.org \
--cc=dcbw@redhat.com \
--cc=devel@driverdev.osuosl.org \
--cc=dsd@laptop.org \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jon.nettleton@gmail.com \
--cc=libertas-dev@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mingo@redhat.com \
--cc=mjg@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pgf@laptop.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=richard@laptop.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).