Received: by 10.223.148.5 with SMTP id 5csp6146727wrq; Wed, 17 Jan 2018 10:01:02 -0800 (PST) X-Google-Smtp-Source: ACJfBouhz3qatebuoXnAdg23PSzyAHNcK694NbQ8b8iXIEB3PaJza4E/wlLl/6ucMrDsx5PyemXe X-Received: by 10.84.133.131 with SMTP id f3mr43189042plf.280.1516212062292; Wed, 17 Jan 2018 10:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516212062; cv=none; d=google.com; s=arc-20160816; b=b6R++/iuo+ImfQQ8XunXLHc/2+HHmscdwt+r6St8eVlTlG/vzwQ3/QMQRLyIzbSTYn UC6dFrNl36liKk41vF5jpZwaTyyemr8wAg8wv1Feowi58g2E3U8uqF0YOHLXdLZ52eGV vFglvOHg1Ne7SPIwi7K1gcBYQANDqUaDopHxiYk05GzW4WynHumdvN6G69B97210Kou2 XA1vRGtMQ58TYalstIaN6/TY521SjToEHyVhECyURqp4+ZHd/rPXd9ATH7i4ZlFkvIPY 7hNNIwmIMvVDfiUARnvX2iVnYbVHIbEPbiU0GvphPY8zIByHGY87OzpJ1VBQJnSAcsZU 4tpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8tJYEdQaYZPfHATDqwVdKeo0cSMq39kx4dMkKrC9lEE=; b=wpuzx736usVp2myRu9uRY1hek4VYCugz1I/NhJwDGrLP4DdGVI+VCvEHztgbopHFzI oEuZOOIKD7JWRKq1qXcTc+b5Q7pn3mKgamohRSqaVcSas3voev95fqoqTsw44BcLiPnC T7eOXWUXN0lZ5ytajBBgdmYnlM4jhyvYjelDW0MKGOBI9w7R+yC6h2zjjvFPTx/rv1OD 9En6G2CPe8RANa7NyeyLqHnr9rqcALt5JJZDqk48yI1rsbDmWOiD6wQH/mMGDVyWd6OV 9YArxLnVlbvm6TdLIJZKYGzMdckMeh+eJzIbxMbDXdVoNngMd6JKFPobmn9dpfq47mH/ TK3A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si4681034plo.697.2018.01.17.10.00.46; Wed, 17 Jan 2018 10:01:02 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754389AbeAQR7t (ORCPT + 99 others); Wed, 17 Jan 2018 12:59:49 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:39988 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753669AbeAQR7o (ORCPT ); Wed, 17 Jan 2018 12:59:44 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id E332A2726CF From: Enric Balletbo i Serra To: Lee Jones , Sebastian Reichel Cc: Gwendal Grignou , Benson Leung , Guenter Roeck , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Sameer Nanda Subject: [PATCH 3/3] mfd: cros_ec_dev: Register cros_usbpd-charger driver as a subdevice. Date: Wed, 17 Jan 2018 18:59:32 +0100 Message-Id: <20180117175932.20636-4-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180117175932.20636-1-enric.balletbo@collabora.com> References: <20180117175932.20636-1-enric.balletbo@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sameer Nanda Check whether this EC instance has USBPD host command support and instatiate the cros_usbpd-charger driver as a subdevice in such case. Signed-off-by: Sameer Nanda Signed-off-by: Enric Balletbo i Serra --- drivers/mfd/cros_ec_dev.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 26a8731499bf..d98f03f3d251 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -37,6 +37,9 @@ static const struct attribute_group *cros_ec_groups[] = { &cros_ec_attr_group, &cros_ec_lightbar_attr_group, &cros_ec_vbc_attr_group, +#if IS_ENABLED(CONFIG_CHARGER_CROS_USB_PD) + &cros_usb_pd_charger_attr_group, +#endif NULL, }; @@ -269,6 +272,24 @@ static void __remove(struct device *dev) kfree(ec); } +static const struct mfd_cell cros_usb_pd_charger_devs[] = { + { + .name = "cros-usb-pd-charger", + .id = -1, + }, +}; + +static void cros_ec_usb_pd_charger_register(struct cros_ec_dev *ec) +{ + int ret; + + ret = mfd_add_devices(ec->dev, 0, cros_usb_pd_charger_devs, + ARRAY_SIZE(cros_usb_pd_charger_devs), + NULL, 0, NULL); + if (ret) + dev_err(ec->dev, "failed to add usb-pd-charger device\n"); +} + static void cros_ec_sensors_register(struct cros_ec_dev *ec) { /* @@ -451,6 +472,10 @@ static int ec_device_probe(struct platform_device *pdev) if (cros_ec_debugfs_init(ec)) dev_warn(dev, "failed to create debugfs directory\n"); + /* check whether this EC instance has the PD charge manager */ + if (cros_ec_check_features(ec, EC_FEATURE_USB_PD)) + cros_ec_usb_pd_charger_register(ec); + /* check whether this EC is a sensor hub. */ if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE)) cros_ec_sensors_register(ec); -- 2.15.1