* [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller
@ 2019-01-07 18:34 Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 01/16] dt-bindings: olpc,xo1.75-ec: Add OLPC XO-1.75 EC bindings Lubomir Rintel
` (15 more replies)
0 siblings, 16 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel
Hello!
This is a third spin of the patch set that adds support for the Embedded
Controller on an OLPC XO 1.75 machine.
The previous patch set got feedback from Darren Hart, Sebastian Reichel and
Andy Shevchenko which I'm very thankful for. It hopefully incorporates fixes
for all issues that were pointed out. Details in individual patches.
Tested to work on an OLPC XO 1.75 and also tested not to break x86
support with an OLPC XO 1 machine. I don't have a XO 1.5, but it's
unlikely this breaks it when XO 1 works.
Thank you
Lubo
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 01/16] dt-bindings: olpc,xo1.75-ec: Add OLPC XO-1.75 EC bindings
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 02/16] Platform: OLPC: Remove an unused include Lubomir Rintel
` (14 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
The OLPC XO-1.75 Embedded Controller is a SPI master that uses extra
signals for handshaking. It needs to know when is the slave (Linux)
side's TX FIFO ready for transfer (the ready-gpio signal on the SPI
controller node) and when does it wish to respond with a command (the
cmd-gpio property).
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Changes since v1:
- s/cmd-gpio/cmd-gpios/
- s/ready-gpio/ready-gpios/ in the documentation paragraph
- Remove status = "okay" from the example
.../bindings/misc/olpc,xo1.75-ec.txt | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt
diff --git a/Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt b/Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt
new file mode 100644
index 000000000000..8c4d649cdd8f
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt
@@ -0,0 +1,23 @@
+OLPC XO-1.75 Embedded Controller
+
+Required properties:
+- compatible: Should be "olpc,xo1.75-ec".
+- cmd-gpios: gpio specifier of the CMD pin
+
+The embedded controller requires the SPI controller driver to signal readiness
+to receive a transfer (that is, when TX FIFO contains the response data) by
+strobing the ACK pin with the ready signal. See the "ready-gpios" property of the
+SSP binding as documented in:
+<Documentation/devicetree/bindings/spi/spi-pxa2xx.txt>.
+
+Example:
+ &ssp3 {
+ spi-slave;
+ ready-gpios = <&gpio 125 GPIO_ACTIVE_HIGH>;
+
+ slave {
+ compatible = "olpc,xo1.75-ec";
+ spi-cpha;
+ cmd-gpios = <&gpio 155 GPIO_ACTIVE_HIGH>;
+ };
+ };
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 02/16] Platform: OLPC: Remove an unused include
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 01/16] dt-bindings: olpc,xo1.75-ec: Add OLPC XO-1.75 EC bindings Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 03/16] Revert "platform/olpc: Make ec explicitly non-modular" Lubomir Rintel
` (13 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
Also, the header is x86 specific, while there are non-x86 OLPC machines.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
drivers/platform/olpc/olpc-ec.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 374a8028fec7..981955dce926 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -17,7 +17,6 @@
#include <linux/init.h>
#include <linux/list.h>
#include <linux/olpc-ec.h>
-#include <asm/olpc.h>
struct ec_cmd_desc {
u8 cmd;
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 03/16] Revert "platform/olpc: Make ec explicitly non-modular"
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 01/16] dt-bindings: olpc,xo1.75-ec: Add OLPC XO-1.75 EC bindings Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 02/16] Platform: OLPC: Remove an unused include Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-08 8:29 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 04/16] Platform: OLPC: Move OLPC config symbol out of x86 tree Lubomir Rintel
` (12 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
It doesn't make sense to always have this built-in, e.g. on ARM
multiplatform kernels.
A better way to address the problem the original commit aimed to solve is
to fix Kconfig. That is what the next commit in the series does.
This reverts commit f48d1496b8537d75776478c6942dd87f34d7f270.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
Changes since v1:
- Sort it later in the patch set
drivers/platform/olpc/olpc-ec.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 981955dce926..35a21c66cd0d 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -1,8 +1,6 @@
/*
* Generic driver for the OLPC Embedded Controller.
*
- * Author: Andres Salomon <dilinger@queued.net>
- *
* Copyright (C) 2011-2012 One Laptop per Child Foundation.
*
* Licensed under the GPL v2 or later.
@@ -14,7 +12,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
-#include <linux/init.h>
+#include <linux/module.h>
#include <linux/list.h>
#include <linux/olpc-ec.h>
@@ -327,4 +325,8 @@ static int __init olpc_ec_init_module(void)
{
return platform_driver_register(&olpc_ec_plat_driver);
}
+
arch_initcall(olpc_ec_init_module);
+
+MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
+MODULE_LICENSE("GPL");
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 04/16] Platform: OLPC: Move OLPC config symbol out of x86 tree
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (2 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 03/16] Revert "platform/olpc: Make ec explicitly non-modular" Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-08 5:54 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 05/16] Platform: OLPC: Add XO-1.75 EC driver Lubomir Rintel
` (11 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
There are ARM OLPC machines that use mostly the same drivers, including
EC infrastructure, DCON and Battery.
While at that, fix Kconfig to allow building this as a module.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Changes since v1:
- Use 'depends on OLPC && X86' idiom (thanks Andy Shevchenko)
arch/x86/Kconfig | 11 -----------
drivers/input/mouse/Kconfig | 3 ++-
drivers/platform/Kconfig | 2 ++
drivers/platform/olpc/Kconfig | 11 +++++++++++
drivers/staging/olpc_dcon/Kconfig | 3 ++-
5 files changed, 17 insertions(+), 13 deletions(-)
create mode 100644 drivers/platform/olpc/Kconfig
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6185d4f33296..0a3fc97827cf 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2707,17 +2707,6 @@ config SCx200HR_TIMER
processor goes idle (as is done by the scheduler). The
other workaround is idle=poll boot option.
-config OLPC
- bool "One Laptop Per Child support"
- depends on !X86_PAE
- select GPIOLIB
- select OF
- select OF_PROMTREE
- select IRQ_DOMAIN
- ---help---
- Add support for detecting the unique features of the OLPC
- XO hardware.
-
config OLPC_XO1_PM
bool "OLPC XO-1 Power Management"
depends on OLPC && MFD_CS5535=y && PM_SLEEP
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 566a1e3aa504..cf12d0e4fba2 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -165,7 +165,8 @@ config MOUSE_PS2_TOUCHKIT
config MOUSE_PS2_OLPC
bool "OLPC PS/2 mouse protocol extension"
- depends on MOUSE_PS2 && OLPC
+ depends on MOUSE_PS2
+ depends on OLPC && X86
help
Say Y here if you have an OLPC XO-1 laptop (with built-in
PS/2 touchpad/tablet device). The manufacturer calls the
diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig
index d4c2e424a700..4313d73d3618 100644
--- a/drivers/platform/Kconfig
+++ b/drivers/platform/Kconfig
@@ -10,3 +10,5 @@ source "drivers/platform/goldfish/Kconfig"
source "drivers/platform/chrome/Kconfig"
source "drivers/platform/mellanox/Kconfig"
+
+source "drivers/platform/olpc/Kconfig"
diff --git a/drivers/platform/olpc/Kconfig b/drivers/platform/olpc/Kconfig
new file mode 100644
index 000000000000..7b736c9e67ac
--- /dev/null
+++ b/drivers/platform/olpc/Kconfig
@@ -0,0 +1,11 @@
+config OLPC
+ tristate "One Laptop Per Child support"
+ depends on X86 || ARM || COMPILE_TEST
+ depends on !X86_PAE
+ select GPIOLIB
+ select OF
+ select OF_PROMTREE if X86
+ select IRQ_DOMAIN
+ help
+ Add support for detecting the unique features of the OLPC
+ XO hardware.
diff --git a/drivers/staging/olpc_dcon/Kconfig b/drivers/staging/olpc_dcon/Kconfig
index 192cc8d0853f..ff540350f50f 100644
--- a/drivers/staging/olpc_dcon/Kconfig
+++ b/drivers/staging/olpc_dcon/Kconfig
@@ -1,8 +1,9 @@
config FB_OLPC_DCON
tristate "One Laptop Per Child Display CONtroller support"
- depends on OLPC && FB
+ depends on FB
depends on I2C
depends on BACKLIGHT_LCD_SUPPORT
+ depends on OLPC && X86
depends on (GPIO_CS5535 || GPIO_CS5535=n)
select BACKLIGHT_CLASS_DEVICE
help
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 05/16] Platform: OLPC: Add XO-1.75 EC driver
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (3 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 04/16] Platform: OLPC: Move OLPC config symbol out of x86 tree Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-08 6:23 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 06/16] Platform: OLPC: Avoid a warning if the EC didn't register yet Lubomir Rintel
` (10 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
It's based off the driver from the OLPC kernel sources. Somewhat
modernized and cleaned up, for better or worse.
Modified to plug into the olpc-ec driver infrastructure (so that battery
interface and debugfs could be reused) and the SPI slave framework.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
Changes since v1:
- Cosmetic style changes; whitespace, ordering of declarations and
#includes, remoted extra comas from sentinels
- Count the terminating NUL in LOG_BUF_SIZE
- Make olpc_xo175_ec_is_valid_cmd() return -EINVAL instead of -1
on error
- Spell keyboard/touchpad in full for CHAN_KEYBOARD/TOUCHPAD messages
- Use a #define for PM wakeup processing time
- Log a message on unknown event
- Escape logging payload with %*pE
- Replace an open-coded min()
- Correct an error code on short read
- replaced PM callback #ifdefs with __maybe_unusedm SET_RUNTIME_PM_OPS
and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS
- dev_get_drvdata() instead of a round-trip through platform device
- s/unsigned char x/u8 x/ in olpc_xo175_ec_resume()
- Use GENMASK() instead of 0xffff for the event mask
- Replace cmd tx/resp rx buffers with structures
- Turned suspend hint arguments into a struct, and tidied up the comment
Basically all of the above is based on the review by Andy Shevchenko.
drivers/platform/olpc/Kconfig | 15 +
drivers/platform/olpc/Makefile | 1 +
drivers/platform/olpc/olpc-xo175-ec.c | 763 ++++++++++++++++++++++++++
3 files changed, 779 insertions(+)
create mode 100644 drivers/platform/olpc/olpc-xo175-ec.c
diff --git a/drivers/platform/olpc/Kconfig b/drivers/platform/olpc/Kconfig
index 7b736c9e67ac..7c643d24ad0f 100644
--- a/drivers/platform/olpc/Kconfig
+++ b/drivers/platform/olpc/Kconfig
@@ -9,3 +9,18 @@ config OLPC
help
Add support for detecting the unique features of the OLPC
XO hardware.
+
+if OLPC
+
+config OLPC_XO175_EC
+ tristate "OLPC XO 1.75 Embedded Controller"
+ depends on ARCH_MMP || COMPILE_TEST
+ select SPI_SLAVE
+ help
+ Include support for the OLPC XO Embedded Controller (EC). The EC
+ provides various platform services, including support for the power,
+ button, restart, shutdown and battery charging status.
+
+ Unless you have an OLPC XO laptop, you will want to say N.
+
+endif
diff --git a/drivers/platform/olpc/Makefile b/drivers/platform/olpc/Makefile
index dc8b26bc7209..5b43f383289e 100644
--- a/drivers/platform/olpc/Makefile
+++ b/drivers/platform/olpc/Makefile
@@ -2,3 +2,4 @@
# OLPC XO platform-specific drivers
#
obj-$(CONFIG_OLPC) += olpc-ec.o
+obj-$(CONFIG_OLPC_XO175_EC) += olpc-xo175-ec.o
diff --git a/drivers/platform/olpc/olpc-xo175-ec.c b/drivers/platform/olpc/olpc-xo175-ec.c
new file mode 100644
index 000000000000..74db06bacc44
--- /dev/null
+++ b/drivers/platform/olpc/olpc-xo175-ec.c
@@ -0,0 +1,763 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for the OLPC XO-1.75 Embedded Controller.
+ *
+ * The EC protocol is documented at:
+ * http://wiki.laptop.org/go/XO_1.75_HOST_to_EC_Protocol
+ *
+ * Copyright (C) 2010 One Laptop per Child Foundation.
+ * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
+ */
+
+#include <linux/completion.h>
+#include <linux/ctype.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/input.h>
+#include <linux/kfifo.h>
+#include <linux/module.h>
+#include <linux/olpc-ec.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/reboot.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/spi/spi.h>
+#include <asm/system_misc.h>
+
+struct ec_cmd_t {
+ u8 cmd;
+ u8 bytes_returned;
+};
+
+enum ec_chan_t {
+ CHAN_NONE = 0,
+ CHAN_SWITCH,
+ CHAN_CMD_RESP,
+ CHAN_KEYBOARD,
+ CHAN_TOUCHPAD,
+ CHAN_EVENT,
+ CHAN_DEBUG,
+ CHAN_CMD_ERROR,
+};
+
+/*
+ * EC events
+ */
+#define EVENT_AC_CHANGE 1 /* AC plugged/unplugged */
+#define EVENT_BATTERY_STATUS 2 /* Battery low/full/error/gone */
+#define EVENT_BATTERY_CRITICAL 3 /* Battery critical voltage */
+#define EVENT_BATTERY_SOC_CHANGE 4 /* 1% SOC Change */
+#define EVENT_BATTERY_ERROR 5 /* Abnormal error, query for cause */
+#define EVENT_POWER_PRESSED 6 /* Power button was pressed */
+#define EVENT_POWER_PRESS_WAKE 7 /* Woken up with a power button */
+#define EVENT_TIMED_HOST_WAKE 8 /* Host wake timer */
+#define EVENT_OLS_HIGH_LIMIT 9 /* OLS crossed dark threshold */
+#define EVENT_OLS_LOW_LIMIT 10 /* OLS crossed light threshold */
+
+/*
+ * EC commands
+ * (from http://dev.laptop.org/git/users/rsmith/ec-1.75/tree/ec_cmd.h)
+ */
+#define CMD_GET_API_VERSION 0x08 /* out: u8 */
+#define CMD_READ_VOLTAGE 0x10 /* out: u16, *9.76/32, mV */
+#define CMD_READ_CURRENT 0x11 /* out: s16, *15.625/120, mA */
+#define CMD_READ_ACR 0x12 /* out: s16, *6250/15, uAh */
+#define CMD_READ_BATT_TEMPERATURE 0x13 /* out: u16, *100/256, deg C */
+#define CMD_READ_AMBIENT_TEMPERATURE 0x14 /* unimplemented, no hardware */
+#define CMD_READ_BATTERY_STATUS 0x15 /* out: u8, bitmask */
+#define CMD_READ_SOC 0x16 /* out: u8, percentage */
+#define CMD_READ_GAUGE_ID 0x17 /* out: u8 * 8 */
+#define CMD_READ_GAUGE_DATA 0x18 /* in: u8 addr, out: u8 data */
+#define CMD_READ_BOARD_ID 0x19 /* out: u16 (platform id) */
+#define CMD_READ_BATT_ERR_CODE 0x1f /* out: u8, error bitmask */
+#define CMD_SET_DCON_POWER 0x26 /* in: u8 */
+#define CMD_RESET_EC 0x28 /* none */
+#define CMD_READ_BATTERY_TYPE 0x2c /* out: u8 */
+#define CMD_SET_AUTOWAK 0x33 /* out: u8 */
+#define CMD_SET_EC_WAKEUP_TIMER 0x36 /* in: u32, out: ? */
+#define CMD_READ_EXT_SCI_MASK 0x37 /* ? */
+#define CMD_WRITE_EXT_SCI_MASK 0x38 /* ? */
+#define CMD_CLEAR_EC_WAKEUP_TIMER 0x39 /* none */
+#define CMD_ENABLE_RUNIN_DISCHARGE 0x3B /* none */
+#define CMD_DISABLE_RUNIN_DISCHARGE 0x3C /* none */
+#define CMD_READ_MPPT_ACTIVE 0x3d /* out: u8 */
+#define CMD_READ_MPPT_LIMIT 0x3e /* out: u8 */
+#define CMD_SET_MPPT_LIMIT 0x3f /* in: u8 */
+#define CMD_DISABLE_MPPT 0x40 /* none */
+#define CMD_ENABLE_MPPT 0x41 /* none */
+#define CMD_READ_VIN 0x42 /* out: u16 */
+#define CMD_EXT_SCI_QUERY 0x43 /* ? */
+#define RSP_KEYBOARD_DATA 0x48 /* ? */
+#define RSP_TOUCHPAD_DATA 0x49 /* ? */
+#define CMD_GET_FW_VERSION 0x4a /* out: u8 * 16 */
+#define CMD_POWER_CYCLE 0x4b /* none */
+#define CMD_POWER_OFF 0x4c /* none */
+#define CMD_RESET_EC_SOFT 0x4d /* none */
+#define CMD_READ_GAUGE_U16 0x4e /* ? */
+#define CMD_ENABLE_MOUSE 0x4f /* ? */
+#define CMD_ECHO 0x52 /* in: u8 * 5, out: u8 * 5 */
+#define CMD_GET_FW_DATE 0x53 /* out: u8 * 16 */
+#define CMD_GET_FW_USER 0x54 /* out: u8 * 16 */
+#define CMD_TURN_OFF_POWER 0x55 /* none (same as 0x4c) */
+#define CMD_READ_OLS 0x56 /* out: u16 */
+#define CMD_OLS_SMT_LEDON 0x57 /* none */
+#define CMD_OLS_SMT_LEDOFF 0x58 /* none */
+#define CMD_START_OLS_ASSY 0x59 /* none */
+#define CMD_STOP_OLS_ASSY 0x5a /* none */
+#define CMD_OLS_SMTTEST_STOP 0x5b /* none */
+#define CMD_READ_VIN_SCALED 0x5c /* out: u16 */
+#define CMD_READ_BAT_MIN_W 0x5d /* out: u16 */
+#define CMD_READ_BAR_MAX_W 0x5e /* out: u16 */
+#define CMD_RESET_BAT_MINMAX_W 0x5f /* none */
+#define CMD_READ_LOCATION 0x60 /* in: u16 addr, out: u8 data */
+#define CMD_WRITE_LOCATION 0x61 /* in: u16 addr, u8 data */
+#define CMD_KEYBOARD_CMD 0x62 /* in: u8, out: ? */
+#define CMD_TOUCHPAD_CMD 0x63 /* in: u8, out: ? */
+#define CMD_GET_FW_HASH 0x64 /* out: u8 * 16 */
+#define CMD_SUSPEND_HINT 0x65 /* in: u8 */
+#define CMD_ENABLE_WAKE_TIMER 0x66 /* in: u8 */
+#define CMD_SET_WAKE_TIMER 0x67 /* in: 32 */
+#define CMD_ENABLE_WAKE_AUTORESET 0x68 /* in: u8 */
+#define CMD_OLS_SET_LIMITS 0x69 /* in: u16, u16 */
+#define CMD_OLS_GET_LIMITS 0x6a /* out: u16, u16 */
+#define CMD_OLS_SET_CEILING 0x6b /* in: u16 */
+#define CMD_OLS_GET_CEILING 0x6c /* out: u16 */
+
+/*
+ * Accepted EC commands, and how many bytes they return. There are plenty
+ * of EC commands that are no longer implemented, or are implemented only on
+ * certain older boards.
+ */
+static const struct ec_cmd_t olpc_xo175_ec_cmds[] = {
+ { CMD_GET_API_VERSION, 1 },
+ { CMD_READ_VOLTAGE, 2 },
+ { CMD_READ_CURRENT, 2 },
+ { CMD_READ_ACR, 2 },
+ { CMD_READ_BATT_TEMPERATURE, 2 },
+ { CMD_READ_BATTERY_STATUS, 1 },
+ { CMD_READ_SOC, 1 },
+ { CMD_READ_GAUGE_ID, 8 },
+ { CMD_READ_GAUGE_DATA, 1 },
+ { CMD_READ_BOARD_ID, 2 },
+ { CMD_READ_BATT_ERR_CODE, 1 },
+ { CMD_SET_DCON_POWER, 0 },
+ { CMD_RESET_EC, 0 },
+ { CMD_READ_BATTERY_TYPE, 1 },
+ { CMD_ENABLE_RUNIN_DISCHARGE, 0 },
+ { CMD_DISABLE_RUNIN_DISCHARGE, 0 },
+ { CMD_READ_MPPT_ACTIVE, 1 },
+ { CMD_READ_MPPT_LIMIT, 1 },
+ { CMD_SET_MPPT_LIMIT, 0 },
+ { CMD_DISABLE_MPPT, 0 },
+ { CMD_ENABLE_MPPT, 0 },
+ { CMD_READ_VIN, 2 },
+ { CMD_GET_FW_VERSION, 16 },
+ { CMD_POWER_CYCLE, 0 },
+ { CMD_POWER_OFF, 0 },
+ { CMD_RESET_EC_SOFT, 0 },
+ { CMD_ECHO, 5 },
+ { CMD_GET_FW_DATE, 16 },
+ { CMD_GET_FW_USER, 16 },
+ { CMD_TURN_OFF_POWER, 0 },
+ { CMD_READ_OLS, 2 },
+ { CMD_OLS_SMT_LEDON, 0 },
+ { CMD_OLS_SMT_LEDOFF, 0 },
+ { CMD_START_OLS_ASSY, 0 },
+ { CMD_STOP_OLS_ASSY, 0 },
+ { CMD_OLS_SMTTEST_STOP, 0 },
+ { CMD_READ_VIN_SCALED, 2 },
+ { CMD_READ_BAT_MIN_W, 2 },
+ { CMD_READ_BAR_MAX_W, 2 },
+ { CMD_RESET_BAT_MINMAX_W, 0 },
+ { CMD_READ_LOCATION, 1 },
+ { CMD_WRITE_LOCATION, 0 },
+ { CMD_GET_FW_HASH, 16 },
+ { CMD_SUSPEND_HINT, 0 },
+ { CMD_ENABLE_WAKE_TIMER, 0 },
+ { CMD_SET_WAKE_TIMER, 0 },
+ { CMD_ENABLE_WAKE_AUTORESET, 0 },
+ { CMD_OLS_SET_LIMITS, 0 },
+ { CMD_OLS_GET_LIMITS, 4 },
+ { CMD_OLS_SET_CEILING, 0 },
+ { CMD_OLS_GET_CEILING, 2 },
+ { CMD_READ_EXT_SCI_MASK, 2 },
+ { CMD_WRITE_EXT_SCI_MASK, 0 },
+
+ { }
+};
+
+#define EC_MAX_CMD_DATA_LEN 5
+#define EC_MAX_RESP_LEN 16
+
+#define LOG_BUF_SIZE 128
+
+#define PM_WAKEUP_TIME 1000
+
+#define EC_ALL_EVENTS GENMASK(15, 0)
+
+enum ec_state_t {
+ CMD_STATE_IDLE = 0,
+ CMD_STATE_WAITING_FOR_SWITCH,
+ CMD_STATE_CMD_IN_TX_FIFO,
+ CMD_STATE_CMD_SENT,
+ CMD_STATE_RESP_RECEIVED,
+ CMD_STATE_ERROR_RECEIVED,
+};
+
+struct olpc_xo175_ec_cmd {
+ u8 command;
+ u8 nr_args;
+ u8 data_len;
+ u8 args[EC_MAX_CMD_DATA_LEN];
+};
+
+struct olpc_xo175_ec_resp {
+ u8 channel;
+ u8 byte;
+};
+
+struct olpc_xo175_ec {
+ bool suspended;
+
+ /* SPI related stuff. */
+ struct spi_device *spi;
+ struct spi_transfer xfer;
+ struct spi_message msg;
+ union {
+ struct olpc_xo175_ec_cmd cmd;
+ struct olpc_xo175_ec_resp resp;
+ } tx_buf, rx_buf;
+
+ /* GPIO for the CMD signals. */
+ struct gpio_desc *gpio_cmd;
+
+ /* Command handling related state. */
+ spinlock_t cmd_state_lock;
+ int cmd_state;
+ bool cmd_running;
+ struct completion cmd_done;
+ struct olpc_xo175_ec_cmd cmd;
+ u8 resp_data[EC_MAX_RESP_LEN];
+ int expected_resp_len;
+ int resp_len;
+
+ /* Power button. */
+ struct input_dev *pwrbtn;
+
+ /* Debug handling. */
+ char logbuf[LOG_BUF_SIZE];
+ int logbuf_len;
+};
+
+static struct platform_device *olpc_ec;
+
+static int olpc_xo175_ec_is_valid_cmd(u8 cmd)
+{
+ const struct ec_cmd_t *p;
+
+ for (p = olpc_xo175_ec_cmds; p->cmd; p++) {
+ if (p->cmd == cmd)
+ return p->bytes_returned;
+ }
+
+ return -EINVAL;
+}
+
+static void olpc_xo175_ec_flush_logbuf(struct olpc_xo175_ec *priv)
+{
+ dev_dbg(&priv->spi->dev, "got debug string [%*pE]\n",
+ priv->logbuf_len, priv->logbuf);
+ priv->logbuf_len = 0;
+}
+
+static void olpc_xo175_ec_complete(void *arg);
+
+static void olpc_xo175_ec_send_command(struct olpc_xo175_ec *priv, void *cmd,
+ size_t cmdlen)
+{
+ int ret;
+
+ memcpy(&priv->tx_buf, cmd, cmdlen);
+ priv->xfer.len = cmdlen;
+
+ spi_message_init_with_transfers(&priv->msg, &priv->xfer, 1);
+
+ priv->msg.complete = olpc_xo175_ec_complete;
+ priv->msg.context = priv;
+
+ ret = spi_async(priv->spi, &priv->msg);
+ if (ret)
+ dev_err(&priv->spi->dev, "spi_async() failed %d\n", ret);
+}
+
+static void olpc_xo175_ec_read_packet(struct olpc_xo175_ec *priv)
+{
+ u8 nonce[] = {0xA5, 0x5A};
+
+ olpc_xo175_ec_send_command(priv, nonce, sizeof(nonce));
+}
+
+static void olpc_xo175_ec_complete(void *arg)
+{
+ struct olpc_xo175_ec *priv = arg;
+ struct device *dev = &priv->spi->dev;
+ struct power_supply *psy;
+ unsigned long flags;
+ u8 channel;
+ u8 byte;
+ int ret;
+
+ ret = priv->msg.status;
+ if (ret) {
+ dev_err(dev, "SPI transfer failed: %d\n", ret);
+
+ spin_lock_irqsave(&priv->cmd_state_lock, flags);
+ if (priv->cmd_running) {
+ priv->resp_len = 0;
+ priv->cmd_state = CMD_STATE_ERROR_RECEIVED;
+ complete(&priv->cmd_done);
+ }
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+
+ if (ret != -EINTR)
+ olpc_xo175_ec_read_packet(priv);
+
+ return;
+ }
+
+ channel = priv->rx_buf.resp.channel;
+ byte = priv->rx_buf.resp.byte;
+
+ switch (channel) {
+ case CHAN_NONE:
+ spin_lock_irqsave(&priv->cmd_state_lock, flags);
+
+ if (!priv->cmd_running) {
+ /* We can safely ignore these */
+ dev_err(dev, "spurious FIFO read packet\n");
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+ return;
+ }
+
+ priv->cmd_state = CMD_STATE_CMD_SENT;
+ if (!priv->expected_resp_len)
+ complete(&priv->cmd_done);
+ olpc_xo175_ec_read_packet(priv);
+
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+ return;
+
+ case CHAN_SWITCH:
+ spin_lock_irqsave(&priv->cmd_state_lock, flags);
+
+ if (!priv->cmd_running) {
+ /* Just go with the flow */
+ dev_err(dev, "spurious SWITCH packet\n");
+ memset(&priv->cmd, 0, sizeof(priv->cmd));
+ priv->cmd.command = CMD_ECHO;
+ }
+
+ priv->cmd_state = CMD_STATE_CMD_IN_TX_FIFO;
+
+ /* Throw command into TxFIFO */
+ gpiod_set_value_cansleep(priv->gpio_cmd, 0);
+ olpc_xo175_ec_send_command(priv, &priv->cmd, sizeof(priv->cmd));
+
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+ return;
+
+ case CHAN_CMD_RESP:
+ spin_lock_irqsave(&priv->cmd_state_lock, flags);
+
+ if (!priv->cmd_running) {
+ dev_err(dev, "spurious response packet\n");
+ } else if (priv->resp_len >= priv->expected_resp_len) {
+ dev_err(dev, "too many response packets\n");
+ } else {
+ priv->resp_data[priv->resp_len++] = byte;
+ if (priv->resp_len == priv->expected_resp_len) {
+ priv->cmd_state = CMD_STATE_RESP_RECEIVED;
+ complete(&priv->cmd_done);
+ }
+ }
+
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+ break;
+
+ case CHAN_CMD_ERROR:
+ spin_lock_irqsave(&priv->cmd_state_lock, flags);
+
+ if (!priv->cmd_running) {
+ dev_err(dev, "spurious cmd error packet\n");
+ } else {
+ priv->resp_data[0] = byte;
+ priv->resp_len = 1;
+ priv->cmd_state = CMD_STATE_ERROR_RECEIVED;
+ complete(&priv->cmd_done);
+ }
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+ break;
+
+ case CHAN_KEYBOARD:
+ dev_warn(dev, "keyboard is not supported\n");
+ break;
+
+ case CHAN_TOUCHPAD:
+ dev_warn(dev, "touchpad is not supported\n");
+ break;
+
+ case CHAN_EVENT:
+ dev_dbg(dev, "got event %.2x\n", byte);
+ switch (byte) {
+ case EVENT_AC_CHANGE:
+ psy = power_supply_get_by_name("olpc-ac");
+ if (psy) {
+ power_supply_changed(psy);
+ power_supply_put(psy);
+ }
+ break;
+ case EVENT_BATTERY_STATUS:
+ case EVENT_BATTERY_CRITICAL:
+ case EVENT_BATTERY_SOC_CHANGE:
+ case EVENT_BATTERY_ERROR:
+ psy = power_supply_get_by_name("olpc-battery");
+ if (psy) {
+ power_supply_changed(psy);
+ power_supply_put(psy);
+ }
+ break;
+ case EVENT_POWER_PRESSED:
+ input_report_key(priv->pwrbtn, KEY_POWER, 1);
+ input_sync(priv->pwrbtn);
+ input_report_key(priv->pwrbtn, KEY_POWER, 0);
+ input_sync(priv->pwrbtn);
+ /* fall through */
+ case EVENT_POWER_PRESS_WAKE:
+ case EVENT_TIMED_HOST_WAKE:
+ pm_wakeup_event(priv->pwrbtn->dev.parent,
+ PM_WAKEUP_TIME);
+ break;
+ default:
+ dev_dbg(dev, "ignored unknown event %.2x\n", byte);
+ break;
+ }
+ break;
+
+ case CHAN_DEBUG:
+ if (byte == '\n') {
+ olpc_xo175_ec_flush_logbuf(priv);
+ } else if (isprint(byte)) {
+ priv->logbuf[priv->logbuf_len++] = byte;
+ if (priv->logbuf_len == LOG_BUF_SIZE)
+ olpc_xo175_ec_flush_logbuf(priv);
+ }
+ break;
+
+ default:
+ dev_warn(dev, "unknown channel: %d, %.2x\n", channel, byte);
+ break;
+ }
+
+ /* Most non-command packets get the TxFIFO refilled and an ACK. */
+ olpc_xo175_ec_read_packet(priv);
+}
+
+/*
+ * This function is protected with a mutex. We can safely assume that
+ * there will be only one instance of this function running at a time.
+ * One of the ways in which we enforce this is by waiting until we get
+ * all response bytes back from the EC, rather than just the number that
+ * the caller requests (otherwise, we might start a new command while an
+ * old command's response bytes are still incoming).
+ */
+static int olpc_xo175_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *resp,
+ size_t resp_len, void *ec_cb_arg)
+{
+ struct olpc_xo175_ec *priv = ec_cb_arg;
+ struct device *dev = &priv->spi->dev;
+ unsigned long flags;
+ size_t nr_bytes;
+ int ret = 0;
+
+ dev_dbg(dev, "CMD %x, %d bytes expected\n", cmd, resp_len);
+
+ if (inlen > 5) {
+ dev_err(dev, "command len %d too big!\n", resp_len);
+ return -EOVERFLOW;
+ }
+
+ /* Suspending in the middle of an EC command hoses things badly! */
+ if (WARN_ON(priv->suspended))
+ return -EBUSY;
+
+ /* Ensure a valid command and return bytes */
+ nr_bytes = olpc_xo175_ec_is_valid_cmd(cmd);
+ if (nr_bytes < 0) {
+ dev_err_ratelimited(dev, "unknown command 0x%x\n", cmd);
+
+ /*
+ * Assume the best in our callers, and allow unknown commands
+ * through. I'm not the charitable type, but it was beaten
+ * into me. Just maintain a minimum standard of sanity.
+ */
+ if (resp_len > sizeof(priv->resp_data)) {
+ dev_err(dev, "response too big: %d!\n", resp_len);
+ return -EOVERFLOW;
+ }
+ nr_bytes = resp_len;
+ }
+ resp_len = min(resp_len, nr_bytes);
+
+ spin_lock_irqsave(&priv->cmd_state_lock, flags);
+
+ /* Initialize the state machine */
+ init_completion(&priv->cmd_done);
+ priv->cmd_running = true;
+ priv->cmd_state = CMD_STATE_WAITING_FOR_SWITCH;
+ memset(&priv->cmd, 0, sizeof(priv->cmd));
+ priv->cmd.command = cmd;
+ priv->cmd.nr_args = inlen;
+ priv->cmd.data_len = 0;
+ memcpy(priv->cmd.args, inbuf, inlen);
+ priv->expected_resp_len = nr_bytes;
+ priv->resp_len = 0;
+
+ /* Tickle the cmd gpio to get things started */
+ gpiod_set_value_cansleep(priv->gpio_cmd, 1);
+
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+
+ /* The irq handler should do the rest */
+ if (!wait_for_completion_timeout(&priv->cmd_done,
+ msecs_to_jiffies(4000))) {
+ dev_err(dev, "EC cmd error: timeout in STATE %d\n",
+ priv->cmd_state);
+ gpiod_set_value_cansleep(priv->gpio_cmd, 0);
+ spi_slave_abort(priv->spi);
+ olpc_xo175_ec_read_packet(priv);
+ return -ETIMEDOUT;
+ }
+
+ spin_lock_irqsave(&priv->cmd_state_lock, flags);
+
+ /* Deal with the results. */
+ if (priv->cmd_state == CMD_STATE_ERROR_RECEIVED) {
+ /* EC-provided error is in the single response byte */
+ dev_err(dev, "command 0x%x returned error 0x%x\n",
+ cmd, priv->resp_data[0]);
+ ret = -EREMOTEIO;
+ } else if (priv->resp_len != nr_bytes) {
+ dev_err(dev, "command 0x%x returned %d bytes, expected %d bytes\n",
+ cmd, priv->resp_len, nr_bytes);
+ ret = -EREMOTEIO;
+ } else {
+ /*
+ * We may have 8 bytes in priv->resp, but we only care about
+ * what we've been asked for. If the caller asked for only 2
+ * bytes, give them that. We've guaranteed that
+ * resp_len <= priv->resp_len and priv->resp_len == nr_bytes.
+ */
+ memcpy(resp, priv->resp_data, resp_len);
+ }
+
+ /* This should already be low, but just in case. */
+ gpiod_set_value_cansleep(priv->gpio_cmd, 0);
+ priv->cmd_running = false;
+
+ spin_unlock_irqrestore(&priv->cmd_state_lock, flags);
+
+ return ret;
+}
+
+static int olpc_xo175_ec_set_event_mask(unsigned int mask)
+{
+ unsigned char args[2];
+
+ args[0] = (mask >> 0) & 0xff;
+ args[1] = (mask >> 8) & 0xff;
+ return olpc_ec_cmd(CMD_WRITE_EXT_SCI_MASK, args, 2, NULL, 0);
+}
+
+static void olpc_xo175_ec_restart(enum reboot_mode mode, const char *cmd)
+{
+ while (1) {
+ olpc_ec_cmd(CMD_POWER_CYCLE, NULL, 0, NULL, 0);
+ mdelay(1000);
+ }
+}
+
+static void olpc_xo175_ec_power_off(void)
+{
+ while (1) {
+ olpc_ec_cmd(CMD_POWER_OFF, NULL, 0, NULL, 0);
+ mdelay(1000);
+ }
+}
+
+static int __maybe_unused olpc_xo175_ec_suspend(struct device *dev)
+{
+ struct olpc_xo175_ec *priv = dev_get_drvdata(dev);
+ static struct {
+ u8 suspend;
+ u32 suspend_count;
+ } __packed hintargs;
+ static unsigned int suspend_count;
+
+ /*
+ * SOC_SLEEP is not wired to the EC on B3 and earlier boards.
+ * This command lets the EC know instead. The suspend count doesn't seem
+ * to be used anywhere but in the EC debug output.
+ */
+ hintargs.suspend = 1;
+ hintargs.suspend_count = suspend_count++;
+ olpc_ec_cmd(CMD_SUSPEND_HINT, (void *)&hintargs, sizeof(hintargs),
+ NULL, 0);
+
+ /*
+ * After we've sent the suspend hint, don't allow further EC commands
+ * to be run until we've resumed. Userspace tasks should be frozen,
+ * but kernel threads and interrupts could still schedule EC commands.
+ */
+ priv->suspended = true;
+
+ return 0;
+}
+
+static int __maybe_unused olpc_xo175_ec_resume_noirq(struct device *dev)
+{
+ struct olpc_xo175_ec *priv = dev_get_drvdata(dev);
+
+ priv->suspended = false;
+
+ return 0;
+}
+
+static int __maybe_unused olpc_xo175_ec_resume(struct device *dev)
+{
+ u8 x = 0;
+
+ /*
+ * The resume hint is only needed if no other commands are
+ * being sent during resume. all it does is tell the EC
+ * the SoC is definitely awake.
+ */
+ olpc_ec_cmd(CMD_SUSPEND_HINT, &x, 1, NULL, 0);
+
+ /* Enable all EC events while we're awake */
+ olpc_xo175_ec_set_event_mask(EC_ALL_EVENTS);
+
+ return 0;
+}
+
+static struct olpc_ec_driver olpc_xo175_ec_driver = {
+ .ec_cmd = olpc_xo175_ec_cmd,
+};
+
+static int olpc_xo175_ec_remove(struct spi_device *spi)
+{
+ if (pm_power_off == olpc_xo175_ec_power_off)
+ pm_power_off = NULL;
+ if (arm_pm_restart == olpc_xo175_ec_restart)
+ arm_pm_restart = NULL;
+
+ spi_slave_abort(spi);
+
+ platform_device_unregister(olpc_ec);
+ olpc_ec = NULL;
+
+ return 0;
+}
+
+static int olpc_xo175_ec_probe(struct spi_device *spi)
+{
+ struct olpc_xo175_ec *priv;
+ int ret;
+
+ if (olpc_ec) {
+ dev_err(&spi->dev, "OLPC EC already registered.\n");
+ return -EBUSY;
+ }
+
+ priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->gpio_cmd = devm_gpiod_get(&spi->dev, "cmd", GPIOD_OUT_LOW);
+ if (IS_ERR(priv->gpio_cmd)) {
+ dev_err(&spi->dev, "failed to get cmd gpio: %ld\n",
+ PTR_ERR(priv->gpio_cmd));
+ return PTR_ERR(priv->gpio_cmd);
+ }
+
+ priv->spi = spi;
+
+ spin_lock_init(&priv->cmd_state_lock);
+ priv->cmd_state = CMD_STATE_IDLE;
+ init_completion(&priv->cmd_done);
+
+ priv->logbuf_len = 0;
+
+ /* Set up power button input device */
+ priv->pwrbtn = devm_input_allocate_device(&spi->dev);
+ if (!priv->pwrbtn)
+ return -ENOMEM;
+ priv->pwrbtn->name = "Power Button";
+ priv->pwrbtn->dev.parent = &spi->dev;
+ input_set_capability(priv->pwrbtn, EV_KEY, KEY_POWER);
+ ret = input_register_device(priv->pwrbtn);
+ if (ret) {
+ dev_err(&spi->dev, "error registering input device: %d\n", ret);
+ return ret;
+ }
+
+ spi_set_drvdata(spi, priv);
+
+ priv->xfer.rx_buf = &priv->rx_buf;
+ priv->xfer.tx_buf = &priv->tx_buf;
+
+ olpc_xo175_ec_read_packet(priv);
+
+ olpc_ec_driver_register(&olpc_xo175_ec_driver, priv);
+ olpc_ec = platform_device_register_resndata(&spi->dev, "olpc-ec", -1,
+ NULL, 0, NULL, 0);
+
+ /* Enable all EC events while we're awake */
+ olpc_xo175_ec_set_event_mask(EC_ALL_EVENTS);
+
+ if (pm_power_off == NULL)
+ pm_power_off = olpc_xo175_ec_power_off;
+ if (arm_pm_restart == NULL)
+ arm_pm_restart = olpc_xo175_ec_restart;
+
+ dev_info(&spi->dev, "OLPC XO-1.75 Embedded Controller driver\n");
+
+ return 0;
+}
+
+static const struct dev_pm_ops olpc_xo175_ec_pm_ops = {
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(NULL, olpc_xo175_ec_resume_noirq)
+ SET_RUNTIME_PM_OPS(olpc_xo175_ec_suspend, olpc_xo175_ec_resume, NULL)
+};
+
+static const struct of_device_id olpc_xo175_ec_of_match[] = {
+ { .compatible = "olpc,xo1.75-ec" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, olpc_xo175_ec_of_match);
+
+static struct spi_driver olpc_xo175_ec_spi_driver = {
+ .driver = {
+ .name = "olpc-xo175-ec",
+ .of_match_table = olpc_xo175_ec_of_match,
+ .pm = &olpc_xo175_ec_pm_ops,
+ },
+ .probe = olpc_xo175_ec_probe,
+ .remove = olpc_xo175_ec_remove,
+};
+module_spi_driver(olpc_xo175_ec_spi_driver);
+
+MODULE_DESCRIPTION("OLPC XO-1.75 Embedded Controller driver");
+MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); /* Functionality */
+MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>"); /* Bugs */
+MODULE_LICENSE("GPL");
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 06/16] Platform: OLPC: Avoid a warning if the EC didn't register yet
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (4 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 05/16] Platform: OLPC: Add XO-1.75 EC driver Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 07/16] Platform: OLPC: Move EC-specific functionality out from x86 Lubomir Rintel
` (9 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
Just return EPROBE_DEFER, so that whoever attempted to use the EC call can
defer their work.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Changes since v2:
- Adjust the commit message for the s/ENODEV/EPROBE_DEFER/ change
Changes since v1:
- EPROBE_DEFER instead of ENODEV
drivers/platform/olpc/olpc-ec.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 35a21c66cd0d..9ee993d5d54b 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -116,8 +116,11 @@ 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;
- /* Ensure a driver and ec hook have been registered */
- if (WARN_ON(!ec_driver || !ec_driver->ec_cmd))
+ /* Driver not yet registered. */
+ if (!ec_driver)
+ return -EPROBE_DEFER;
+
+ if (WARN_ON(!ec_driver->ec_cmd))
return -ENODEV;
if (!ec)
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 07/16] Platform: OLPC: Move EC-specific functionality out from x86
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (5 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 06/16] Platform: OLPC: Avoid a warning if the EC didn't register yet Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-08 4:09 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 08/16] Platform: OLPC: Use BIT() and GENMASK() for event masks Lubomir Rintel
` (8 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
Move the olpc-ec driver away from the X86 OLPC platform so that it could be
used by the ARM based laptops too. Notably, the driver for the OLPC battery,
which is also used on the ARM models, builds on this driver's interface.
It is actually plaform independent: the OLPC EC commands with their argument
and responses are mostly the same despite the delivery mechanism is
different.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Changes since v1:
- Cosmetic changes in line wrapping.
- Remove an old extra copy of EC_SCI_* defines
- Change version to u8
- Explain which parts are platform independent are in the commit message
arch/x86/include/asm/olpc.h | 31 ---------
arch/x86/platform/olpc/olpc.c | 119 +++++---------------------------
drivers/platform/olpc/olpc-ec.c | 99 +++++++++++++++++++++++++-
include/linux/olpc-ec.h | 32 ++++++++-
4 files changed, 145 insertions(+), 136 deletions(-)
diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index c2bf1de5d901..6fe76282aceb 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -9,12 +9,10 @@
struct olpc_platform_t {
int flags;
uint32_t boardrev;
- int ecver;
};
#define OLPC_F_PRESENT 0x01
#define OLPC_F_DCON 0x02
-#define OLPC_F_EC_WIDE_SCI 0x04
#ifdef CONFIG_OLPC
@@ -64,13 +62,6 @@ static inline int olpc_board_at_least(uint32_t rev)
return olpc_platform_info.boardrev >= rev;
}
-extern void olpc_ec_wakeup_set(u16 value);
-extern void olpc_ec_wakeup_clear(u16 value);
-extern bool olpc_ec_wakeup_available(void);
-
-extern int olpc_ec_mask_write(u16 bits);
-extern int olpc_ec_sci_query(u16 *sci_value);
-
#else
static inline int machine_is_olpc(void)
@@ -83,14 +74,6 @@ static inline int olpc_has_dcon(void)
return 0;
}
-static inline void olpc_ec_wakeup_set(u16 value) { }
-static inline void olpc_ec_wakeup_clear(u16 value) { }
-
-static inline bool olpc_ec_wakeup_available(void)
-{
- return false;
-}
-
#endif
#ifdef CONFIG_OLPC_XO1_PM
@@ -101,20 +84,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value);
extern int pci_olpc_init(void);
-/* SCI source values */
-
-#define EC_SCI_SRC_EMPTY 0x00
-#define EC_SCI_SRC_GAME 0x01
-#define EC_SCI_SRC_BATTERY 0x02
-#define EC_SCI_SRC_BATSOC 0x04
-#define EC_SCI_SRC_BATERR 0x08
-#define EC_SCI_SRC_EBOOK 0x10 /* XO-1 only */
-#define EC_SCI_SRC_WLAN 0x20 /* XO-1 only */
-#define EC_SCI_SRC_ACPWR 0x40
-#define EC_SCI_SRC_BATCRIT 0x80
-#define EC_SCI_SRC_GPWAKE 0x100 /* XO-1.5 only */
-#define EC_SCI_SRC_ALL 0x1FF
-
/* GPIO assignments */
#define OLPC_GPIO_MIC_AC 1
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index f0e920fb98ad..c6c62b4f251f 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -30,9 +30,6 @@
struct olpc_platform_t olpc_platform_info;
EXPORT_SYMBOL_GPL(olpc_platform_info);
-/* EC event mask to be applied during suspend (defining wakeup sources). */
-static u16 ec_wakeup_mask;
-
/* what the timeout *should* be (in ms) */
#define EC_BASE_TIMEOUT 20
@@ -186,83 +183,6 @@ static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
return ret;
}
-void olpc_ec_wakeup_set(u16 value)
-{
- ec_wakeup_mask |= value;
-}
-EXPORT_SYMBOL_GPL(olpc_ec_wakeup_set);
-
-void olpc_ec_wakeup_clear(u16 value)
-{
- ec_wakeup_mask &= ~value;
-}
-EXPORT_SYMBOL_GPL(olpc_ec_wakeup_clear);
-
-/*
- * Returns true if the compile and runtime configurations allow for EC events
- * to wake the system.
- */
-bool olpc_ec_wakeup_available(void)
-{
- if (!machine_is_olpc())
- return false;
-
- /*
- * XO-1 EC wakeups are available when olpc-xo1-sci driver is
- * compiled in
- */
-#ifdef CONFIG_OLPC_XO1_SCI
- if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) /* XO-1 */
- return true;
-#endif
-
- /*
- * XO-1.5 EC wakeups are available when olpc-xo15-sci driver is
- * compiled in
- */
-#ifdef CONFIG_OLPC_XO15_SCI
- if (olpc_platform_info.boardrev >= olpc_board_pre(0xd0)) /* XO-1.5 */
- return true;
-#endif
-
- return false;
-}
-EXPORT_SYMBOL_GPL(olpc_ec_wakeup_available);
-
-int olpc_ec_mask_write(u16 bits)
-{
- if (olpc_platform_info.flags & OLPC_F_EC_WIDE_SCI) {
- __be16 ec_word = cpu_to_be16(bits);
- return olpc_ec_cmd(EC_WRITE_EXT_SCI_MASK, (void *) &ec_word, 2,
- NULL, 0);
- } else {
- unsigned char ec_byte = bits & 0xff;
- return olpc_ec_cmd(EC_WRITE_SCI_MASK, &ec_byte, 1, NULL, 0);
- }
-}
-EXPORT_SYMBOL_GPL(olpc_ec_mask_write);
-
-int olpc_ec_sci_query(u16 *sci_value)
-{
- int ret;
-
- if (olpc_platform_info.flags & OLPC_F_EC_WIDE_SCI) {
- __be16 ec_word;
- ret = olpc_ec_cmd(EC_EXT_SCI_QUERY,
- NULL, 0, (void *) &ec_word, 2);
- if (ret == 0)
- *sci_value = be16_to_cpu(ec_word);
- } else {
- unsigned char ec_byte;
- ret = olpc_ec_cmd(EC_SCI_QUERY, NULL, 0, &ec_byte, 1);
- if (ret == 0)
- *sci_value = ec_byte;
- }
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
-
static bool __init check_ofw_architecture(struct device_node *root)
{
const char *olpc_arch;
@@ -296,6 +216,10 @@ static bool __init platform_detect(void)
if (success) {
olpc_platform_info.boardrev = get_board_revision(root);
olpc_platform_info.flags |= OLPC_F_PRESENT;
+
+ pr_info("OLPC board revision %s%X\n",
+ ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
+ olpc_platform_info.boardrev >> 4);
}
of_node_put(root);
@@ -315,27 +239,8 @@ static int __init add_xo1_platform_devices(void)
return PTR_ERR_OR_ZERO(pdev);
}
-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 int olpc_xo1_ec_suspend(struct platform_device *pdev)
{
- olpc_ec_mask_write(ec_wakeup_mask);
-
/*
* Squelch SCIs while suspended. This is a fix for
* <http://dev.laptop.org/ticket/1835>.
@@ -359,15 +264,27 @@ static int olpc_xo1_ec_resume(struct platform_device *pdev)
}
static struct olpc_ec_driver ec_xo1_driver = {
- .probe = olpc_xo1_ec_probe,
.suspend = olpc_xo1_ec_suspend,
.resume = olpc_xo1_ec_resume,
.ec_cmd = olpc_xo1_ec_cmd,
+#ifdef CONFIG_OLPC_XO1_SCI
+ /*
+ * XO-1 EC wakeups are available when olpc-xo1-sci driver is
+ * compiled in
+ */
+ .wakeup_available = true,
+#endif
};
static struct olpc_ec_driver ec_xo1_5_driver = {
- .probe = olpc_xo1_ec_probe,
.ec_cmd = olpc_xo1_ec_cmd,
+#ifdef CONFIG_OLPC_XO1_5_SCI
+ /*
+ * XO-1.5 EC wakeups are available when olpc-xo15-sci driver is
+ * compiled in
+ */
+ .wakeup_available = true,
+#endif
};
static int __init olpc_init(void)
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 9ee993d5d54b..2b80174b8f4b 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -30,6 +30,7 @@ struct ec_cmd_desc {
struct olpc_ec_priv {
struct olpc_ec_driver *drv;
+ u8 version;
struct work_struct worker;
struct mutex cmd_lock;
@@ -39,6 +40,12 @@ struct olpc_ec_priv {
struct dentry *dbgfs_dir;
+ /*
+ * EC event mask to be applied during suspend (defining wakeup
+ * sources).
+ */
+ u16 ec_wakeup_mask;
+
/*
* Running an EC command while suspending means we don't always finish
* the command before the machine suspends. This means that the EC
@@ -150,6 +157,88 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
}
EXPORT_SYMBOL_GPL(olpc_ec_cmd);
+void olpc_ec_wakeup_set(u16 value)
+{
+ struct olpc_ec_priv *ec = ec_priv;
+
+ if (WARN_ON(!ec))
+ return;
+
+ ec->ec_wakeup_mask |= value;
+}
+EXPORT_SYMBOL_GPL(olpc_ec_wakeup_set);
+
+void olpc_ec_wakeup_clear(u16 value)
+{
+ struct olpc_ec_priv *ec = ec_priv;
+
+ if (WARN_ON(!ec))
+ return;
+
+ ec->ec_wakeup_mask &= ~value;
+}
+EXPORT_SYMBOL_GPL(olpc_ec_wakeup_clear);
+
+int olpc_ec_mask_write(u16 bits)
+{
+ struct olpc_ec_priv *ec = ec_priv;
+
+ if (WARN_ON(!ec))
+ return -ENODEV;
+
+ /* EC version 0x5f adds support for wide SCI mask */
+ if (ec->version >= 0x5f) {
+ __be16 ec_word = cpu_to_be16(bits);
+
+ return olpc_ec_cmd(EC_WRITE_EXT_SCI_MASK, (void *) &ec_word, 2, NULL, 0);
+ } else {
+ unsigned char ec_byte = bits & 0xff;
+
+ return olpc_ec_cmd(EC_WRITE_SCI_MASK, &ec_byte, 1, NULL, 0);
+ }
+}
+EXPORT_SYMBOL_GPL(olpc_ec_mask_write);
+
+/*
+ * Returns true if the compile and runtime configurations allow for EC events
+ * to wake the system.
+ */
+bool olpc_ec_wakeup_available(void)
+{
+ if (WARN_ON(!ec_driver))
+ return false;
+
+ return ec_driver->wakeup_available;
+}
+EXPORT_SYMBOL_GPL(olpc_ec_wakeup_available);
+
+int olpc_ec_sci_query(u16 *sci_value)
+{
+ struct olpc_ec_priv *ec = ec_priv;
+ int ret;
+
+ if (WARN_ON(!ec))
+ return -ENODEV;
+
+ /* EC version 0x5f adds support for wide SCI mask */
+ if (ec->version >= 0x5f) {
+ __be16 ec_word;
+
+ ret = olpc_ec_cmd(EC_EXT_SCI_QUERY, NULL, 0, (void *)&ec_word, 2);
+ if (ret == 0)
+ *sci_value = be16_to_cpu(ec_word);
+ } else {
+ unsigned char ec_byte;
+
+ ret = olpc_ec_cmd(EC_SCI_QUERY, NULL, 0, &ec_byte, 1);
+ if (ret == 0)
+ *sci_value = ec_byte;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
+
#ifdef CONFIG_DEBUG_FS
/*
@@ -277,14 +366,16 @@ static int olpc_ec_probe(struct platform_device *pdev)
ec_priv = ec;
platform_set_drvdata(pdev, ec);
- err = ec_driver->probe ? ec_driver->probe(pdev) : 0;
+ /* get the EC revision */
+ err = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ec->version, 1);
if (err) {
ec_priv = NULL;
kfree(ec);
- } else {
- ec->dbgfs_dir = olpc_ec_setup_debugfs();
+ return err;
}
+ ec->dbgfs_dir = olpc_ec_setup_debugfs();
+
return err;
}
@@ -294,6 +385,8 @@ static int olpc_ec_suspend(struct device *dev)
struct olpc_ec_priv *ec = platform_get_drvdata(pdev);
int err = 0;
+ olpc_ec_mask_write(ec->ec_wakeup_mask);
+
if (ec_driver->suspend)
err = ec_driver->suspend(pdev);
if (!err)
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
index 79bdc6328c52..7fa3d27f7fee 100644
--- a/include/linux/olpc-ec.h
+++ b/include/linux/olpc-ec.h
@@ -16,14 +16,28 @@
#define EC_SCI_QUERY 0x84
#define EC_EXT_SCI_QUERY 0x85
+/* SCI source values */
+#define EC_SCI_SRC_EMPTY 0x00
+#define EC_SCI_SRC_GAME 0x01
+#define EC_SCI_SRC_BATTERY 0x02
+#define EC_SCI_SRC_BATSOC 0x04
+#define EC_SCI_SRC_BATERR 0x08
+#define EC_SCI_SRC_EBOOK 0x10 /* XO-1 only */
+#define EC_SCI_SRC_WLAN 0x20 /* XO-1 only */
+#define EC_SCI_SRC_ACPWR 0x40
+#define EC_SCI_SRC_BATCRIT 0x80
+#define EC_SCI_SRC_GPWAKE 0x100 /* XO-1.5 only */
+#define EC_SCI_SRC_ALL 0x1FF
+
struct platform_device;
struct olpc_ec_driver {
- int (*probe)(struct platform_device *);
int (*suspend)(struct platform_device *);
int (*resume)(struct platform_device *);
int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
+
+ bool wakeup_available;
};
#ifdef CONFIG_OLPC
@@ -33,11 +47,27 @@ extern void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg);
extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
size_t outlen);
+extern void olpc_ec_wakeup_set(u16 value);
+extern void olpc_ec_wakeup_clear(u16 value);
+
+extern int olpc_ec_mask_write(u16 bits);
+extern int olpc_ec_sci_query(u16 *sci_value);
+
+extern bool olpc_ec_wakeup_available(void);
+
#else
static inline int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
size_t outlen) { return -ENODEV; }
+static inline void olpc_ec_wakeup_set(u16 value) { }
+static inline void olpc_ec_wakeup_clear(u16 value) { }
+
+static inline bool olpc_ec_wakeup_available(void)
+{
+ return false;
+}
+
#endif /* CONFIG_OLPC */
#endif /* _LINUX_OLPC_EC_H */
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 08/16] Platform: OLPC: Use BIT() and GENMASK() for event masks
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (6 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 07/16] Platform: OLPC: Move EC-specific functionality out from x86 Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 09/16] Platform: OLPC: add a regulator for the DCON Lubomir Rintel
` (7 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
Just a cosmetic tidy-up.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
Changes since v1:
- This patch was added to the set.
include/linux/olpc-ec.h | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
index 7fa3d27f7fee..f7b6a7eda232 100644
--- a/include/linux/olpc-ec.h
+++ b/include/linux/olpc-ec.h
@@ -2,6 +2,8 @@
#ifndef _LINUX_OLPC_EC_H
#define _LINUX_OLPC_EC_H
+#include <linux/bits.h>
+
/* XO-1 EC commands */
#define EC_FIRMWARE_REV 0x08
#define EC_WRITE_SCI_MASK 0x1b
@@ -17,17 +19,16 @@
#define EC_EXT_SCI_QUERY 0x85
/* SCI source values */
-#define EC_SCI_SRC_EMPTY 0x00
-#define EC_SCI_SRC_GAME 0x01
-#define EC_SCI_SRC_BATTERY 0x02
-#define EC_SCI_SRC_BATSOC 0x04
-#define EC_SCI_SRC_BATERR 0x08
-#define EC_SCI_SRC_EBOOK 0x10 /* XO-1 only */
-#define EC_SCI_SRC_WLAN 0x20 /* XO-1 only */
-#define EC_SCI_SRC_ACPWR 0x40
-#define EC_SCI_SRC_BATCRIT 0x80
-#define EC_SCI_SRC_GPWAKE 0x100 /* XO-1.5 only */
-#define EC_SCI_SRC_ALL 0x1FF
+#define EC_SCI_SRC_GAME BIT(0)
+#define EC_SCI_SRC_BATTERY BIT(1)
+#define EC_SCI_SRC_BATSOC BIT(2)
+#define EC_SCI_SRC_BATERR BIT(3)
+#define EC_SCI_SRC_EBOOK BIT(4) /* XO-1 only */
+#define EC_SCI_SRC_WLAN BIT(5) /* XO-1 only */
+#define EC_SCI_SRC_ACPWR BIT(6)
+#define EC_SCI_SRC_BATCRIT BIT(7)
+#define EC_SCI_SRC_GPWAKE BIT(8) /* XO-1.5 only */
+#define EC_SCI_SRC_ALL GENMASK(8, 0)
struct platform_device;
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 09/16] Platform: OLPC: add a regulator for the DCON
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (7 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 08/16] Platform: OLPC: Use BIT() and GENMASK() for event masks Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 10/16] dt-bindings: olpc_battery: Add XO-1.5 battery Lubomir Rintel
` (6 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
All OLPC ECs are able to turn the power to the DCON on an off. Use the
regulator framework to expose the functionality.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
Changes since v1:
- Use idiomatic form of return on error
- Avoid mixing bool and int
drivers/platform/olpc/Kconfig | 1 +
drivers/platform/olpc/olpc-ec.c | 67 +++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/drivers/platform/olpc/Kconfig b/drivers/platform/olpc/Kconfig
index 7c643d24ad0f..c5a872fb286f 100644
--- a/drivers/platform/olpc/Kconfig
+++ b/drivers/platform/olpc/Kconfig
@@ -6,6 +6,7 @@ config OLPC
select OF
select OF_PROMTREE if X86
select IRQ_DOMAIN
+ select REGULATOR
help
Add support for detecting the unique features of the OLPC
XO hardware.
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 2b80174b8f4b..f725ab2a2db9 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -14,6 +14,7 @@
#include <linux/workqueue.h>
#include <linux/module.h>
#include <linux/list.h>
+#include <linux/regulator/driver.h>
#include <linux/olpc-ec.h>
struct ec_cmd_desc {
@@ -34,6 +35,10 @@ struct olpc_ec_priv {
struct work_struct worker;
struct mutex cmd_lock;
+ /* DCON regulator */
+ struct regulator_dev *dcon_rdev;
+ bool dcon_enabled;
+
/* Pending EC commands */
struct list_head cmd_q;
spinlock_t cmd_q_lock;
@@ -344,9 +349,61 @@ static struct dentry *olpc_ec_setup_debugfs(void)
#endif /* CONFIG_DEBUG_FS */
+static int olpc_ec_set_dcon_power(struct olpc_ec_priv *ec, bool state)
+{
+ unsigned char ec_byte = state;
+ int ret;
+
+ if (ec->dcon_enabled == state)
+ return 0;
+
+ ret = olpc_ec_cmd(EC_DCON_POWER_MODE, &ec_byte, 1, NULL, 0);
+ if (ret)
+ return ret;
+
+ ec->dcon_enabled = state;
+ return 0;
+}
+
+static int dcon_regulator_enable(struct regulator_dev *rdev)
+{
+ struct olpc_ec_priv *ec = rdev_get_drvdata(rdev);
+
+ return olpc_ec_set_dcon_power(ec, true);
+}
+
+static int dcon_regulator_disable(struct regulator_dev *rdev)
+{
+ struct olpc_ec_priv *ec = rdev_get_drvdata(rdev);
+
+ return olpc_ec_set_dcon_power(ec, false);
+}
+
+static int dcon_regulator_is_enabled(struct regulator_dev *rdev)
+{
+ struct olpc_ec_priv *ec = rdev_get_drvdata(rdev);
+
+ return ec->dcon_enabled ? 1 : 0;
+}
+
+static struct regulator_ops dcon_regulator_ops = {
+ .enable = dcon_regulator_enable,
+ .disable = dcon_regulator_disable,
+ .is_enabled = dcon_regulator_is_enabled,
+};
+
+static const struct regulator_desc dcon_desc = {
+ .name = "dcon",
+ .id = 0,
+ .ops = &dcon_regulator_ops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+};
+
static int olpc_ec_probe(struct platform_device *pdev)
{
struct olpc_ec_priv *ec;
+ struct regulator_config config = { };
int err;
if (!ec_driver)
@@ -374,6 +431,16 @@ static int olpc_ec_probe(struct platform_device *pdev)
return err;
}
+ config.dev = pdev->dev.parent;
+ config.driver_data = ec;
+ ec->dcon_enabled = true;
+ ec->dcon_rdev = devm_regulator_register(&pdev->dev, &dcon_desc,
+ &config);
+ if (IS_ERR(ec->dcon_rdev)) {
+ dev_err(&pdev->dev, "failed to register DCON regulator\n");
+ return PTR_ERR(ec->dcon_rdev);
+ }
+
ec->dbgfs_dir = olpc_ec_setup_debugfs();
return err;
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 10/16] dt-bindings: olpc_battery: Add XO-1.5 battery
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (8 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 09/16] Platform: OLPC: add a regulator for the DCON Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 11/16] x86, olpc: Use a correct version when making up a battery node Lubomir Rintel
` (5 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel, Rob Herring, Sebastian Reichel
The XO-1 and XO-1.5 batteries apparently differ in an ability to report
ambient temperature.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
Changes since v1:
- Collected Reviewed-by and Acked-by tags
Documentation/devicetree/bindings/power/supply/olpc_battery.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/power/supply/olpc_battery.txt b/Documentation/devicetree/bindings/power/supply/olpc_battery.txt
index c8901b3992d9..8d87d6b35a98 100644
--- a/Documentation/devicetree/bindings/power/supply/olpc_battery.txt
+++ b/Documentation/devicetree/bindings/power/supply/olpc_battery.txt
@@ -2,4 +2,4 @@ OLPC battery
~~~~~~~~~~~~
Required properties:
- - compatible : "olpc,xo1-battery"
+ - compatible : "olpc,xo1-battery" or "olpc,xo1.5-battery"
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 11/16] x86, olpc: Use a correct version when making up a battery node
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (9 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 10/16] dt-bindings: olpc_battery: Add XO-1.5 battery Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 12/16] power: supply: olpc_battery: Use DT to get battery version Lubomir Rintel
` (4 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
The XO-1 and XO-1.5 batteries apparently differ in an ability to report
ambient temperature. Add a different compatible string to the 1.5
battery.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Changes since v1:
- Avoid splitting string literals
arch/x86/platform/olpc/olpc_dt.c | 84 +++++++++++++++++++++-----------
1 file changed, 56 insertions(+), 28 deletions(-)
diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
index b4ab779f1d47..8557add82752 100644
--- a/arch/x86/platform/olpc/olpc_dt.c
+++ b/arch/x86/platform/olpc/olpc_dt.c
@@ -217,10 +217,28 @@ static u32 __init olpc_dt_get_board_revision(void)
return be32_to_cpu(rev);
}
-void __init olpc_dt_fixup(void)
+int olpc_dt_compatible_match(phandle node, const char *compat)
{
- int r;
char buf[64];
+ int plen;
+ char *p;
+ int len;
+
+ plen = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf));
+ if (plen <= 0)
+ return 0;
+
+ len = strlen(compat);
+ for (p = buf; p < buf + plen; p += strlen(p) + 1) {
+ if (strcmp(p, compat) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+void __init olpc_dt_fixup(void)
+{
phandle node;
u32 board_rev;
@@ -228,41 +246,51 @@ void __init olpc_dt_fixup(void)
if (!node)
return;
- /*
- * If the battery node has a compatible property, we are running a new
- * enough firmware and don't have fixups to make.
- */
- r = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf));
- if (r > 0)
- return;
-
- pr_info("PROM DT: Old firmware detected, applying fixes\n");
-
- /* Add olpc,xo1-battery compatible marker to battery node */
- olpc_dt_interpret("\" /battery@0\" find-device"
- " \" olpc,xo1-battery\" +compatible"
- " device-end");
-
board_rev = olpc_dt_get_board_revision();
if (!board_rev)
return;
if (board_rev >= olpc_board_pre(0xd0)) {
+ if (olpc_dt_compatible_match(node, "olpc,xo1.5-battery"))
+ return;
+
+ /* Add olpc,xo1.5-battery compatible marker to battery node */
+ olpc_dt_interpret("\" /battery@0\" find-device");
+ olpc_dt_interpret(" \" olpc,xo1.5-battery\" +compatible");
+ olpc_dt_interpret("device-end");
+
+ /* We're running a very old firmware if this is missing. */
+ if (olpc_dt_compatible_match(node, "olpc,xo1-battery"))
+ return;
+
/* XO-1.5: add dcon device */
- olpc_dt_interpret("\" /pci/display@1\" find-device"
- " new-device"
- " \" dcon\" device-name \" olpc,xo1-dcon\" +compatible"
- " finish-device device-end");
+ olpc_dt_interpret("\" /pci/display@1\" find-device");
+ olpc_dt_interpret(" new-device");
+ olpc_dt_interpret(" \" dcon\" device-name");
+ olpc_dt_interpret(" \" olpc,xo1-dcon\" +compatible");
+ olpc_dt_interpret(" finish-device");
+ olpc_dt_interpret("device-end");
} else {
+ /* We're running a very old firmware if this is missing. */
+ if (olpc_dt_compatible_match(node, "olpc,xo1-battery"))
+ return;
+
/* XO-1: add dcon device, mark RTC as olpc,xo1-rtc */
- olpc_dt_interpret("\" /pci/display@1,1\" find-device"
- " new-device"
- " \" dcon\" device-name \" olpc,xo1-dcon\" +compatible"
- " finish-device device-end"
- " \" /rtc\" find-device"
- " \" olpc,xo1-rtc\" +compatible"
- " device-end");
+ olpc_dt_interpret("\" /pci/display@1,1\" find-device");
+ olpc_dt_interpret(" new-device");
+ olpc_dt_interpret(" \" dcon\" device-name");
+ olpc_dt_interpret(" \" olpc,xo1-dcon\" +compatible");
+ olpc_dt_interpret(" finish-device");
+ olpc_dt_interpret("device-end");
+ olpc_dt_interpret("\" /rtc\" find-device");
+ olpc_dt_interpret(" \" olpc,xo1-rtc\" +compatible");
+ olpc_dt_interpret("device-end");
}
+
+ /* Add olpc,xo1-battery compatible marker to battery node */
+ olpc_dt_interpret("\" /battery@0\" find-device");
+ olpc_dt_interpret(" \" olpc,xo1-battery\" +compatible");
+ olpc_dt_interpret("device-end");
}
void __init olpc_dt_build_devicetree(void)
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 12/16] power: supply: olpc_battery: Use DT to get battery version
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (10 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 11/16] x86, olpc: Use a correct version when making up a battery node Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 13/16] power: supply: olpc_battery: Move priv data to a struct Lubomir Rintel
` (3 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel, Andy Shevchenko, Sebastian Reichel
Avoid using the x86 OLPC platform specific call to get the board
version. That wouldn't work on FDT-based ARM MMP2 platform.
Add the XO 1.5 compatible string too. This is actually not completely
necessary as the battery nodes on XO 1.5 claim to be compatible with
"olpc,xo1-battery", but there are, in fact, differencies.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
Changes since v2:
- Clarify the XO 1 compatibility in the commit message.
Changes since v1:
- Sort the new include a bit higher
drivers/power/supply/olpc_battery.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index 5a97e42a3547..5323987d9284 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -14,6 +14,7 @@
#include <linux/types.h>
#include <linux/err.h>
#include <linux/device.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/jiffies.h>
@@ -622,11 +623,13 @@ static int olpc_battery_probe(struct platform_device *pdev)
olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, NULL);
if (IS_ERR(olpc_ac))
return PTR_ERR(olpc_ac);
-
- if (olpc_board_at_least(olpc_board_pre(0xd0))) { /* XO-1.5 */
+ if (of_property_match_string(pdev->dev.of_node, "compatible",
+ "olpc,xo1.5-battery") >= 0) {
+ /* XO-1.5 */
olpc_bat_desc.properties = olpc_xo15_bat_props;
olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props);
- } else { /* XO-1 */
+ } else {
+ /* XO-1 */
olpc_bat_desc.properties = olpc_xo1_bat_props;
olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
}
@@ -672,6 +675,7 @@ static int olpc_battery_remove(struct platform_device *pdev)
static const struct of_device_id olpc_battery_ids[] = {
{ .compatible = "olpc,xo1-battery" },
+ { .compatible = "olpc,xo1.5-battery" },
{}
};
MODULE_DEVICE_TABLE(of, olpc_battery_ids);
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 13/16] power: supply: olpc_battery: Move priv data to a struct
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (11 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 12/16] power: supply: olpc_battery: Use DT to get battery version Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 14/16] power: supply: olpc_battery: Use devm_power_supply_register() Lubomir Rintel
` (2 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel, Andy Shevchenko
The global variables for private data are not too nice. I'd like some
more, and that would clutter the global name space even further.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
Changes since v2:
- Bring the allocaton of the priv data structure here
Changes since v1:
- Split out the move to devm_* into a separate patch
drivers/power/supply/olpc_battery.c | 73 ++++++++++++++++++-----------
1 file changed, 45 insertions(+), 28 deletions(-)
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index 5323987d9284..c024aae01cb1 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -53,6 +53,12 @@
#define BAT_ADDR_MFR_TYPE 0x5F
+struct olpc_battery_data {
+ struct power_supply *olpc_ac;
+ struct power_supply *olpc_bat;
+ char bat_serial[17];
+};
+
/*********************************************************************
* Power
*********************************************************************/
@@ -91,11 +97,8 @@ static const struct power_supply_desc olpc_ac_desc = {
.get_property = olpc_ac_get_prop,
};
-static struct power_supply *olpc_ac;
-
-static char bat_serial[17]; /* Ick */
-
-static int olpc_bat_get_status(union power_supply_propval *val, uint8_t ec_byte)
+static int olpc_bat_get_status(struct olpc_battery_data *data,
+ union power_supply_propval *val, uint8_t ec_byte)
{
if (olpc_platform_info.ecver > 0x44) {
if (ec_byte & (BAT_STAT_CHARGING | BAT_STAT_TRICKLE))
@@ -326,6 +329,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
+ struct olpc_battery_data *data = power_supply_get_drvdata(psy);
int ret = 0;
__be16 ec_word;
uint8_t ec_byte;
@@ -347,7 +351,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
- ret = olpc_bat_get_status(val, ec_byte);
+ ret = olpc_bat_get_status(data, val, ec_byte);
if (ret)
return ret;
break;
@@ -450,8 +454,8 @@ static int olpc_bat_get_property(struct power_supply *psy,
if (ret)
return ret;
- sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf));
- val->strval = bat_serial;
+ sprintf(data->bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf));
+ val->strval = data->bat_serial;
break;
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
ret = olpc_bat_get_voltage_max_design(val);
@@ -579,17 +583,17 @@ static struct power_supply_desc olpc_bat_desc = {
.use_for_apm = 1,
};
-static struct power_supply *olpc_bat;
-
static int olpc_battery_suspend(struct platform_device *pdev,
pm_message_t state)
{
- if (device_may_wakeup(&olpc_ac->dev))
+ struct olpc_battery_data *data = platform_get_drvdata(pdev);
+
+ if (device_may_wakeup(&data->olpc_ac->dev))
olpc_ec_wakeup_set(EC_SCI_SRC_ACPWR);
else
olpc_ec_wakeup_clear(EC_SCI_SRC_ACPWR);
- if (device_may_wakeup(&olpc_bat->dev))
+ if (device_may_wakeup(&data->olpc_bat->dev))
olpc_ec_wakeup_set(EC_SCI_SRC_BATTERY | EC_SCI_SRC_BATSOC
| EC_SCI_SRC_BATERR);
else
@@ -601,9 +605,15 @@ static int olpc_battery_suspend(struct platform_device *pdev,
static int olpc_battery_probe(struct platform_device *pdev)
{
- int ret;
+ struct power_supply_config psy_cfg = {};
+ struct olpc_battery_data *data;
uint8_t status;
+ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+ platform_set_drvdata(pdev, data);
+
/*
* We've seen a number of EC protocol changes; this driver requires
* the latest EC protocol, supported by 0x44 and above.
@@ -620,9 +630,13 @@ static int olpc_battery_probe(struct platform_device *pdev)
/* Ignore the status. It doesn't actually matter */
- olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, NULL);
- if (IS_ERR(olpc_ac))
- return PTR_ERR(olpc_ac);
+ psy_cfg.of_node = pdev->dev.of_node;
+ psy_cfg.drv_data = data;
+
+ data->olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg);
+ if (IS_ERR(data->olpc_ac))
+ return PTR_ERR(data->olpc_ac);
+
if (of_property_match_string(pdev->dev.of_node, "compatible",
"olpc,xo1.5-battery") >= 0) {
/* XO-1.5 */
@@ -634,42 +648,45 @@ static int olpc_battery_probe(struct platform_device *pdev)
olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
}
- olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, NULL);
+ data->olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg);
if (IS_ERR(olpc_bat)) {
ret = PTR_ERR(olpc_bat);
goto battery_failed;
}
- ret = device_create_bin_file(&olpc_bat->dev, &olpc_bat_eeprom);
+ ret = device_create_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom);
if (ret)
goto eeprom_failed;
- ret = device_create_file(&olpc_bat->dev, &olpc_bat_error);
+ ret = device_create_file(&data->olpc_bat->dev, &olpc_bat_error);
if (ret)
goto error_failed;
if (olpc_ec_wakeup_available()) {
- device_set_wakeup_capable(&olpc_ac->dev, true);
- device_set_wakeup_capable(&olpc_bat->dev, true);
+ device_set_wakeup_capable(&data->olpc_ac->dev, true);
+ device_set_wakeup_capable(&data->olpc_bat->dev, true);
}
return 0;
error_failed:
- device_remove_bin_file(&olpc_bat->dev, &olpc_bat_eeprom);
+ device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom);
eeprom_failed:
- power_supply_unregister(olpc_bat);
+ power_supply_unregister(data->olpc_bat);
battery_failed:
- power_supply_unregister(olpc_ac);
+ power_supply_unregister(data->olpc_ac);
return ret;
}
static int olpc_battery_remove(struct platform_device *pdev)
{
- device_remove_file(&olpc_bat->dev, &olpc_bat_error);
- device_remove_bin_file(&olpc_bat->dev, &olpc_bat_eeprom);
- power_supply_unregister(olpc_bat);
- power_supply_unregister(olpc_ac);
+ struct olpc_battery_data *data = platform_get_drvdata(pdev);
+
+ device_remove_file(&data->olpc_bat->dev, &olpc_bat_error);
+ device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom);
+ power_supply_unregister(data->olpc_bat);
+ power_supply_unregister(data->olpc_ac);
+
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 14/16] power: supply: olpc_battery: Use devm_power_supply_register()
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (12 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 13/16] power: supply: olpc_battery: Move priv data to a struct Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 15/16] power: supply: olpc_battery: Avoid using platform_info Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 16/16] power: supply: olpc_battery: Add OLPC XO 1.75 support Lubomir Rintel
15 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel, Sebastian Reichel
This simplifies the error handling.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
Changes since v1:
- This was split off the "power: supply: olpc_battery: Move priv data to
a struct" patch.
drivers/power/supply/olpc_battery.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index c024aae01cb1..0c9f7ce6b26b 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -633,7 +633,7 @@ static int olpc_battery_probe(struct platform_device *pdev)
psy_cfg.of_node = pdev->dev.of_node;
psy_cfg.drv_data = data;
- data->olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg);
+ data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg);
if (IS_ERR(data->olpc_ac))
return PTR_ERR(data->olpc_ac);
@@ -648,15 +648,13 @@ static int olpc_battery_probe(struct platform_device *pdev)
olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
}
- data->olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg);
- if (IS_ERR(olpc_bat)) {
- ret = PTR_ERR(olpc_bat);
- goto battery_failed;
- }
+ data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg);
+ if (IS_ERR(data->olpc_bat))
+ return PTR_ERR(data->olpc_bat);
ret = device_create_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom);
if (ret)
- goto eeprom_failed;
+ return ret;
ret = device_create_file(&data->olpc_bat->dev, &olpc_bat_error);
if (ret)
@@ -671,10 +669,6 @@ static int olpc_battery_probe(struct platform_device *pdev)
error_failed:
device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom);
-eeprom_failed:
- power_supply_unregister(data->olpc_bat);
-battery_failed:
- power_supply_unregister(data->olpc_ac);
return ret;
}
@@ -684,9 +678,6 @@ static int olpc_battery_remove(struct platform_device *pdev)
device_remove_file(&data->olpc_bat->dev, &olpc_bat_error);
device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom);
- power_supply_unregister(data->olpc_bat);
- power_supply_unregister(data->olpc_ac);
-
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 15/16] power: supply: olpc_battery: Avoid using platform_info
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (13 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 14/16] power: supply: olpc_battery: Use devm_power_supply_register() Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-08 5:54 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 16/16] power: supply: olpc_battery: Add OLPC XO 1.75 support Lubomir Rintel
15 siblings, 1 reply; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel, Sebastian Reichel
This wouldn't work on the DT-based ARM platform. Let's read the EC version
directly from the EC driver instead.
This makes the driver no longer x86 specific.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
Changes since v2:
- Move the priv data allocation hunk from this patch to a proper place
Changes since v1:
- Use uint8_t instead of unsigned char [1] for ecver
drivers/power/supply/Kconfig | 2 +-
drivers/power/supply/olpc_battery.c | 27 ++++++++++++++++++---------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index e901b9879e7e..67a3bb26da39 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -151,7 +151,7 @@ config BATTERY_PMU
config BATTERY_OLPC
tristate "One Laptop Per Child battery"
- depends on X86_32 && OLPC
+ depends on OLPC
help
Say Y to enable support for the battery on the OLPC laptop.
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index 0c9f7ce6b26b..8ebb4284cf05 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -20,8 +20,6 @@
#include <linux/jiffies.h>
#include <linux/sched.h>
#include <linux/olpc-ec.h>
-#include <asm/olpc.h>
-
#define EC_BAT_VOLTAGE 0x10 /* uint16_t, *9.76/32, mV */
#define EC_BAT_CURRENT 0x11 /* int16_t, *15.625/120, mA */
@@ -57,6 +55,7 @@ struct olpc_battery_data {
struct power_supply *olpc_ac;
struct power_supply *olpc_bat;
char bat_serial[17];
+ int new_proto;
};
/*********************************************************************
@@ -100,7 +99,7 @@ static const struct power_supply_desc olpc_ac_desc = {
static int olpc_bat_get_status(struct olpc_battery_data *data,
union power_supply_propval *val, uint8_t ec_byte)
{
- if (olpc_platform_info.ecver > 0x44) {
+ if (data->new_proto) {
if (ec_byte & (BAT_STAT_CHARGING | BAT_STAT_TRICKLE))
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else if (ec_byte & BAT_STAT_DISCHARGING)
@@ -608,19 +607,29 @@ static int olpc_battery_probe(struct platform_device *pdev)
struct power_supply_config psy_cfg = {};
struct olpc_battery_data *data;
uint8_t status;
+ uint8_t ecver;
+ int ret;
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
platform_set_drvdata(pdev, data);
- /*
- * We've seen a number of EC protocol changes; this driver requires
- * the latest EC protocol, supported by 0x44 and above.
- */
- if (olpc_platform_info.ecver < 0x44) {
+ /* See if the EC is already there and get the EC revision */
+ ret = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ecver, 1);
+ if (ret)
+ return ret;
+
+ if (ecver > 0x44) {
+ /* XO 1 or 1.5 with a new EC firmware. */
+ data->new_proto = 1;
+ } else if (ecver < 0x44) {
+ /*
+ * We've seen a number of EC protocol changes; this driver
+ * requires the latest EC protocol, supported by 0x44 and above.
+ */
printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
- "battery driver.\n", olpc_platform_info.ecver);
+ "battery driver.\n", ecver);
return -ENXIO;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 16/16] power: supply: olpc_battery: Add OLPC XO 1.75 support
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
` (14 preceding siblings ...)
2019-01-07 18:34 ` [PATCH v3 15/16] power: supply: olpc_battery: Avoid using platform_info Lubomir Rintel
@ 2019-01-07 18:34 ` Lubomir Rintel
2019-01-08 7:11 ` kbuild test robot
15 siblings, 1 reply; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-07 18:34 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
The battery and the protocol are essentially the same as OLPC XO 1.5,
but the responses from the EC are LSB first.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Changes since v2:
- Fix the version conditional
Changes since v1:
- s/s16 ecword_to_cpu/u16 ecword_to_cpu/
- s/u16 ec_byte/u16 ec_word/
drivers/power/supply/olpc_battery.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index 8ebb4284cf05..e32c1e457026 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -56,6 +56,7 @@ struct olpc_battery_data {
struct power_supply *olpc_bat;
char bat_serial[17];
int new_proto;
+ int little_endian;
};
/*********************************************************************
@@ -321,6 +322,14 @@ static int olpc_bat_get_voltage_max_design(union power_supply_propval *val)
return ret;
}
+static u16 ecword_to_cpu(struct olpc_battery_data *data, u16 ec_word)
+{
+ if (data->little_endian)
+ return le16_to_cpu(ec_word);
+ else
+ return be16_to_cpu(ec_word);
+}
+
/*********************************************************************
* Battery properties
*********************************************************************/
@@ -393,7 +402,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
if (ret)
return ret;
- val->intval = (s16)be16_to_cpu(ec_word) * 9760L / 32;
+ val->intval = ecword_to_cpu(data, ec_word) * 9760L / 32;
break;
case POWER_SUPPLY_PROP_CURRENT_AVG:
case POWER_SUPPLY_PROP_CURRENT_NOW:
@@ -401,7 +410,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
if (ret)
return ret;
- val->intval = (s16)be16_to_cpu(ec_word) * 15625L / 120;
+ val->intval = ecword_to_cpu(data, ec_word) * 15625L / 120;
break;
case POWER_SUPPLY_PROP_CAPACITY:
ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1);
@@ -432,21 +441,21 @@ static int olpc_bat_get_property(struct power_supply *psy,
if (ret)
return ret;
- val->intval = (s16)be16_to_cpu(ec_word) * 10 / 256;
+ val->intval = ecword_to_cpu(data, ec_word) * 10 / 256;
break;
case POWER_SUPPLY_PROP_TEMP_AMBIENT:
ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
if (ret)
return ret;
- val->intval = (int)be16_to_cpu(ec_word) * 10 / 256;
+ val->intval = (int)ecword_to_cpu(data, ec_word) * 10 / 256;
break;
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2);
if (ret)
return ret;
- val->intval = (s16)be16_to_cpu(ec_word) * 6250 / 15;
+ val->intval = ecword_to_cpu(data, ec_word) * 6250 / 15;
break;
case POWER_SUPPLY_PROP_SERIAL_NUMBER:
ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8);
@@ -620,7 +629,11 @@ static int olpc_battery_probe(struct platform_device *pdev)
if (ret)
return ret;
- if (ecver > 0x44) {
+ if (of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")) {
+ /* XO 1.75 */
+ data->new_proto = 1;
+ data->little_endian = 1;
+ } else if (ecver > 0x44) {
/* XO 1 or 1.5 with a new EC firmware. */
data->new_proto = 1;
} else if (ecver < 0x44) {
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 07/16] Platform: OLPC: Move EC-specific functionality out from x86
2019-01-07 18:34 ` [PATCH v3 07/16] Platform: OLPC: Move EC-specific functionality out from x86 Lubomir Rintel
@ 2019-01-08 4:09 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-01-08 4:09 UTC (permalink / raw)
To: Lubomir Rintel
Cc: kbuild-all, Andy Shevchenko, Darren Hart, platform-driver-x86,
James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
[-- Attachment #1: Type: text/plain, Size: 4615 bytes --]
Hi Lubomir,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc1 next-20190107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Lubomir-Rintel/Add-support-for-OLPC-XO-1-75-Embedded-Controller/20190108-114514
config: i386-randconfig-x002-201901 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
Note: the linux-review/Lubomir-Rintel/Add-support-for-OLPC-XO-1-75-Embedded-Controller/20190108-114514 HEAD 874facbe5f41ca7d9e5f8921613bd1713cd24b6a builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/power/supply/olpc_battery.c: In function 'olpc_bat_get_status':
>> drivers/power/supply/olpc_battery.c:99:24: error: 'struct olpc_platform_t' has no member named 'ecver'
if (olpc_platform_info.ecver > 0x44) {
^
drivers/power/supply/olpc_battery.c: In function 'olpc_battery_probe':
drivers/power/supply/olpc_battery.c:610:24: error: 'struct olpc_platform_t' has no member named 'ecver'
if (olpc_platform_info.ecver < 0x44) {
^
drivers/power/supply/olpc_battery.c:612:43: error: 'struct olpc_platform_t' has no member named 'ecver'
"battery driver.\n", olpc_platform_info.ecver);
^
vim +99 drivers/power/supply/olpc_battery.c
1ca5b9d2 drivers/power/olpc_battery.c David Woodhouse 2008-05-04 96
b2bd8a3b drivers/power/olpc_battery.c Andres Salomon 2008-05-02 97 static int olpc_bat_get_status(union power_supply_propval *val, uint8_t ec_byte)
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 98 {
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 @99 if (olpc_platform_info.ecver > 0x44) {
8f7e5798 drivers/power/olpc_battery.c Andres Salomon 2009-06-30 100 if (ec_byte & (BAT_STAT_CHARGING | BAT_STAT_TRICKLE))
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 101 val->intval = POWER_SUPPLY_STATUS_CHARGING;
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 102 else if (ec_byte & BAT_STAT_DISCHARGING)
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 103 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 104 else if (ec_byte & BAT_STAT_FULL)
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 105 val->intval = POWER_SUPPLY_STATUS_FULL;
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 106 else /* er,... */
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 107 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 108 } else {
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 109 /* Older EC didn't report charge/discharge bits */
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 110 if (!(ec_byte & BAT_STAT_AC)) /* No AC means discharging */
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 111 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 112 else if (ec_byte & BAT_STAT_FULL)
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 113 val->intval = POWER_SUPPLY_STATUS_FULL;
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 114 else /* Not _necessarily_ true but EC doesn't tell all yet */
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 115 val->intval = POWER_SUPPLY_STATUS_CHARGING;
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 116 }
fb972873 drivers/power/olpc_battery.c David Woodhouse 2007-05-04 117
b2bd8a3b drivers/power/olpc_battery.c Andres Salomon 2008-05-02 118 return 0;
b2bd8a3b drivers/power/olpc_battery.c Andres Salomon 2008-05-02 119 }
b2bd8a3b drivers/power/olpc_battery.c Andres Salomon 2008-05-02 120
:::::: The code at line 99 was first introduced by commit
:::::: fb972873a767220333ffb509de8d9131336e212c [BATTERY] One Laptop Per Child power/battery driver
:::::: TO: David Woodhouse <dwmw2@infradead.org>
:::::: CC: David Woodhouse <dwmw2@infradead.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28383 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 04/16] Platform: OLPC: Move OLPC config symbol out of x86 tree
2019-01-07 18:34 ` [PATCH v3 04/16] Platform: OLPC: Move OLPC config symbol out of x86 tree Lubomir Rintel
@ 2019-01-08 5:54 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-01-08 5:54 UTC (permalink / raw)
To: Lubomir Rintel
Cc: kbuild-all, Andy Shevchenko, Darren Hart, platform-driver-x86,
James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
[-- Attachment #1: Type: text/plain, Size: 24440 bytes --]
Hi Lubomir,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc1 next-20190107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Lubomir-Rintel/Add-support-for-OLPC-XO-1-75-Embedded-Controller/20190108-114514
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All error/warnings (new ones prefixed by >>):
>> sound/pci/cs5535audio/cs5535audio_olpc.c:28:6: error: redefinition of 'olpc_analog_input'
void olpc_analog_input(struct snd_ac97 *ac97, int on)
^~~~~~~~~~~~~~~~~
In file included from sound/pci/cs5535audio/cs5535audio_olpc.c:19:0:
sound/pci/cs5535audio/cs5535audio.h:131:20: note: previous definition of 'olpc_analog_input' was here
static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { }
^~~~~~~~~~~~~~~~~
>> sound/pci/cs5535audio/cs5535audio_olpc.c:51:6: error: redefinition of 'olpc_mic_bias'
void olpc_mic_bias(struct snd_ac97 *ac97, int on)
^~~~~~~~~~~~~
In file included from sound/pci/cs5535audio/cs5535audio_olpc.c:19:0:
sound/pci/cs5535audio/cs5535audio.h:132:20: note: previous definition of 'olpc_mic_bias' was here
static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { }
^~~~~~~~~~~~~
>> sound/pci/cs5535audio/cs5535audio_olpc.c:137:6: error: redefinition of 'olpc_prequirks'
void olpc_prequirks(struct snd_card *card,
^~~~~~~~~~~~~~
In file included from sound/pci/cs5535audio/cs5535audio_olpc.c:19:0:
sound/pci/cs5535audio/cs5535audio.h:124:20: note: previous definition of 'olpc_prequirks' was here
static inline void olpc_prequirks(struct snd_card *card,
^~~~~~~~~~~~~~
sound/pci/cs5535audio/cs5535audio_olpc.c: In function 'olpc_prequirks':
>> sound/pci/cs5535audio/cs5535audio_olpc.c:144:6: error: implicit declaration of function 'olpc_board_at_least' [-Werror=implicit-function-declaration]
if (olpc_board_at_least(olpc_board_pre(0xb3)))
^~~~~~~~~~~~~~~~~~~
>> sound/pci/cs5535audio/cs5535audio_olpc.c:144:26: error: implicit declaration of function 'olpc_board_pre'; did you mean 'olpc_mic_put'? [-Werror=implicit-function-declaration]
if (olpc_board_at_least(olpc_board_pre(0xb3)))
^~~~~~~~~~~~~~
olpc_mic_put
sound/pci/cs5535audio/cs5535audio_olpc.c: At top level:
>> sound/pci/cs5535audio/cs5535audio_olpc.c:148:5: error: redefinition of 'olpc_quirks'
int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
^~~~~~~~~~~
In file included from sound/pci/cs5535audio/cs5535audio_olpc.c:19:0:
sound/pci/cs5535audio/cs5535audio.h:126:19: note: previous definition of 'olpc_quirks' was here
static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
^~~~~~~~~~~
>> sound/pci/cs5535audio/cs5535audio_olpc.c:189:6: error: redefinition of 'olpc_quirks_cleanup'
void olpc_quirks_cleanup(void)
^~~~~~~~~~~~~~~~~~~
In file included from sound/pci/cs5535audio/cs5535audio_olpc.c:19:0:
sound/pci/cs5535audio/cs5535audio.h:130:20: note: previous definition of 'olpc_quirks_cleanup' was here
static inline void olpc_quirks_cleanup(void) { }
^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
In file included from include/linux/export.h:45:0,
from include/linux/linkage.h:7,
from include/linux/kernel.h:7,
from drivers/staging/olpc_dcon/olpc_dcon.c:13:
drivers/staging/olpc_dcon/olpc_dcon.c: In function 'dcon_bus_stabilize':
>> drivers/staging/olpc_dcon/olpc_dcon.c:141:10: error: implicit declaration of function 'olpc_board_at_least' [-Werror=implicit-function-declaration]
BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
^
include/linux/compiler.h:77:42: note: in definition of macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
>> drivers/staging/olpc_dcon/olpc_dcon.c:141:3: note: in expansion of macro 'BUG_ON'
BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
^~~~~~
>> drivers/staging/olpc_dcon/olpc_dcon.c:141:30: error: implicit declaration of function 'olpc_board'; did you mean 'olpc_ec_cmd'? [-Werror=implicit-function-declaration]
BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
^
include/linux/compiler.h:77:42: note: in definition of macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
>> drivers/staging/olpc_dcon/olpc_dcon.c:141:3: note: in expansion of macro 'BUG_ON'
BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
^~~~~~
cc1: some warnings being treated as errors
--
arch/x86/platform/olpc/olpc-xo15-sci.c: In function 'process_sci_queue':
>> arch/x86/platform/olpc/olpc-xo15-sci.c:106:7: error: implicit declaration of function 'olpc_ec_sci_query'; did you mean 'process_sci_queue'? [-Werror=implicit-function-declaration]
r = olpc_ec_sci_query(&data);
^~~~~~~~~~~~~~~~~
process_sci_queue
arch/x86/platform/olpc/olpc-xo15-sci.c: In function 'xo15_sci_add':
>> arch/x86/platform/olpc/olpc-xo15-sci.c:174:2: error: implicit declaration of function 'olpc_ec_mask_write'; did you mean 'olpc_ec_wakeup_set'? [-Werror=implicit-function-declaration]
olpc_ec_mask_write(EC_SCI_SRC_ALL);
^~~~~~~~~~~~~~~~~~
olpc_ec_wakeup_set
cc1: some warnings being treated as errors
--
arch/x86/platform/olpc/olpc.c:189:6: error: redefinition of 'olpc_ec_wakeup_set'
void olpc_ec_wakeup_set(u16 value)
^~~~~~~~~~~~~~~~~~
In file included from arch/x86/platform/olpc/olpc.c:27:0:
arch/x86/include/asm/olpc.h:86:20: note: previous definition of 'olpc_ec_wakeup_set' was here
static inline void olpc_ec_wakeup_set(u16 value) { }
^~~~~~~~~~~~~~~~~~
arch/x86/platform/olpc/olpc.c:195:6: error: redefinition of 'olpc_ec_wakeup_clear'
void olpc_ec_wakeup_clear(u16 value)
^~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/platform/olpc/olpc.c:27:0:
arch/x86/include/asm/olpc.h:87:20: note: previous definition of 'olpc_ec_wakeup_clear' was here
static inline void olpc_ec_wakeup_clear(u16 value) { }
^~~~~~~~~~~~~~~~~~~~
arch/x86/platform/olpc/olpc.c:205:6: error: redefinition of 'olpc_ec_wakeup_available'
bool olpc_ec_wakeup_available(void)
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/platform/olpc/olpc.c:27:0:
arch/x86/include/asm/olpc.h:89:20: note: previous definition of 'olpc_ec_wakeup_available' was here
static inline bool olpc_ec_wakeup_available(void)
^~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/platform/olpc/olpc.c: In function 'olpc_ec_wakeup_available':
>> arch/x86/platform/olpc/olpc.c:224:37: error: implicit declaration of function 'olpc_board_pre' [-Werror=implicit-function-declaration]
if (olpc_platform_info.boardrev >= olpc_board_pre(0xd0)) /* XO-1.5 */
^~~~~~~~~~~~~~
arch/x86/platform/olpc/olpc.c: In function 'olpc_init':
>> arch/x86/platform/olpc/olpc.c:377:7: error: implicit declaration of function 'olpc_ofw_present'; did you mean 'olpc_ofw_detect'? [-Werror=implicit-function-declaration]
if (!olpc_ofw_present() || !platform_detect())
^~~~~~~~~~~~~~~~
olpc_ofw_detect
>> arch/x86/platform/olpc/olpc.c:382:3: error: implicit declaration of function 'olpc_ec_driver_register'; did you mean 'platform_driver_register'? [-Werror=implicit-function-declaration]
olpc_ec_driver_register(&ec_xo1_driver, NULL);
^~~~~~~~~~~~~~~~~~~~~~~
platform_driver_register
>> arch/x86/platform/olpc/olpc.c:388:6: error: implicit declaration of function 'olpc_board_at_least' [-Werror=implicit-function-declaration]
if (olpc_board_at_least(olpc_board(0xb1)))
^~~~~~~~~~~~~~~~~~~
>> arch/x86/platform/olpc/olpc.c:388:26: error: implicit declaration of function 'olpc_board'; did you mean 'olpc_init'? [-Werror=implicit-function-declaration]
if (olpc_board_at_least(olpc_board(0xb1)))
^~~~~~~~~~
olpc_init
arch/x86/platform/olpc/olpc.c: At top level:
>> arch/x86/platform/olpc/olpc.c:408:1: warning: data definition has no type or storage class
postcore_initcall(olpc_init);
^~~~~~~~~~~~~~~~~
>> arch/x86/platform/olpc/olpc.c:408:1: error: type defaults to 'int' in declaration of 'postcore_initcall' [-Werror=implicit-int]
>> arch/x86/platform/olpc/olpc.c:408:1: warning: parameter names (without types) in function declaration
arch/x86/platform/olpc/olpc.c:373:19: warning: 'olpc_init' defined but not used [-Wunused-function]
static int __init olpc_init(void)
^~~~~~~~~
arch/x86/platform/olpc/olpc.c:42:19: warning: 'olpc_ec_timeout_set' defined but not used [-Wunused-function]
static int __init olpc_ec_timeout_set(char *str)
^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
>> arch/x86/platform/olpc/olpc_ofw.c:23:13: error: redefinition of 'setup_olpc_ofw_pgd'
void __init setup_olpc_ofw_pgd(void)
^~~~~~~~~~~~~~~~~~
In file included from arch/x86/platform/olpc/olpc_ofw.c:11:0:
arch/x86/include/asm/olpc_ofw.h:34:20: note: previous definition of 'setup_olpc_ofw_pgd' was here
static inline void setup_olpc_ofw_pgd(void) { }
^~~~~~~~~~~~~~~~~~
>> arch/x86/platform/olpc/olpc_ofw.c:92:13: error: redefinition of 'olpc_ofw_detect'
void __init olpc_ofw_detect(void)
^~~~~~~~~~~~~~~
In file included from arch/x86/platform/olpc/olpc_ofw.c:11:0:
arch/x86/include/asm/olpc_ofw.h:33:20: note: previous definition of 'olpc_ofw_detect' was here
static inline void olpc_ofw_detect(void) { }
^~~~~~~~~~~~~~~
--
arch/x86/platform/olpc/olpc_dt.c: In function 'olpc_dt_getsibling':
>> arch/x86/platform/olpc/olpc_dt.c:34:6: error: implicit declaration of function 'olpc_ofw' [-Werror=implicit-function-declaration]
if (olpc_ofw("peer", args, res) || (s32)node == -1)
^~~~~~~~
arch/x86/platform/olpc/olpc_dt.c: In function 'olpc_dt_fixup':
>> arch/x86/platform/olpc/olpc_dt.c:250:19: error: implicit declaration of function 'olpc_board_pre' [-Werror=implicit-function-declaration]
if (board_rev >= olpc_board_pre(0xd0)) {
^~~~~~~~~~~~~~
arch/x86/platform/olpc/olpc_dt.c: At top level:
>> arch/x86/platform/olpc/olpc_dt.c:268:13: error: redefinition of 'olpc_dt_build_devicetree'
void __init olpc_dt_build_devicetree(void)
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from arch/x86/platform/olpc/olpc_dt.c:24:0:
arch/x86/include/asm/olpc_ofw.h:35:20: note: previous definition of 'olpc_dt_build_devicetree' was here
static inline void olpc_dt_build_devicetree(void) { }
^~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/platform/olpc/olpc_dt.c: In function 'olpc_dt_build_devicetree':
>> arch/x86/platform/olpc/olpc_dt.c:272:7: error: implicit declaration of function 'olpc_ofw_is_installed' [-Werror=implicit-function-declaration]
if (!olpc_ofw_is_installed())
^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
drivers/input/mouse/hgpk.c: In function 'hgpk_reconnect':
>> drivers/input/mouse/hgpk.c:763:6: error: implicit declaration of function 'olpc_board_at_least' [-Werror=implicit-function-declaration]
if (olpc_board_at_least(olpc_board(0xb2)))
^~~~~~~~~~~~~~~~~~~
>> drivers/input/mouse/hgpk.c:763:26: error: implicit declaration of function 'olpc_board'; did you mean 'Elf_Word'? [-Werror=implicit-function-declaration]
if (olpc_board_at_least(olpc_board(0xb2)))
^~~~~~~~~~
Elf_Word
cc1: some warnings being treated as errors
vim +/olpc_analog_input +28 sound/pci/cs5535audio/cs5535audio_olpc.c
c8974be546 Jordan Crouse 2008-11-06 17
c8974be546 Jordan Crouse 2008-11-06 18 #include <asm/olpc.h>
57d4bf6d8e Jaya Kumar 2008-11-06 @19 #include "cs5535audio.h"
57d4bf6d8e Jaya Kumar 2008-11-06 20
3c55494670 Andres Salomon 2009-12-14 21 #define DRV_NAME "cs5535audio-olpc"
3c55494670 Andres Salomon 2009-12-14 22
d6276b7802 Andres Salomon 2008-11-06 23 /*
d6276b7802 Andres Salomon 2008-11-06 24 * OLPC has an additional feature on top of the regular AD1888 codec features.
d6276b7802 Andres Salomon 2008-11-06 25 * It has an Analog Input mode that is switched into (after disabling the
d6276b7802 Andres Salomon 2008-11-06 26 * High Pass Filter) via GPIO. It is supported on B2 and later models.
d6276b7802 Andres Salomon 2008-11-06 27 */
d6276b7802 Andres Salomon 2008-11-06 @28 void olpc_analog_input(struct snd_ac97 *ac97, int on)
d6276b7802 Andres Salomon 2008-11-06 29 {
d6276b7802 Andres Salomon 2008-11-06 30 int err;
d6276b7802 Andres Salomon 2008-11-06 31
0fb497f5b6 Andres Salomon 2008-11-06 32 if (!machine_is_olpc())
0fb497f5b6 Andres Salomon 2008-11-06 33 return;
0fb497f5b6 Andres Salomon 2008-11-06 34
d6276b7802 Andres Salomon 2008-11-06 35 /* update the High Pass Filter (via AC97_AD_TEST2) */
d6276b7802 Andres Salomon 2008-11-06 36 err = snd_ac97_update_bits(ac97, AC97_AD_TEST2,
d6276b7802 Andres Salomon 2008-11-06 37 1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT);
d6276b7802 Andres Salomon 2008-11-06 38 if (err < 0) {
00980aa9c7 Takashi Iwai 2014-02-25 39 dev_err(ac97->bus->card->dev,
00980aa9c7 Takashi Iwai 2014-02-25 40 "setting High Pass Filter - %d\n", err);
d6276b7802 Andres Salomon 2008-11-06 41 return;
d6276b7802 Andres Salomon 2008-11-06 42 }
d6276b7802 Andres Salomon 2008-11-06 43
d6276b7802 Andres Salomon 2008-11-06 44 /* set Analog Input through GPIO */
3c55494670 Andres Salomon 2009-12-14 45 gpio_set_value(OLPC_GPIO_MIC_AC, on);
d6276b7802 Andres Salomon 2008-11-06 46 }
57d4bf6d8e Jaya Kumar 2008-11-06 47
bf1e527835 Andres Salomon 2008-11-06 48 /*
bf1e527835 Andres Salomon 2008-11-06 49 * OLPC XO-1's V_REFOUT is a mic bias enable.
bf1e527835 Andres Salomon 2008-11-06 50 */
bf1e527835 Andres Salomon 2008-11-06 @51 void olpc_mic_bias(struct snd_ac97 *ac97, int on)
bf1e527835 Andres Salomon 2008-11-06 52 {
bf1e527835 Andres Salomon 2008-11-06 53 int err;
bf1e527835 Andres Salomon 2008-11-06 54
0fb497f5b6 Andres Salomon 2008-11-06 55 if (!machine_is_olpc())
0fb497f5b6 Andres Salomon 2008-11-06 56 return;
0fb497f5b6 Andres Salomon 2008-11-06 57
bf1e527835 Andres Salomon 2008-11-06 58 on = on ? 0 : 1;
bf1e527835 Andres Salomon 2008-11-06 59 err = snd_ac97_update_bits(ac97, AC97_AD_MISC,
bf1e527835 Andres Salomon 2008-11-06 60 1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT);
bf1e527835 Andres Salomon 2008-11-06 61 if (err < 0)
00980aa9c7 Takashi Iwai 2014-02-25 62 dev_err(ac97->bus->card->dev, "setting MIC Bias - %d\n", err);
bf1e527835 Andres Salomon 2008-11-06 63 }
bf1e527835 Andres Salomon 2008-11-06 64
466ae3055b Andres Salomon 2008-11-06 65 static int olpc_dc_info(struct snd_kcontrol *kctl,
57d4bf6d8e Jaya Kumar 2008-11-06 66 struct snd_ctl_elem_info *uinfo)
57d4bf6d8e Jaya Kumar 2008-11-06 67 {
57d4bf6d8e Jaya Kumar 2008-11-06 68 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
57d4bf6d8e Jaya Kumar 2008-11-06 69 uinfo->count = 1;
57d4bf6d8e Jaya Kumar 2008-11-06 70 uinfo->value.integer.min = 0;
57d4bf6d8e Jaya Kumar 2008-11-06 71 uinfo->value.integer.max = 1;
57d4bf6d8e Jaya Kumar 2008-11-06 72 return 0;
57d4bf6d8e Jaya Kumar 2008-11-06 73 }
57d4bf6d8e Jaya Kumar 2008-11-06 74
466ae3055b Andres Salomon 2008-11-06 75 static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
57d4bf6d8e Jaya Kumar 2008-11-06 76 {
3c55494670 Andres Salomon 2009-12-14 77 v->value.integer.value[0] = gpio_get_value(OLPC_GPIO_MIC_AC);
57d4bf6d8e Jaya Kumar 2008-11-06 78 return 0;
57d4bf6d8e Jaya Kumar 2008-11-06 79 }
57d4bf6d8e Jaya Kumar 2008-11-06 80
466ae3055b Andres Salomon 2008-11-06 81 static int olpc_dc_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
57d4bf6d8e Jaya Kumar 2008-11-06 82 {
466ae3055b Andres Salomon 2008-11-06 83 struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl);
57d4bf6d8e Jaya Kumar 2008-11-06 84
466ae3055b Andres Salomon 2008-11-06 85 olpc_analog_input(cs5535au->ac97, v->value.integer.value[0]);
57d4bf6d8e Jaya Kumar 2008-11-06 86 return 1;
57d4bf6d8e Jaya Kumar 2008-11-06 87 }
57d4bf6d8e Jaya Kumar 2008-11-06 88
bf1e527835 Andres Salomon 2008-11-06 89 static int olpc_mic_info(struct snd_kcontrol *kctl,
bf1e527835 Andres Salomon 2008-11-06 90 struct snd_ctl_elem_info *uinfo)
bf1e527835 Andres Salomon 2008-11-06 91 {
bf1e527835 Andres Salomon 2008-11-06 92 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
bf1e527835 Andres Salomon 2008-11-06 93 uinfo->count = 1;
bf1e527835 Andres Salomon 2008-11-06 94 uinfo->value.integer.min = 0;
bf1e527835 Andres Salomon 2008-11-06 95 uinfo->value.integer.max = 1;
bf1e527835 Andres Salomon 2008-11-06 96 return 0;
bf1e527835 Andres Salomon 2008-11-06 97 }
bf1e527835 Andres Salomon 2008-11-06 98
bf1e527835 Andres Salomon 2008-11-06 99 static int olpc_mic_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
bf1e527835 Andres Salomon 2008-11-06 100 {
bf1e527835 Andres Salomon 2008-11-06 101 struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl);
bf1e527835 Andres Salomon 2008-11-06 102 struct snd_ac97 *ac97 = cs5535au->ac97;
bf1e527835 Andres Salomon 2008-11-06 103 int i;
bf1e527835 Andres Salomon 2008-11-06 104
bf1e527835 Andres Salomon 2008-11-06 105 i = (snd_ac97_read(ac97, AC97_AD_MISC) >> AC97_AD_VREFD_SHIFT) & 0x1;
bf1e527835 Andres Salomon 2008-11-06 106 v->value.integer.value[0] = i ? 0 : 1;
bf1e527835 Andres Salomon 2008-11-06 107 return 0;
bf1e527835 Andres Salomon 2008-11-06 108 }
bf1e527835 Andres Salomon 2008-11-06 109
bf1e527835 Andres Salomon 2008-11-06 110 static int olpc_mic_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
bf1e527835 Andres Salomon 2008-11-06 111 {
bf1e527835 Andres Salomon 2008-11-06 112 struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl);
bf1e527835 Andres Salomon 2008-11-06 113
bf1e527835 Andres Salomon 2008-11-06 114 olpc_mic_bias(cs5535au->ac97, v->value.integer.value[0]);
bf1e527835 Andres Salomon 2008-11-06 115 return 1;
bf1e527835 Andres Salomon 2008-11-06 116 }
bf1e527835 Andres Salomon 2008-11-06 117
e23e7a1436 Bill Pemberton 2012-12-06 118 static struct snd_kcontrol_new olpc_cs5535audio_ctls[] = {
57d4bf6d8e Jaya Kumar 2008-11-06 119 {
57d4bf6d8e Jaya Kumar 2008-11-06 120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
466ae3055b Andres Salomon 2008-11-06 121 .name = "DC Mode Enable",
466ae3055b Andres Salomon 2008-11-06 122 .info = olpc_dc_info,
466ae3055b Andres Salomon 2008-11-06 123 .get = olpc_dc_get,
466ae3055b Andres Salomon 2008-11-06 124 .put = olpc_dc_put,
b5ccc57b06 Andres Salomon 2008-11-06 125 .private_value = 0,
bf1e527835 Andres Salomon 2008-11-06 126 },
bf1e527835 Andres Salomon 2008-11-06 127 {
bf1e527835 Andres Salomon 2008-11-06 128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
bf1e527835 Andres Salomon 2008-11-06 129 .name = "MIC Bias Enable",
bf1e527835 Andres Salomon 2008-11-06 130 .info = olpc_mic_info,
bf1e527835 Andres Salomon 2008-11-06 131 .get = olpc_mic_get,
bf1e527835 Andres Salomon 2008-11-06 132 .put = olpc_mic_put,
bf1e527835 Andres Salomon 2008-11-06 133 .private_value = 0,
bf1e527835 Andres Salomon 2008-11-06 134 },
57d4bf6d8e Jaya Kumar 2008-11-06 135 };
57d4bf6d8e Jaya Kumar 2008-11-06 136
e23e7a1436 Bill Pemberton 2012-12-06 @137 void olpc_prequirks(struct snd_card *card,
3556d18465 Andres Salomon 2008-11-06 138 struct snd_ac97_template *ac97)
3556d18465 Andres Salomon 2008-11-06 139 {
3556d18465 Andres Salomon 2008-11-06 140 if (!machine_is_olpc())
3556d18465 Andres Salomon 2008-11-06 141 return;
3556d18465 Andres Salomon 2008-11-06 142
3556d18465 Andres Salomon 2008-11-06 143 /* invert EAPD if on an OLPC B3 or higher */
3556d18465 Andres Salomon 2008-11-06 @144 if (olpc_board_at_least(olpc_board_pre(0xb3)))
3556d18465 Andres Salomon 2008-11-06 145 ac97->scaps |= AC97_SCAP_INV_EAPD;
3556d18465 Andres Salomon 2008-11-06 146 }
3556d18465 Andres Salomon 2008-11-06 147
e23e7a1436 Bill Pemberton 2012-12-06 @148 int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
57d4bf6d8e Jaya Kumar 2008-11-06 149 {
466ae3055b Andres Salomon 2008-11-06 150 struct snd_ctl_elem_id elem;
bf1e527835 Andres Salomon 2008-11-06 151 int i, err;
466ae3055b Andres Salomon 2008-11-06 152
c8974be546 Jordan Crouse 2008-11-06 153 if (!machine_is_olpc())
c8974be546 Jordan Crouse 2008-11-06 154 return 0;
c8974be546 Jordan Crouse 2008-11-06 155
3c55494670 Andres Salomon 2009-12-14 156 if (gpio_request(OLPC_GPIO_MIC_AC, DRV_NAME)) {
00980aa9c7 Takashi Iwai 2014-02-25 157 dev_err(card->dev, "unable to allocate MIC GPIO\n");
3c55494670 Andres Salomon 2009-12-14 158 return -EIO;
3c55494670 Andres Salomon 2009-12-14 159 }
3c55494670 Andres Salomon 2009-12-14 160 gpio_direction_output(OLPC_GPIO_MIC_AC, 0);
3c55494670 Andres Salomon 2009-12-14 161
466ae3055b Andres Salomon 2008-11-06 162 /* drop the original AD1888 HPF control */
466ae3055b Andres Salomon 2008-11-06 163 memset(&elem, 0, sizeof(elem));
466ae3055b Andres Salomon 2008-11-06 164 elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
57a4451d26 Takashi Iwai 2013-10-29 165 strlcpy(elem.name, "High Pass Filter Enable", sizeof(elem.name));
466ae3055b Andres Salomon 2008-11-06 166 snd_ctl_remove_id(card, &elem);
466ae3055b Andres Salomon 2008-11-06 167
bf1e527835 Andres Salomon 2008-11-06 168 /* drop the original V_REFOUT control */
bf1e527835 Andres Salomon 2008-11-06 169 memset(&elem, 0, sizeof(elem));
bf1e527835 Andres Salomon 2008-11-06 170 elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
57a4451d26 Takashi Iwai 2013-10-29 171 strlcpy(elem.name, "V_REFOUT Enable", sizeof(elem.name));
bf1e527835 Andres Salomon 2008-11-06 172 snd_ctl_remove_id(card, &elem);
bf1e527835 Andres Salomon 2008-11-06 173
bf1e527835 Andres Salomon 2008-11-06 174 /* add the OLPC-specific controls */
bf1e527835 Andres Salomon 2008-11-06 175 for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) {
bf1e527835 Andres Salomon 2008-11-06 176 err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i],
57d4bf6d8e Jaya Kumar 2008-11-06 177 ac97->private_data));
3c55494670 Andres Salomon 2009-12-14 178 if (err < 0) {
3c55494670 Andres Salomon 2009-12-14 179 gpio_free(OLPC_GPIO_MIC_AC);
bf1e527835 Andres Salomon 2008-11-06 180 return err;
bf1e527835 Andres Salomon 2008-11-06 181 }
3c55494670 Andres Salomon 2009-12-14 182 }
bf1e527835 Andres Salomon 2008-11-06 183
c8f0eeebc1 Andres Salomon 2008-11-06 184 /* turn off the mic by default */
c8f0eeebc1 Andres Salomon 2008-11-06 185 olpc_mic_bias(ac97, 0);
bf1e527835 Andres Salomon 2008-11-06 186 return 0;
57d4bf6d8e Jaya Kumar 2008-11-06 187 }
3c55494670 Andres Salomon 2009-12-14 188
e23e7a1436 Bill Pemberton 2012-12-06 @189 void olpc_quirks_cleanup(void)
:::::: The code at line 28 was first introduced by commit
:::::: d6276b78028dfab944dd4a58124aefcc9aa580da ALSA: cs5535audio: create function for setting OLPC's Analog Input mode
:::::: TO: Andres Salomon <dilinger@queued.net>
:::::: CC: Takashi Iwai <tiwai@suse.de>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66572 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 15/16] power: supply: olpc_battery: Avoid using platform_info
2019-01-07 18:34 ` [PATCH v3 15/16] power: supply: olpc_battery: Avoid using platform_info Lubomir Rintel
@ 2019-01-08 5:54 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-01-08 5:54 UTC (permalink / raw)
To: Lubomir Rintel
Cc: kbuild-all, Andy Shevchenko, Darren Hart, platform-driver-x86,
James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel, Sebastian Reichel
[-- Attachment #1: Type: text/plain, Size: 1176 bytes --]
Hi Lubomir,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v5.0-rc1 next-20190107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Lubomir-Rintel/Add-support-for-OLPC-XO-1-75-Embedded-Controller/20190108-114514
config: i386-randconfig-s3-201901 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
>> WARNING: vmlinux.o(.text+0x49efd): Section mismatch in reference from the function olpc_dt_compatible_match() to the function .init.text:olpc_dt_getproperty()
The function olpc_dt_compatible_match() references
the function __init olpc_dt_getproperty().
This is often because olpc_dt_compatible_match lacks a __init
annotation or the annotation of olpc_dt_getproperty is wrong.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32943 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 05/16] Platform: OLPC: Add XO-1.75 EC driver
2019-01-07 18:34 ` [PATCH v3 05/16] Platform: OLPC: Add XO-1.75 EC driver Lubomir Rintel
@ 2019-01-08 6:23 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-01-08 6:23 UTC (permalink / raw)
To: Lubomir Rintel
Cc: kbuild-all, Andy Shevchenko, Darren Hart, platform-driver-x86,
James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]
Hi Lubomir,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc1 next-20190107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Lubomir-Rintel/Add-support-for-OLPC-XO-1-75-Embedded-Controller/20190108-114514
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
>> drivers/platform/olpc/olpc-xo175-ec.c:26:10: fatal error: asm/system_misc.h: No such file or directory
#include <asm/system_misc.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
coccinelle warnings: (new ones prefixed by >>)
>> drivers/platform/olpc/olpc-xo175-ec.c:496:5-13: WARNING: Unsigned expression compared with zero: nr_bytes < 0
vim +26 drivers/platform/olpc/olpc-xo175-ec.c
> 26 #include <asm/system_misc.h>
27
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66582 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 16/16] power: supply: olpc_battery: Add OLPC XO 1.75 support
2019-01-07 18:34 ` [PATCH v3 16/16] power: supply: olpc_battery: Add OLPC XO 1.75 support Lubomir Rintel
@ 2019-01-08 7:11 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-01-08 7:11 UTC (permalink / raw)
To: Lubomir Rintel
Cc: kbuild-all, Andy Shevchenko, Darren Hart, platform-driver-x86,
James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel,
Lubomir Rintel
[-- Attachment #1: Type: text/plain, Size: 13622 bytes --]
Hi Lubomir,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc1 next-20190108]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Lubomir-Rintel/Add-support-for-OLPC-XO-1-75-Embedded-Controller/20190108-114514
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All error/warnings (new ones prefixed by >>):
>> arch/x86/platform/olpc/olpc.c:325:1: warning: 'postcore_initcall()' has implicit return type
>> arch/x86/platform/olpc/olpc.c:30:24: warning: symbol 'olpc_platform_info' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc.c:294:14: error: undefined identifier 'olpc_ofw_present'
>> arch/x86/platform/olpc/olpc.c:298:43: error: undefined identifier 'olpc_board_pre'
>> arch/x86/platform/olpc/olpc.c:299:17: error: undefined identifier 'olpc_ec_driver_register'
arch/x86/platform/olpc/olpc.c:301:17: error: undefined identifier 'olpc_ec_driver_register'
>> arch/x86/platform/olpc/olpc.c:305:13: error: undefined identifier 'olpc_board_at_least'
arch/x86/platform/olpc/olpc.c:316:43: error: undefined identifier 'olpc_board_pre'
--
>> arch/x86/platform/olpc/olpc_ofw.c:17:5: warning: symbol 'olpc_ofw_pgd' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc_ofw.c:31:14: warning: incorrect type in assignment (different address spaces)
arch/x86/platform/olpc/olpc_ofw.c:31:14: expected struct pgd_t [usertype] *base
arch/x86/platform/olpc/olpc_ofw.c:31:14: got void [noderef] <asn:2> *
>> arch/x86/platform/olpc/olpc_ofw.c:43:23: warning: incorrect type in argument 1 (different address spaces)
arch/x86/platform/olpc/olpc_ofw.c:43:23: expected void [noderef] <asn:2> *addr
arch/x86/platform/olpc/olpc_ofw.c:43:23: got struct pgd_t [usertype] *base
>> arch/x86/platform/olpc/olpc_ofw.c:23:13: warning: symbol 'setup_olpc_ofw_pgd' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc_ofw.c:46:5: warning: symbol '__olpc_ofw' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc_ofw.c:80:6: warning: symbol 'olpc_ofw_present' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc_ofw.c:92:13: warning: symbol 'olpc_ofw_detect' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc_ofw.c:117:13: warning: symbol 'olpc_ofw_is_installed' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc_ofw.c:58:28: warning: non size-preserving pointer to integer cast
>> arch/x86/platform/olpc/olpc_ofw.c:101:40: warning: non size-preserving integer to pointer cast
--
>> arch/x86/platform/olpc/olpc_dt.c:34:13: error: undefined identifier 'olpc_ofw'
arch/x86/platform/olpc/olpc_dt.c:48:13: error: undefined identifier 'olpc_ofw'
arch/x86/platform/olpc/olpc_dt.c:65:13: error: undefined identifier 'olpc_ofw'
arch/x86/platform/olpc/olpc_dt.c:85:21: error: undefined identifier 'olpc_ofw'
arch/x86/platform/olpc/olpc_dt.c:105:13: error: undefined identifier 'olpc_ofw'
arch/x86/platform/olpc/olpc_dt.c:120:13: error: undefined identifier 'olpc_ofw'
arch/x86/platform/olpc/olpc_dt.c:173:13: error: undefined identifier 'olpc_ofw'
arch/x86/platform/olpc/olpc_dt.c:190:13: error: undefined identifier 'olpc_ofw'
>> arch/x86/platform/olpc/olpc_dt.c:220:5: warning: symbol 'olpc_dt_compatible_match' was not declared. Should it be static?
>> arch/x86/platform/olpc/olpc_dt.c:253:26: error: undefined identifier 'olpc_board_pre'
>> arch/x86/platform/olpc/olpc_dt.c:300:14: error: undefined identifier 'olpc_ofw_is_installed'
--
>> drivers/power/supply/olpc_battery.c:328:24: warning: cast to restricted __le16
>> drivers/power/supply/olpc_battery.c:330:24: warning: cast to restricted __be16
>> drivers/power/supply/olpc_battery.c:330:24: warning: cast to restricted __be16
>> drivers/power/supply/olpc_battery.c:330:24: warning: cast to restricted __be16
>> drivers/power/supply/olpc_battery.c:330:24: warning: cast to restricted __be16
>> drivers/power/supply/olpc_battery.c:405:51: warning: incorrect type in argument 2 (different base types)
drivers/power/supply/olpc_battery.c:405:51: expected unsigned short [usertype] ec_word
drivers/power/supply/olpc_battery.c:405:51: got restricted __be16 [addressable] [usertype] ec_word
drivers/power/supply/olpc_battery.c:413:51: warning: incorrect type in argument 2 (different base types)
drivers/power/supply/olpc_battery.c:413:51: expected unsigned short [usertype] ec_word
drivers/power/supply/olpc_battery.c:413:51: got restricted __be16 [addressable] [usertype] ec_word
drivers/power/supply/olpc_battery.c:444:51: warning: incorrect type in argument 2 (different base types)
drivers/power/supply/olpc_battery.c:444:51: expected unsigned short [usertype] ec_word
drivers/power/supply/olpc_battery.c:444:51: got restricted __be16 [addressable] [usertype] ec_word
drivers/power/supply/olpc_battery.c:451:56: warning: incorrect type in argument 2 (different base types)
drivers/power/supply/olpc_battery.c:451:56: expected unsigned short [usertype] ec_word
drivers/power/supply/olpc_battery.c:451:56: got restricted __be16 [addressable] [usertype] ec_word
drivers/power/supply/olpc_battery.c:458:51: warning: incorrect type in argument 2 (different base types)
drivers/power/supply/olpc_battery.c:458:51: expected unsigned short [usertype] ec_word
drivers/power/supply/olpc_battery.c:458:51: got restricted __be16 [addressable] [usertype] ec_word
--
>> drivers/platform/olpc/olpc-ec.c:70:6: warning: symbol 'olpc_ec_driver_register' was not declared. Should it be static?
>> drivers/platform/olpc/olpc-ec.c:126:5: warning: symbol 'olpc_ec_cmd' was not declared. Should it be static?
>> drivers/platform/olpc/olpc-ec.c:165:6: warning: symbol 'olpc_ec_wakeup_set' was not declared. Should it be static?
>> drivers/platform/olpc/olpc-ec.c:176:6: warning: symbol 'olpc_ec_wakeup_clear' was not declared. Should it be static?
>> drivers/platform/olpc/olpc-ec.c:187:5: warning: symbol 'olpc_ec_mask_write' was not declared. Should it be static?
>> drivers/platform/olpc/olpc-ec.c:211:6: warning: symbol 'olpc_ec_wakeup_available' was not declared. Should it be static?
>> drivers/platform/olpc/olpc-ec.c:220:5: warning: symbol 'olpc_ec_sci_query' was not declared. Should it be static?
--
>> drivers/platform/olpc/olpc-xo175-ec.c:26:11: error: unable to open 'asm/system_misc.h'
--
>> drivers/input/mouse/hgpk.c:763:13: error: undefined identifier 'olpc_board_at_least'
--
>> sound/pci/cs5535audio/cs5535audio_olpc.c:28:6: warning: symbol 'olpc_analog_input' was not declared. Should it be static?
>> sound/pci/cs5535audio/cs5535audio_olpc.c:51:6: warning: symbol 'olpc_mic_bias' was not declared. Should it be static?
>> sound/pci/cs5535audio/cs5535audio_olpc.c:144:13: error: undefined identifier 'olpc_board_at_least'
>> sound/pci/cs5535audio/cs5535audio_olpc.c:148:5: warning: symbol 'olpc_quirks' was not declared. Should it be static?
>> sound/pci/cs5535audio/cs5535audio_olpc.c:189:6: warning: symbol 'olpc_quirks_cleanup' was not declared. Should it be static?
--
>> drivers/staging/olpc_dcon/olpc_dcon.c:141:17: error: undefined identifier 'olpc_board_at_least'
drivers/staging/olpc_dcon/olpc_dcon.c:202:14: error: undefined identifier 'olpc_board_at_least'
drivers/staging/olpc_dcon/olpc_dcon.c:799:13: error: undefined identifier 'olpc_board_at_least'
--
>> drivers/staging/olpc_dcon/olpc_dcon_xo_1.c:42:18: warning: symbol 'gpios' was not declared. Should it be static?
>> drivers/staging/olpc_dcon/olpc_dcon_xo_1.c:48:44: warning: incorrect type in initializer (different modifiers)
drivers/staging/olpc_dcon/olpc_dcon_xo_1.c:48:44: expected struct dcon_gpio *pin
drivers/staging/olpc_dcon/olpc_dcon_xo_1.c:48:44: got struct dcon_gpio const *
vim +328 drivers/power/supply/olpc_battery.c
324
325 static u16 ecword_to_cpu(struct olpc_battery_data *data, u16 ec_word)
326 {
327 if (data->little_endian)
> 328 return le16_to_cpu(ec_word);
329 else
> 330 return be16_to_cpu(ec_word);
331 }
332
333 /*********************************************************************
334 * Battery properties
335 *********************************************************************/
336 static int olpc_bat_get_property(struct power_supply *psy,
337 enum power_supply_property psp,
338 union power_supply_propval *val)
339 {
340 struct olpc_battery_data *data = power_supply_get_drvdata(psy);
341 int ret = 0;
342 __be16 ec_word;
343 uint8_t ec_byte;
344 __be64 ser_buf;
345
346 ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1);
347 if (ret)
348 return ret;
349
350 /* Theoretically there's a race here -- the battery could be
351 removed immediately after we check whether it's present, and
352 then we query for some other property of the now-absent battery.
353 It doesn't matter though -- the EC will return the last-known
354 information, and it's as if we just ran that _little_ bit faster
355 and managed to read it out before the battery went away. */
356 if (!(ec_byte & (BAT_STAT_PRESENT | BAT_STAT_TRICKLE)) &&
357 psp != POWER_SUPPLY_PROP_PRESENT)
358 return -ENODEV;
359
360 switch (psp) {
361 case POWER_SUPPLY_PROP_STATUS:
362 ret = olpc_bat_get_status(data, val, ec_byte);
363 if (ret)
364 return ret;
365 break;
366 case POWER_SUPPLY_PROP_CHARGE_TYPE:
367 if (ec_byte & BAT_STAT_TRICKLE)
368 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
369 else if (ec_byte & BAT_STAT_CHARGING)
370 val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
371 else
372 val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE;
373 break;
374 case POWER_SUPPLY_PROP_PRESENT:
375 val->intval = !!(ec_byte & (BAT_STAT_PRESENT |
376 BAT_STAT_TRICKLE));
377 break;
378
379 case POWER_SUPPLY_PROP_HEALTH:
380 if (ec_byte & BAT_STAT_DESTROY)
381 val->intval = POWER_SUPPLY_HEALTH_DEAD;
382 else {
383 ret = olpc_bat_get_health(val);
384 if (ret)
385 return ret;
386 }
387 break;
388
389 case POWER_SUPPLY_PROP_MANUFACTURER:
390 ret = olpc_bat_get_mfr(val);
391 if (ret)
392 return ret;
393 break;
394 case POWER_SUPPLY_PROP_TECHNOLOGY:
395 ret = olpc_bat_get_tech(val);
396 if (ret)
397 return ret;
398 break;
399 case POWER_SUPPLY_PROP_VOLTAGE_AVG:
400 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
401 ret = olpc_ec_cmd(EC_BAT_VOLTAGE, NULL, 0, (void *)&ec_word, 2);
402 if (ret)
403 return ret;
404
> 405 val->intval = ecword_to_cpu(data, ec_word) * 9760L / 32;
406 break;
407 case POWER_SUPPLY_PROP_CURRENT_AVG:
408 case POWER_SUPPLY_PROP_CURRENT_NOW:
409 ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2);
410 if (ret)
411 return ret;
412
413 val->intval = ecword_to_cpu(data, ec_word) * 15625L / 120;
414 break;
415 case POWER_SUPPLY_PROP_CAPACITY:
416 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1);
417 if (ret)
418 return ret;
419 val->intval = ec_byte;
420 break;
421 case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
422 if (ec_byte & BAT_STAT_FULL)
423 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
424 else if (ec_byte & BAT_STAT_LOW)
425 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
426 else
427 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
428 break;
429 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
430 ret = olpc_bat_get_charge_full_design(val);
431 if (ret)
432 return ret;
433 break;
434 case POWER_SUPPLY_PROP_CHARGE_NOW:
435 ret = olpc_bat_get_charge_now(val);
436 if (ret)
437 return ret;
438 break;
439 case POWER_SUPPLY_PROP_TEMP:
440 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2);
441 if (ret)
442 return ret;
443
444 val->intval = ecword_to_cpu(data, ec_word) * 10 / 256;
445 break;
446 case POWER_SUPPLY_PROP_TEMP_AMBIENT:
447 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
448 if (ret)
449 return ret;
450
451 val->intval = (int)ecword_to_cpu(data, ec_word) * 10 / 256;
452 break;
453 case POWER_SUPPLY_PROP_CHARGE_COUNTER:
454 ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2);
455 if (ret)
456 return ret;
457
458 val->intval = ecword_to_cpu(data, ec_word) * 6250 / 15;
459 break;
460 case POWER_SUPPLY_PROP_SERIAL_NUMBER:
461 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8);
462 if (ret)
463 return ret;
464
465 sprintf(data->bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf));
466 val->strval = data->bat_serial;
467 break;
468 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
469 ret = olpc_bat_get_voltage_max_design(val);
470 if (ret)
471 return ret;
472 break;
473 default:
474 ret = -EINVAL;
475 break;
476 }
477
478 return ret;
479 }
480
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 67282 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 03/16] Revert "platform/olpc: Make ec explicitly non-modular"
2019-01-07 18:34 ` [PATCH v3 03/16] Revert "platform/olpc: Make ec explicitly non-modular" Lubomir Rintel
@ 2019-01-08 8:29 ` Lubomir Rintel
0 siblings, 0 replies; 23+ messages in thread
From: Lubomir Rintel @ 2019-01-08 8:29 UTC (permalink / raw)
To: Andy Shevchenko, Darren Hart, platform-driver-x86
Cc: James Cameron, Mark Rutland, Pavel Machek, Rob Herring,
Sebastian Reichel, x86, devicetree, linux-pm, linux-kernel
On Mon, 2019-01-07 at 19:34 +0100, Lubomir Rintel wrote:
> It doesn't make sense to always have this built-in, e.g. on ARM
> multiplatform kernels.
>
> A better way to address the problem the original commit aimed to solve is
> to fix Kconfig. That is what the next commit in the series does.
>
> This reverts commit f48d1496b8537d75776478c6942dd87f34d7f270.
The kBuild but figured out that this is not such a great idea.
I'm going to follow-up with a new patch set; sorry for the noise.
>
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
>
> ---
> Changes since v1:
> - Sort it later in the patch set
>
> drivers/platform/olpc/olpc-ec.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
> index 981955dce926..35a21c66cd0d 100644
> --- a/drivers/platform/olpc/olpc-ec.c
> +++ b/drivers/platform/olpc/olpc-ec.c
> @@ -1,8 +1,6 @@
> /*
> * Generic driver for the OLPC Embedded Controller.
> *
> - * Author: Andres Salomon <dilinger@queued.net>
> - *
> * Copyright (C) 2011-2012 One Laptop per Child Foundation.
> *
> * Licensed under the GPL v2 or later.
> @@ -14,7 +12,7 @@
> #include <linux/platform_device.h>
> #include <linux/slab.h>
> #include <linux/workqueue.h>
> -#include <linux/init.h>
> +#include <linux/module.h>
> #include <linux/list.h>
> #include <linux/olpc-ec.h>
>
> @@ -327,4 +325,8 @@ static int __init olpc_ec_init_module(void)
> {
> return platform_driver_register(&olpc_ec_plat_driver);
> }
> +
> arch_initcall(olpc_ec_init_module);
> +
> +MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
> +MODULE_LICENSE("GPL");
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2019-01-08 8:29 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 18:34 [PATCH v3 00/16] Add support for OLPC XO 1.75 Embedded Controller Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 01/16] dt-bindings: olpc,xo1.75-ec: Add OLPC XO-1.75 EC bindings Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 02/16] Platform: OLPC: Remove an unused include Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 03/16] Revert "platform/olpc: Make ec explicitly non-modular" Lubomir Rintel
2019-01-08 8:29 ` Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 04/16] Platform: OLPC: Move OLPC config symbol out of x86 tree Lubomir Rintel
2019-01-08 5:54 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 05/16] Platform: OLPC: Add XO-1.75 EC driver Lubomir Rintel
2019-01-08 6:23 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 06/16] Platform: OLPC: Avoid a warning if the EC didn't register yet Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 07/16] Platform: OLPC: Move EC-specific functionality out from x86 Lubomir Rintel
2019-01-08 4:09 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 08/16] Platform: OLPC: Use BIT() and GENMASK() for event masks Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 09/16] Platform: OLPC: add a regulator for the DCON Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 10/16] dt-bindings: olpc_battery: Add XO-1.5 battery Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 11/16] x86, olpc: Use a correct version when making up a battery node Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 12/16] power: supply: olpc_battery: Use DT to get battery version Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 13/16] power: supply: olpc_battery: Move priv data to a struct Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 14/16] power: supply: olpc_battery: Use devm_power_supply_register() Lubomir Rintel
2019-01-07 18:34 ` [PATCH v3 15/16] power: supply: olpc_battery: Avoid using platform_info Lubomir Rintel
2019-01-08 5:54 ` kbuild test robot
2019-01-07 18:34 ` [PATCH v3 16/16] power: supply: olpc_battery: Add OLPC XO 1.75 support Lubomir Rintel
2019-01-08 7:11 ` kbuild test robot
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).