Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp419440imm; Tue, 5 Jun 2018 23:08:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJutCVDcHxm3VwsX+KoRiM0c3Ik0EuC7+UTMAJsDIqSqkYx2c2l6PZkZIdvCZIFyPic+vcS X-Received: by 2002:a17:902:1ea:: with SMTP id b97-v6mr833850plb.58.1528265327178; Tue, 05 Jun 2018 23:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528265327; cv=none; d=google.com; s=arc-20160816; b=ghQeD7LMNlaSgV1TuFBmCjcddJ78YuHfApEK4DH26IiS9+jHgFezKT8Id3t2bppo+k teomxUxbHfqKFMAT6z8lzu1gMkv591ziAFZvFMkdvycsLzcdiYJzE9iCOmGQZVUbhpDg J9G8cwGNPlxiZR49On9/37eQ4yPf7DSvr2VYZy8Lu566/aAA2gukjDhfd/ktthmg4TUg MAtoBoHZJTygnh/XlrPPKZUc4+I6g8Hh+ZuRiZ511H/HkjImZ+aNUgO3vt8DAthc0guO T22f5dnfcoo8jOr+hZIw7vPjurXrX3atvkwlmq1ohc8nS3+M7YaEJ0o4vUU+REaFSBfT 7POQ== 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=+C13mqiwZTid8+wirz6bBV3H2LYc+LAt/ZTaRM/HWag=; b=TKqz39rX5fmoMbdA8f7tYFlOURql5kW9v4hg8NjazNQRwE0Ados/4De8SSbtzDtFEM HKWno8+OrsKxav5luZgFSdNWSxNrIts0sq0Ob8D36Op3287ZRe1mlBpcn+45nlCmR8Nk g4l7avGNUf1DybX4gIRgzxscIa4kkEFFIuxttf3ACF9NghklUvclwJKbQV6kQ0lxPeRH +Q3Rvm/Njx5h64IFTjWg3XjqxDEN+Cs9J0ej+b7JrulcYX0+uUZCkfNeV2wTH4MLAjR8 7F/OucDDEmksKlO2V4iDZlDLiCDUR8L1fzD9WtSOyFwYqeKXKebyeoTCK9Ry/r0yk99B HFsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JjMLH+cj; 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 e76-v6si12450348pfj.250.2018.06.05.23.08.33; Tue, 05 Jun 2018 23:08:47 -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=JjMLH+cj; 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 S932203AbeFFGH5 (ORCPT + 99 others); Wed, 6 Jun 2018 02:07:57 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:27635 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932131AbeFFGHv (ORCPT ); Wed, 6 Jun 2018 02:07:51 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w5667HKa015184; Wed, 6 Jun 2018 01:07:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1528265237; bh=+C13mqiwZTid8+wirz6bBV3H2LYc+LAt/ZTaRM/HWag=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=JjMLH+cjCW5X7ga2dL1YOOKweyx/RMQ6+hkILu53JHlYR45MUrAABDl85Dc5XHLm/ ejN5eTkyuc/Ewpa9leT6vAnR6A55fSyPoUq0eFArsMJjld5TsbEGgssTnFlCpWnsdZ V7rg80ramHPjDPV7gH76/JrhHSIh5Ji+Yc5T6QYM= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w5667HV1025061; Wed, 6 Jun 2018 01:07:17 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) 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.1466.3; Wed, 6 Jun 2018 01:07:16 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 6 Jun 2018 01:07:17 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w5666wtX012358; Wed, 6 Jun 2018 01:07:13 -0500 From: Faiz Abbas To: , , , , CC: , , , , , , Subject: [PATCH v3 4/6] bus: ti-sysc: Add support for software reset Date: Wed, 6 Jun 2018 11:38:24 +0530 Message-ID: <20180606060826.14671-5-faiz_abbas@ti.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180606060826.14671-1-faiz_abbas@ti.com> References: <20180606060826.14671-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 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c index 4a2244419b9b..74d716a7bd6e 100644 --- a/drivers/bus/ti-sysc.c +++ b/drivers/bus/ti-sysc.c @@ -22,11 +22,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 { @@ -74,6 +77,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) { @@ -700,6 +708,26 @@ 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); + + val |= (0x1 << ddata->cap->regbits->srst_shift); + sysc_write(ddata, offset, val); + + /* Poll on reset status */ + if (ddata->cfg.quirks & SYSC_QUIRK_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); + } + + return 0; +} + /* At this point the module is configured enough to read the revision */ static int sysc_init_module(struct sysc *ddata) { @@ -716,6 +744,18 @@ 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