Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp830540ybl; Wed, 14 Aug 2019 06:39:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/n+hOMxGGzc07DbDTihQykLW/Etpu2snvt4F9kHgVSd6A8CDLmlz+54QuVJIKHMFWFkis X-Received: by 2002:a17:902:1aa:: with SMTP id b39mr43556711plb.333.1565789975165; Wed, 14 Aug 2019 06:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565789975; cv=none; d=google.com; s=arc-20160816; b=OpfN7ozTC1pqgMIP9wtit/rXo4OJ4E0tN7+v52yp04FidIvTpq2FafmN2G/lkvvao5 rGUT+SuYPOd5/3LkcCeysj6yAld+6Pxp5dF+eAwKbKGkP5vLfJ/QAS+NAunOBKricSZx JfEyfLsv5wHOLBZzzYzLNkXFNGbodSJBc+2fsDLVlGZy+VOMt5dmeGMy6hdS9toaDHv/ IJKoxX4k7L1d0HswapsLHfRvvBX43pRH7FyHEgb3Bbt0km+qLY0ANd/ofTRgYaIJ0782 TSeSXh+gA9WfVQXcrV2Ww6WSEgDO8CHwhzMRUeA3aptHZxU6Bjv5mPLdrN7O8QqfkhwN BPRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=aThyHL8ApwvdhvY3BnDVs0kFkolqrKiAquo0tskXkcg=; b=iml+idE1ETaY5jgL0zsT0PVqIqq1ui0qkPbh0ugohjCoz7X7V8GtUXqmPpRFYlkfSn WYXbrYBTL1NezR6Q9cmIRVWwCphsLULoqel7cH46vAkEKb8bAcPiC4lSZKn/31EVEAOv AiX/V/2CRjJHtSxXE2bnELvWCuE9VgRGN4CIwasm5GAi7c47A99blpkjSzDhXV250ofZ r9ff5Kfyu//6zQSKXNJ18iZmvqCicfMFSoGmlJVTu3HiTusuQ+9cu+icBtJo25gkqDP5 nkFO3/3FRzIyUQHHN1fbBH18+pxCCs18ndFmi2MuFfq/xnmepVFCRhrRDGfScgfPwro/ RIoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=IdYwQLhG; 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 m32si63451574pld.236.2019.08.14.06.39.19; Wed, 14 Aug 2019 06:39:35 -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=@ti.com header.s=ti-com-17Q1 header.b=IdYwQLhG; 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 S1727756AbfHNNi3 (ORCPT + 99 others); Wed, 14 Aug 2019 09:38:29 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:47112 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbfHNNi3 (ORCPT ); Wed, 14 Aug 2019 09:38:29 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7EDcKTR075923; Wed, 14 Aug 2019 08:38:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1565789900; bh=aThyHL8ApwvdhvY3BnDVs0kFkolqrKiAquo0tskXkcg=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=IdYwQLhGto2moxtF4RXiQKJEPdAyT1FbAHYmlU/u5t+GnknGuqF2ookzKY2qbPLJI bvcjQQv6PzOzK+0lxODlqcqlpgf5W1WHQIUp/7wTpK3pWTpx4UGv1jDZ+l9DI6KbHo OzPdWRE3N7IZnctJF06lL1Rti/bm2x1L9Q2f1OXk= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7EDcKi0130999 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Aug 2019 08:38:20 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 14 Aug 2019 08:38:20 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 14 Aug 2019 08:38:20 -0500 Received: from [192.168.2.14] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x7EDcHrH100252; Wed, 14 Aug 2019 08:38:17 -0500 Subject: Re: [PATCH v10 5/6] usb:cdns3 Add Cadence USB3 DRD Driver To: Pawel Laszczak , CC: , , , , , , , , , References: <1563733939-21214-1-git-send-email-pawell@cadence.com> <1563733939-21214-6-git-send-email-pawell@cadence.com> From: Roger Quadros Message-ID: <2c5ed505-6fee-1816-e5bb-59a9ed96fb70@ti.com> Date: Wed, 14 Aug 2019 16:38:17 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1563733939-21214-6-git-send-email-pawell@cadence.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit 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 On 21/07/2019 21:32, Pawel Laszczak wrote: > This patch introduce new Cadence USBSS DRD driver to Linux kernel. > > The Cadence USBSS DRD Controller is a highly configurable IP Core which > can be instantiated as Dual-Role Device (DRD), Peripheral Only and > Host Only (XHCI)configurations. > > The current driver has been validated with FPGA platform. We have > support for PCIe bus, which is used on FPGA prototyping. > > The host side of USBSS-DRD controller is compliant with XHCI > specification, so it works with standard XHCI Linux driver. > > Signed-off-by: Pawel Laszczak > --- > drivers/usb/Kconfig | 2 + > drivers/usb/Makefile | 2 + > drivers/usb/cdns3/Kconfig | 46 + > drivers/usb/cdns3/Makefile | 17 + > drivers/usb/cdns3/cdns3-pci-wrap.c | 203 +++ > drivers/usb/cdns3/core.c | 554 +++++++ > drivers/usb/cdns3/core.h | 109 ++ > drivers/usb/cdns3/debug.h | 171 ++ > drivers/usb/cdns3/debugfs.c | 87 ++ > drivers/usb/cdns3/drd.c | 390 +++++ > drivers/usb/cdns3/drd.h | 166 ++ > drivers/usb/cdns3/ep0.c | 914 +++++++++++ > drivers/usb/cdns3/gadget-export.h | 28 + > drivers/usb/cdns3/gadget.c | 2338 ++++++++++++++++++++++++++++ > drivers/usb/cdns3/gadget.h | 1321 ++++++++++++++++ > drivers/usb/cdns3/host-export.h | 28 + > drivers/usb/cdns3/host.c | 71 + > drivers/usb/cdns3/trace.c | 11 + > drivers/usb/cdns3/trace.h | 493 ++++++ > 19 files changed, 6951 insertions(+) > create mode 100644 drivers/usb/cdns3/Kconfig > create mode 100644 drivers/usb/cdns3/Makefile > create mode 100644 drivers/usb/cdns3/cdns3-pci-wrap.c > create mode 100644 drivers/usb/cdns3/core.c > create mode 100644 drivers/usb/cdns3/core.h > create mode 100644 drivers/usb/cdns3/debug.h > create mode 100644 drivers/usb/cdns3/debugfs.c > create mode 100644 drivers/usb/cdns3/drd.c > create mode 100644 drivers/usb/cdns3/drd.h > create mode 100644 drivers/usb/cdns3/ep0.c > create mode 100644 drivers/usb/cdns3/gadget-export.h > create mode 100644 drivers/usb/cdns3/gadget.c > create mode 100644 drivers/usb/cdns3/gadget.h > create mode 100644 drivers/usb/cdns3/host-export.h > create mode 100644 drivers/usb/cdns3/host.c > create mode 100644 drivers/usb/cdns3/trace.c > create mode 100644 drivers/usb/cdns3/trace.h > > diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c > new file mode 100644 > index 000000000000..291f08be56fe > --- /dev/null > +++ b/drivers/usb/cdns3/gadget.c > @@ -0,0 +1,2338 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Cadence USBSS DRD Driver - gadget side. > + * > + * Copyright (C) 2018-2019 Cadence Design Systems. > + * Copyright (C) 2017-2018 NXP > + * > + * Authors: Pawel Jez , > + * Pawel Laszczak > + * Peter Chen > + */ > + > + > +static void cdns3_gadget_config(struct cdns3_device *priv_dev) > +{ > + struct cdns3_usb_regs __iomem *regs = priv_dev->regs; > + u32 reg; > + > + cdns3_ep0_config(priv_dev); > + > + /* enable interrupts for endpoint 0 (in and out) */ > + writel(EP_IEN_EP_OUT0 | EP_IEN_EP_IN0, ®s->ep_ien); > + > + /* > + * Driver needs to modify LFPS minimal U1 Exit time for DEV_VER_TI_V1 > + * revision of controller. > + */ > + if (priv_dev->dev_ver == DEV_VER_TI_V1) { > + reg = readl(®s->dbg_link1); > + > + reg &= ~DBG_LINK1_LFPS_MIN_GEN_U1_EXIT_MASK; > + reg |= DBG_LINK1_LFPS_MIN_GEN_U1_EXIT(0x55) | > + DBG_LINK1_LFPS_MIN_GEN_U1_EXIT_SET; > + writel(reg, ®s->dbg_link1); > + } > + > + /* > + * By default some platforms has set protected access to memory. > + * This cause problem with cache, so driver restore non-secure > + * access to memory. > + */ > + reg = readl(®s->dma_axi_ctrl); Why read the reg at all if you are just overwriting it below? > + reg = DMA_AXI_CTRL_MARPROT(DMA_AXI_CTRL_NON_SECURE) | > + DMA_AXI_CTRL_MAWPROT(DMA_AXI_CTRL_NON_SECURE); Otherwise you need to read modify only necessary bits and then write. i.e. #define DMA_AXI_CTRL_MAPROT_MASK 0x3 reg &= ~(DMA_AXI_CTRL_MARPROT(DMA_AXI_CTRL_MAPROT_MASK) | DMA_AXI_CTRL_MARPROT(DMA_AXI_CTRL_MAPROT_MASK)) reg |= DMA_AXI_CTRL_MARPROT(DMA_AXI_CTRL_NON_SECURE) | DMA_AXI_CTRL_MAWPROT(DMA_AXI_CTRL_NON_SECURE); > + writel(reg, ®s->dma_axi_ctrl); > + > + /* enable generic interrupt*/ > + writel(USB_IEN_INIT, ®s->usb_ien); > + writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, ®s->usb_conf); > + > + cdns3_configure_dmult(priv_dev, NULL); > + > + cdns3_gadget_pullup(&priv_dev->gadget, 1); > +} > + cheers, -roger -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki