From patchwork Tue Feb 24 17:33:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 44958 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BFF592029F for ; Tue, 24 Feb 2015 17:34:49 +0000 (UTC) Received: by wesu56 with SMTP id u56sf18267192wes.1 for ; Tue, 24 Feb 2015 09:34:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=eE/XpqyijTgkjiedf4F5fimAB1yCC9qWtbRb9qQaTWU=; b=i5dwxLjAUFAA+3HH+z6LSN4qZ10R6J38od78zYyJp+BbyVcbOy78Tm68SF29HoOODC az9qpUoYCOjo7pDvAquaTI4pgRWELhomZZGW2X3G3lAUgOYo0RL04VxA1nY3atwJNqyI qZI7kM2P/1f7LoDnlb+cbHBN0x9MfJQVZzjK11mZDdu26HoKiFe1eYvbc8na3toNV9KC OYj8EaFLDsx5ijWuahKzKqreHI0oDSoONfsvh5BCR9X1MU9v9ni6QCvy62qqBTNyP7/q ghUDT12J7g5YOM+zqpGtZbd9C59FOkZLNXeTo6x8BQo01NOizg+moNAGcuDTpiKf4OEM 5NMw== X-Gm-Message-State: ALoCoQk2LaKSwo2tr0MEzOWKyQvH7RAzS/f6oVuCGP8R4xLNoH+OCK8sSddyLL7yVKUxMIFEt6a9 X-Received: by 10.112.161.9 with SMTP id xo9mr2357167lbb.7.1424799289012; Tue, 24 Feb 2015 09:34:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.75 with SMTP id da11ls649808lad.95.gmail; Tue, 24 Feb 2015 09:34:48 -0800 (PST) X-Received: by 10.112.199.162 with SMTP id jl2mr15158781lbc.48.1424799288837; Tue, 24 Feb 2015 09:34:48 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id r3si28928391lbo.9.2015.02.24.09.34.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 09:34:48 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbiz11 with SMTP id z11so26509412lbi.8 for ; Tue, 24 Feb 2015 09:34:48 -0800 (PST) X-Received: by 10.152.28.5 with SMTP id x5mr15047640lag.112.1424799288666; Tue, 24 Feb 2015 09:34:48 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2060275lbj; Tue, 24 Feb 2015 09:34:47 -0800 (PST) X-Received: by 10.68.134.5 with SMTP id pg5mr1168934pbb.31.1424799286475; Tue, 24 Feb 2015 09:34:46 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj2si3967527pdb.83.2015.02.24.09.34.45; Tue, 24 Feb 2015 09:34:46 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753388AbbBXRek (ORCPT + 28 others); Tue, 24 Feb 2015 12:34:40 -0500 Received: from mail-we0-f175.google.com ([74.125.82.175]:36067 "EHLO mail-we0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753343AbbBXReg (ORCPT ); Tue, 24 Feb 2015 12:34:36 -0500 Received: by wevk48 with SMTP id k48so26727411wev.3 for ; Tue, 24 Feb 2015 09:34:35 -0800 (PST) X-Received: by 10.180.187.200 with SMTP id fu8mr32990402wic.28.1424799274390; Tue, 24 Feb 2015 09:34:34 -0800 (PST) Received: from localhost.localdomain (host86-177-159-74.range86-177.btcentralplus.com. [86.177.159.74]) by mx.google.com with ESMTPSA id ch6sm61135254wjc.3.2015.02.24.09.34.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Feb 2015 09:34:33 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com, mturquette@linaro.org, sboyd@codeaurora.org, devicetree@vger.kernel.org Subject: [PATCH v3 3/4] clk: Provide an always-on clock domain framework Date: Tue, 24 Feb 2015 17:33:41 +0000 Message-Id: <1424799222-9301-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424799222-9301-1-git-send-email-lee.jones@linaro.org> References: <1424799222-9301-1-git-send-email-lee.jones@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Lots of platforms contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the clk_disabled_unused() procedure. Signed-off-by: Lee Jones --- drivers/clk/Makefile | 1 + drivers/clk/clk-always-on.c | 62 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 drivers/clk/clk-always-on.c diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index d478ceb..0d42541 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_HAVE_CLK) += clk-devres.o obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o obj-$(CONFIG_COMMON_CLK) += clk.o obj-$(CONFIG_COMMON_CLK) += clk-divider.o +obj-$(CONFIG_COMMON_CLK) += clk-always-on.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-factor.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-rate.o obj-$(CONFIG_COMMON_CLK) += clk-gate.o diff --git a/drivers/clk/clk-always-on.c b/drivers/clk/clk-always-on.c new file mode 100644 index 0000000..f3d90ac --- /dev/null +++ b/drivers/clk/clk-always-on.c @@ -0,0 +1,62 @@ +/* + * Always-on Clock Domain + * + * Copyright (C) 2015 STMicroelectronics – All Rights Reserved + * + * Author: Lee Jones + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include + +static void ao_clock_domain_hog_clock(struct platform_device *pdev, int index) +{ + struct device_node *np = pdev->dev.of_node; + struct clk *clk; + int ret; + + clk = of_clk_get(np, index); + if (IS_ERR(clk)) { + dev_warn(&pdev->dev, "Failed get clock %s[%d]: %li\n", + np->full_name, index, PTR_ERR(clk)); + return; + } + + ret = clk_prepare_enable(clk); + if (ret) + dev_warn(&pdev->dev, "Failed to enable clock: %s\n", __clk_get_name(clk)); +} + +static int ao_clock_domain_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + int nclks, i; + + nclks = of_count_phandle_with_args(np, "clocks", "#clock-cells"); + + for (i = 0; i < nclks; i++) + ao_clock_domain_hog_clock(pdev, i); + + return 0; +} + +static const struct of_device_id ao_clock_domain_match[] = { + { .compatible = "clk-always-on" }, + { }, +}; + +static struct platform_driver ao_clock_domain_driver = { + .probe = ao_clock_domain_probe, + .driver = { + .name = "clk-always-on", + .of_match_table = ao_clock_domain_match, + }, +}; +module_platform_driver(ao_clock_domain_driver);