Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp745138imm; Mon, 9 Jul 2018 09:51:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeWnC5yrSFV8oGnvf0A1Q9nZChCsV4lzKBZHRV2l15qkkU/69MhBZsJxKEbC45oo3SftJD1 X-Received: by 2002:a63:735d:: with SMTP id d29-v6mr19698957pgn.156.1531155072770; Mon, 09 Jul 2018 09:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531155072; cv=none; d=google.com; s=arc-20160816; b=Hd7ix+cnhP12t4U68fNcIeGvi7dH5x+g5aAN3SbGmBmM4Hwj/VEOaZ1JP4YeyEuIIi KjIglpzsSUkZhxKmv9BW43LCgiyT06wzIdePPDRJJYurgOie7JSO8dVr/kCfQfT+8eNr k2N/A6a8lCg+RUUEkv6L6B2yqO3SNs44fa/o+S/Pt96pbYQotDQxwqglAJ8FY0zCoLs0 rACkBLr+N9bAOPx8hRz4fUMSfxAJngx47a2xZ6OfndlbREH+ref8aT1pObDzjL3siHfB r6E+6YvqPi3yz001Rnk3wMDVNhiQ2PFmbw4HmojT837cYVudYZTw3KXGcxTkJw2XZhxh cb3g== 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:dkim-signature :arc-authentication-results; bh=tQJsEaHyyv93K5m2A7LrG63PRcI7bXdM08KYTCpkeuE=; b=B6w20GEj7/hPofdZ9w3P5nJTE2BWvHkuZ6KbXvsw+wnIhqb9Z96fbJuymYI3zIslnK voz5JPXBeypJdOr35TNfjJL4Qa6GmkhS5qHFPHaqQtoseo8JlvjxrzPgPePZRdPl2DIf TOAD04k2wzkPEuvi7/5gzUHCfND8eoA93x8W0azS3j3hMK3jXf/369lIuNE3R3zSextU DWnud1T1MbpVyZUeGvXVsakCn6/hh2CBLuV7BePCu/mgOcgcTu4r01GVx8RmyqMPdON/ KhZwDcJGDEThV70z3Ss+C4bz2/Vl+PmH5HzZoaQgVKyDYSQUXbfI/Sxj0QQdiPBpU1Ip VzzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NK60s9Dx; 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 e3-v6si14990063pld.229.2018.07.09.09.50.58; Mon, 09 Jul 2018 09:51:12 -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=NK60s9Dx; 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 S933620AbeGIQr0 (ORCPT + 99 others); Mon, 9 Jul 2018 12:47:26 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:45070 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933339AbeGIQrV (ORCPT ); Mon, 9 Jul 2018 12:47:21 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id w69GlCBe092187; Mon, 9 Jul 2018 11:47:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1531154832; bh=tQJsEaHyyv93K5m2A7LrG63PRcI7bXdM08KYTCpkeuE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=NK60s9Dx7Qfz0Sk56tdxZG+gQKNrpy7NJFVN/ghect/DgCNJpL92X5SE/+5/MlTsd cT+itUAGtEHQdpwv5jY+63tDDPibmJIHW3Pv/5JsBVBPRhEdpXCgsLF80IK+qP1IIT TQdCXCXHsIXqOFxfx+kbQTG3OETX0BN8xU2C4h7E= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w69GlCJo018088; Mon, 9 Jul 2018 11:47:12 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 9 Jul 2018 11:47:11 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 9 Jul 2018 11:47:11 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w69GkpWE001873; Mon, 9 Jul 2018 11:47:08 -0500 From: Faiz Abbas To: , , , , CC: , , , , , , , Subject: [PATCH v5 4/6] bus: ti-sysc: Add support for software reset Date: Mon, 9 Jul 2018 22:18:39 +0530 Message-ID: <20180709164841.14182-5-faiz_abbas@ti.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180709164841.14182-1-faiz_abbas@ti.com> References: <20180709164841.14182-1-faiz_abbas@ti.com> MIME-Version: 1.0 Content-Type: text/plain 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 Add support for the software reset of a target interconnect module using its sysconfig and sysstatus registers. Signed-off-by: Faiz Abbas --- drivers/bus/ti-sysc.c | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c index ad1cd6888757..1b1b2ced3494 100644 --- a/drivers/bus/ti-sysc.c +++ b/drivers/bus/ti-sysc.c @@ -23,11 +23,14 @@ #include #include #include +#include #include #include +#define MAX_MODULE_SOFTRESET_WAIT 10000 + static const char * const reg_names[] = { "rev", "sysc", "syss", }; enum sysc_clocks { @@ -88,6 +91,11 @@ struct sysc { struct delayed_work idle_work; }; +void sysc_write(struct sysc *ddata, int offset, u32 value) +{ + writel_relaxed(value, ddata->module_va + offset); +} + static u32 sysc_read(struct sysc *ddata, int offset) { if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { @@ -943,6 +951,31 @@ static void sysc_init_revision_quirks(struct sysc *ddata) } } +static int sysc_reset(struct sysc *ddata) +{ + int offset = ddata->offsets[SYSC_SYSCONFIG]; + int val = sysc_read(ddata, offset); + + /* + * Currently only support reset status in sysstatus. + * Warn and return error in all other cases + */ + if (!ddata->cfg.syss_mask) { + dev_err(ddata->dev, "No ti,syss-mask. Reset failed\n"); + return -EINVAL; + } + + val |= (0x1 << ddata->cap->regbits->srst_shift); + sysc_write(ddata, offset, val); + + /* Poll on reset status */ + offset = ddata->offsets[SYSC_SYSSTATUS]; + + return readl_poll_timeout(ddata->module_va + offset, val, + (val & ddata->cfg.syss_mask) == 0x0, + 100, MAX_MODULE_SOFTRESET_WAIT); +} + /* At this point the module is configured enough to read the revision */ static int sysc_init_module(struct sysc *ddata) { @@ -960,6 +993,17 @@ static int sysc_init_module(struct sysc *ddata) return 0; } + if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) && + !ddata->legacy_mode) { + error = sysc_reset(ddata); + if (error) { + dev_err(ddata->dev, "Reset failed with %d\n", error); + pm_runtime_put_sync(ddata->dev); + + return error; + } + } + ddata->revision = sysc_read_revision(ddata); pm_runtime_put_sync(ddata->dev); -- 2.17.0