From patchwork Mon Sep 2 14:15:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Afzal Mohammed X-Patchwork-Id: 2852846 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 530499F3DC for ; Mon, 2 Sep 2013 14:15:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB3702015B for ; Mon, 2 Sep 2013 14:15:49 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F36E420125 for ; Mon, 2 Sep 2013 14:15:47 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VGUuv-0002rC-Ce; Mon, 02 Sep 2013 14:15:45 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VGUut-0008Sf-8J; Mon, 02 Sep 2013 14:15:43 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VGUur-0008SL-4F for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2013 14:15:41 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r82EFI8s020833; Mon, 2 Sep 2013 09:15:18 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r82EFIGK032086; Mon, 2 Sep 2013 09:15:18 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Mon, 2 Sep 2013 09:15:18 -0500 Received: from afzal-Latitude-E6420.apr.dhcp.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id r82EFFG4020123; Mon, 2 Sep 2013 09:15:16 -0500 From: Afzal Mohammed To: , , Subject: [PATCH RFC 1/6] reset: is_reset and clear_reset api's Date: Mon, 2 Sep 2013 19:45:14 +0530 Message-ID: <5dcf227d360f748ddc965f6c13ff0b31c3e90dab.1378129416.git.afzal@ti.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130902_101541_265765_C05F1A89 X-CRM114-Status: GOOD ( 10.98 ) X-Spam-Score: -9.3 (---------) Cc: Shawn Guo , Dan Carpenter , Philipp Zabel , Pavel Machek , Stephen Warren X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enhance reset framework with "is_reset" and "clear_reset" api's. is_reset - used by client driver to know reset status clear_reset - used by client driver to clear reset status These functionalities may sometimes be achieved by using existing api like deassert. But in some scenarios, steps to achieve reset requires clearing reset, deassert reset, enabling clock to module and then checking reset status. Here enabling clock module is coming in between reset procedure, hence enhance framework with additional api's. Signed-off-by: Afzal Mohammed --- drivers/reset/core.c | 32 ++++++++++++++++++++++++++++++++ include/linux/reset-controller.h | 2 ++ include/linux/reset.h | 2 ++ 3 files changed, 36 insertions(+) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index d1b6089..ba12171 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -127,6 +127,38 @@ int reset_control_deassert(struct reset_control *rstc) EXPORT_SYMBOL_GPL(reset_control_deassert); /** + * reset_control_is_reset - check reset status + * @rstc: reset controller + * + * Returns a boolean or negative error code + * + */ +int reset_control_is_reset(struct reset_control *rstc) +{ + if (rstc->rcdev->ops->is_reset) + return rstc->rcdev->ops->is_reset(rstc->rcdev, rstc->id); + + return -ENOSYS; +} +EXPORT_SYMBOL_GPL(reset_control_is_reset); + +/** + * reset_control_clear_reset - clear the reset + * @rstc: reset controller + * + * Returns zero on success or negative error code + * + */ +int reset_control_clear_reset(struct reset_control *rstc) +{ + if (rstc->rcdev->ops->clear_reset) + return rstc->rcdev->ops->clear_reset(rstc->rcdev, rstc->id); + + return -ENOSYS; +} +EXPORT_SYMBOL_GPL(reset_control_clear_reset); + +/** * reset_control_get - Lookup and obtain a reference to a reset controller. * @dev: device to be reset by the controller * @id: reset line name diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h index 2f61311..c9bbadb 100644 --- a/include/linux/reset-controller.h +++ b/include/linux/reset-controller.h @@ -17,6 +17,8 @@ struct reset_control_ops { int (*reset)(struct reset_controller_dev *rcdev, unsigned long id); int (*assert)(struct reset_controller_dev *rcdev, unsigned long id); int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id); + int (*is_reset)(struct reset_controller_dev *rcdev, unsigned long id); + int (*clear_reset)(struct reset_controller_dev *rcdev, unsigned long i); }; struct module; diff --git a/include/linux/reset.h b/include/linux/reset.h index 6082247..da59f9f 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h @@ -7,6 +7,8 @@ struct reset_control; int reset_control_reset(struct reset_control *rstc); int reset_control_assert(struct reset_control *rstc); int reset_control_deassert(struct reset_control *rstc); +int reset_control_is_reset(struct reset_control *rstc); +int reset_control_clear_reset(struct reset_control *rstc); struct reset_control *reset_control_get(struct device *dev, const char *id); void reset_control_put(struct reset_control *rstc);