From patchwork Thu May 7 15:08:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 194214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4572CC54E49 for ; Thu, 7 May 2020 15:09:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 257F020838 for ; Thu, 7 May 2020 15:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727119AbgEGPJH (ORCPT ); Thu, 7 May 2020 11:09:07 -0400 Received: from mga09.intel.com ([134.134.136.24]:51959 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbgEGPJG (ORCPT ); Thu, 7 May 2020 11:09:06 -0400 IronPort-SDR: gS1L6o4TKnqL34qvH0708YlAerJyLAN5izssj4p92lZ6FoJVJjYjKGDSS5g3/fiD8vdJGY/uWT 5YYFfw+h+bDA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2020 08:09:05 -0700 IronPort-SDR: QC+4mudJ9wfcqdNd0xGussco6cO6WWj0JFCpTHA8voeqeFU9tklzAMCAFiyXnmomrdpqwOANda zMqM74xOhS2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,364,1583222400"; d="scan'208";a="370143308" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 07 May 2020 08:09:03 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Prashant Malani , Benson Leung , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 1/4] usb: typec: Add typec_find_orientation() Date: Thu, 7 May 2020 18:08:57 +0300 Message-Id: <20200507150900.12102-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200507150900.12102-1-heikki.krogerus@linux.intel.com> References: <20200507150900.12102-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Function that converts orientation string into orientation value. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/class.c | 36 ++++++++++++++++++++++++------------ include/linux/usb/typec.h | 1 + 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 8d894bdff77d..c9234748537a 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -917,6 +917,12 @@ EXPORT_SYMBOL_GPL(typec_unregister_cable); /* ------------------------------------------------------------------------- */ /* USB Type-C ports */ +static const char * const typec_orientations[] = { + [TYPEC_ORIENTATION_NONE] = "unknown", + [TYPEC_ORIENTATION_NORMAL] = "normal", + [TYPEC_ORIENTATION_REVERSE] = "reverse", +}; + static const char * const typec_roles[] = { [TYPEC_SINK] = "sink", [TYPEC_SOURCE] = "source", @@ -1248,18 +1254,9 @@ static ssize_t orientation_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct typec_port *p = to_typec_port(dev); - enum typec_orientation orientation = typec_get_orientation(p); - - switch (orientation) { - case TYPEC_ORIENTATION_NORMAL: - return sprintf(buf, "%s\n", "normal"); - case TYPEC_ORIENTATION_REVERSE: - return sprintf(buf, "%s\n", "reverse"); - case TYPEC_ORIENTATION_NONE: - default: - return sprintf(buf, "%s\n", "unknown"); - } + struct typec_port *port = to_typec_port(dev); + + return sprintf(buf, "%s\n", typec_orientations[port->orientation]); } static DEVICE_ATTR_RO(orientation); @@ -1451,6 +1448,21 @@ void typec_set_pwr_opmode(struct typec_port *port, } EXPORT_SYMBOL_GPL(typec_set_pwr_opmode); +/** + * typec_find_orientation - Convert orientation string to enum typec_orientation + * @name: Orientation string + * + * This routine is used to find the typec_orientation by its string name @name. + * + * Returns the orientation value on success, otherwise negative error code. + */ +int typec_find_orientation(const char *name) +{ + return match_string(typec_orientations, ARRAY_SIZE(typec_orientations), + name); +} +EXPORT_SYMBOL_GPL(typec_find_orientation); + /** * typec_find_port_power_role - Get the typec port power capability * @name: port power capability string diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index b00a2642a9cd..5daa1c49761c 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -254,6 +254,7 @@ int typec_set_mode(struct typec_port *port, int mode); void *typec_get_drvdata(struct typec_port *port); +int typec_find_orientation(const char *name); int typec_find_port_power_role(const char *name); int typec_find_power_role(const char *name); int typec_find_port_data_role(const char *name); From patchwork Thu May 7 15:09:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 194215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37CE1C54E7F for ; Thu, 7 May 2020 15:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A60D20870 for ; Thu, 7 May 2020 15:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727933AbgEGPJN (ORCPT ); Thu, 7 May 2020 11:09:13 -0400 Received: from mga09.intel.com ([134.134.136.24]:51959 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727918AbgEGPJM (ORCPT ); Thu, 7 May 2020 11:09:12 -0400 IronPort-SDR: k+/CFJE1JrgR8wzC8QxySdj+9LhbVKgkxXdITn5vY0s0pZdTf/jeFoAK62oLbe1fuE3txlJJIA l6JRhgVpuyyw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2020 08:09:12 -0700 IronPort-SDR: Kdrobe9NAtsReK2ebrrU91inXeF/GvEXjazQacylEEL53S5oJzHVKS/HvPfU4QqjwViDbiazsE Z9Qscr3hT4HA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,364,1583222400"; d="scan'208";a="370143331" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 07 May 2020 08:09:10 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Prashant Malani , Benson Leung , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 4/4] MAINTAINERS: Add entry for Intel PMC mux driver Date: Thu, 7 May 2020 18:09:00 +0300 Message-Id: <20200507150900.12102-5-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200507150900.12102-1-heikki.krogerus@linux.intel.com> References: <20200507150900.12102-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org I will be maintaining the Intel PMC mux control driver. Signed-off-by: Heikki Krogerus --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 2926327e4976..5a7b0205397b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17590,6 +17590,13 @@ F: Documentation/driver-api/usb/typec.rst F: drivers/usb/typec/ F: include/linux/usb/typec.h +USB TYPEC INTEL PMC MUX DRIVER +M: Heikki Krogerus +L: linux-usb@vger.kernel.org +S: Maintained +F: Documentation/firmware-guide/acpi/intel-pmc-mux.rst +F: drivers/usb/typec/mux/intel_pmc_mux.c + USB TYPEC PI3USB30532 MUX DRIVER M: Hans de Goede L: linux-usb@vger.kernel.org