From patchwork Tue May 1 22:21:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mats Karrman X-Patchwork-Id: 10374559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95CE86032A for ; Tue, 1 May 2018 22:22:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C0A28D53 for ; Tue, 1 May 2018 22:22:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 718CD28DA1; Tue, 1 May 2018 22:22:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A52728D53 for ; Tue, 1 May 2018 22:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751128AbeEAWVk (ORCPT ); Tue, 1 May 2018 18:21:40 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:42755 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751036AbeEAWVj (ORCPT ); Tue, 1 May 2018 18:21:39 -0400 Received: by mail-lf0-f65.google.com with SMTP id u21-v6so18072654lfu.9 for ; Tue, 01 May 2018 15:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bJqUAhnmBIMovH2yr/3OE5jmIzgZoNpxslTeVE3r/bc=; b=fzvp/4NftiXgdf4yJTiL8anueP9Yk9WBDm4ybKfzJMgLnuSAy4Zk8DcAFz/kdwldi1 saV0vVBR0MKeYnGRYvdYrAPess1ZPnzeCvll8Fs+VXXE85d5rKHGWECjOeKjKOPj+uHT +F63pW6g+gYiR++zFwMlY81dJBvF3PyLKdtJaX/8vl2E3YFCsKv9tqQncfiMjAqa4USa zqWSPIc4QTeXtK6rEIqP3JqXIfn8QEyfpc8BK2dnvYUta/GBeM/A9aZElqKQta/0rYD3 XZHCquN/3EeO47+snVwVX3LoARoIve8fkX+qQqz/iUy2/4z82ZJ9mMjhu0C/LrZlS92b C/fw== 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; bh=bJqUAhnmBIMovH2yr/3OE5jmIzgZoNpxslTeVE3r/bc=; b=qfhghyLvmBjv3nim+boUmkJ+Cn/vuAHY5ShH7WpysX4RDNGSHHORvHE2f32w3d3xSy UpjGnyCcqYJ/AXH/hn3lZgtv0Y/+qHKLfajCueUfv9+1LQRvAeTKnuOVhevXbW/2ZwN6 wcV1tv4tDjyz4EYOcvN98Ca872fIcyF18S0ZQXJyWu38yHYdRoOguzwM/Yof+npuuY2q dGnTi1p6NdSOSerGDVwyGrGORnv2yzlhJboM5hWX8c9MKccoE6pUpCmGNl8GeEHDHO/f QkPeD/3lvqY4B9qPQrIfPWfmGwmuI4qlggb/l9VjqjQJ3ZuvsJuHD7UbbTA/5vlSLje1 lIjg== X-Gm-Message-State: ALQs6tA92Cl0JtlZMln+RmHEfP5nSSYTuzUNM/aa6MlZW+mn0qtUaZjE FdiLEN5byBoRjRBKvqR/Is0= X-Google-Smtp-Source: AB8JxZroH81E/YfMnTqxj3AJZsvHSZ8XSWi40vuqdo2mQX1kvLNVyw9+4k56dU+hphhe44VP9sFtXA== X-Received: by 2002:a2e:9cc7:: with SMTP id g7-v6mr12256184ljj.141.1525213297559; Tue, 01 May 2018 15:21:37 -0700 (PDT) Received: from matsnb.lan ([195.84.96.49]) by smtp.gmail.com with ESMTPSA id j85-v6sm2196840lfh.5.2018.05.01.15.21.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 May 2018 15:21:36 -0700 (PDT) From: Mats Karrman To: Heikki Krogerus , Hans de Goede , Guenter Roeck , Greg Kroah-Hartman Cc: Rob Herring , linux-usb@vger.kernel.org Subject: [RFC PATCH 1/7] usb: typec: Generalize mux mode names Date: Wed, 2 May 2018 00:21:07 +0200 Message-Id: <1525213273-6103-2-git-send-email-mats.dev.list@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525213273-6103-1-git-send-email-mats.dev.list@gmail.com> References: <1525213273-6103-1-git-send-email-mats.dev.list@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current naming used for tcpc_mux_mode constants makes too much assumptioms about the usage of the signals. This patch replaces the names with generic names more closely tied to the Type-C specifications and also adds some new ones. At the same time TCPC_MUX_* defines are removed as they do not fit the new concept and currently have no in-tree users. Signed-off-by: Mats Karrman --- drivers/usb/typec/mux/pi3usb30532.c | 7 ++++--- drivers/usb/typec/tcpm.c | 2 +- include/linux/usb/tcpm.h | 21 ++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/usb/typec/mux/pi3usb30532.c b/drivers/usb/typec/mux/pi3usb30532.c index b0e88db..279f3c3 100644 --- a/drivers/usb/typec/mux/pi3usb30532.c +++ b/drivers/usb/typec/mux/pi3usb30532.c @@ -83,18 +83,19 @@ static int pi3usb30532_mux_set(struct typec_mux *mux, int state) new_conf = pi->conf; switch (state) { + default: case TYPEC_MUX_NONE: new_conf = PI3USB30532_CONF_OPEN; break; - case TYPEC_MUX_USB: + case TYPEC_MUX_2CH_USBSS: new_conf = (new_conf & PI3USB30532_CONF_SWAP) | PI3USB30532_CONF_USB3; break; - case TYPEC_MUX_DP: + case TYPEC_MUX_4CH_AM: new_conf = (new_conf & PI3USB30532_CONF_SWAP) | PI3USB30532_CONF_4LANE_DP; break; - case TYPEC_MUX_DOCK: + case TYPEC_MUX_2CH_USBSS_2CH_AM: new_conf = (new_conf & PI3USB30532_CONF_SWAP) | PI3USB30532_CONF_USB3_AND_2LANE_DP; break; diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 7ee417a..0451ea0 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -790,7 +790,7 @@ static int tcpm_set_roles(struct tcpm_port *port, bool attached, else usb_role = USB_ROLE_DEVICE; - ret = tcpm_mux_set(port, TYPEC_MUX_USB, usb_role, orientation); + ret = tcpm_mux_set(port, TYPEC_MUX_2CH_USBSS, usb_role, orientation); if (ret < 0) return ret; diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index b231b93..3518965 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -93,20 +93,19 @@ struct tcpc_config { const struct typec_altmode_desc *alt_modes; }; -/* Mux state attributes */ -#define TCPC_MUX_USB_ENABLED BIT(0) /* USB enabled */ -#define TCPC_MUX_DP_ENABLED BIT(1) /* DP enabled */ -#define TCPC_MUX_POLARITY_INVERTED BIT(2) /* Polarity inverted */ - -/* Mux modes, decoded to attributes */ +/* Mux modes */ enum tcpc_mux_mode { - TYPEC_MUX_NONE = 0, /* Open switch */ - TYPEC_MUX_USB = TCPC_MUX_USB_ENABLED, /* USB only */ - TYPEC_MUX_DP = TCPC_MUX_DP_ENABLED, /* DP only */ - TYPEC_MUX_DOCK = TCPC_MUX_USB_ENABLED | /* Both USB and DP */ - TCPC_MUX_DP_ENABLED, + TYPEC_MUX_NONE, /* Open switch */ + TYPEC_MUX_2CH_USBSS, /* 2ch USB SS */ + TYPEC_MUX_4CH_AM, /* 4ch Alt Mode */ + TYPEC_MUX_2CH_USBSS_2CH_AM, /* 2ch USB SS + 2ch Alt Mode */ + + // Example of additional modes that may be needed in future: + TYPEC_MUX_4CH_USBSS, /* 4ch USB SS */ + TYPEC_MUX_2CH_USBSS_2CH_AM_B, /* 2ch USB SS + 2ch Alt Mode (e.g. DP GPU2) */ }; + /** * struct tcpc_dev - Port configuration and callback functions * @config: Pointer to port configuration