Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp70375lqo; Wed, 15 May 2024 08:03:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFs+b/D52fJIJkk287U//kcPeRrNuxA5Bp2mm6Lc3cHVa+uIY+BrNXw5uy3v18CqBVazx1UmN4l3mBIZ2keZ78YWDJLs8513WLDr5Xpg== X-Google-Smtp-Source: AGHT+IE9zY8rH7elLXnbdDsuCzGu0HuC+tBN8LRKz/YNwoPKRT3dH6xjolq0hV1UNv/A7YcokPqP X-Received: by 2002:a17:906:5a5a:b0:a5a:34ae:10ea with SMTP id a640c23a62f3a-a5a34ae118emr908806466b.76.1715785385373; Wed, 15 May 2024 08:03:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715785385; cv=pass; d=google.com; s=arc-20160816; b=hOPslCB1/goLAOpo5vLKSiO+Wi0HiuG4kOaal1LrvST+DQEGMFUjdT/Z2FJBSzb3Tf L4y+quPmAA5B/NoY3q5aCKhW0VVmbqy4oyU6NCiD5kM6RWbqsW3SrMU0MSUIu2QIUpeR 1oPqvmOWLCu/u7ox26JBtq0jMhu72u2FSbkHRS0laMSG0L5lxS3ATik82pl1fD/b0Iy1 jqDiXtnXm5yr8647nPyG45Hk4IqxkD18tnLMgZadCY5Bj+r2zkRzoPbwFBXArLcn49YI /Y9i2RairXob0sUdP3PwPhJ72tadeAfZl13z8pkicb32gg8LU2WsNO7Xafedau0kmD5p YAlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1UyqZmUfboktWppmzlMbge493UhsV2Qc8tBPPHmQa0s=; fh=bWPMWumIyHkAtafXjzBr8GFOvAX+a8OVA9yGAFKUNsg=; b=cvDRDOVWLshbc4d33BYnUcW4hiGgPGMHd9h8isroIfhVYX9MJiX1ziSIkfvFz2V8Tj WISIVLeKYw01gQ9H0uoZhR0Uw3m6Sarlbqu3QMgRWBrFxGc+yxB01vQQ2HwZ8Ch803GJ D1PUcA0QfRhrq49TwuEn4fn98D1ykcuaCRs5Y/QQTQTMMkub9Af6xNEsbhL+vPBWckr9 4iU1UockAerGqwqSpgXXFA4sss57tb8sN2JBIx9/fUXKbcA3bJORbKdl0dP6IruY1i76 0q3/tifTKI0PA3vvX2gvwJ0178RTCCbX87kdfy0mt92OdWalxmaqR/iBfAkD2oCTCcDz vh+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dJl3MCaF; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-180035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a76684079si289424266b.405.2024.05.15.08.03.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 08:03:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dJl3MCaF; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-180035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8B1E41F225BB for ; Wed, 15 May 2024 15:02:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 000E3155A5B; Wed, 15 May 2024 15:01:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dJl3MCaF" Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AB2C155A2B for ; Wed, 15 May 2024 15:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715785313; cv=none; b=UYYGWkLMKKJtS875d7KJANpHWZVaAjK6/fWsgnQHnpcVLHDEBkIYHlhSvasU7g8vJYWA1snpTf9sslXWs1RKRh2RUGV/jOQS/Kdf4NjCn1FYeptFcaEoouY8+497szoMwv0pLkERWubE9DmedSuPNtpg/ZJYFzScrgFEaQTjCck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715785313; c=relaxed/simple; bh=ScHBNCjfwH0hgsz8GZny0v3ytqV7J3w0ocDS7d+1VoI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o7gY7rQv2Se9Q1JnRMJxUZlmLMUi9aMd+pCMuPhqgOT3oYO94VSgB9qMqDb5pi4E7v7Jms/BoOnpotbNtXVDH+AUOYRtBfvCeax4ntAgQ6sesyRTclRn9n+qrkkPrgcqmwIDdrbQjJBbe+LBs5E8luIOU9W4r3rONy8/G5sKFkI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=dJl3MCaF; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e4b90b03a9so76802241fa.1 for ; Wed, 15 May 2024 08:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715785310; x=1716390110; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1UyqZmUfboktWppmzlMbge493UhsV2Qc8tBPPHmQa0s=; b=dJl3MCaFt/4v3FygCxRHjHN9zOqmdNhNlo1EPkCzVGKI9Yi25D5IHgLeZJaq++ZH01 gtVEnJXXNjYebR9EnogSbPVbiLUPUWfjN68+O2q5z4SK98/SK23PyD85QL4ceiNAcFqV VeTYjL5JwY3TP2mGtPFCubqeqsRkAznyJKFNesuaTZSrZU86ONCdi4fyVMsPZnko0VsF 4pFACOc8Of/WQHIw5WpRUsww+qo678orS68qP4NaJtJiqIAxrYjw/RYz4zpJRgLW9P0l qsR3r7S+FrtprUzB14vU+93bcgn/LmIyB9wAB/EENKdlZUZp59hTsRsY68fCNbWRtdVY LbzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715785310; x=1716390110; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1UyqZmUfboktWppmzlMbge493UhsV2Qc8tBPPHmQa0s=; b=O9DfJTY7W39vK7rSz2z1w5wK9VVbAgaZ1DJ/5+gZHt+JhqeTMjd5GB/QiFqLvelhhd oVjtCNn96MkMC1hWYXRoFcq8SHV4L1CHhZFfEpMuAFiGK+EJooB+hbgO+PRMvAdCERRN j+ZtXLprM1ULYpBx24oSwfqxkvP2iYc+vMht2nWYnXRtrJwyGhn+IWkYeUBClSt6ZjWD 0R4vpCSxjQa/EEFrqnCvi0XpN7chi4bRtaPY7FvvXXpax8NZ2DOHJizIfi2Gz6WZ1pVG 8yiBvBILA3S8F8F3PmmZ7x0Y4PuWy7BcjGoCiP+PQRYU6zkWmfq/A1iBmrkJHh4iFLuB JmTQ== X-Forwarded-Encrypted: i=1; AJvYcCUJgvLgTVf0r1AWxlyBKCy3Sn12cgKCWZpRLPxDYxsekRfkVBDE5uD+j9XDHfa2pO1/TyfVKQZPA37Umz2kKlAinST+UwFiip4LEw5e X-Gm-Message-State: AOJu0YxGreyxab89jk7Et9BbvCucqfAgW1hJarDiw3SPHYnWqVQmLScV n9Sg3f+h1sa4eiXhlNPFPHMiPpPPqe/KclYlg1kDdr7dFJ4FqH05qK9SNvCXsEHUyygHcEoMdsK M2qQ= X-Received: by 2002:a2e:f1a:0:b0:2e6:a7c3:775a with SMTP id 38308e7fff4ca-2e6a7c37977mr49132481fa.52.1715785310131; Wed, 15 May 2024 08:01:50 -0700 (PDT) Received: from eriador.lumag.spb.ru (dzdbxzyyyyyyyyyyyykxt-3.rev.dnainternet.fi. [2001:14ba:a0c3:3a00::227]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2e4d1622740sm21039371fa.119.2024.05.15.08.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 08:01:49 -0700 (PDT) Date: Wed, 15 May 2024 18:01:48 +0300 From: Dmitry Baryshkov To: Heikki Krogerus Cc: Greg Kroah-Hartman , Neil Armstrong , Bjorn Andersson , Konrad Dybcio , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 7/8] usb: typec: ucsi: glink: merge pmic_glink_altmode driver Message-ID: References: <20240416-ucsi-glink-altmode-v1-0-890db00877ac@linaro.org> <20240416-ucsi-glink-altmode-v1-7-890db00877ac@linaro.org> <46fktwtp3xers6tcpov3qo4zswptvajewsdltm45zbz2kmmpzp@cthu6ylttup3> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Heikki, On Sat, May 04, 2024 at 09:49:42AM +0300, Dmitry Baryshkov wrote: > On Mon, 22 Apr 2024 at 18:02, Heikki Krogerus > wrote: > > > > Hi Dmitry, > > > > On Mon, Apr 22, 2024 at 03:45:22PM +0300, Dmitry Baryshkov wrote: > > > On Mon, Apr 22, 2024 at 01:59:10PM +0300, Heikki Krogerus wrote: > > > > Hi Dmitry, > > > > > > > > On Tue, Apr 16, 2024 at 05:20:56AM +0300, Dmitry Baryshkov wrote: > > > > > Move handling of USB Altmode to the ucsi_glink driver. This way the > > > > > altmode is properly registered in the Type-C framework, the altmode > > > > > handlers can use generic typec calls, the UCSI driver can use > > > > > orientation information from altmode messages and vice versa, the > > > > > altmode handlers can use GPIO-based orientation inormation from UCSI > > > > > GLINK driver. > > > > > [skipped] > > > Note, the existing UCSI displayport AltMode driver depends on the UCSI > > > actually handling the altomode. It needs a partner, etc. > > > [skipped the patch] > > > > > +static void pmic_glink_ucsi_set_state(struct ucsi_connector *con, > > > > > + struct pmic_glink_ucsi_port *port) > > > > > +{ > > > > > + struct typec_displayport_data dp_data = {}; > > > > > + struct typec_altmode *altmode = NULL; > > > > > + unsigned long flags; > > > > > + void *data = NULL; > > > > > + int mode; > > > > > + > > > > > + spin_lock_irqsave(&port->lock, flags); > > > > > + > > > > > + if (port->svid == USB_SID_PD) { > > > > > + mode = TYPEC_STATE_USB; > > > > > + } else if (port->svid == USB_TYPEC_DP_SID && port->mode == DPAM_HPD_OUT) { > > > > > + mode = TYPEC_STATE_SAFE; > > > > > + } else if (port->svid == USB_TYPEC_DP_SID) { > > > > > + altmode = find_altmode(con, port->svid); > > > > > + if (!altmode) { > > > > > + dev_err(con->ucsi->dev, "altmode woth SVID 0x%04x not found\n", > > > > > + port->svid); > > > > > + spin_unlock_irqrestore(&port->lock, flags); > > > > > + return; > > > > > + } > > > > > + > > > > > + mode = TYPEC_MODAL_STATE(port->mode - DPAM_HPD_A); > > > > > + > > > > > + dp_data.status = DP_STATUS_ENABLED; > > > > > + dp_data.status |= DP_STATUS_CON_DFP_D; > > > > > + if (port->hpd_state) > > > > > + dp_data.status |= DP_STATUS_HPD_STATE; > > > > > + if (port->hpd_irq) > > > > > + dp_data.status |= DP_STATUS_IRQ_HPD; > > > > > + dp_data.conf = DP_CONF_SET_PIN_ASSIGN(port->mode - DPAM_HPD_A); > > > > > + > > > > > + data = &dp_data; > > > > > + } else { > > > > > + dev_err(con->ucsi->dev, "Unsupported SVID 0x%04x\n", port->svid); > > > > > + spin_unlock_irqrestore(&port->lock, flags); > > > > > + return; > > > > > + } > > > > > + > > > > > + spin_unlock_irqrestore(&port->lock, flags); > > > > > + > > > > > + if (altmode) > > > > > + typec_altmode_set_port(altmode, mode, data); > > > > > > > > So if the port altmode is using the ucsi_displayport_ops, you can > > > > simply register the partner altmode here instead. That should > > > > guarantee that it'll bind to the DP altmode driver which will take > > > > care of typec_altmode_enter() etc. > > > > > > In our case the altmode is unfortunately completely hidden inside the > > > firmware. It is not exported via the native UCSI interface. Even if I > > > plug the DP dongle, there is no partner / altmode being reported by the > > > PPM. All DP events are reported via additional GLINK messages. > > > > I understand that there is no alt mode being reported, but I assumed > > that there is a notification about connections. > > > > If that's not the case, then you need to use this code path to > > register the partner device as well I think. The partner really has to > > be registered somehow. > > > > > The goal is to use the core Type-C altmode handling, while keeping UCSI > > > out of the altmode business. > > > > > > This allows the core to handle switches / muxes / retimers, report the > > > altmode to the userspace via sysfs, keep the link between the DP part of > > > the stack and the typec port, but at the same time we don't get errors > > > from UCSI because of the PPM reporting unsupported commands, etc. > > > > I understand, and just to be clear, I don't have a problem with > > bypassing UCSI. But that does not mean you can skip the alt mode > > registration. > > > > The primary purpose of drivers/usb/typec/ucsi/displayport.c is to > > emulate the partner DP alt mode device a little so that the actual DP > > alt mode driver drivers/usb/typec/altmodes/displayport.c is happy. The > > altmode driver will then make sure that all the muxes, switches and > > what have you, are configured as they should, and more importantly, > > make sure the DP alt mode is exposed to the user space exactly the > > same way as it's exposed on all the other systems. > > > > There are a couple of UCSI commands that are being used there yes, but > > by modifying it so that those UCSI commands are executed conditionally > > - by checking the ALT_MODE_DETAILS feature - you should be able to use > > it also in this case. > > I have played with the DP AltMode driver. I got it somewhat working, > but I think I'm facing a control issue. > Basically, the altmode driver wants to control pin assignment on its > own. It works with the software TCPM, as we control it. > It works with the normal UCSI, because it still can configure pin > config. However with PMIC GLINK implementation there is no way to > control pin assignment from the Linux side. The firmware does that for > us. > What would be the recommended way to handle it? Is it okay to override > status_update to return just the selected pin config? Or is there any > other (better) way to handle such an issue? Any suggestions or further comments? Is it better to extend the DisplayPort Altmode driver with the 'forced' transitions? Or it would be fine to just register a partner device, emulate the userspace events, but completely ignore the existing displayport driver? > > > > > You really need to register the partner alt mode(s) one way or the > > other in any case, and the partner device itself you absolutely must > > register. The user space interface needs to be consistent. > > For reference, the partner is being reported and registered by the > UCSI firmware. It's only the altmode itself where I'm facing the > issue. -- With best wishes Dmitry