From patchwork Fri Aug 19 19:08:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12949100 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 15A504A09 for ; Fri, 19 Aug 2022 19:08:22 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id pm17so5472660pjb.3 for ; Fri, 19 Aug 2022 12:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=tlVqcJR2RWJzIVx+j8QXqXkEF4w+7JdP2qYqCLd2xU4=; b=MTI4vdwl4gqRh60KksQSrtWRv3xKQhL4y0uyrbG6EjptfSnhYcS/a2IpoCAADgnsj3 /UA8bAe96gCub5qyGe1JCpglsSCvv8stYJ71yjXiPbOm1hQq8V5KlyMXspDtHeEdtetG 6C3hMAN05XCtZ7qvcPGFYqj4O39JqGpaHzHEc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=tlVqcJR2RWJzIVx+j8QXqXkEF4w+7JdP2qYqCLd2xU4=; b=tgG0BYXqPjVHU+IggS+WScvQZb+JFIDLZnxfbAMmd7YtwEf0O3auAIADn7uYw9gtUm BPkgfWCAYkGXshrv3O8yndx39b0U1Hyn0d96lnKzNAumlpNhw12J+NkWoKOBBP5O1aV9 gw86hGBI+IuAkLjeVfheMijOitcK02UpLAgq/UXBpYWXHo9drhUsXOgHcuxnUc9rJLI+ Ys+Q+e4jspQTg2xT7K88YqLtzzYQUypk21+5ObRZG0YSPw/ozLB8jytzlrjhN5IKrAX/ XiABIfplCFkYQVEz/xRptFZoqvHNVwHrssEhGTJiIUKxPBbcCk0H3rfb7JVK9WxDzmZF O0Tw== X-Gm-Message-State: ACgBeo3OkmEkav/UZd9K7NIS1LLnfgEaJSE3bqUd28OgOHxzMlAZQYau amqKYpcErFX4VhIGpCfz7VaWLw== X-Google-Smtp-Source: AA6agR7nsL+lGm9wkhClhGQEYjdyYIzCzzJ7BrY20bzxN4eaO+k5+HpggVpEqvpCtXksK6OiKfxxig== X-Received: by 2002:a17:902:b483:b0:170:a89f:32b3 with SMTP id y3-20020a170902b48300b00170a89f32b3mr8695426plr.149.1660936102550; Fri, 19 Aug 2022 12:08:22 -0700 (PDT) Received: from pmalani.c.googlers.com.com (137.22.168.34.bc.googleusercontent.com. [34.168.22.137]) by smtp.gmail.com with ESMTPSA id b14-20020a170903228e00b00172a567d910sm3499775plh.289.2022.08.19.12.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:08:22 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: bleung@chromium.org, Prashant Malani , Enric Balletbo i Serra , Guenter Roeck , Heikki Krogerus Subject: [PATCH 1/4] platform/chrome: cros_ec_typec: Add bit offset for DP VDO Date: Fri, 19 Aug 2022 19:08:02 +0000 Message-Id: <20220819190807.1275937-2-pmalani@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog In-Reply-To: <20220819190807.1275937-1-pmalani@chromium.org> References: <20220819190807.1275937-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the right macro while constructing the DP_PORT_VDO to ensure the Pin Assignment offsets are correct. Fixes: 1ff5d97f070c ("platform/chrome: cros_ec_typec: Register port altmodes") Signed-off-by: Prashant Malani Reviewed-by: Tzung-Bi Shih Acked-by: Heikki Krogerus --- drivers/platform/chrome/cros_ec_typec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index de6ee0f926a6..4d81d8d45b73 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -25,7 +25,8 @@ #define DRV_NAME "cros-ec-typec" -#define DP_PORT_VDO (BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D) | DP_CAP_DFP_D) +#define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \ + DP_CAP_DFP_D) /* Supported alt modes. */ enum { From patchwork Fri Aug 19 19:08:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12949101 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 C00F54A09 for ; Fri, 19 Aug 2022 19:08:28 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id y15so1126873pfr.9 for ; Fri, 19 Aug 2022 12:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=NY3og6uVOGIRfydWAoiK8DTzipQrxXXqtzrWPkrx8rE=; b=VJQxFgKABXidqeK6PcYka/SLJnrMhsN5piLG5aBGrmKOX55QepEObQ88MWMkZXJH0H MiYLtWEBXs8MGcNVMdwZMFOJBshSIXYwtMBZzDrFt9ptpY6CdufVoVXJu16TZ0tajZkv YxXPq9YarjoNbmyvcRjmrlu7hctfeeWFP38yY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=NY3og6uVOGIRfydWAoiK8DTzipQrxXXqtzrWPkrx8rE=; b=qIc/9we2ftKa6yMeJpLD5nQygRRyuVby4DadQ5eQu0Zegi9+9yGv2nZOhr1Rb34zxf 9RYp8gHe6vrLyctBdFHkOS5et4q10F/m7yVd3ewZo4MW7RitoPbj843gB1N0orc3ujRi UIj+vscv+0WdBbhBbewYnK7HS1Xvh5NZWmBg0H/pcN0o++DINH9SdsoWb7DkBlrj+jGh hDG145qscz15Q6ThbAGfmdK6lO0akcRyFjJZqXLEuO1YguDP2cYnxH2sp0nwkiWnvAJ/ iOlk0Pm/3MnfjEI0WmUK/mCRzCQO6JOhtwxXY6zYFR6TCUmVknAVxGomv2rsp+ZAP++E wJiA== X-Gm-Message-State: ACgBeo1fKmweCD0V8r0LV/K4tu4xZIIZBIEMhZNlDCYfOYuz29YkEZmz 5qlGSMNxTs5zd4w0x3o6IiUoAg== X-Google-Smtp-Source: AA6agR4hHW67M1U75F44AWEu1mn0JI3XHNB4+7SKR0ssNvQHD9p15ZaaWOD10jBLMG5e8LtgM67xsg== X-Received: by 2002:a63:6b02:0:b0:422:7cf8:4bf with SMTP id g2-20020a636b02000000b004227cf804bfmr7501437pgc.92.1660936108315; Fri, 19 Aug 2022 12:08:28 -0700 (PDT) Received: from pmalani.c.googlers.com.com (137.22.168.34.bc.googleusercontent.com. [34.168.22.137]) by smtp.gmail.com with ESMTPSA id b14-20020a170903228e00b00172a567d910sm3499775plh.289.2022.08.19.12.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:08:28 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: bleung@chromium.org, Prashant Malani , Enric Balletbo i Serra , Guenter Roeck , Heikki Krogerus Subject: [PATCH 2/4] platform/chrome: cros_ec_typec: Correct alt mode index Date: Fri, 19 Aug 2022 19:08:03 +0000 Message-Id: <20220819190807.1275937-3-pmalani@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog In-Reply-To: <20220819190807.1275937-1-pmalani@chromium.org> References: <20220819190807.1275937-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Alt mode indices used by USB PD (Power Delivery) start with 1, not 0. Update the alt mdoe registration code to factor this in to the alt mode descriptor. Fixes: de0f49487db3 ("platform/chrome: cros_ec_typec: Register partner altmodes") Signed-off-by: Prashant Malani Reviewed-by: Tzung-Bi Shih Acked-by: Heikki Krogerus --- drivers/platform/chrome/cros_ec_typec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 4d81d8d45b73..dc5722db2066 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -698,7 +698,7 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_ for (j = 0; j < sop_disc->svids[i].mode_count; j++) { memset(&desc, 0, sizeof(desc)); desc.svid = sop_disc->svids[i].svid; - desc.mode = j; + desc.mode = j + 1; desc.vdo = sop_disc->svids[i].mode_vdo[j]; if (is_partner) From patchwork Fri Aug 19 19:08:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12949102 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 BCB7E4A09 for ; Fri, 19 Aug 2022 19:08:32 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id u22so4876537plq.12 for ; Fri, 19 Aug 2022 12:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=LRNQZAQfuVWPtn0ySqLWsoQsRuvJYWivZoqggybL5d4=; b=OJYjgn5Ecua8yljlsSDpa51lK5T4ff4foNJdIiSLf5dNe6a6frhKr7dxS9Bbj8nSoo HnirEUD7kvbmjSOXMm+vZvJWj9rRAvvR6hfXpQowjzOFLjXwmEz0eKisYWgGc6noO/v0 yHP6AClXhnWajIVHARTyTmYCabfyodtv1lpm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=LRNQZAQfuVWPtn0ySqLWsoQsRuvJYWivZoqggybL5d4=; b=ZsPMC6wt0W22wm/V24S4VfySyyXm776d1mUIm7xKQidnNRyedF2QcridaCzf0hXqAz Jf3KrfCG4q4Sllbn+26wtdqSXKilvdpbFdd6WU3Alnrx+LP1W40AhirAk4KEWvbRUPA6 YwWhsy3pYMLX0bZUJas+7VISR//kgUX6MbAZEuUV9X1bG4xDekofWgdcAofb6OoAmKaX 7sM0L/gwXBuarxpYHf+h2YMCUqxtfPaoVH+0yzQcOL675OptPWBiweEPWdjcYDLQRviE oLU0gwiRLzt2JyBWyzwdcP7bBihuesBbi5Y0YE+jfoXtAawEv0mvvMsiooKUMpaIJ0y7 m4Qw== X-Gm-Message-State: ACgBeo2/VCwRLhbtCgGyTiTDjcOiOBIzfS5fJlY4eFipTz4ByhE6//Ui Mqaw6OD9IXt0/qbiKxLG02yeNQ== X-Google-Smtp-Source: AA6agR5y8NDxG372IwiHy3L/WeoVZMiJNDnSzObCzFMnj9kywQ5kojSHeAn2uZkfOggsjIO+U3I8Zw== X-Received: by 2002:a17:903:494:b0:172:9823:e355 with SMTP id jj20-20020a170903049400b001729823e355mr8608235plb.75.1660936112240; Fri, 19 Aug 2022 12:08:32 -0700 (PDT) Received: from pmalani.c.googlers.com.com (137.22.168.34.bc.googleusercontent.com. [34.168.22.137]) by smtp.gmail.com with ESMTPSA id b14-20020a170903228e00b00172a567d910sm3499775plh.289.2022.08.19.12.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:08:32 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: bleung@chromium.org, Prashant Malani , Enric Balletbo i Serra , Guenter Roeck , Heikki Krogerus Subject: [PATCH 3/4] platform/chrome: cros_ec_typec: Stash port driver info Date: Fri, 19 Aug 2022 19:08:04 +0000 Message-Id: <20220819190807.1275937-4-pmalani@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog In-Reply-To: <20220819190807.1275937-1-pmalani@chromium.org> References: <20220819190807.1275937-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Stash port number and a pointer to the driver-specific struct in the local Type-C port struct. These can be useful to the port driver to figure out how to communicate with the ChromeOS EC when an altmode driver related callback is invoked from the Type-C class code. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index dc5722db2066..7daf4207c11e 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -44,6 +44,7 @@ struct cros_typec_altmode_node { /* Per port data. */ struct cros_typec_port { struct typec_port *port; + int port_num; /* Initial capabilities for the port. */ struct typec_capability caps; struct typec_partner *partner; @@ -71,6 +72,8 @@ struct cros_typec_port { struct ec_response_typec_discovery *disc_data; struct list_head partner_mode_list; struct list_head plug_mode_list; + + struct cros_typec_data *typec_data; }; /* Platform-specific data for the Chrome OS EC Type C controller. */ @@ -368,6 +371,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) goto unregister_ports; } + cros_port->port_num = port_num; + cros_port->typec_data = typec; typec->ports[port_num] = cros_port; cap = &cros_port->caps; From patchwork Fri Aug 19 19:08:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12949103 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 88AB74A09 for ; Fri, 19 Aug 2022 19:08:36 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id p18so4883032plr.8 for ; Fri, 19 Aug 2022 12:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=DqrEek4KEewVAx/BWFwpw/lOY/BhLwmErxM0R0EWxLo=; b=MwFNBQo0TZ6ZipDVfvyCnneHe7+leBOXAzZu5KqzchrPPb9Yjc/vvEEVuvx+qV39vO V5YCldxxCyOYEdgy093cDUANWG7mMGS+mR3UEfYCTayQ2a4lv/xVijHlz9ZSl8fLus7o 3YcHWTykQ89fdE+pG+jslDjXurkjxMpD/BRHU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=DqrEek4KEewVAx/BWFwpw/lOY/BhLwmErxM0R0EWxLo=; b=MlUuIM9nvF/4Cp10q0ft8eGrAkAoUjT4jiIHD0SXHDuNHK5uGhQlIt44xNFpV4rcS8 fEllmaurRUsK62Q2ZlBWsWtSF63Cx2T+XJYSw4wYKGditYChsxVBhyLy432ANr7iq0LT VEEvHP1Dl6jNuDvcjg5TmV53RP1I92Glf82i7IvTaq1b1eNILf+ORj7UVps0dCBBpQb5 +9p0/XJc8f6TwdDbNv9P/EJNygjtS0nFxZI1jZWBQmi1A+I3qofpYpC1He8VdzW9qzDj VPhvjZK6zFOaYsNiN9BF20iVMZbZ8Q7FzJY61fTuCUKQS5UQmHd3m/Svo7/z9vdxIT0f SxYA== X-Gm-Message-State: ACgBeo2h/W5rv9vSq/cFD4hL81wfyDlWyqrmx0cOAi9l5/RyENpaW+5x FO+XjNptMn94KBmM9bUTVjLXSg== X-Google-Smtp-Source: AA6agR4T/qUdLe4Pb2e1At9eR7z2ZJw11QKB/5L2FNFC3ZuaAZNkzzsZtZz5GcksgRnluCf8GT0Tyw== X-Received: by 2002:a17:90b:4b89:b0:1f5:68b:b14e with SMTP id lr9-20020a17090b4b8900b001f5068bb14emr16054333pjb.30.1660936115902; Fri, 19 Aug 2022 12:08:35 -0700 (PDT) Received: from pmalani.c.googlers.com.com (137.22.168.34.bc.googleusercontent.com. [34.168.22.137]) by smtp.gmail.com with ESMTPSA id b14-20020a170903228e00b00172a567d910sm3499775plh.289.2022.08.19.12.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:08:35 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: bleung@chromium.org, Prashant Malani , Enric Balletbo i Serra , Guenter Roeck , Heikki Krogerus Subject: [PATCH 4/4] platform/chrome: cros_ec_typec: Use Type-C driver data Date: Fri, 19 Aug 2022 19:08:05 +0000 Message-Id: <20220819190807.1275937-5-pmalani@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog In-Reply-To: <20220819190807.1275937-1-pmalani@chromium.org> References: <20220819190807.1275937-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Altmode driver callbacks need EC-specific port information to communicate with the ChromeOS EC. To accomplish this, save a pointer to the driver-specific port struct in the Type-C port's driver data field. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 7daf4207c11e..e3f75440030d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -379,6 +379,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) ret = cros_typec_parse_port_props(cap, fwnode, dev); if (ret < 0) goto unregister_ports; + cap->driver_data = cros_port; cros_port->port = typec_register_port(dev, cap); if (IS_ERR(cros_port->port)) {