From patchwork Sat Jan 11 19:42:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3470021 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 00EEF9F2E9 for ; Sat, 11 Jan 2014 19:46:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2608720165 for ; Sat, 11 Jan 2014 19:46:51 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 91A2420172 for ; Sat, 11 Jan 2014 19:46:49 +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 1W24UK-0001XV-I9; Sat, 11 Jan 2014 19:44:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W24Tq-0000a2-BD; Sat, 11 Jan 2014 19:44:26 +0000 Received: from mail-ee0-x234.google.com ([2a00:1450:4013:c00::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W24T8-0000PI-Nm for linux-arm-kernel@lists.infradead.org; Sat, 11 Jan 2014 19:43:50 +0000 Received: by mail-ee0-f52.google.com with SMTP id e53so373348eek.39 for ; Sat, 11 Jan 2014 11:43:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NVjloku0e5VODtJg/uJ52A+HBko6qxdaDpHjSbDuuGA=; b=qs5JWT16qTNQ1b2UE+OJ9ZLNqMALkQO7+bJ/ia/uFeQ0MKrChQKzAqCfBb5bUfZowk /Xv0DmakK8AD2jVqEu4ImxZBXT1lfBoWkO84ePD+Hu6+1RlgLhizI2wl5B+EoynhDk4+ GX17F2BnL3ET16l8V35bgojGkFx+REOhZb1pP2Zzbq+G/hfBszWw2LPK+V1nOQA33N5B NalB29cDSqrDW1HYtvToABXu4MlLDXMZSNqveVyqP4bDzKN4y6dF6X5cQ2BfTlbHP0P8 hO73bM7zByLZnINaJTDKwLxp5jSkTw0oY/HqkSkFxPAcyVJqvuJLgBAR4+rKjai5Z3OX H2vw== X-Received: by 10.14.109.5 with SMTP id r5mr1048042eeg.110.1389469401046; Sat, 11 Jan 2014 11:43:21 -0800 (PST) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id e3sm25312484eeg.11.2014.01.11.11.43.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jan 2014 11:43:20 -0800 (PST) From: Tomasz Figa To: linux-pm@vger.kernel.org Subject: [PATCH RFC 06/10] ARM: s3c64xx: pm: Add device tree based power domain instantiation Date: Sat, 11 Jan 2014 20:42:48 +0100 Message-Id: <1389469372-17199-7-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389469372-17199-1-git-send-email-tomasz.figa@gmail.com> References: <1389469372-17199-1-git-send-email-tomasz.figa@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140111_144343_007153_B92C9446 X-CRM114-Status: GOOD ( 19.65 ) X-Spam-Score: -2.0 (--) Cc: Mark Rutland , devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Russell King , Pawel Moll , Len Brown , Greg Kroah-Hartman , Tomasz Figa , Ian Campbell , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Rob Herring , Tomasz Figa , Bartlomiej Zolnierkiewicz , Kukjin Kim , Pavel Machek , Kumar Gala , Stephen Warren , linux-arm-kernel@lists.infradead.org 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This patch adds support for registering power domains of S3C64xx SoCs and binding devices to them using device tree. Signed-off-by: Tomasz Figa --- arch/arm/mach-s3c64xx/pm.c | 71 +++++++++++++++++++++---- include/dt-bindings/arm/s3c64xx-power-domains.h | 26 +++++++++ 2 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 include/dt-bindings/arm/s3c64xx-power-domains.h diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c index 717d9be..673baaf 100644 --- a/arch/arm/mach-s3c64xx/pm.c +++ b/arch/arm/mach-s3c64xx/pm.c @@ -17,8 +17,11 @@ #include #include #include +#include #include +#include + #include #include @@ -164,17 +167,63 @@ static struct s3c64xx_pm_domain s3c64xx_pm_v = { }, }; -static struct s3c64xx_pm_domain *s3c64xx_pm_domains[] = { - &s3c64xx_pm_irom, - &s3c64xx_pm_etm, - &s3c64xx_pm_g, - &s3c64xx_pm_v, - &s3c64xx_pm_i, - &s3c64xx_pm_p, - &s3c64xx_pm_s, - &s3c64xx_pm_f, +static struct s3c64xx_pm_domain *s3c64xx_pm_domains[NR_DOMAINS] = { + [DOMAIN_V] = &s3c64xx_pm_v, + [DOMAIN_G] = &s3c64xx_pm_g, + [DOMAIN_I] = &s3c64xx_pm_i, + [DOMAIN_P] = &s3c64xx_pm_p, + [DOMAIN_F] = &s3c64xx_pm_f, + [DOMAIN_S] = &s3c64xx_pm_s, + [DOMAIN_ETM] = &s3c64xx_pm_etm, + [DOMAIN_IROM] = &s3c64xx_pm_irom, +}; + +#ifdef CONFIG_OF +static struct of_device_id s3c64xx_pd_matches[] = { + { .compatible = "samsung,s3c6400-clock", }, + { .compatible = "samsung,s3c6410-clock", }, + { }, }; +static struct genpd_onecell_data pd_data; + +static int s3c64xx_pm_parse_domains(void) +{ + struct device_node *np; + int i; + + np = of_find_matching_node(NULL, s3c64xx_pd_matches); + if (!np) + return -ENODEV; + + pd_data.domains = kcalloc(ARRAY_SIZE(s3c64xx_pm_domains), + sizeof(*pd_data.domains), GFP_KERNEL); + if (!pd_data.domains) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(s3c64xx_pm_domains); ++i) { + struct s3c64xx_pm_domain *pd = s3c64xx_pm_domains[i]; + struct dev_power_governor *gov = NULL; + int on; + + on = __raw_readl(S3C64XX_NORMAL_CFG) & pd->ena; + + if (pd->always_on) + gov = &pm_domain_always_on_gov; + + pm_genpd_init(&pd->pd, gov, !on); + pd_data.domains[i] = &pd->pd; + + pr_debug("%s: registered domain %s\n", __func__, pd->pd.name); + } + + pd_data.domain_num = ARRAY_SIZE(s3c64xx_pm_domains); + of_genpd_add_provider(np, of_genpd_xlate_onecell, &pd_data); + + return 0; +} +#endif + #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK void s3c_pm_debug_smdkled(u32 set, u32 clear) { @@ -311,6 +360,10 @@ int __init s3c64xx_pm_init(void) s3c_pm_init(); +#ifdef CONFIG_OF + if (of_have_populated_dt()) + return s3c64xx_pm_parse_domains(); +#endif for (i = 0; i < ARRAY_SIZE(s3c64xx_pm_domains); i++) { struct s3c64xx_pm_domain *pd = s3c64xx_pm_domains[i]; diff --git a/include/dt-bindings/arm/s3c64xx-power-domains.h b/include/dt-bindings/arm/s3c64xx-power-domains.h new file mode 100644 index 0000000..ce39bef --- /dev/null +++ b/include/dt-bindings/arm/s3c64xx-power-domains.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2014 Tomasz Figa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Device Tree binding constants for Samsung S3C64xx power domains. +*/ + +#ifndef _DT_BINDINGS_ARM_S3C64XX_POWER_DOMAINS_H +#define _DT_BINDINGS_ARM_S3C64XX_POWER_DOMAINS_H + +#define DOMAIN_V 0 +#define DOMAIN_G 1 +#define DOMAIN_I 2 +#define DOMAIN_P 3 +#define DOMAIN_F 4 +#define DOMAIN_S 5 +#define DOMAIN_ETM 6 +#define DOMAIN_IROM 7 + +/* Total number of clocks. */ +#define NR_DOMAINS (DOMAIN_IROM + 1) + +#endif /* _DT_BINDINGS_ARM_S3C64XX_POWER_DOMAINS_H */