Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp68611ybb; Thu, 9 Apr 2020 17:26:24 -0700 (PDT) X-Google-Smtp-Source: APiQypKJDAQ3mHxc3uM7drHZQpAYLAm6CnSCq6JpJuoHKVpUc+4lh1mwWPofTiT3O8TeOyWoJyUh X-Received: by 2002:a37:4c8d:: with SMTP id z135mr1669366qka.128.1586478384388; Thu, 09 Apr 2020 17:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586478384; cv=none; d=google.com; s=arc-20160816; b=0Qq4WW0aVUIzNrtBfiTPGz3EA00inAZhzZNuR40B3EomByc9ekspxqvKs+qXgeXS9H g1v9jWjcsJ79jVmqUdGzBsnoFtg9gjLG0qdxN4liK16dbFgI2A9FjEAw+ajDgAQMieZs ZacCyus4vR8RtRfbvDbZQW2GX9DfISPRofbGYFSdty4dY0nxtijwMsmSpBMSRGvO1sNp rn6s1WP8YlwLj0bsYD7GgOdLSdjdJWdXH5esfaTeCc8+cuaGpAUONTxFLWFWGOquGc1M XsVTDag7NGLwQwdnryTHhniKfEnldNMDIctCXamJxmKWIGNcQVFc2DwWsDj/CG5yigR/ 1b3g== 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=m26VU8kqB/DEHGOXzBmFr8CE11PxubWxWkwy9EMFTsY=; b=cx38uNmoxMRjcXteD+lfsYG6dUsycJUcWXecuoWO8SLlQgJ+hlq8eRZ1B3OzeZsV6+ 7bsyMtMVGBz9C+GLlcWY8yGTHBvd12nvkUlfK6UArFWHEznbFhuprZ6UpcwOuvMCnfGy QsgJyWwfpRUfnk1eM2yqVUS2rtPcIW7CI+/YO5AcbfMpxTjGQz79Ki1qbUUCgntLaFq0 b/d73h/sIiY48RV5dBpi6ukTRTD+PTt5Tn7KxMRLVM9Dqq3yCrglGqE5k5VPL3OTwXPb iLOIWWAmH4Dw886R6p5BPCViNCOQtwf+52qK+RP5fsFtDjziMzPXKwk+FIrYx95D1SO6 zRJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XV6TQi1+; 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 o27si231604qtc.358.2020.04.09.17.26.09; Thu, 09 Apr 2020 17:26:24 -0700 (PDT) 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=XV6TQi1+; 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 S1727126AbgDJAXs (ORCPT + 99 others); Thu, 9 Apr 2020 20:23:48 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:34835 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbgDJAXs (ORCPT ); Thu, 9 Apr 2020 20:23:48 -0400 Received: by mail-pj1-f65.google.com with SMTP id mn19so183967pjb.0 for ; Thu, 09 Apr 2020 17:23:48 -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=m26VU8kqB/DEHGOXzBmFr8CE11PxubWxWkwy9EMFTsY=; b=XV6TQi1+yyXeItytY1IFyJWSjQ86G5tgy2RJZEkg8R82FDoxDRYreDrajhbj+S2Ekj +a7at3nm9LfdG7I2rlgaPBaE9Ag8tPPFn0AIJ7+flphf3TvVkSl/OPXq+Q+tB8FZrxpT i7VjdBnSzGJJ9Q4S+2D5mGx13X75Wyj+Jhb8k= 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=m26VU8kqB/DEHGOXzBmFr8CE11PxubWxWkwy9EMFTsY=; b=p5jPeszNhs2LOa85hNQlC/Ez2atNxUJc+fLE1BRnYLr0VwvhO8PDS4oSget6Wj7OmV Y/1KypONq4iInqyxvYYIJtLyv2oyEt8yhshU2id2/1P05znR1lRQ0qCpoJy8UbS25OM2 3mpGCAlVDqnx1Dzm/7HDqUIl+knr8Z3Yyzs677CWW+/YAePFzOUriID/vEfXOOwUeClt YNpzvC26+D2HH4eysV8Mp+wy06qVPdbCJKRtMZ6UbEu4V9T+OHVhcI6a23ywHWSaxEki jOy55j0Iehod1Q2fULunC/dobiv3sfawBhLBHlw7azEbhctGTVsN/YMcpA9nBnRy78km DrvQ== X-Gm-Message-State: AGi0PuaHWecZTuGUDJ0bsq7o9dqQb3+0XBPhiN9yXMscqRlBUqTgnjyF GQklk9RRV77bG5SPf+Y5UcStQhWaP3k= X-Received: by 2002:a17:902:ac85:: with SMTP id h5mr2128211plr.76.1586478227295; Thu, 09 Apr 2020 17:23:47 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id z7sm286952pju.37.2020.04.09.17.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 17:23:46 -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 v3 1/3] platform/chrome: typec: Use notifier for updates Date: Thu, 9 Apr 2020 17:23:15 -0700 Message-Id: <20200410002316.202107-2-pmalani@chromium.org> X-Mailer: git-send-email 2.26.0.110.g2183baf09c-goog In-Reply-To: <20200410002316.202107-1-pmalani@chromium.org> References: <20200410002316.202107-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 Register a listener for the cros-usbpd-notifier, and update port state when a notification comes in. Signed-off-by: Prashant Malani --- Changes in v3: - Fixed ordering issue in Kconfig dependency. Changes in v2: - Added Kconfig dependency to CROS_USBPD_NOTIFY. - Fixed spacing error. - Removed superfluous devm_warn() call. drivers/platform/chrome/Kconfig | 1 + drivers/platform/chrome/cros_ec_typec.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index 03ea5129ed0c3..a484ab2c91ff0 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig @@ -217,6 +217,7 @@ config CROS_EC_SYSFS config CROS_EC_TYPEC tristate "ChromeOS EC Type-C Connector Control" depends on MFD_CROS_EC_DEV && TYPEC + depends on CROS_USBPD_NOTIFY default MFD_CROS_EC_DEV help If you say Y here, you get support for accessing Type C connector diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 874269c070739..d444dd7422a2a 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ struct cros_typec_data { struct typec_port *ports[EC_USB_PD_MAX_PORTS]; /* Initial capabilities for each port. */ struct typec_capability *caps[EC_USB_PD_MAX_PORTS]; + struct notifier_block nb; }; static int cros_typec_parse_port_props(struct typec_capability *cap, @@ -272,6 +274,22 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) return 0; } +static int cros_ec_typec_event(struct notifier_block *nb, + unsigned long host_event, void *_notify) +{ + struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, + nb); + int ret, i; + + for (i = 0; i < typec->num_ports; i++) { + ret = cros_typec_port_update(typec, i); + if (ret < 0) + dev_warn(typec->dev, "Update failed for port: %d\n", i); + } + + return NOTIFY_OK; +} + #ifdef CONFIG_ACPI static const struct acpi_device_id cros_typec_acpi_id[] = { { "GOOG0014", 0 }, @@ -332,6 +350,11 @@ static int cros_typec_probe(struct platform_device *pdev) goto unregister_ports; } + typec->nb.notifier_call = cros_ec_typec_event; + ret = cros_usbpd_register_notify(&typec->nb); + if (ret < 0) + goto unregister_ports; + return 0; unregister_ports: -- 2.26.0.110.g2183baf09c-goog