Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1412677 > unrolled thread
| Started by | Brian Norris <briannorris@chromium.org> |
|---|---|
| First post | 2016-06-03 03:30 +0200 |
| Last post | 2016-06-03 03:30 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/4] pwm: add support for ChromeOS EC PWM Brian Norris <briannorris@chromium.org> - 2016-06-03 03:30 +0200
[PATCH v2 3/4] doc: dt: pwm: add binding for ChromeOS EC PWM Brian Norris <briannorris@chromium.org> - 2016-06-03 03:30 +0200
Re: [PATCH v2 3/4] doc: dt: pwm: add binding for ChromeOS EC PWM Rob Herring <robh@kernel.org> - 2016-06-06 15:40 +0200
[PATCH v2 2/4] mfd: cros_ec: add EC_PWM function definitions Brian Norris <briannorris@chromium.org> - 2016-06-03 03:30 +0200
[PATCH v2 1/4] mfd: cros_ec: Add cros_ec_cmd_xfer_status helper Brian Norris <briannorris@chromium.org> - 2016-06-03 03:30 +0200
| From | Brian Norris <briannorris@chromium.org> |
|---|---|
| Date | 2016-06-03 03:30 +0200 |
| Subject | [PATCH v2 0/4] pwm: add support for ChromeOS EC PWM |
| Message-ID | <rFM5X-55O-5@gated-at.bofh.it> |
Hi, This is version 2 of my series to support the new ChromeOS EC PWM API, so we can control, e.g., a PWM backlight when its PWM is attached to the EC. It uses Boris's latest "atomic" hooks for the PWM API (i.e., the ->apply() callback), which were recently merged. It seems nice to have the cros_ec_cmd_xfer_status() helper, which we have locally in the ChromeOS kernel, and which has been part of another larger patch series: https://lkml.org/lkml/2016/4/12/342 So I've picked it into this series as well. Tomeu has acknowledged his USB PD series is on hold for now, so this should be OK. As this touches MFD (sort of), drivers/platform/chrome/, and drivers/pwm/, I'm still not sure who it should all go through: Lee, Thierry, or Olof? Please review. Regards, Brian Change log (also documented in each patch): v2: * drop the "google,max-pwms" property * separate the cros_ec vs. PWM abstractions a little more clearly in the driver * remove dynamic kzalloc()'s and rely on on-stack memory instead * auto-probe the number of PWMs supported Brian Norris (3): mfd: cros_ec: add EC_PWM function definitions doc: dt: pwm: add binding for ChromeOS EC PWM pwm: add ChromeOS EC PWM driver Tomeu Vizoso (1): mfd: cros_ec: Add cros_ec_cmd_xfer_status helper .../devicetree/bindings/pwm/google,cros-ec-pwm.txt | 23 ++ drivers/platform/chrome/cros_ec_proto.c | 15 ++ drivers/pwm/Kconfig | 7 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-cros-ec.c | 237 +++++++++++++++++++++ include/linux/mfd/cros_ec.h | 18 ++ include/linux/mfd/cros_ec_commands.h | 31 +++ 7 files changed, 332 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/google,cros-ec-pwm.txt create mode 100644 drivers/pwm/pwm-cros-ec.c -- 2.8.0.rc3.226.g39d4020
[toc] | [next] | [standalone]
| From | Brian Norris <briannorris@chromium.org> |
|---|---|
| Date | 2016-06-03 03:30 +0200 |
| Subject | [PATCH v2 3/4] doc: dt: pwm: add binding for ChromeOS EC PWM |
| Message-ID | <rFM5X-55O-9@gated-at.bofh.it> |
| In reply to | #1412677 |
The ChromeOS Embedded Controller can support controlling its attached
PWMs via its host-command interface. The number of supported PWMs varies
on a per-board basis, but we can autodetect this by checking the error
codes, so we don't need an extra property for this. And because the EC
only allows specifying the duty cycle and not the period, we don't
specify the period via pwm-cells, and instead have only support 1 cell
-- to specify the index.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
v2: dropped the "google,max-pwms" property
.../devicetree/bindings/pwm/google,cros-ec-pwm.txt | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 Documentation/devicetree/bindings/pwm/google,cros-ec-pwm.txt
diff --git a/Documentation/devicetree/bindings/pwm/google,cros-ec-pwm.txt b/Documentation/devicetree/bindings/pwm/google,cros-ec-pwm.txt
new file mode 100644
index 000000000000..472bd46ab5a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/google,cros-ec-pwm.txt
@@ -0,0 +1,23 @@
+* PWM controlled by ChromeOS EC
+
+Google's ChromeOS EC PWM is a simple PWM attached to the Embedded Controller
+(EC) and controlled via a host-command interface.
+
+An EC PWM node should be only found as a sub-node of the EC node (see
+Documentation/devicetree/bindings/mfd/cros-ec.txt).
+
+Required properties:
+- compatible: Must contain "google,cros-ec-pwm"
+- #pwm-cells: Should be 1. The cell specifies the PWM index.
+
+Example:
+ cros-ec@0 {
+ compatible = "google,cros-ec-spi";
+
+ ...
+
+ cros_ec_pwm: ec-pwm {
+ compatible = "google,cros-ec-pwm";
+ #pwm-cells = <1>;
+ };
+ };
--
2.8.0.rc3.226.g39d4020
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2016-06-06 15:40 +0200 |
| Subject | Re: [PATCH v2 3/4] doc: dt: pwm: add binding for ChromeOS EC PWM |
| Message-ID | <rH2V4-5xv-9@gated-at.bofh.it> |
| In reply to | #1412680 |
On Thu, Jun 02, 2016 at 06:21:43PM -0700, Brian Norris wrote: > The ChromeOS Embedded Controller can support controlling its attached > PWMs via its host-command interface. The number of supported PWMs varies > on a per-board basis, but we can autodetect this by checking the error > codes, so we don't need an extra property for this. And because the EC > only allows specifying the duty cycle and not the period, we don't > specify the period via pwm-cells, and instead have only support 1 cell > -- to specify the index. > > Signed-off-by: Brian Norris <briannorris@chromium.org> > --- > v2: dropped the "google,max-pwms" property > > .../devicetree/bindings/pwm/google,cros-ec-pwm.txt | 23 ++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > create mode 100644 Documentation/devicetree/bindings/pwm/google,cros-ec-pwm.txt Acked-by: Rob Herring <robh@kernel.org>
[toc] | [prev] | [next] | [standalone]
| From | Brian Norris <briannorris@chromium.org> |
|---|---|
| Date | 2016-06-03 03:30 +0200 |
| Subject | [PATCH v2 2/4] mfd: cros_ec: add EC_PWM function definitions |
| Message-ID | <rFM5X-55O-13@gated-at.bofh.it> |
| In reply to | #1412677 |
The EC_CMD_PWM_{GET,SET}_DUTY commands allow us to control a PWM that is
attached to the EC, rather than the main host SoC. The API provides
functionality-based (e.g., keyboard light, backlight) or index-based
addressing of the PWM(s). Duty cycles are represented by a 16-bit value,
where 0 maps to 0% duty cycle and U16_MAX maps to 100%. The period
cannot be controlled.
This command set is more generic than, e.g.,
EC_CMD_PWM_{GET,SET}_KEYBOARD_BACKLIGHT and could possibly used to
replace it on future products.
Let's update the command header to include the definitions.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
v2: no change
include/linux/mfd/cros_ec_commands.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index 13b630c10d4c..d673575e0ada 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -949,6 +949,37 @@ struct ec_params_pwm_set_fan_duty {
uint32_t percent;
} __packed;
+#define EC_CMD_PWM_SET_DUTY 0x25
+/* 16 bit duty cycle, 65535 = 100% */
+#define EC_PWM_MAX_DUTY 65535
+
+enum ec_pwm_type {
+ /* All types, indexed by board-specific enum pwm_channel */
+ EC_PWM_TYPE_GENERIC = 0,
+ /* Keyboard backlight */
+ EC_PWM_TYPE_KB_LIGHT,
+ /* Display backlight */
+ EC_PWM_TYPE_DISPLAY_LIGHT,
+ EC_PWM_TYPE_COUNT,
+};
+
+struct ec_params_pwm_set_duty {
+ uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
+ uint8_t pwm_type; /* ec_pwm_type */
+ uint8_t index; /* Type-specific index, or 0 if unique */
+} __packed;
+
+#define EC_CMD_PWM_GET_DUTY 0x26
+
+struct ec_params_pwm_get_duty {
+ uint8_t pwm_type; /* ec_pwm_type */
+ uint8_t index; /* Type-specific index, or 0 if unique */
+} __packed;
+
+struct ec_response_pwm_get_duty {
+ uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
+} __packed;
+
/*****************************************************************************/
/*
* Lightbar commands. This looks worse than it is. Since we only use one HOST
--
2.8.0.rc3.226.g39d4020
[toc] | [prev] | [next] | [standalone]
| From | Brian Norris <briannorris@chromium.org> |
|---|---|
| Date | 2016-06-03 03:30 +0200 |
| Subject | [PATCH v2 1/4] mfd: cros_ec: Add cros_ec_cmd_xfer_status helper |
| Message-ID | <rFM5X-55O-15@gated-at.bofh.it> |
| In reply to | #1412677 |
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
So that callers of cros_ec_cmd_xfer don't have to repeat boilerplate
code when checking for errors from the EC side.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
v2: no change
drivers/platform/chrome/cros_ec_proto.c | 15 +++++++++++++++
include/linux/mfd/cros_ec.h | 18 ++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index b6e161f71b26..ecc544c728f0 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -380,3 +380,18 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
return ret;
}
EXPORT_SYMBOL(cros_ec_cmd_xfer);
+
+int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
+ struct cros_ec_command *msg)
+{
+ int ret;
+
+ ret = cros_ec_cmd_xfer(ec_dev, msg);
+ if (ret < 0)
+ dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret);
+ else if (msg->result != EC_RES_SUCCESS)
+ return -EECRESULT - msg->result;
+
+ return ret;
+}
+EXPORT_SYMBOL(cros_ec_cmd_xfer_status);
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index 64184d27e3cd..b1e48dfbf50a 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -40,6 +40,9 @@
#define EC_MAX_REQUEST_OVERHEAD 1
#define EC_MAX_RESPONSE_OVERHEAD 2
+/* ec_command return value for non-success result from EC */
+#define EECRESULT 1000
+
/*
* Command interface between EC and AP, for LPC, I2C and SPI interfaces.
*/
@@ -226,6 +229,21 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
struct cros_ec_command *msg);
/**
+ * cros_ec_cmd_xfer_status - Send a command to the ChromeOS EC
+ *
+ * This function is identical to cros_ec_cmd_xfer, except it returns succes
+ * status only if both the command was transmitted successfully and the EC
+ * replied with success status. It's not necessary to check msg->result when
+ * using this function.
+ *
+ * @ec_dev: EC device
+ * @msg: Message to write
+ * @return: Num. of bytes transferred on success, <0 on failure
+ */
+int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
+ struct cros_ec_command *msg);
+
+/**
* cros_ec_remove - Remove a ChromeOS EC
*
* Call this to deregister a ChromeOS EC, then clean up any private data.
--
2.8.0.rc3.226.g39d4020
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web