From patchwork Fri Jun 17 19:58:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 637285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rWWLN3H07z9t26 for ; Sat, 18 Jun 2016 05:59:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b=ClEX4Mhr; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964792AbcFQT7g (ORCPT ); Fri, 17 Jun 2016 15:59:36 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:34923 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933414AbcFQT6g (ORCPT ); Fri, 17 Jun 2016 15:58:36 -0400 Received: by mail-pa0-f42.google.com with SMTP id hl6so31204088pac.2 for ; Fri, 17 Jun 2016 12:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ae/C757S8DnzVjicu8A8G0f7wS25onKN+Gwxv7yc18U=; b=ClEX4MhrPqwQjVs2J5AUt34RveDrI9Tic3HljOfL1mo/Yk9sBZk55R30ViTZ2R6c08 /U6iXdqup31CfEXc15LkYVRhc0pgzEOQxfpP8vDlrmRC350SV/MQFXUAQxYslQafzJU0 7ZdgigzuIbndjxsreQPpZSVl+aru0TvBtBGjs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ae/C757S8DnzVjicu8A8G0f7wS25onKN+Gwxv7yc18U=; b=QkDto5mq10b/8QjT1rqi2/SkMNWnYHv0si85ZF5ji6ysDCL7Co9AOsKztSpaZvuXkQ UgvvSYBSTSLCo0uYXk2Ry9vP3XI9yTWBmofKsB9VvpFpDKUK8nfh5j0aDF0hiMDS1Boy FB9qZ2TPpKaSbL8tK3YsnmQIcHYkTrVRp9eXwsZyM+FA6K7J1swevYPWU9z6eSb6Ymgv V9xkiTX3x8ng1OFL+v38ZeRSilZERsdkeZotTtrI0F+cIWYqn0TFhgOWnpWjooeICx1Y C4zffjYUxudMoICi7BUm2w178kEZAuBMNJhzMu0f9gLwMWr50K+TUCVvPxR0vgaU3UI2 mSiw== X-Gm-Message-State: ALyK8tKq2BnAbjInHvZhBq8yQ9o5OKUpBDUmzXhj//U8aOgJAdoxvYuGz7rV+i2OZTWIm2x7 X-Received: by 10.66.73.138 with SMTP id l10mr4158485pav.92.1466193515721; Fri, 17 Jun 2016 12:58:35 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id 144sm36181160pfu.83.2016.06.17.12.58.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jun 2016 12:58:35 -0700 (PDT) From: Brian Norris To: Lee Jones , Thierry Reding , Olof Johansson Cc: , Doug Anderson , Brian Norris , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, Boris Brezillon , Stephen Barber , Javier Martinez Canillas , Benson Leung , Enric Balletbo , Randall Spangler , Shawn Nematbakhsh , Dmitry Torokhov , Todd Broch , Gwendal Grignou , Tomeu Vizoso , Brian Norris Subject: [PATCH v3 2/4] mfd: cros_ec: add EC_PWM function definitions Date: Fri, 17 Jun 2016 12:58:13 -0700 Message-Id: <1466193495-95801-3-git-send-email-briannorris@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1466193495-95801-1-git-send-email-briannorris@chromium.org> References: <1466193495-95801-1-git-send-email-briannorris@chromium.org> Sender: linux-pwm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pwm@vger.kernel.org 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 --- v3: * convert from 65535 to 0xffff v2: * no changes --- 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..7e7a8d4b4551 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, 0xffff = 100% */ +#define EC_PWM_MAX_DUTY 0xffff + +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