Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp812268ybj; Thu, 7 May 2020 08:11:05 -0700 (PDT) X-Google-Smtp-Source: APiQypKwYbI05HLBZyjGGUISJYnlgH7OC09xOapecHhNYkctRUaagTL9D0P3TjMBabtGKVgeWeOS X-Received: by 2002:a05:6402:b82:: with SMTP id cf2mr11756131edb.49.1588864264972; Thu, 07 May 2020 08:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588864264; cv=none; d=google.com; s=arc-20160816; b=HO1tgjMYnyQgBAJvv1GnzI5ztXGa2PjcErrwfyM4rX6e1kVi4QJ35lr56MIf4mj8YY nQhL2pQIc91J7/UR/JD1f0UypbZA72x91y0SEONQVSAoyYw5facmhK3CYvsPRNiSeBAh wasOWBQk5Nsl5gsrGOqhoXek2h23p0ObeWeUM5Mj9q4Xwxm7X/x3UzXo50TwgkpBScRs va1uXMwJLmFAEmWyNmBU6LmRaGa8ld7Zv+8DLNCMtKBFkbkqalVNU1cVy5THbRgLb2ta DatwTCx6wNg1AXZ1wVdAef1xFKUjlfZlu+sWJvLdCnKAB825wT5wqYdDXym7r1UyLUAc rfIw== 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 :ironport-sdr:ironport-sdr; bh=MoSNxOjqAXrVztAUXH9VBjszrlbFXdlIg5yXceusqeA=; b=c1ZRn47JmqaIkb/YmVPmtqwx7gZsf9DOn+ajliajKp0aFVUlLCRre6UAhI55nzbQuX 06pmfXC2PteNoNgq/jCROEemn0T+QUgosvf27PYcbrBScQiUnSRqCXX333UMn/9I2mYx Y7lBxDeedvy4GdIXFEbKy2cd0jtAHBOLoYepBOtKPXeqNJmp2kGbGpUCY0Z1KTmMqox4 wKAbkKEXH5PKuh0+5Pm1YzkFXGtIgennwEeBxONVjrl/5DxD1kkY2u7gVS5O6a2uV99+ BHX/o7nKgFGvXweeyu5qbzgj25fcyTjj2VeUmBL3o8toNuffv6r/Puew2gNk0IQaYcpQ p6CA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x23si3145371ejb.130.2020.05.07.08.10.41; Thu, 07 May 2020 08:11:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbgEGPJK (ORCPT + 99 others); Thu, 7 May 2020 11:09:10 -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 S1727833AbgEGPJI (ORCPT ); Thu, 7 May 2020 11:09:08 -0400 IronPort-SDR: pCxfU4fUfFb/ZnA8LrxMWOadiMJSYbt1zgDkCBweq2LriFqlwiOY8aULzVwRrfBqThVQk0iCZA clmVwrvaTJsw== 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:07 -0700 IronPort-SDR: vqZo7as03LfCIUCXjkULgUVHfl7jY6XAFnHJfcq6GOZaYujfYLbUj5yEa69jZEdJay4XqPSU6e NxgktWHZ5WZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,364,1583222400"; d="scan'208";a="370143316" 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:05 -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 2/4] usb: typec: mux: intel_pmc_mux: Support for static SBU/HSL orientation Date: Thu, 7 May 2020 18:08:58 +0300 Message-Id: <20200507150900.12102-3-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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The SBU and HSL orientation may be fixed/static from the mux PoW. Apparently the retimer may take care of the orientation of these lines. Handling the static SBU (AUX) and HSL orientation with device properties. If the SBU orientation is static, a device property "sbu-orintation" can be used. When the property exists, the driver always sets the SBU orientation according to the property value, and when it's not set, the driver uses the cable plug orientation with SBU. And with static HSL orientation, "hsl-orientation" device property can be used in the same way. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/mux/intel_pmc_mux.c | 42 +++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index f5c5e0aef66f..1aac218099f3 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -91,6 +91,9 @@ struct pmc_usb_port { u8 usb2_port; u8 usb3_port; + + enum typec_orientation sbu_orientation; + enum typec_orientation hsl_orientation; }; struct pmc_usb { @@ -99,6 +102,22 @@ struct pmc_usb { struct pmc_usb_port *port; }; +static int sbu_orientation(struct pmc_usb_port *port) +{ + if (port->sbu_orientation) + return port->sbu_orientation - 1; + + return port->orientation - 1; +} + +static int hsl_orientation(struct pmc_usb_port *port) +{ + if (port->hsl_orientation) + return port->hsl_orientation - 1; + + return port->orientation - 1; +} + static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) { u8 response[4]; @@ -151,8 +170,9 @@ pmc_usb_mux_dp(struct pmc_usb_port *port, struct typec_mux_state *state) req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT; req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT; - req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_AUX_SHIFT; - req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_HSL_SHIFT; + + req.mode_data |= sbu_orientation(port) << PMC_USB_ALTMODE_ORI_AUX_SHIFT; + req.mode_data |= hsl_orientation(port) << PMC_USB_ALTMODE_ORI_HSL_SHIFT; req.mode_data |= (state->mode - TYPEC_STATE_MODAL) << PMC_USB_ALTMODE_DP_MODE_SHIFT; @@ -173,8 +193,9 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state) req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT; req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT; - req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_AUX_SHIFT; - req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_HSL_SHIFT; + + req.mode_data |= sbu_orientation(port) << PMC_USB_ALTMODE_ORI_AUX_SHIFT; + req.mode_data |= hsl_orientation(port) << PMC_USB_ALTMODE_ORI_HSL_SHIFT; if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TBT3) req.mode_data |= PMC_USB_ALTMODE_TBT_TYPE; @@ -211,8 +232,8 @@ static int pmc_usb_connect(struct pmc_usb_port *port) msg[0] |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT; msg[1] = port->usb2_port << PMC_USB_MSG_USB2_PORT_SHIFT; - msg[1] |= (port->orientation - 1) << PMC_USB_MSG_ORI_HSL_SHIFT; - msg[1] |= (port->orientation - 1) << PMC_USB_MSG_ORI_AUX_SHIFT; + msg[1] |= hsl_orientation(port) << PMC_USB_MSG_ORI_HSL_SHIFT; + msg[1] |= sbu_orientation(port) << PMC_USB_MSG_ORI_AUX_SHIFT; return pmc_usb_command(port, msg, sizeof(msg)); } @@ -296,6 +317,7 @@ static int pmc_usb_register_port(struct pmc_usb *pmc, int index, struct usb_role_switch_desc desc = { }; struct typec_switch_desc sw_desc = { }; struct typec_mux_desc mux_desc = { }; + const char *str; int ret; ret = fwnode_property_read_u8(fwnode, "usb2-port", &port->usb2_port); @@ -306,6 +328,14 @@ static int pmc_usb_register_port(struct pmc_usb *pmc, int index, if (ret) return ret; + ret = fwnode_property_read_string(fwnode, "sbu-orientation", &str); + if (!ret) + port->sbu_orientation = typec_find_orientation(str); + + ret = fwnode_property_read_string(fwnode, "hsl-orientation", &str); + if (!ret) + port->hsl_orientation = typec_find_orientation(str); + port->num = index; port->pmc = pmc; -- 2.26.2