Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1116912ybt; Fri, 26 Jun 2020 21:59:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj3huYJcq1c90A1DyvQg7OklBDFF3p+9HC7Zs39isXiGr9xQVGckQgwkFvi8JYmmJFasBS X-Received: by 2002:a17:906:e2ca:: with SMTP id gr10mr5221058ejb.81.1593233973956; Fri, 26 Jun 2020 21:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593233973; cv=none; d=google.com; s=arc-20160816; b=sGfaKiOyV5JvXRG5PrA0uU+av8tt1IyLB8TZiWEjMEBNWkExnFMfaOnP+/UKYHDhkS zWbmiHkdlSemILyBEIIJra7nne6lPzZ6iUrvhHUFLWN0jQxFs+O2dH31MYFWwqJOuYmF p/h47XxWAm+QmbboNPFWGik/A4VekUGzJSWKOzk4uOS9ZyMRavd6yzNZL5Tr01aZ1wXZ QK1yJi4kIuDyO4laQloAtP6XIVO2TtuffjPxJd1njTYDHrXUwiTeh6uonAiMzcy6DCTx a6XNshuwm6J+zz3rL8pCXKxqdwiFZFlPS9uN/defTv7EINkdS92c+ZmKXDPWqDUtDJW9 oYKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P8NKTX8nvqvvpwDNqscc3f+sNP0CS2ggbCM49q8PTvA=; b=vL+nZTzzcgaCUoy3jM9r1wrDu/lD93bx7OXQHKG3EPorcmc0oFnF9OViLRkZH5z2JN ejjC7u35ac5bV0V1/KibP8dBzF5i9ueHINFXXBcQ73Qj2ktUOeEMwYSwTHdIpDJlDbjz uFOzMu9rlca2EiABH8Ic3LoewglRl1A3ewL1zvkFq5HImDf3msCjtbkpieZp6P6jjggy OVU0GTKYbZa2oM5/JQBBAjVTbke4OhuTM4rJ5O8eXahGsBw/xfRzBp/meMUXppUCHYV3 rhReDdJwqXqy4Yu4Y9v1Ad4lcW6HFE78GsAIvxTnUIwTNu0NFd+ztIDbWA+8XMntxTsi M9kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=i8Yg4X4k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mc22si17936132ejb.655.2020.06.26.21.59.11; Fri, 26 Jun 2020 21:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=i8Yg4X4k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725980AbgF0E7C (ORCPT + 99 others); Sat, 27 Jun 2020 00:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbgF0E7B (ORCPT ); Sat, 27 Jun 2020 00:59:01 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86A1C03E979 for ; Fri, 26 Jun 2020 21:59:01 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id y18so5054013plr.4 for ; Fri, 26 Jun 2020 21:59:01 -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 :mime-version:content-transfer-encoding; bh=P8NKTX8nvqvvpwDNqscc3f+sNP0CS2ggbCM49q8PTvA=; b=i8Yg4X4kJ/kFg2eeCj4JxRInDiI7JofmtmH6FfftXww0T06jcYljYGOP9A7lJshnHA r6WMDuGe1mnI/3TWhuPKu7iAjXqESroM+lRT7Xb9DbAw7Kfan7qV7stxuDhDRl9kXPYw iLNvQIpqJ6mIbVZKm2cFRm8O8NTQzcw/tda+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P8NKTX8nvqvvpwDNqscc3f+sNP0CS2ggbCM49q8PTvA=; b=T+5OaHv9jAVHc/S+sIv19hTHSGloyCy/EwC+PsJCqwDWZHzTnXs2gsTm6U7+l/S/oH EB26HzqgNaL+hvMhTUoonWDNFK5B3keurpU3glIwoth4MLrwoc7s0GcA+saFOe6XNQX8 GI9cemlfrVnC5HqNdQctq0+yttYSPRuo6HlHFxkyY8w6y7ARoaLlkwsWrfdFVaaMlyZ6 u2gUBObgdDInyVEg14H1a5JUuG3G/m67jqZ1ywrpxxBAE/ofBtsuvbg1k3Q+cxrg5+kT DcVYtqqv9EqiAEEAt2xpn7tG/yOX9LBuQa54/gSrDjflPossquOtdsDaGWL8IhSr358A wGUA== X-Gm-Message-State: AOAM532PGBrUgiCSBxx4sdpYzM0P2O6rNpSCKM5R0hPRmzS8RzH2HZAG ma7aLrzya70vv5XfEYTiYzPHnt3Q0Qs= X-Received: by 2002:a17:90a:a616:: with SMTP id c22mr6352237pjq.44.1593233941159; Fri, 26 Jun 2020 21:59:01 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id a33sm16123185pgl.75.2020.06.26.21.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 21:59:00 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH 2/2] platform/chrome: cros_ec_typec: Add PM support Date: Fri, 26 Jun 2020 21:58:41 -0700 Message-Id: <20200627045840.1314019-2-pmalani@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200627045840.1314019-1-pmalani@chromium.org> References: <20200627045840.1314019-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define basic suspend resume functions for cros-ec-typec. On suspend, we simply ensure that any pending port update work is completed, and on resume, we re-poll the port state to account for any changes/disconnections that might have occurred during suspend. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 630170fb2cbe..68f15a47450c 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -725,11 +725,45 @@ static int cros_typec_probe(struct platform_device *pdev) return ret; } +#ifdef CONFIG_PM_SLEEP + +static int cros_typec_suspend(struct device *dev) +{ + struct cros_typec_data *typec = dev_get_drvdata(dev); + + cancel_work_sync(&typec->port_work); + + return 0; +} + +static int cros_typec_resume(struct device *dev) +{ + struct cros_typec_data *typec = dev_get_drvdata(dev); + + /* Refresh port state. */ + schedule_work(&typec->port_work); + + return 0; +} + +static const struct dev_pm_ops cros_typec_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(cros_typec_suspend, cros_typec_resume) +}; + +#define DEV_PM_OPS (&cros_typec_pm_ops) + +#else + +#define DEV_PM_OPS NULL + +#endif /* CONFIG_PM_SLEEP */ + static struct platform_driver cros_typec_driver = { .driver = { .name = DRV_NAME, .acpi_match_table = ACPI_PTR(cros_typec_acpi_id), .of_match_table = of_match_ptr(cros_typec_of_match), + .pm = DEV_PM_OPS, }, .probe = cros_typec_probe, }; -- 2.27.0.212.ge8ba1cc988-goog