From patchwork Thu May 23 17:31:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 17170 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B041A2395B for ; Thu, 23 May 2013 17:33:24 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id d1sf4549590qcz.0 for ; Thu, 23 May 2013 10:32:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=bYldq9sZ2+3BTA6xnCkzl6k/DWHDQqLg9QyBf65M6Fc=; b=dE6ouFXM1hJ79P9MdJc3/3LbPKvdz1HTmQYhzdDA3z3Pyeea1XQkG96XD4hpT5K7IS Ad7LO1MIh/CqMT4VPWgFBZHeY7kA3t9OmL6skUrf28UMhTXXaWkAJvNhQI15VrTR7oxD 9+sjqm4GAJM12P2eFMEWGAU+WR3Qr1l2F8ZV3Bs/YvPgF7yDAYilZGDEksE7R51Pvkch Nx8fdqgHSnB2LmfiEJNl0VKgWCbyvxD13NEWTscC/Cn0rXmfVn/NGOvIlEtIFojxc16N FSUA0aoPcxmSQRBdF29iC8nwhJQNXLWoqzAFOEcEFa5d/gwSsj67tnsNU+gLezl7J/Pj kYTw== X-Received: by 10.224.205.138 with SMTP id fq10mr599406qab.1.1369330349182; Thu, 23 May 2013 10:32:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.82.226 with SMTP id l2ls1444577qey.6.gmail; Thu, 23 May 2013 10:32:29 -0700 (PDT) X-Received: by 10.58.250.66 with SMTP id za2mr5972282vec.56.1369330349006; Thu, 23 May 2013 10:32:29 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id q13si6922320vcw.82.2013.05.23.10.32.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 10:32:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id hr11so2373188vcb.19 for ; Thu, 23 May 2013 10:32:28 -0700 (PDT) X-Received: by 10.220.246.8 with SMTP id lw8mr5989226vcb.8.1369330348809; Thu, 23 May 2013 10:32:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp62534vcs; Thu, 23 May 2013 10:32:28 -0700 (PDT) X-Received: by 10.15.48.4 with SMTP id g4mr10124794eew.10.1369330335820; Thu, 23 May 2013 10:32:15 -0700 (PDT) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com [207.126.144.133]) by mx.google.com with SMTP id 8si17199519eeg.151.2013.05.23.10.31.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 May 2013 10:32:15 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.133; Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKUZ5SgYOh4Pu2t7OctIOAkIzr9OYNf1zQ@postini.com; Thu, 23 May 2013 17:32:15 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id EC86C4E; Thu, 23 May 2013 17:30:39 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 905A34E; Thu, 23 May 2013 17:31:37 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 28B1924C2C0; Thu, 23 May 2013 19:31:28 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.279.5; Thu, 23 May 2013 19:31:36 +0200 From: Linus Walleij To: , Rob Herring , Mike Turquette Cc: , Arnd Bergmann , Linus Walleij Subject: [PATCH 1/6] ARM: u300: add syscon node Date: Thu, 23 May 2013 19:31:23 +0200 Message-ID: <1369330288-14856-2-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1369330288-14856-1-git-send-email-linus.walleij@stericsson.com> References: <1369330288-14856-1-git-send-email-linus.walleij@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnw0Bqx5HzryvU4ZoIndym9rPiTWYaIhteSqmDOi1UuZ0/jsZFv1uY4mgYdll5jak02Z+xZ X-Original-Sender: linus.walleij@stericsson.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Linus Walleij This adds a device tree node for the U300 system controller and remaps this dynamically instead of using hard-coded virtual addresses. The board power set-up code is altered to fetch a reference to the syscon using ampersand <&syscon> notation. This way of passing a pointer to the syscon will also be used by the clocks. Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/arm/ste-u300.txt | 30 +++++++++++++++++++--- arch/arm/boot/dts/ste-u300.dts | 6 +++++ arch/arm/mach-u300/core.c | 22 +++++++++++++--- arch/arm/mach-u300/regulator.c | 21 ++++++++++++--- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/ste-u300.txt b/Documentation/devicetree/bindings/arm/ste-u300.txt index cd9001a..69b5ab0 100644 --- a/Documentation/devicetree/bindings/arm/ste-u300.txt +++ b/Documentation/devicetree/bindings/arm/ste-u300.txt @@ -8,15 +8,39 @@ Required root node property: compatible="stericsson,u300"; +Required node: syscon +This contains the system controller. +- compatible: must be "stericsson,u300-syscon". +- reg: the base address and size of the system controller. + Boards with the U300 SoC include: S365 "Small Board U365": Required node: s365 +This contains the board-specific information. +- compatible: must be "stericsson,s365". +- vana15-supply: the regulator supplying the 1.5V to drive the + board. +- syscon: a pointer to the syscon node so we can acccess the + syscon registers to set the board as self-powered. Example: -s365 { - compatible = "stericsson,s365"; - vana15-supply = <&ab3100_ldo_d_reg>; +/ { + model = "ST-Ericsson U300"; + compatible = "stericsson,u300"; + #address-cells = <1>; + #size-cells = <1>; + + s365 { + compatible = "stericsson,s365"; + vana15-supply = <&ab3100_ldo_d_reg>; + syscon = <&syscon>; + }; + + syscon: syscon@c0011000 { + compatible = "stericsson,u300-syscon"; + reg = <0xc0011000 0x1000>; + }; }; diff --git a/arch/arm/boot/dts/ste-u300.dts b/arch/arm/boot/dts/ste-u300.dts index 35a2d58..0530095 100644 --- a/arch/arm/boot/dts/ste-u300.dts +++ b/arch/arm/boot/dts/ste-u300.dts @@ -27,6 +27,12 @@ s365 { compatible = "stericsson,s365"; vana15-supply = <&ab3100_ldo_d_reg>; + syscon = <&syscon>; + }; + + syscon: syscon@c0011000 { + compatible = "stericsson,u300-syscon"; + reg = <0xc0011000 0x1000>; }; timer: timer@c0014000 { diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c index 9caf5ea..bde6540 100644 --- a/arch/arm/mach-u300/core.c +++ b/arch/arm/mach-u300/core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,8 @@ #define U300_SYSCON_BCR_EXTRA_BOOT_OPTION_MASK (0x01FC) #define U300_SYSCON_BCR_APP_BOOT_SERV_MASK (0x0003) +static void __iomem *syscon_base; + /* * Static I/O mappings that are needed for booting the U300 platforms. The * only things we need are the areas where we find the timer, syscon and @@ -205,7 +208,7 @@ static void __init u300_init_check_chip(void) const char unknown[] = "UNKNOWN"; /* Read out and print chip ID */ - val = readw(U300_SYSCON_VBASE + U300_SYSCON_CIDR); + val = readw(syscon_base + U300_SYSCON_CIDR); /* This is in funky bigendian order... */ val = (val & 0xFFU) << 8 | (val >> 8); chip = db_chips; @@ -294,10 +297,21 @@ static struct of_dev_auxdata u300_auxdata_lookup[] __initdata = { static void __init u300_init_irq_dt(void) { + struct device_node *syscon; struct clk *clk; + syscon = of_find_node_by_path("/syscon@c0011000"); + if (!syscon) { + pr_crit("could not find syscon node\n"); + return; + } + syscon_base = of_iomap(syscon, 0); + if (!syscon_base) { + pr_crit("could not remap syscon\n"); + return; + } /* initialize clocking early, we want to clock the INTCON */ - u300_clk_init(U300_SYSCON_VBASE); + u300_clk_init(syscon_base); /* Bootstrap EMIF and SEMI clocks */ clk = clk_get_sys("pl172", NULL); @@ -330,9 +344,9 @@ static void __init u300_init_machine_dt(void) u300_auxdata_lookup, NULL); /* Enable SEMI self refresh */ - val = readw(U300_SYSCON_VBASE + U300_SYSCON_SMCR) | + val = readw(syscon_base + U300_SYSCON_SMCR) | U300_SYSCON_SMCR_SEMI_SREFREQ_ENABLE; - writew(val, U300_SYSCON_VBASE + U300_SYSCON_SMCR); + writew(val, syscon_base + U300_SYSCON_SMCR); } static const char * u300_board_compat[] = { diff --git a/arch/arm/mach-u300/regulator.c b/arch/arm/mach-u300/regulator.c index 1cbe88c..273fceb 100644 --- a/arch/arm/mach-u300/regulator.c +++ b/arch/arm/mach-u300/regulator.c @@ -16,8 +16,8 @@ #include #include /* Those are just for writing in syscon */ +#include #include -#include "u300-regs.h" /* Power Management Control 16bit (R/W) */ #define U300_SYSCON_PMCR (0x50) @@ -57,10 +57,25 @@ void u300_pm_poweroff(void) */ static int __init __u300_init_boardpower(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; + struct device_node *syscon_np; + static void __iomem *syscon_base; int err; u32 val; pr_info("U300: setting up board power\n"); + + syscon_np = of_parse_phandle(np, "syscon", 0); + if (!syscon_np) { + pr_crit("U300: no syscon node\n"); + return -ENODEV; + } + syscon_base = of_iomap(syscon_np, 0); + if (!syscon_base) { + pr_crit("U300: could not remap syscon\n"); + return -ENODEV; + } + main_power_15 = regulator_get(&pdev->dev, "vana15"); if (IS_ERR(main_power_15)) { @@ -81,9 +96,9 @@ static int __init __u300_init_boardpower(struct platform_device *pdev) * the rest of the U300 power management is implemented. */ pr_info("U300: disable system controller pull-up\n"); - val = readw(U300_SYSCON_VBASE + U300_SYSCON_PMCR); + val = readw(syscon_base + U300_SYSCON_PMCR); val &= ~U300_SYSCON_PMCR_DCON_ENABLE; - writew(val, U300_SYSCON_VBASE + U300_SYSCON_PMCR); + writew(val, syscon_base + U300_SYSCON_PMCR); /* Register globally exported PM poweroff hook */ pm_power_off = u300_pm_poweroff;