Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1092805ybl; Fri, 24 Jan 2020 15:28:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwAT+I5/e/GewXONLckVQiXPpdsxQyc9RTa/tMsZcNeqsBdXJIYJIbmKlmq1FFh9HWHyZaY X-Received: by 2002:aca:dc04:: with SMTP id t4mr863936oig.51.1579908534981; Fri, 24 Jan 2020 15:28:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579908534; cv=none; d=google.com; s=arc-20160816; b=yzS2va6NZKpICbWLmiid1q2/46pGcsUHCOmN435lGckZsHkRG18E2BL77kYLYCr7rp tL/iRr//3GKid2HJnRT6aeTSllgOnGnvAX01ViY9tfVUqHaVZytIE0IXkzVULMjmpBvk upEohQFZ8kF+EjCIatIVCxULJix4+8V050if8biAc5rt4FWlpKAJh26K/TCBOqG3PkHQ e3eGZ6+oT//SLwwqqZxWTEUs7ATBzGFQH8et5T3psduSIF3dl4JSMESC1Mlb7gRw16/s otsyILWVtCnTu8hOnARg4ux3NzcKSuW/lW1Cc4cRL512i2+qtd5h+56vLKXg31O+RZPK MhbA== 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=pMA+QteS/JKIrgzNNehkgXK6WKtqs9yO/7325HU0xxA=; b=ZyBJacWYRdNohlaBH3osSgmoS9sDHgmLh3bWVsUZLBbtwInytVayRHrdMOdv87ojUx 6fTnqOsuCVvRkcZHAOzSvQDFiDmpcN5QXZcBUtJCUoQckSeCGoAyOW19K5KtQpYFxYh/ p5J4uFU6uD710VownNzbwSlzCJXxdpUZkrQU5nPBTXgSbtvYTjwtB5ZsXIQJ77Koxafj +Exc9dbUZ9dqCX5+79OiiFJLvQBnjwNXo1IeTxAyeEItqbcyk5xsUXSTFK3to63mZ6ff wcBrD5IeeWXTGgXzzN1Xtd7t/C3tcQirzMzKUWecSVwbmrl8W9fsYY5nQi8CpdtIZe6H 8j5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J8T7f7GL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id x11si470853oic.185.2020.01.24.15.28.42; Fri, 24 Jan 2020 15:28:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J8T7f7GL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729563AbgAXX1f (ORCPT + 99 others); Fri, 24 Jan 2020 18:27:35 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36607 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729530AbgAXX1f (ORCPT ); Fri, 24 Jan 2020 18:27:35 -0500 Received: by mail-pl1-f194.google.com with SMTP id a6so1409244plm.3 for ; Fri, 24 Jan 2020 15:27:34 -0800 (PST) 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=pMA+QteS/JKIrgzNNehkgXK6WKtqs9yO/7325HU0xxA=; b=J8T7f7GLnK78uiyRBnCLfOmhrZTQC9Snw78JgipV4iORMKkCyjpWK6Ywu969t4OCWn vHVgk8OMilaDg72I96iQnY49oKejS5E4WkIGj7sHU4H9yMdm7xTCLQ/pLUUUruZZOKSd 5TxNBzu5M228WEMt7/FxGDohHhvzc8IdHhmw0= 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=pMA+QteS/JKIrgzNNehkgXK6WKtqs9yO/7325HU0xxA=; b=QLG08TzaGNZikLuVzK9+XsReaCZGwsBPpY7CRKuCsuwqDL8Q/7G3bUsDg6Ih/H5jGU Y91/yG3godmE1Yu1dJ5CujLt/5DhqxiNGLtCUM6SBr9fwNKI7LzSpzKYcZ99mAr66gfT XsY28LbgJK9zz1nu/EXCXs7w3jU51PRLwC813t4wRYRCD3+l1RCBGPtX8CR5d97cWnu3 +0yEAuvbk4/fpc4toJDGka/QeApKDajsKX3k/ggMvKVkGPyvBl7BKgH+QK+bEonAH8le ShLlhlxZq2c4k3gENS7oXwgKFrOtYbHxZKdi+MItsNwZJaLXfmYO6dR8YQ6+vClndL5J WRoA== X-Gm-Message-State: APjAAAV/mMzgmLs3I3bepfl9Vz1fuSUbYfVk5EjtwusHsR69gdc0f4km Mrn0p6Sx/hsC385d72+T6jTxGQ== X-Received: by 2002:a17:902:6ac3:: with SMTP id i3mr6070491plt.111.1579908454326; Fri, 24 Jan 2020 15:27:34 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id b12sm2823103pfr.26.2020.01.24.15.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2020 15:27:33 -0800 (PST) From: Prashant Malani To: enric.balletbo@collabora.com, groeck@chromium.org, bleung@chromium.org, lee.jones@linaro.org, sre@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Jon Flatley , Prashant Malani Subject: [PATCH v8 4/4] power: supply: cros-ec-usbpd-charger: Fix host events Date: Fri, 24 Jan 2020 15:18:38 -0800 Message-Id: <20200124231834.63628-4-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200124231834.63628-1-pmalani@chromium.org> References: <20200124231834.63628-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 From: Jon Flatley There's a bug on ACPI platforms where host events from the ECPD ACPI device never make their way to the cros-ec-usbpd-charger driver. This makes it so the only time the charger driver updates its state is when user space accesses its sysfs attributes. Now that these events have been unified into a single notifier chain on both ACPI and non-ACPI platforms, update the charger driver to use this new notifier. Reviewed-by: Benson Leung Co-Developed-by: Prashant Malani Signed-off-by: Jon Flatley Signed-off-by: Prashant Malani --- Changes in v8(pmalani@chromium.org): - No changes. Changes in v7(pmalani@chromium.org): - Alphabetize #include header. Changes in v6(pmalani@chromium.org): - Patch first introduced into the series in v6. drivers/power/supply/Kconfig | 2 +- drivers/power/supply/cros_usbpd-charger.c | 50 ++++++++--------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 27164a1d3c7c4..ba74ddd793c3d 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -659,7 +659,7 @@ config CHARGER_RT9455 config CHARGER_CROS_USBPD tristate "ChromeOS EC based USBPD charger" - depends on CROS_EC + depends on CROS_USBPD_NOTIFY default n help Say Y here to enable ChromeOS EC based USBPD charger diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c index 6cc7c3910e098..7eea080048f43 100644 --- a/drivers/power/supply/cros_usbpd-charger.c +++ b/drivers/power/supply/cros_usbpd-charger.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -524,32 +525,21 @@ static int cros_usbpd_charger_property_is_writeable(struct power_supply *psy, } static int cros_usbpd_charger_ec_event(struct notifier_block *nb, - unsigned long queued_during_suspend, + unsigned long host_event, void *_notify) { - struct cros_ec_device *ec_device; - struct charger_data *charger; - u32 host_event; + struct charger_data *charger = container_of(nb, struct charger_data, + notifier); - charger = container_of(nb, struct charger_data, notifier); - ec_device = charger->ec_device; - - host_event = cros_ec_get_host_event(ec_device); - if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { - cros_usbpd_charger_power_changed(charger->ports[0]->psy); - return NOTIFY_OK; - } else { - return NOTIFY_DONE; - } + cros_usbpd_charger_power_changed(charger->ports[0]->psy); + return NOTIFY_OK; } static void cros_usbpd_charger_unregister_notifier(void *data) { struct charger_data *charger = data; - struct cros_ec_device *ec_device = charger->ec_device; - blocking_notifier_chain_unregister(&ec_device->event_notifier, - &charger->notifier); + cros_usbpd_unregister_notify(&charger->notifier); } static int cros_usbpd_charger_probe(struct platform_device *pd) @@ -683,21 +673,17 @@ static int cros_usbpd_charger_probe(struct platform_device *pd) goto fail; } - if (ec_device->mkbp_event_supported) { - /* Get PD events from the EC */ - charger->notifier.notifier_call = cros_usbpd_charger_ec_event; - ret = blocking_notifier_chain_register( - &ec_device->event_notifier, - &charger->notifier); - if (ret < 0) { - dev_warn(dev, "failed to register notifier\n"); - } else { - ret = devm_add_action_or_reset(dev, - cros_usbpd_charger_unregister_notifier, - charger); - if (ret < 0) - goto fail; - } + /* Get PD events from the EC */ + charger->notifier.notifier_call = cros_usbpd_charger_ec_event; + ret = cros_usbpd_register_notify(&charger->notifier); + if (ret < 0) { + dev_warn(dev, "failed to register notifier\n"); + } else { + ret = devm_add_action_or_reset(dev, + cros_usbpd_charger_unregister_notifier, + charger); + if (ret < 0) + goto fail; } return 0; -- 2.25.0.341.g760bfbb309-goog