Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp509761lqh; Tue, 7 May 2024 06:16:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVkJENpd8s2H0WWzijTgacbOQ6qy9xIGVxLACBLYF92p+Vf0jntDJ67jxXHS9gUoHHiCV7fmy5QbCZkThqf0JNOt/fvbZ9rS7II/qIhWw== X-Google-Smtp-Source: AGHT+IGQFfmtQ8pqplLBKFqQdXJh6Yz6X3niygngvzdUq+AHkuZtzaEapYAPQlIP6YisfOzvyS3E X-Received: by 2002:a17:90a:d481:b0:2a5:f70c:9ec6 with SMTP id s1-20020a17090ad48100b002a5f70c9ec6mr9728942pju.24.1715087778232; Tue, 07 May 2024 06:16:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715087778; cv=pass; d=google.com; s=arc-20160816; b=Y5avgb+AFaeiuuh61J8VrQHUKxcFfdUg66EbK9Cxpjs4HQvy8M1f8W9FY2H5qpDYer kqDJdBaRZfe8n3FQDz4eq+oyyotykzO/moKBZcmJeHjhGFGqYLdI97E7qFyoW7wxvEPl 0+q2BNbVJ4PeQtN5ngY0Qyc++V7rPe4tk/R8jcc083NymTOB0Q32ZFa+1+jSWDiEdWKo VqYqsSV9klFsE+LjmNDj3PGtXQItTf+Lm3t+6aG9NQ+KBAQkpHfgSNUK4We2ogGfx90k yazI9SE/bN5FajThaR8m5dQScW2aP6HOjmDWuuO6RQTl5l3KE80goej5tukpq4mtZ+yG 1cvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=cnZup5gSPBBIDg9DceCWgHDe4eLEHTcO16KO9rh+7N0=; fh=22mbfOgIhC+TU/zlPnJwkhyk82Fde/vcTS9rjwDkC0U=; b=XCd+5dCiucwk6RLnCfgGfEMZiW7XLV3IgKBF00t+F/yajTRau5TuWG3tb6mO3g+8CB GxLTpdG6veNI99imgtisxOLYtJ/qxDZFwUWm5ftLPN4ZJ3HtYR2DdaK/UwRqzl/zb7xl B+3gW/6wRrHgA+Vh8MXR7LdjXXdw83CgsS01f8TxaKIyvsXOFnzwZtGaPGqZhoVB8QQQ mH0CfAGaLXp4wr3rmdZCvwguvDUoAnQmFq6+HPSu3dyZou7U1xxe/2EJmEDuf7MS+EU7 DpuXnc6jAMsBZ0+2uPn49iPsrR1eOjEsb2DCa0Rox8tUZLnX9ZizvGXQB/GFJK3b8G3T X/XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=EoK5TtZO; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-171364-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171364-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id mh5-20020a17090b4ac500b002a63dcc38d7si8418969pjb.30.2024.05.07.06.16.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:16:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171364-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=EoK5TtZO; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-171364-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171364-linux.lists.archive=gmail.com@vger.kernel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 17AA6281BE8 for ; Tue, 7 May 2024 13:16:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 472AF15E5C1; Tue, 7 May 2024 13:15:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="EoK5TtZO" Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 2C1CE156F20 for ; Tue, 7 May 2024 13:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715087731; cv=none; b=gomw4h0aNVCBqjpQJSWodL7hCC7HRepv35mmCZsrFzlcbO5aof4SOFxaPUAUonQr6euyMj9GlGgVH8W5bADa92TxT0s6Tk+M+PqirYFRBw1LE3wR1KPpjMegHU/z6uLxfyH3EK5fQeepPWwLeBk7lY5/LkgL08jRHpuXkM/bJU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715087731; c=relaxed/simple; bh=jZxGP6shR2wef0DT3YtnzW2++LqK4oDUegkJE4HZQ/E=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=cRO+gdd1tgiR66rAAXFz+j3l72Fm5zJplitATZIhL4DRlwB9GP0j5XFKeYVXgmN/OKGj8yfaLKPhyS8jvkjw7scdB4C0cRnPcWmt60+h7lJd87YQBGzBqD9Hs5hhTqBCvp9MtreUKIMu06Kw+m3jdnajG5/zfm8MDDcmjnmB5bA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=EoK5TtZO; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-34e28e32ea4so2315333f8f.2 for ; Tue, 07 May 2024 06:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715087726; x=1715692526; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cnZup5gSPBBIDg9DceCWgHDe4eLEHTcO16KO9rh+7N0=; b=EoK5TtZOd2b8t848qniHiCiKOG5u+eLETzkS3122Vcj0Ju0s8puZvszZSi/T4fXuqK K5KqIEiRy10hxXqg1cF191GuY5mShrCDegwYEUAy5DEZQsk62ejvxqcCw/yIqvkMmpLl RnhfgUN7lKfx+q8Qrz602ewZokfieiKYGxRw22KV3djVy5Jmx7VU9T4cvg4ZQLDuX2dM kLtHeDU2xgyW19kaH+j8tThb9gJH4jhuZwbG/Dd2mzvMx8O9yL5iHdVbuu5U2dU7Gt6L n/iK3UkhyqI7Pcrnbx7prRIs24d8hySDp7NYHT+oXJ9jaOwfpT4tAclV4OiOGE08qZPn RNDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715087726; x=1715692526; 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=cnZup5gSPBBIDg9DceCWgHDe4eLEHTcO16KO9rh+7N0=; b=ZTxvAcZsfRydNu4mRGOYZs8KX1+avLsqa2vSbX/PmbaQBbKiKt0eXrGOwxF+rOVsG0 XYvYoLAcyqto7buynTcAiRY9Kg0zXIb1MIvMC5zoMTrv5p8W1BhFdEuw3UJ2KWgPAVN1 jgip4VzzbfsQgPb07CW9db5Twcf7vgGsF249mLUSLX8DYUDH/xc7UKbwVytFGtg5xu+A tr7kwVEmeZ7Fz+Twud3x15vyReTJtYD1bDFfffgKtfYe5bLzIZxLYX0ImKzkpfpGRRdw WzzPZ/DDMTUudAgbUPk/cr9AmXjBkp4R91aQE404g1ua1tDIdjr1OKGao53FHkvdHxOD vIFw== X-Gm-Message-State: AOJu0YyrvEQOSSkZyQ3LJCCMIBwodY6InpVlExMPQqQKKHjSmikmWShl +qCvG68e4q9ZkQjX/sg/3Mn7ZfuCmLOOQGuhhqLkcOPPS97rTBeUjMQQnV7Iijvt//lkJEWEd/z B X-Received: by 2002:a05:6000:255:b0:34e:5551:49e6 with SMTP id m21-20020a056000025500b0034e555149e6mr8100379wrz.14.1715087726510; Tue, 07 May 2024 06:15:26 -0700 (PDT) Received: from arnold.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id o16-20020adfcf10000000b0034b1bd76d30sm12891416wrj.28.2024.05.07.06.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:15:26 -0700 (PDT) From: Corentin Labbe To: gregkh@linuxfoundation.org, johan@kernel.org Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, martin.blumenstingl@googlemail.com, david@ixit.cz, Corentin Labbe Subject: [PATCH v7 0/1] usb: serial: add support for CH348 Date: Tue, 7 May 2024 13:15:21 +0000 Message-Id: <20240507131522.3546113-1-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Changes since v6: - read and print the device version during probe - Only request one bulk out channel from usb-serial core - Implement status report / interrupt handling - Fix buffer->rate calculation / enable support for slow baud rates - use a mutex to protect against concurrent writes - split write buffers for slow baud rates Important note, v7 is mostly done from work of Martin Blumenstingl, so the changelog was built from https://github.com/xdarklight/ch348/commits/main/ Great thanks to him Corentin Labbe (1): usb: serial: add support for CH348 drivers/usb/serial/Kconfig | 9 + drivers/usb/serial/Makefile | 1 + drivers/usb/serial/ch348.c | 725 ++++++++++++++++++++++++++++++++++++ 3 files changed, 735 insertions(+) create mode 100644 drivers/usb/serial/ch348.c -- 2.43.2