Received: by 10.223.164.202 with SMTP id h10csp1561087wrb; Wed, 15 Nov 2017 23:48:20 -0800 (PST) X-Google-Smtp-Source: AGs4zMaNjnCYuWyG5zPmq96dnMm3vBCURnGJRiffB0rJoqKTzbQpS2ZERcvJ+XEcYI0JMf2kV7Ps X-Received: by 10.84.128.227 with SMTP id a90mr864607pla.224.1510818500020; Wed, 15 Nov 2017 23:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510818499; cv=none; d=google.com; s=arc-20160816; b=OxXNdPQrXcrl7K+XKk9PVQYp4Pcs1HW6UJsKVtlc7SY6lV31dQx3d0KCU41q48vPrX GGIZ5tNsnJpe8pfXb8bj8c4ZCWg7kkPsPYRUZaZ+/H4qQZ6fZc9GeKRR0lH2pbfa8pkV fuDCrdFOwBA/dMXzPR4WHtbSFlnrKWCjTdkRcJzZY7DN9XE6XCpqJyXvRLUgjSfSs/qX QWMmPzJdGV/0qyQ6YyyzQQMDfY9JRHDJN6J41CZKvvfHRaseRycpOsf6zomGu754/A/C oxirarkCmpGNblGl2YnOYVEi6oPv8403PuwRC/ct89O0pRtsNopMcttbkxz/mjjsELaB BwYA== 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:arc-authentication-results; bh=SfYHQWyjP0mVSexzt8uO9g3XDy2nOSZaO/wRS5n/ZkA=; b=mpwNl5HZfmAh0hXgOdfWt2TnAYiXcMK8DVCcTl6gsyIR0VFS5L7Hupdu6rJhdywXz2 EwhwBRrSP0K/3tdM2ahwnO62kNm21RoSdUjQOv3EVZ018O9OLfmruJQ+fG3AlAX0D8tO gjGv0pfjBGX2vd/q5baQp5JEoePRKYk6gtdgzbxwaF8KL5PFhG3vIikoAC8hItzV6ktT rlNASuQYc3+rxWLHoryWOvCJien0ixLwtjLn4OztuWJ6skv7Nd/y2FNUZkwrVtqwgi6P VT3fswMLxuPScvBCVR3iHuw8gH2HtHd2VwOtxPHDT7IU+S9+L8/emTDhXZY8OLeB0c/D PX2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uCxqAnwe; 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=NONE 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 x17si438824plr.426.2017.11.15.23.48.07; Wed, 15 Nov 2017 23:48:19 -0800 (PST) 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=uCxqAnwe; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759330AbdKPHq6 (ORCPT + 91 others); Thu, 16 Nov 2017 02:46:58 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:52258 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759020AbdKPHq1 (ORCPT ); Thu, 16 Nov 2017 02:46:27 -0500 Received: by mail-pf0-f193.google.com with SMTP id m88so11791745pfi.9; Wed, 15 Nov 2017 23:46:27 -0800 (PST) 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=SfYHQWyjP0mVSexzt8uO9g3XDy2nOSZaO/wRS5n/ZkA=; b=uCxqAnweV5dD9JQGsmPQ/lNl+ZLm8g6PQikX+hyHKUEYBSatAIfCAId099dNsm0okQ QAqRReqZqqV9wFbcGTCUdL+ImVaZszHB6jpu8sS6u4t/G+/sMsns6MJ+uzeKac3ppFeT soLkUIJY+aHG12RwIGXebgiLVEljfaAoWoAcBxhVz1016WV/wzCe1RISDcT5SrzZvCxr rQVVBDoQlqjOThvH9+EoaHKGIH66rB1hzCF4rEuk1OxdupVTA+pARm/ZMM6MgSX0wgc8 Vhvw34EhCg0cb3dRC5AaenCP0Qhwiaf/ZB/TJC+DWc4FISNDJrBAAssvMAD6E/KSYBu5 qF+Q== 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=SfYHQWyjP0mVSexzt8uO9g3XDy2nOSZaO/wRS5n/ZkA=; b=Vj8JH8WN2xFpRfvBRZuy0omHCbErldmrhUQjId9HTITdSoN7kBS0n/cuFG3Gpqh/T3 gtNlstI0t6DCjvF40DSSQ6dT1xSjnjj+3ahpH+ftdk3nVtbH0HmBv/QXVUXFe9Dx60PK YmnzfBlix19ZH/YOMe9pBUBjEZ6OVioz4+hCzpEsxyuWGYJbAm52PxkoWgsVdx1FJa/3 PU1ntAG7GMDIJPCkjMjVGOlx94KXE5Z8F31NHKZ24JOYklCNI6Jl5ZG672ECSVcO/go9 agK7A4qZ6NLGXTOoZbVllwz/V2RXem49CdZoUXn43hCZ/VeGXQD62rn5coljpiD4/5Zt xGtQ== X-Gm-Message-State: AJaThX4mjq3mSF2efO5LJ9+ND7N23pq5Y3KJzmZHg+EstFZccqcdgHfL SsOmaCN97vjvhPF63y88h7o= X-Received: by 10.101.77.139 with SMTP id p11mr828038pgq.286.1510818386742; Wed, 15 Nov 2017 23:46:26 -0800 (PST) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id z8sm1411229pgs.41.2017.11.15.23.46.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 23:46:26 -0800 (PST) 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, "Ji-Ze Hong (Peter Hong)" Subject: [PATCH V1 4/4] usb: serial: f81534: add H/W disable port support Date: Thu, 16 Nov 2017 15:46:09 +0800 Message-Id: <1510818369-10323-4-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510818369-10323-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1510818369-10323-1-git-send-email-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 F81532/534 can be disable port by manufacturer with following H/W design. 1: Connect DCD/DSR/CTS/RI pin to ground. 2: Connect RX pin to ground. In driver, we'll implements some detect method likes following: 1: Read MSR. 2: Turn MCR LOOP bit on, off and read LSR after delay with 60ms. It'll contain BREAK status in LSR. Signed-off-by: Ji-Ze Hong (Peter Hong) --- drivers/usb/serial/f81534.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index 30b966d71ae8..18bd2a478199 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -751,6 +751,74 @@ static int f81534_find_config_idx(struct usb_serial *serial, u8 *index) } /* + * The F81532/534 will not report serial port to USB serial subsystem when + * H/W DCD/DSR/CTS/RI/RX pin connected to ground. + * + * To detect RX pin status, we'll enable MCR interal loopback, disable it and + * delayed for 60ms. It connected to ground If LSR register report UART_LSR_BI. + */ +static int f81534_check_port_hw_disabled(struct usb_serial *serial, int phy) +{ + int status; + u8 old_mcr; + u8 msr; + u8 lsr; + u8 msr_mask; + + msr_mask = UART_MSR_DCD | UART_MSR_RI | UART_MSR_DSR | UART_MSR_CTS; + + status = f81534_get_register(serial, + F81534_MODEM_STATUS_REG + phy * 0x10, &msr); + if (status) + return status; + + if ((msr & msr_mask) != msr_mask) + return 0; + + status = f81534_set_register(serial, + F81534_FIFO_CONTROL_REG + phy * 0x10, + UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | + UART_FCR_CLEAR_XMIT); + if (status) + return status; + + status = f81534_get_register(serial, + F81534_MODEM_CONTROL_REG + phy * 0x10, + &old_mcr); + if (status) + return status; + + status = f81534_set_register(serial, + F81534_MODEM_CONTROL_REG + phy * 0x10, + UART_MCR_LOOP); + if (status) + return status; + + status = f81534_set_register(serial, + F81534_MODEM_CONTROL_REG + phy * 0x10, 0x0); + if (status) + return status; + + msleep(60); + + status = f81534_get_register(serial, + F81534_LINE_STATUS_REG + phy * 0x10, &lsr); + if (status) + return status; + + status = f81534_set_register(serial, + F81534_MODEM_CONTROL_REG + phy * 0x10, + old_mcr); + if (status) + return status; + + if ((lsr & UART_LSR_BI) == UART_LSR_BI) + return -ENODEV; + + return 0; +} + +/* * We had 2 generation of F81532/534 IC. All has an internal storage. * * 1st is pure USB-to-TTL RS232 IC and designed for 4 ports only, no any @@ -832,6 +900,9 @@ static int f81534_calc_num_ports(struct usb_serial *serial, /* New style, find all possible ports */ for (i = 0; i < F81534_NUM_PORT; ++i) { + if (f81534_check_port_hw_disabled(serial, i)) + continue; + if (setting[i] & F81534_PORT_UNAVAILABLE) continue; @@ -1306,6 +1377,9 @@ static int f81534_attach(struct usb_serial *serial) /* Assign phy-to-logic mapping */ for (i = 0; i < F81534_NUM_PORT; ++i) { + if (f81534_check_port_hw_disabled(serial, i)) + serial_priv->conf_data[i] |= F81534_PORT_UNAVAILABLE; + if (serial_priv->conf_data[i] & F81534_PORT_UNAVAILABLE) continue; -- 2.7.4 From 1584148448120315914@xxx Wed Nov 15 16:01:28 +0000 2017 X-GM-THRID: 1583462875866554693 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread