Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2101873imu; Thu, 10 Jan 2019 08:18:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN5EPiHH7es0pCVWO6WtmoxYzPcAX9izGC8ro/03KFiE8hRaiCG10ovFTh9If+Bs4uqH9/yo X-Received: by 2002:a17:902:5a4d:: with SMTP id f13mr11252755plm.49.1547137093725; Thu, 10 Jan 2019 08:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547137093; cv=none; d=google.com; s=arc-20160816; b=fMNoXTxaYZrQDy4TUse6FBJKoInrjr7xJeNWvVMcxgJUt8dUIJW+jqZUAAr7IDZvxc 8F5KANPNazHlwyRasS/Z92sSk+V2LiPEuGAKm3KIUUbgfyGmm9IF1JdZ4rLXYIuvLoQ9 rPWAsObOuLyiHSXNMLW0ijSnV5GnGn1UHryXz3E0Y6GuEdKv5TzTClt3elzVnswsreOT npAb3Y+t8LsrCoOVY1TYgzexgS9+ty+YReToCffIHstXdmVI/c8NRwXmZ3tPOVOxd4Tc 7PVPhnm73sEbrvD77HM3G/y2QQeDKpAyXqsUtZQadnT+tc2jq3ugAjaxxunh/313SskT CagA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=sw50tcgNgr1jaX/gPIw/5Ma8kA6L6qkYhNC/N0csP+4=; b=lKjezSLmBxH6ovfAa+v8r9pZ00Os4nY5AO/9TKMM/2++lIviB3DNOHacPox4QDXkR+ 5YmIOgTm62tGuQODaIPI02psN4vD9QJtk6spfU+apB8iIiraHzX6D7HOneHdLY1FsS2D KuGWG5h1FizL/ugM4c9aLyG+1sZoTtXkTsvGbxFAnOY54WW0JfCyQXFD1/InIR+tYsmG 4SQAaIHl/dAeifns+/dkrwcOo7wqoFV9Xn1M1sIWvt9nYtIwxkEBcWgJJt4K1e3vl3s4 bjo+TxCTvaNLhY3nJz6SLDUj4xFDy7lxtcvAFq7PX8ebfsx+9jzW3ZhHjqdVJgv+UdZt IAog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=vxlHSybG; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si72747609pfl.279.2019.01.10.08.17.57; Thu, 10 Jan 2019 08:18:13 -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=@ti.com header.s=ti-com-17Q1 header.b=vxlHSybG; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728331AbfAJOS6 (ORCPT + 99 others); Thu, 10 Jan 2019 09:18:58 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:53230 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727653AbfAJOS5 (ORCPT ); Thu, 10 Jan 2019 09:18:57 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x0AEIekd041451; Thu, 10 Jan 2019 08:18:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1547129920; bh=sw50tcgNgr1jaX/gPIw/5Ma8kA6L6qkYhNC/N0csP+4=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=vxlHSybGhcEZY3I2CZWey/z8a5EebITUJAKAS62UBQuqdEE7PXhj4xWmMl+gwo3yF ql7fQvg2y7JQHfEj7KFWLjZbn0qfcYY3E5kWagiPxnuNOdVKp4QVFYJbFFeAhrXuXY tObLczOCe58y1ssmcIbcx6ZrB5rS9Z9IXPfbMWxM= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x0AEIeTH099515 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 08:18:40 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Thu, 10 Jan 2019 08:18:40 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Thu, 10 Jan 2019 08:18:40 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x0AEIeuk024405; Thu, 10 Jan 2019 08:18:40 -0600 Date: Thu, 10 Jan 2019 08:18:40 -0600 From: Bin Liu To: Min Guo CC: Rob Herring , Greg Kroah-Hartman , Mark Rutland , Matthias Brugger , Alan Stern , , , , , , , Yonglong Wu Subject: Re: [PATCH 4/4] usb: musb: Add support for MediaTek musb controller Message-ID: <20190110141840.GA18026@uda0271908> Mail-Followup-To: Bin Liu , Min Guo , Rob Herring , Greg Kroah-Hartman , Mark Rutland , Matthias Brugger , Alan Stern , chunfeng.yun@mediatek.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Yonglong Wu References: <1545896066-897-1-git-send-email-min.guo@mediatek.com> <1545896066-897-5-git-send-email-min.guo@mediatek.com> <20190108154441.GG25910@uda0271908> <1547037068.4433.122.camel@mhfsdcap03> <20190109140144.GI25910@uda0271908> <1547105062.4433.144.camel@mhfsdcap03> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1547105062.4433.144.camel@mhfsdcap03> User-Agent: Mutt/1.5.21 (2010-09-15) X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Min, Please briefly summarize the controller differences in the commit log, such as - WIC interrupt registers; - data toggle bit; - no dedicated DMA interrupt line; so that we can quickly understand the core driver is modified accordingly to handle the differences. On Thu, Jan 10, 2019 at 03:24:22PM +0800, Min Guo wrote: > Hi Bin, [snip] > > > > > + musb_writeb(mbase, MUSB_INTRUSB, > > > > > + musb_readb(mbase, MUSB_INTRUSB)); > > > > > > > > For this clearing register bit operation, please create platform hooks > > > > musb_clearb() and musb_clearw() in struct musb_platform_ops instead, > > > > then follow how musb_readb() pointer is assigned in > > > > musb_init_controller() to use the W1C version for mtk platform. > > > > > > I have tried implementing musb_readb(), musb_readw() interface with > > > interrupt status W1C function in struct musb_platform_ops. But this > > > interface will require a global variable to hold MAC basic address for > > > judgment, and then special handling of the interrupt state. A global > > > variable will make the driver work with only a single instance, so it > > > can't work on some MTK platforms which have two instances. > > > > I didn't mean to modify musb_read*(), but > > > > > How about creating musb_clearb/w() as following: > > > void (*clearb)(void __iomem *addr, unsigned offset, u8 data); > > > void (*clearw)(void __iomem *addr, unsigned offset, u16 data); > > > > this is what I was asking for, similar to what musb_readb/w() is > > implemented. > > I will prepare a patch for musb_clearb/w(). This doesn't have to be a separate patch. > > > > > + musb_writew(mbase, MUSB_INTRRX, > > > > > + musb_readw(mbase, MUSB_INTRRX)); > > > > > + musb_writew(mbase, MUSB_INTRTX, > > > > > + musb_readw(mbase, MUSB_INTRTX)); > > > > > + } [snip] > > > > > + /* MediaTek controller has private toggle register */ > > > > > > > > only one toggle register for all endpoints? how does it handle > > > > difference toggle values for different endpoints? > > > > > > MediaTek controller has separate registers to describe TX/RX toggle. > > > > Is it one register per endpoint? > > MUSB_RXTOG/MUSB_TXTOG is common register, each bit reflects the toggle > state of an endpoint. bit[0] not used,bit[1~8] corresponds to ep[1~8] > > > > > > > > > + if (musb->ops->quirks & MUSB_MTK_QUIRKS) { > > > > > + u16 toggle; > > > > > + u8 epnum = qh->hw_ep->epnum; > > > > > + > > > > > + if (is_in) > > > > > + toggle = musb_readl(musb->mregs, MUSB_RXTOG); > > > > this line seems telling there is just *one* register for all endpoints. > > Yes, all endpoint share this register, endpoint and bit are one-to-one > correspondence. Okay, thanks. Sorry I missed the bit operation in the code below. > > > > > > > > > should use musb_readw() instead? MUSB_RXTOG seems to be 16bit. > > > > > > Ok > > > > > > > > + else > > > > > + toggle = musb_readl(musb->mregs, MUSB_TXTOG); > > > > > + > > > > > + csr = toggle & (1 << epnum); Regards, -Bin.