Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4264055imu; Mon, 14 Jan 2019 18:57:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6bQyFeV6z80zR46zzT8FmUFswcNh4dkt491kLSNlhaTviySjKQOufZ5+SzElp1LjCToEjw X-Received: by 2002:a17:902:e20b:: with SMTP id ce11mr1691707plb.251.1547521031622; Mon, 14 Jan 2019 18:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521031; cv=none; d=google.com; s=arc-20160816; b=sRsV+yurdopCrvOCY0rgbtmRTQcWW8xDRd9BySOeuKLz88Vy5d8XR6ilWTfilpy8Dj 0ScVH3kGGb2/Y49r/Y3e0P9MH4rDiOszw6u1Q6BCuxeTiS/i8Fomow5nS1exaLvjyC9B ZMp9Vd7xHZwjJbws59bb1eS/ohqMMyeiOoOnxcyIag+qjBPSZjrG4AZkLR0uJgmOvhYu 1HHFgNfewEM/m++dUOQevfItG7x1Ge+6U/Qxfhn4/FrKKZJJ2ckkeQs7QJ7Ra9soUIeE 290rd9P0vZ79GU3dxX50HxOnp62a5HQxG0+G3P2gqblUiF3sJ4hmc5a7IKcjCFNfSIXm QDPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=AR5hsBxYYn2+AX2kaUg2xlQWEi5O29AQmLq/6lww9pY=; b=fyUCCviOqd4SobUDUy6coOFB1Yya0ht4JiFGF+cfsas37S5/yL4dEPAl/VdyIIargR cj8EIUZ6eCVdrWv1sEcjcDwz2K2ExVdq3z5dXP6XyVb2oVMqgB1X1NevtPMYCsF84jXL nny9HVjmd5l/ivGwO0cjrH3nvMX/imIDmodGQR5r1FgzCO862aFsTMF5bLOVXzTUGGxs Z7FirjjVitgoj0W7qeGRnREWpwYk6tqcmjzWl1HVRRnJWWmk+Nkb9+NQ0YldiqSWY99B ealruvmuICTbE6bOVE8n3aH9WPiQQHuUd0Uu0fG3+RdA7V1qHA3bEPW8dXWa/E6rbCq8 JO7Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c65si2036212pfe.202.2019.01.14.18.56.56; Mon, 14 Jan 2019 18:57:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727741AbfAOBoL (ORCPT + 99 others); Mon, 14 Jan 2019 20:44:11 -0500 Received: from Mailgw01.mediatek.com ([1.203.163.78]:30927 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726769AbfAOBoK (ORCPT ); Mon, 14 Jan 2019 20:44:10 -0500 X-UUID: 9688400387d94252bd3f98e8ce746956-20190115 X-UUID: 9688400387d94252bd3f98e8ce746956-20190115 Received: from mtkcas36.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 957536321; Tue, 15 Jan 2019 09:44:01 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 15 Jan 2019 09:43:58 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 15 Jan 2019 09:43:58 +0800 From: To: Bin Liu , Rob Herring CC: Greg Kroah-Hartman , Mark Rutland , Matthias Brugger , Alan Stern , , , , , , , Min Guo Subject: [PATCH v2 3/4] usb: musb: Extract set toggle as a separate interface Date: Tue, 15 Jan 2019 09:43:45 +0800 Message-ID: <1547516626-5084-4-git-send-email-min.guo@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1547516626-5084-1-git-send-email-min.guo@mediatek.com> References: <1547516626-5084-1-git-send-email-min.guo@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Min Guo Add a common interface for set data toggle Signed-off-by: Min Guo --- drivers/usb/musb/musb_host.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index b59ce9a..16d0ba4 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -306,6 +306,25 @@ static inline void musb_save_toggle(struct musb_qh *qh, int is_in, usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0); } +static inline u16 musb_set_toggle(struct musb_qh *qh, int is_in, + struct urb *urb) +{ + u16 csr = 0; + u16 toggle = 0; + + toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in); + + if (is_in) + csr = toggle ? (MUSB_RXCSR_H_WR_DATATOGGLE + | MUSB_RXCSR_H_DATATOGGLE) : 0; + else + csr = toggle ? (MUSB_TXCSR_H_WR_DATATOGGLE + | MUSB_TXCSR_H_DATATOGGLE) + : MUSB_TXCSR_CLRDATATOG; + + return csr; +} + /* * Advance this hardware endpoint's queue, completing the specified URB and * advancing to either the next URB queued to that qh, or else invalidating @@ -772,13 +791,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum, ); csr |= MUSB_TXCSR_MODE; - if (!hw_ep->tx_double_buffered) { - if (usb_gettoggle(urb->dev, qh->epnum, 1)) - csr |= MUSB_TXCSR_H_WR_DATATOGGLE - | MUSB_TXCSR_H_DATATOGGLE; - else - csr |= MUSB_TXCSR_CLRDATATOG; - } + if (!hw_ep->tx_double_buffered) + csr |= musb_set_toggle(qh, !is_out, urb); musb_writew(epio, MUSB_TXCSR, csr); /* REVISIT may need to clear FLUSHFIFO ... */ @@ -860,17 +874,12 @@ static void musb_ep_program(struct musb *musb, u8 epnum, /* IN/receive */ } else { - u16 csr; + u16 csr = 0; if (hw_ep->rx_reinit) { musb_rx_reinit(musb, qh, epnum); + csr |= musb_set_toggle(qh, !is_out, urb); - /* init new state: toggle and NYET, maybe DMA later */ - if (usb_gettoggle(urb->dev, qh->epnum, 0)) - csr = MUSB_RXCSR_H_WR_DATATOGGLE - | MUSB_RXCSR_H_DATATOGGLE; - else - csr = 0; if (qh->type == USB_ENDPOINT_XFER_INT) csr |= MUSB_RXCSR_DISNYET; -- 1.9.1