From patchwork Mon Mar 3 16:02:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3755131 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 32BFBBF40C for ; Mon, 3 Mar 2014 16:03:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3227F203E5 for ; Mon, 3 Mar 2014 16:03:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3342F203ED for ; Mon, 3 Mar 2014 16:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754882AbaCCQCw (ORCPT ); Mon, 3 Mar 2014 11:02:52 -0500 Received: from mail-ee0-f49.google.com ([74.125.83.49]:34497 "EHLO mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754855AbaCCQCs (ORCPT ); Mon, 3 Mar 2014 11:02:48 -0500 Received: by mail-ee0-f49.google.com with SMTP id c41so231169eek.36 for ; Mon, 03 Mar 2014 08:02:46 -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=0TqKBQ9CrJEOFWJU7GnFj9lWY8JmTXnveNSz3nMpSi4=; b=eHYW21zYbNRrTQoLjkCoOLizp362FgZ1Si3PrCovaAjWqEb2Ij57e2JDVprbwKstXK oLEYKlcQuFSkjdM0pR+f+ac6qQAb4XD27EJtANWvr5Q8aTvM8ykWCOOEpbvTiuuPVtLV TANcwomNNCSUZHLTc/3pgmm4ZeISQhza77dmQEFBME/7PBia6viMbgAfYmfVTIUEF0bK eeOFHqDalxe65IZ/zrmwuFf8gjtOEA5EUjR7mhBoUccWVf2Aygk34ftgmB1Ln9lLBQuh 9ExksmUNE9QCfo30jCpMqbs825H/qmwfb2Ak1VPpX7fG/9YJy7fWdCgaCNz5Lzu7RZDs hWKg== X-Received: by 10.14.179.129 with SMTP id h1mr41094312eem.26.1393862566239; Mon, 03 Mar 2014 08:02:46 -0800 (PST) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id y51sm51430597eeu.0.2014.03.03.08.02.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Mar 2014 08:02:45 -0800 (PST) From: Tomasz Figa To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Russell King , Kukjin Kim , Kumar Gala , Ian Campbell , Mark Rutland , Pawel Moll , Rob Herring , Bartlomiej Zolnierkiewicz , Stephen Warren , Tomasz Figa , Mark Brown , Stephen Boyd , Lorenzo Pieralisi , Ulf Hansson , Marek Szyprowski , Tomasz Figa Subject: [PATCH v2 07/11] ARM: s3c64xx: pm: Add device tree based power domain instantiation Date: Mon, 3 Mar 2014 17:02:12 +0100 Message-Id: <1393862536-9842-8-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393862536-9842-1-git-send-email-tomasz.figa@gmail.com> References: <1393862536-9842-1-git-send-email-tomasz.figa@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 b422eed..cebbd44 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 @@ -165,17 +168,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) { @@ -312,6 +361,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 */