From patchwork Mon Oct 7 17:55:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 175399 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4606770ill; Mon, 7 Oct 2019 10:56:04 -0700 (PDT) X-Received: by 2002:a63:6641:: with SMTP id a62mr30867484pgc.384.1570470963935; Mon, 07 Oct 2019 10:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570470963; cv=none; d=google.com; s=arc-20160816; b=BGmLU5naoH3t85W8bdnojuY4xOpkfflcajsn1EhBf62m/MuYjpeDcVzH1SyLjFhLLw gMrCcMTbqMF///1ki+bTUcdjAHToMwZbeEMesUPCAhqJTGZLt3mwFR0mCHqZM58O28Sx zaXaBkWeKhx3ZVAcyffmL62ivXD/qJsmCHhJLFVBOtl9nw+rLlW2q2JWwU64z5LTLJZt WZMbaNhcMwJWaq9T55rIpyqgyTgbTPuZCVBzLwi4pIO4NSQknlEAeyWNhFG0QCYPbDvN FNPHICOoXoRs2IjP/rKJPYZ+QCPGJZQOSx0bzo1s0a7nMTzAezrsKTxUVbyM3ZmKOEF1 yRbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YKLbWLWjJ/GA5qz2gzrLI3oAv45tZggVEaoyYmAEWtc=; b=JusGuhClW8fmfEA10uhLi3ItzYpZKCkV7z0xOD2OtRgr/oLu716mnF1zFDKhAPs7cy 1FKNhsQSjQ4FORTKeVmx2E8RErHhmakPoBBR2JhPfDX/ML7JjU5BhKBVuKffs2xOBhBg uNIh5u+Er3x5vDBJ1YXdR9UornJxSOxIFA309cF95eXnanplZxKuk6tlz9rWFf2b1oda 1xvQZMJD0z+RgcsSyYrLVeBacH+5V1w+C6Gzy4d1oPbXQAFR40bHmhA0ER9vOws5xwWl DZNcr1PdHmJ+TBNJBdIIiOxfHW5jnHu444NFreXmnyuCmf/LzjTBoeS0Loe/IQTDINoN ll1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYzDC4h0; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c64sor16703161pfa.21.2019.10.07.10.56.03 for (Google Transport Security); Mon, 07 Oct 2019 10:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYzDC4h0; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YKLbWLWjJ/GA5qz2gzrLI3oAv45tZggVEaoyYmAEWtc=; b=UYzDC4h0moF6TQzBOgkcjKP7aKolNPTebeHscocKWyaubmFmhXEoRiaMdF5qy5ogAn mM09zumDqTlgW8ItdSALOkUZzEib3H67BIfdpf8Tcnhgtxgg588fAu1zMcQcOffL3GHj qKcJDmojl03dF9EWsgoSkdYCy5r5oCQx38zrCIcqPx4hFsKip6dNApLHQ5WDXIgZns5c 4cE7lgRV9iUVqM0hBX91Ni7uZU3+5WG5d9/+wgk1oSY1yoP3Z1Y+ecl0V37tSKe19lrX iELOP5B+MFN2IHQFsm3QMYYUlkQy45Q0XNI+ibrrKGNRFGNiWNZSZcYQAK/4EVIfmach kjfg== 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=YKLbWLWjJ/GA5qz2gzrLI3oAv45tZggVEaoyYmAEWtc=; b=UAqDMS/PvkixjQY5eecPUvoaErSkxc1Y0jeFijF2P3qx1J01DKL9gATT9o2nUS7w9h b7gXXVL1tDF6FiafWPAduE9GuytBNS08xGyxgBNubj9b+guWHyDZc8bB1GJqbuemubTs OncenNo9Fj+660Lahn6Mztv84D41cX8Db04JA5KvTg/son9pJZ7jM47druuTEif1XfzG e8r6ujwxLSkJUnR8+/jEv4mur++n4PmZbekWIckRKHCyhWqXEvFypp9LylSNJiqooRRP cauya2Fy8AXxQ54QUR/UcYL1Uhu8SMJV+1ayvannYZyAB/BpyrkLNyH1CNACTMi4yEzq RpwA== X-Gm-Message-State: APjAAAVyvs2TiSQ+Nijfxq9nu4ITi80m7dFZHkHrPbDLOiZd6CZ/aeYQ f3Hmq4bo/Q/+b4DrrwGtHTHmI2Pd X-Google-Smtp-Source: APXvYqyP5ZSRlyeJVHXlGMo3HFliZL7HfRt+pmiWd6boT4KjdSiMtolf+T6RLS6pFrH4tgGXlUcUKw== X-Received: by 2002:a62:7597:: with SMTP id q145mr33121812pfc.181.1570470963551; Mon, 07 Oct 2019 10:56:03 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id k15sm3820096pgt.25.2019.10.07.10.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 10:56:02 -0700 (PDT) From: John Stultz To: lkml Cc: Yu Chen , Greg Kroah-Hartman , Felipe Balbi , Andy Shevchenko , Rob Herring , Mark Rutland , Matthias Brugger , Chunfeng Yun , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, John Stultz Subject: [RFC][PATCH v2 2/5] usb: dwc3: Execute GCTL Core Soft Reset while switch mdoe for Hisilicon Kirin Soc Date: Mon, 7 Oct 2019 17:55:50 +0000 Message-Id: <20191007175553.66940-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007175553.66940-1-john.stultz@linaro.org> References: <20191007175553.66940-1-john.stultz@linaro.org> From: Yu Chen A GCTL soft reset should be executed when switch mode for dwc3 core of Hisilicon Kirin Soc. Cc: Greg Kroah-Hartman Cc: Felipe Balbi Cc: Andy Shevchenko Cc: Rob Herring Cc: Mark Rutland Cc: Yu Chen Cc: Matthias Brugger Cc: Chunfeng Yun Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Yu Chen Signed-off-by: John Stultz --- drivers/usb/dwc3/core.c | 20 ++++++++++++++++++++ drivers/usb/dwc3/core.h | 3 +++ 2 files changed, 23 insertions(+) -- 2.17.1 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 999ce5e84d3c..440261432421 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -112,6 +112,19 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) dwc->current_dr_role = mode; } +static void dwc3_gctl_core_soft_reset(struct dwc3 *dwc) +{ + u32 reg; + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg |= DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg &= ~DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); +} + static void __dwc3_set_mode(struct work_struct *work) { struct dwc3 *dwc = work_to_dwc(work); @@ -156,6 +169,10 @@ static void __dwc3_set_mode(struct work_struct *work) dwc3_set_prtcap(dwc, dwc->desired_dr_role); + /* Execute a GCTL Core Soft Reset when switch mode */ + if (dwc->gctl_reset_quirk) + dwc3_gctl_core_soft_reset(dwc); + spin_unlock_irqrestore(&dwc->lock, flags); switch (dwc->desired_dr_role) { @@ -1316,6 +1333,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) dwc->dis_metastability_quirk = device_property_read_bool(dev, "snps,dis_metastability_quirk"); + dwc->gctl_reset_quirk = device_property_read_bool(dev, + "snps,gctl-reset-quirk"); + dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 1c8b349379af..b3cb6eec3f8f 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1029,6 +1029,7 @@ struct dwc3_scratchpad_array { * 2 - No de-emphasis * 3 - Reserved * @dis_metastability_quirk: set to disable metastability quirk. + * @gctl_reset_quirk: set to do a gctl soft-reset while switch operation mode. * @imod_interval: set the interrupt moderation interval in 250ns * increments or 0 to disable. */ @@ -1219,6 +1220,8 @@ struct dwc3 { unsigned dis_metastability_quirk:1; + unsigned gctl_reset_quirk:1; + u16 imod_interval; };