Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp4374ybn; Tue, 24 Sep 2019 17:11:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV+DEfWjKxUAFHJh4u4in19aPBjgAAmNhKQty0YYaDE0hLICMu3xf+9DP4kidPao2VrpZ5 X-Received: by 2002:a1c:8097:: with SMTP id b145mr3584123wmd.29.1569370317218; Tue, 24 Sep 2019 17:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569370317; cv=none; d=google.com; s=arc-20160816; b=b0MWSda5akvv/LXRWstEH6KP0SQQD1zxspHx4j4uZ6TokDB4yhkonmUpyPfFr7W30Q R2kR35nAlfOghlqNtAffes5QJP92v4xsoJcrPybVe+pRbYdjFfvkT7hRwlCGJ1aCNdxi j1d//Rv6f1LXMODPKJjJABwraHZ4VqgXBbLI5ng9jRjVfaPpjDMY/sWGxniLdon5BGyG g7ZNyTHZkUR4LJR+QMr8dxHewGYBNRd8vXh3F544oUOXLkYTZzpiOlkZA66+1DDZz7cB LCJtQApwxbivNJA01SUMD1T7tMZxBxZKoikvrwOkilgI3SbvYt79C1SlOByVKtdl+BQQ lKIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=RtXh1F19FRrx1+dh9ZErv4CrcLDH1VpHTstJEgZnqvA=; b=WAd+iQvzUo6HUePKgp6J88rIiPswRgDDQEb3sQ5vRKPzAasm8lQ9228UziE4QucA1N yQfE01ImvzoM1VcuSQapHLUd0s0X9kSdKEqbHPGoxW32QtUwuF+MQHNOortmBtoVWyd4 xux7I4u0DkxgVkgz81cxka7DmZMpdenefd4UWIz77idmkKsUX9Mf17kbMkQaX/cS26YG BZkF+JRelqFqCRGIH5axmw2Wkc2gI1ZAqnb0SuGKRzldcaha6NpXzUcjagdEafx2c5kD kjATSdpz+j/PuRw7pur7AWGf/r3IY+NiMM6E5ZKXHYZAcvtFWSbrjwMHYliGaVn/vJIt KHFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oR7a+Arf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si1761305ejz.239.2019.09.24.17.11.33; Tue, 24 Sep 2019 17:11:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oR7a+Arf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2404094AbfIWCZJ (ORCPT + 99 others); Sun, 22 Sep 2019 22:25:09 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33606 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404042AbfIWCZH (ORCPT ); Sun, 22 Sep 2019 22:25:07 -0400 Received: by mail-pf1-f196.google.com with SMTP id q10so8205254pfl.0; Sun, 22 Sep 2019 19:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RtXh1F19FRrx1+dh9ZErv4CrcLDH1VpHTstJEgZnqvA=; b=oR7a+Arff/D/BXrTMogPjLPUoaBaJTjLaTypIqtrLhCvq06duqizyXI1wDN+agEUb0 vJB6JL8gZmvNISBKlYRpVMU753MlvmBnvdiBfEFKfZPcZKWGYryW90O3PGQGLjEQyTh7 LfZqkhrr+9Hk8C/Jynu+Tk2F5gHPXO9vUHoxEXNu2GA4y0tz5UR4MsUU+89gb30HNIBw taQzoInPBUMC83j9MuofAdoFfNZrejIIIM8ysGsnHG0ePid1zFS/uTcJDYt/9Qup92ox oVdG8dqt5QLpyGJXDQsX4kj1kNcDYOfRwcJgfh/OmBqbxtpnib2kY4BpB922cr0eEoW2 qJVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RtXh1F19FRrx1+dh9ZErv4CrcLDH1VpHTstJEgZnqvA=; b=tIvPeh+ig0hY1DcKUiJLPzwoart/RBfrKY43QOrBJj616seLBkhV1f1jyVRWOPYdSB 4E7MeyrN5Zr3sdtcAPzFTVgRL6Tjuf+tvREXAwSLhiePFT/p6xuHNpnzwoc6qc9BkRJ+ 91eUJBRu5ktbMjfVV/JQOxvdrBKn+p1Razibf2nwJAWPlzEGXjWH/gqeO332GsD4KVjY pdU5jsI7wxXaU7THMJNfr3FO/NDO7Sa9yddhjHsb8TOtZF4R0xT+NMx5NR4nUhfHMPra YlDxmQHrdRuXe6iJyPeHOsoU9uL4qwhBzkenHD6l5LRFJnmZRYGJX1FzE/+7WMxJVcjk coWw== X-Gm-Message-State: APjAAAVE3p6raEgbkd/ffeQXAWyQSI6lZ08eJsuzxgfTYpSRW6/yf7yy neonM0YOeNXfAE0ErgVtihQ= X-Received: by 2002:a63:304:: with SMTP id 4mr27085028pgd.13.1569205506755; Sun, 22 Sep 2019 19:25:06 -0700 (PDT) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id a18sm8342106pgm.25.2019.09.22.19.25.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Sep 2019 19:25:05 -0700 (PDT) From: "Ji-Ze Hong (Peter Hong)" X-Google-Original-From: "Ji-Ze Hong (Peter Hong)" To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, peter_hong@fintek.com.tw, "Ji-Ze Hong (Peter Hong)" Subject: [PATCH V2 5/7] USB: serial: f81232: Set F81534A serial port with RS232 mode Date: Mon, 23 Sep 2019 10:24:47 +0800 Message-Id: <20190923022449.10952-6-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923022449.10952-1-hpeter+linux_kernel@gmail.com> References: <20190923022449.10952-1-hpeter+linux_kernel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Fintek F81532A/534A/535/536 is USB-to-2/4/8/12 serial ports device and the serial ports are default disabled. Each port contains max 3 pins GPIO and the 3 pins are default pull high with input mode. When the serial port had activated (running probe()), we'll transform the 3 pins from GPIO function publicly to control Tranceiver privately use. We'll default set to 0/0/1 for control transceiver to RS232 mode. Otherwise, If the serial port is not active, the 3 pins is in GPIO mode and controlled by global GPIO device with VID/PID: 2c42/16f8. Signed-off-by: Ji-Ze Hong (Peter Hong) --- drivers/usb/serial/f81232.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 36a17aedc2ae..01cb5a5ea1d2 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -96,6 +96,15 @@ MODULE_DEVICE_TABLE(usb, all_serial_id_table); #define F81534A_TRIGGER_MULTPILE_4X BIT(3) #define F81534A_FIFO_128BYTE (BIT(1) | BIT(0)) +/* Serial port self GPIO control, 2bytes [control&output data][input data] */ +#define F81534A_GPIO_REG 0x10e +#define F81534A_GPIO_MODE2_DIR BIT(6) /* 1: input, 0: output */ +#define F81534A_GPIO_MODE1_DIR BIT(5) +#define F81534A_GPIO_MODE0_DIR BIT(4) +#define F81534A_GPIO_MODE2_OUTPUT BIT(2) +#define F81534A_GPIO_MODE1_OUTPUT BIT(1) +#define F81534A_GPIO_MODE0_OUTPUT BIT(0) + struct f81232_private { struct mutex lock; u8 modem_control; @@ -866,6 +875,14 @@ static int f81232_port_probe(struct usb_serial_port *port) static int f81534a_port_probe(struct usb_serial_port *port) { + int status; + + /* tri-state with pull-high, default RS232 Mode */ + status = f81232_set_register(port, F81534A_GPIO_REG, + F81534A_GPIO_MODE2_DIR); + if (status) + return status; + return f81232_port_probe(port); } -- 2.17.1