From patchwork Thu Nov 24 15:25:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yasushi SHOJI X-Patchwork-Id: 25623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3461177wrr; Thu, 24 Nov 2022 07:26:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf6TipDPxcm2d7e/o9tie/x04Dt94MP0MVnYOhjZQlx84KTfFTA/vVzdNCL6udBagVrvJNwR X-Received: by 2002:a63:f91a:0:b0:477:8109:ccea with SMTP id h26-20020a63f91a000000b004778109cceamr15591779pgi.376.1669303581803; Thu, 24 Nov 2022 07:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669303581; cv=none; d=google.com; s=arc-20160816; b=YtDeMBqVPC9TkBdlXgiYvqisNzoaq5ybe0mws8yxEswnR/iGwmnwbofqP+ZlEqsg4P KZEgtM+eKcXzcGkgTf8BJydH0fogxS5DVejlsE0AvaoTauRl23YH4B+UfyZFXRd+BFTC kMUVxrrgOlsNZpjLCz81dcmKQKzD0KeveiC/48Ic2DHIm+RlaXSRevPy0Q1MWrMs170G dc7m2v8OFZ+AWKlPmFeqIZf2unUQUmZnYZmngD4i9vLktoBqpTI4h82twP6+3eBu3Btr mUPs74SMqzMvQmA2yQniOvm4yeDxIKOlIOkIV/TQkaBnGcMvVHIQho1Q7hYU4s/89CAQ M+dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ihmcpAV1uu+DHpKZV9irEtpd+m80Oyx9msRgKJnz1F0=; b=Vgmijh0HJsdwqboM5HJiSlcZsh1eICvV13lwbwRLEWkz7tbcEoA51xX+siKirB+ws8 70eRn/hKNKk4IP5+Aj4mdp6fYqbNvG0k/m+yM0sOyokXoJJHeOXyjypLYQ21ax/gMQDG muFMmIv/hr+PGrIfUNFexVtQ+Ct3duGhUvcRgneZ9R8m7cmcX0yXZB2dOuE2JYFi+8QH TdMexztc1+ytoD3Lju5BtGmLigoneQDNrsVmObxJPiLisxVzbtbAXK5+N8PrcNMHJMqC W9opomJEM4INNcEiL39s+4O6cmfg7DBnyz+DdyjMajIxfqPOaYZJD95gG2GlCzpUQGUc gcQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Twl/kMsZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a63d346000000b0046004f18c6csi1482856pgi.456.2022.11.24.07.26.07; Thu, 24 Nov 2022 07:26:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Twl/kMsZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbiKXPZQ (ORCPT + 99 others); Thu, 24 Nov 2022 10:25:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229951AbiKXPZO (ORCPT ); Thu, 24 Nov 2022 10:25:14 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 514BF769ED; Thu, 24 Nov 2022 07:25:13 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id h193so1790779pgc.10; Thu, 24 Nov 2022 07:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ihmcpAV1uu+DHpKZV9irEtpd+m80Oyx9msRgKJnz1F0=; b=Twl/kMsZwxdO2ceWcTqv1XCLrINDgG2W35Mde55raeC4ydBLb3pDSfL/CBwFJw621d q/NpP37xFeuOxOpUpfhow2GP95UofXUf9Is9/Vu98iBQkUuX5A3Z8IYSA4rNAbOW+k4P eZFSkwcR9bX6262q4A8ySK68sxob1JDk2zn2BhUqEh/UwpRbGp+FwIfzKO5sSUs/HSrL CKpoLbqsqF6CVRoCmgZVbm7iwQfLbbHW2sFciiblOwTat80nyZivmoCAfmwCsrtjmf62 7VZbwGXDpek7GmPLyNYTGwa2gw+55J3Zq8jELIeoZcQgCigqi+ytRb554TKsbh7wXXzu li7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ihmcpAV1uu+DHpKZV9irEtpd+m80Oyx9msRgKJnz1F0=; b=zfArut+XmKHzDWjVtMN+gXc7/CsKjiA83fGy6oX7oW3vHRAta9eMLwSHWhnXb+A1P8 o5+GiBRYBDhoqkIDFxyzfcDmkiGumN1w7tBfWP1k2zEEnoy/8HCaOo/tijZKchUa0xlb f6B1q1O4do1lMyTPZZsrLUx1wUjiwxkd1Opuz/Y3q1VvhN3Yrf3xDsXM7C2mMIxWAxr2 SsQ44UKFLUXvSdldKKhODY8JvdENLK5PrecBOoAiWOgCa66N8NKGTd6Ch/sL+Hn7ziVI RPkKRrZ5I9uLi0oAscpRLSu2siinpA4duYVXadxPJs/Ocn7iDSHnsj/YJobVlQWAia9Y aYzQ== X-Gm-Message-State: ANoB5pm5P8O//bFkpVV8uBB0/GzbuniWn0u04CDI3oSH9TAjvxBG32R5 O9Z4bDDQVM5OQjAOVgAmzarNltvipA8= X-Received: by 2002:a63:225d:0:b0:477:beb8:70f8 with SMTP id t29-20020a63225d000000b00477beb870f8mr6354923pgm.281.1669303512780; Thu, 24 Nov 2022 07:25:12 -0800 (PST) Received: from x570.spacecubics.com (221x245x252x90.ap221.ftth.ucom.ne.jp. [221.245.252.90]) by smtp.gmail.com with ESMTPSA id x13-20020aa79a4d000000b0056ba7cda4b5sm1399420pfj.16.2022.11.24.07.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 07:25:12 -0800 (PST) From: Yasushi SHOJI X-Google-Original-From: Yasushi SHOJI To: Yasushi SHOJI , Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: remigiusz.kollataj@mobica.com, linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] can: mcba_usb: Fix termination command argument Date: Fri, 25 Nov 2022 00:25:03 +0900 Message-Id: <20221124152504.125994-1-yashi@spacecubics.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750391673002593822?= X-GMAIL-MSGID: =?utf-8?q?1750391673002593822?= Microchip USB Analyzer can activate the internal termination resistors by setting the "termination" option ON, or OFF to to deactivate them. As I've observed, both with my oscilloscope and captured USB packets below, you must send "0" to turn it ON, and "1" to turn it OFF. From the schematics in the user's guide, I can confirm that you must drive the CAN_RES signal LOW "0" to activate the resistors. Reverse the argument value of usb_msg.termination to fix this. These are the two commands sequence, ON then OFF. > No. Time Source Destination Protocol Length Info > 1 0.000000 host 1.3.1 USB 46 URB_BULK out > > Frame 1: 46 bytes on wire (368 bits), 46 bytes captured (368 bits) > USB URB > Leftover Capture Data: a80000000000000000000000000000000000a8 > > No. Time Source Destination Protocol Length Info > 2 4.372547 host 1.3.1 USB 46 URB_BULK out > > Frame 2: 46 bytes on wire (368 bits), 46 bytes captured (368 bits) > USB URB > Leftover Capture Data: a80100000000000000000000000000000000a9 Signed-off-by: Yasushi SHOJI --- drivers/net/can/usb/mcba_usb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c index 218b098b261d..47619e9cb005 100644 --- a/drivers/net/can/usb/mcba_usb.c +++ b/drivers/net/can/usb/mcba_usb.c @@ -47,6 +47,10 @@ #define MCBA_VER_REQ_USB 1 #define MCBA_VER_REQ_CAN 2 +/* Drive the CAN_RES signal LOW "0" to activate R24 and R25 */ +#define MCBA_VER_TERMINATION_ON 0 +#define MCBA_VER_TERMINATION_OFF 1 + #define MCBA_SIDL_EXID_MASK 0x8 #define MCBA_DLC_MASK 0xf #define MCBA_DLC_RTR_MASK 0x40 @@ -463,7 +467,7 @@ static void mcba_usb_process_ka_usb(struct mcba_priv *priv, priv->usb_ka_first_pass = false; } - if (msg->termination_state) + if (msg->termination_state == MCBA_VER_TERMINATION_ON) priv->can.termination = MCBA_TERMINATION_ENABLED; else priv->can.termination = MCBA_TERMINATION_DISABLED; @@ -785,9 +789,9 @@ static int mcba_set_termination(struct net_device *netdev, u16 term) }; if (term == MCBA_TERMINATION_ENABLED) - usb_msg.termination = 1; + usb_msg.termination = MCBA_VER_TERMINATION_ON; else - usb_msg.termination = 0; + usb_msg.termination = MCBA_VER_TERMINATION_OFF; mcba_usb_xmit_cmd(priv, (struct mcba_usb_msg *)&usb_msg);