From patchwork Wed Jun 28 13:38:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin LABBE X-Patchwork-Id: 11391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8939009vqr; Wed, 28 Jun 2023 06:47:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6z2i8ozuNdnTmHo5c07ldSw0AYYvmnRjy+gHrD7PTG3RNMBIoZYsztqH2SjBc63+xFDIQe X-Received: by 2002:a05:6512:3ba1:b0:4f9:6c44:1bf3 with SMTP id g33-20020a0565123ba100b004f96c441bf3mr12248087lfv.62.1687960061617; Wed, 28 Jun 2023 06:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687960061; cv=none; d=google.com; s=arc-20160816; b=fB2ZYz3Ixj5MB9qozQUXSmuJ94+CgC4RHqt4ou91SLtCCI/YCgAHRaSCWcXU7SKsjr 5HzyBQrLV/dlBIrcUJ/Dq/xbRW5Qs3Y5RRtzhQexxh5rCJPJdiQlzlk0Pjki1YCrTVm4 AvKH4N3L64kXIlbJPQBYgzexwJdZYEcqJFRBL+qt9tCSgkESM4i7a28nT79i+rktKtn7 MPOT87PwOcee94Dc+IJLxHRNV09B/MkRL1oQWaXPHwnrFpFglq2Tf8RXEOXYyQHUJumg I2pfDvXWNSRR+DPNfHn9B7fn/XR1eMVj0FWDAsQQnOmcurpfrUt8Nl7EkJ8B71PDjzZl hy5w== 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=BD6UVrDj44rW0iJhXXnbinIwh1j5tk1DZT8e7Z3NaOY=; fh=ljIJXa/02WWeFdEyWsNa3R9UMHHsPyI4Sfxsawa6K6M=; b=TErvHv8k7j+kKwBhTZyusu+BvVqWw9RF8bJMtVzvNCGoGr/YKzI0X4Wm9LQxi4tKc3 Qluk0Ld0yeJY2diZQbq1xXFgYMDHtXwRYYT58XGljuiuIDsLppUqlTLNrW4LHI7FOcvy dBi4yoSgHXHf8ITc0stNDNzvVu1E544hIcfNj2iBAWaBOgVc2juJLPmFWcEDf/DP1ttY lx5c0h6/Tzp4tcowRsOXksXrbZaCMkqvIKhrTBRCxKd78Io+Y9RR22jl1hpjNZunApB4 ENiyLnzMS/ndjVJzAW4JSKwAOPx9c9IHrDD2GzLldLGXGK5Ofg0qaCwt2jD/lkBEgkvU u6NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=WWeVCCFb; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b22-20020aa7cd16000000b0051d9ec8860csi2951574edw.263.2023.06.28.06.47.16; Wed, 28 Jun 2023 06:47:41 -0700 (PDT) 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=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=WWeVCCFb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232027AbjF1Nir (ORCPT + 99 others); Wed, 28 Jun 2023 09:38:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjF1Nil (ORCPT ); Wed, 28 Jun 2023 09:38:41 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B40A129 for ; Wed, 28 Jun 2023 06:38:40 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fba64d9296so20826025e9.3 for ; Wed, 28 Jun 2023 06:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687959518; x=1690551518; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BD6UVrDj44rW0iJhXXnbinIwh1j5tk1DZT8e7Z3NaOY=; b=WWeVCCFbIZYErL2dpy976B3XVZvdzxcSOLDIklpFS4QKRgwH1WVfQ9hdJfQU2Oj8kt 59hY7CvgZDiQ23mxOd4qQbzgRVCEMXayqCNT6lb14UlOh+86lDuEuW/zAfWMM7Hgqfig 2zJ1A4rfpFzuqAed6ZUOl65Zf3gBcUAWSGgVpTaqq3LhZr4CBd2zu3uFu2gdjvHNS2x9 auKS8QERrTRDWhPdE9u/Ex/qEGt2GqHNFFo6+me2Mvcbx+ZmJ+LsYv4wR8huegNmSF71 dBz0l5eJ+Xfjo44TJXOiUZGY0XgcBgeOnJL3Hndpk5dgbD9tN0MyNaZwV4tUAs6K1LDr qU7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687959518; x=1690551518; 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=BD6UVrDj44rW0iJhXXnbinIwh1j5tk1DZT8e7Z3NaOY=; b=AoP1Bz6ORPCjQerbKNKFRga7Z7NYfSOb+R324YPHvNk2X6xsWL+LtHxaBHEOCG3nk7 nPxBnj1aOxQANExiIdDTI5KrzVKsFkLdCWkLz56MKpW5QoKPxAbJ4w395sBGqwDlJq1g VOOwOkqXbwi/QWx7LVruEqwbUsu0YrXJpgorcvgMvPaqAKNKgT6bTuhblSQlR2Fs86Mv 77WxMqYSFd/92zvmYgyq3qfsHhMmphmi74puZ4gRsSFa2PAO2WQXZyEBZKDaZ+Ag/S5x Xp0H7OCFPkja3RtwgqwJuq+7WolP0bdyg2Ud6kAy9BK8xccbVpPdP4xtq9YHDAxj64V4 6vBw== X-Gm-Message-State: AC+VfDwSBomaWV9cDGWEibNEiAE5kwTWJQDbX+DLmqZf6z0rYvrF+mN0 GyKhIrxOydyUKQ0Oa6kNdw/78w== X-Received: by 2002:a1c:f603:0:b0:3f8:f80e:7b45 with SMTP id w3-20020a1cf603000000b003f8f80e7b45mr26822235wmc.7.1687959518616; Wed, 28 Jun 2023 06:38:38 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id o23-20020a05600c379700b003fae92e7a8dsm7657539wmr.27.2023.06.28.06.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 06:38:37 -0700 (PDT) From: Corentin Labbe To: gregkh@linuxfoundation.org, johan@kernel.org Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, david@ixit.cz, Corentin Labbe Subject: [PATCH v6 0/2] usb: serial: add support for CH348 Date: Wed, 28 Jun 2023 13:38:32 +0000 Message-Id: <20230628133834.1527941-1-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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?1769954409735735463?= X-GMAIL-MSGID: =?utf-8?q?1769954409735735463?= Hello The CH348 is an octo serial to USB adapter. The following patch adds a driver for supporting it. Since there is no public datasheet, unfortunatly it remains some magic values. It was tested with a large range of baud from 1200 to 1500000 and used with success in one of our kernel CI testlab. Regards Changes since v1: - use a data structure for encoding/decoding messages. - check if needed endpoints exists - fix URB leak in ch348_allocate_status_read error case - test for maximum baud rate as stated by datasheet Changes since v2: - specify ch348_rxbuf data length - Use correct speed_t dwDTERate instead of __le32 - test for maximum baud rate supported according to datasheet - Use a define for CH348_TX_HDRSIZE Changes since v3 - Fixed all reported problem from https://lore.kernel.org/lkml/Y5NDwEakGJbmB6+b@Red/T/#mb6234d0427cfdabf412190565e215995a41482dd Mostly reworked the endpoint mux to be the same than mx_uport Changes since v4: - The V4 was sent against stable and next have ch348_set_termios ktermios parameter const that I forgot to change Changes since v5: - Fixed all reported problem from https://lore.kernel.org/lkml/20230106135338.643951-1-clabbe@baylibre.com/T/#m044aab24dfb652ea34aa06f8ef704da9d6a2e036 - Major change is dropping of all status handling which was unused. It will be probably necessary to bring it back when using GPIO. This will be done when I will finish my next devboard. Corentin Labbe (2): usb: serial: add support for CH348 usb: serial: add myself as maintainer of CH348 MAINTAINERS | 5 + drivers/usb/serial/Kconfig | 9 + drivers/usb/serial/Makefile | 1 + drivers/usb/serial/ch348.c | 491 ++++++++++++++++++++++++++++++++++++ 4 files changed, 506 insertions(+) create mode 100644 drivers/usb/serial/ch348.c Tested-by: David Heidelberg Reviewed-by: David Heidelberg