Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp693675imm; Thu, 5 Jul 2018 07:23:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeDfeK+SzA9laWRXsFZd0x8E3dK5WhlRKDfvlxU7plEE8liV5YLsy2cmI47the0fom18WVj X-Received: by 2002:a17:902:8645:: with SMTP id y5-v6mr6394109plt.334.1530800632592; Thu, 05 Jul 2018 07:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530800632; cv=none; d=google.com; s=arc-20160816; b=RDWsxw9EBuLeOmzwhcXJfUmVFGASVDbxV4algDtr3YgHq41QAepkiRTTaCCUI0mG9q qJn57DVLb6JxW0f0Z7gQSKtE9CXqugm0N34gZKlILqw49FAw4hZWWzRqdUbnhIkfFpcC UK7bG0kQDyTuDmKUqtqZi40lWXOiHYeQKWnKCTwswpahiXX2NLMGqYC6cEVJarRn92B1 G2IEbLsXjHhzAiV4XEdvaiDhKf9FMBGgAUhAN0gk5ThINPy8o+2PA4L3seMygz3PPzX/ 3wlbzKDmvuDVRgDfCByVbXp5HF6U6jbOhxds9BijgvVIwcBLXvyZ5yluRw9v0qdYCGNN EZmw== 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=r0nDY41M61FBqYVJy5eocealUfh8csvf581+1/ANA9I=; b=y6oSs+i6t9NonwYAMR3cX2YVaxmLG6O7hz5Q0zVoUncv9XBEvxvn15B33bx0QL4qwb JFBSUQc8vrNxZEA37fdb4sbqaKgV7XFti4k9MikJNqxxBXs7zhw/GlCy1ayZYiy9DC+c pyN3Kh+z0gpsARq0/d9IJGDYckOFOkkOJDHORkijq5r2N/2gJY7Y3pemPunBykfbETKQ m7kcVaqpaQTWuob3wTF2JJsAYHhMAzEeKEuJRGWh3udikcBtNwOy4gZv8QdXsuC1Im6q MbQa0Sdz0Gz+ozfuvz+iZncncq6qBj8Or1hk/r0Yk/QiVMchLyH7kx0MqfpWafeMNAwo yTdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DQl169bP; 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 f40-v6si6221353plb.504.2018.07.05.07.23.23; Thu, 05 Jul 2018 07:23:52 -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=DQl169bP; 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 S1754086AbeGEOWO (ORCPT + 99 others); Thu, 5 Jul 2018 10:22:14 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:57248 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753512AbeGEOWH (ORCPT ); Thu, 5 Jul 2018 10:22:07 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w65ELhpL072729; Thu, 5 Jul 2018 09:21:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1530800503; bh=r0nDY41M61FBqYVJy5eocealUfh8csvf581+1/ANA9I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DQl169bP9300bx+b6a3x9fIGVrx9HpPIyRKPW9NWN+atEbjDt88U1qgQyu6zohpm/ myoYz/4bSKhtiblMHaupxCkWKJwtAkmAsEIov7kj8vdUOI+AgT/rd/A8wn1plMcfPk N+TGrJHa7hB4i6HjovqhQdIPpXlw4dcj0eiAaZzg= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w65ELhH2019652; Thu, 5 Jul 2018 09:21:43 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 5 Jul 2018 09:21:43 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 5 Jul 2018 09:21:43 -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 w65ELPxj020259; Thu, 5 Jul 2018 09:21:40 -0500 From: Faiz Abbas To: , , , , CC: , , , , , , Subject: [PATCH v4 4/6] bus: ti-sysc: Add support for software reset Date: Thu, 5 Jul 2018 19:53:17 +0530 Message-ID: <20180705142319.19583-5-faiz_abbas@ti.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180705142319.19583-1-faiz_abbas@ti.com> References: <20180705142319.19583-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 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c index ad1cd6888757..ac65a4f336d5 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,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.syss_mask) { + 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) { @@ -960,6 +988,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