From patchwork Mon Apr 22 09:57:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 16302 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B660725DEE for ; Mon, 22 Apr 2013 09:58:47 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id 47sf1827660yhr.4 for ; Mon, 22 Apr 2013 02:58:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :from:to:cc:subject:date:message-id:x-mailer: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=T1EMDxqUeT8sVHR+nsHR7qPNPxW3bXAedLVtyjryPZg=; b=Y0M/T0wG316UG9at7ubtqjrwGl2RnM1E8fKPZHBFsWUh7G4DSpKpvMsqKUQFB3o/x6 th8nkcG+speW/hizjs//xxKEzW8F5M/kJKqBi06CcuemiS3t8lD0YMByY7Jf3WsJLCHe DWmLyWofD43hO0EAfD0sKpM0txoWn3dNUb73LBedF3IvoOCf3XtS+4anPjsg6O01S8Kl q2ilzkk+9wiNP0/kaiZkUo27jCS23N7VcG+UrtdTeQvdjaLhYev2Njf1quytceEMIjdV BKyyAvMxxx/ugjRcMuuwhpQ/ktLd9Ppd/Y05JLIYr/Mk19bGCn5Rd/wARvtYVqQ/1ZvY C2Ew== X-Received: by 10.224.185.17 with SMTP id cm17mr5563449qab.6.1366624681622; Mon, 22 Apr 2013 02:58:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.166 with SMTP id w6ls3014460qeu.14.gmail; Mon, 22 Apr 2013 02:58:01 -0700 (PDT) X-Received: by 10.220.147.12 with SMTP id j12mr18518842vcv.59.1366624681500; Mon, 22 Apr 2013 02:58:01 -0700 (PDT) Received: from mail-vb0-x22b.google.com (mail-vb0-x22b.google.com [2607:f8b0:400c:c02::22b]) by mx.google.com with ESMTPS id b7si15568860vcl.1.2013.04.22.02.58.01 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Apr 2013 02:58:01 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22b is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22b; Received: by mail-vb0-f43.google.com with SMTP id q12so5727293vbe.30 for ; Mon, 22 Apr 2013 02:58:01 -0700 (PDT) X-Received: by 10.58.144.170 with SMTP id sn10mr13793590veb.7.1366624681358; Mon, 22 Apr 2013 02:58:01 -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.58.127.98 with SMTP id nf2csp68866veb; Mon, 22 Apr 2013 02:58:00 -0700 (PDT) X-Received: by 10.194.90.108 with SMTP id bv12mr32775799wjb.4.1366624680348; Mon, 22 Apr 2013 02:58:00 -0700 (PDT) Received: from eu1sys200aog102.obsmtp.com (eu1sys200aog102.obsmtp.com [207.126.144.113]) by mx.google.com with SMTP id t4si38605265eeg.120.2013.04.22.02.57.50 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 22 Apr 2013 02:58:00 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.113 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.113; Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob102.postini.com ([207.126.147.11]) with SMTP ID DSNKUXUJmfmVwrlZFR+k5m2p+9m7rIIcw8qO@postini.com; Mon, 22 Apr 2013 09:57:59 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 58C7BDA; Mon, 22 Apr 2013 09:49:34 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id F312813D8; Mon, 22 Apr 2013 09:57:40 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id BEE9DA8074; Mon, 22 Apr 2013 11:57:35 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.279.5; Mon, 22 Apr 2013 11:57:39 +0200 From: Linus Walleij To: , Liam Girdwood , Mark Brown Cc: Arnd Bergmann , , Linus Walleij Subject: [PATCH 15/23] ARM: u300: set up board power from device tree Date: Mon, 22 Apr 2013 11:57:36 +0200 Message-ID: <1366624656-6648-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQn9UJrZpBdW2YD6rZiYW9pZPXtvZE1ezcEqwGjiR8xRv08SQ+LXKcYJOCEKuFdxiIkkMRfc X-Original-Sender: linus.walleij@stericsson.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22b 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 support for setting up the board power from the device tree on the U300. We use a board-specific node in the device tree for the S365 board and bind a regulator for the board power to this node. Cc: Mark Brown Signed-off-by: Linus Walleij --- Hi Mark, this was especially tricky due to the absence of a function to get a named regulator without a device node. After some cleverness introducing a node for the board akin to the solution I did for Nomadik, this seems to be an acceptable way forward, any other suggestions welcome. --- Documentation/devicetree/bindings/arm/ste-u300.txt | 13 +++++++ arch/arm/mach-u300/regulator.c | 42 ++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/ste-u300.txt b/Documentation/devicetree/bindings/arm/ste-u300.txt index 222dca5..cd9001a 100644 --- a/Documentation/devicetree/bindings/arm/ste-u300.txt +++ b/Documentation/devicetree/bindings/arm/ste-u300.txt @@ -7,3 +7,16 @@ or board power regulator supplies. Required root node property: compatible="stericsson,u300"; + +Boards with the U300 SoC include: + +S365 "Small Board U365": + +Required node: s365 + +Example: + +s365 { + compatible = "stericsson,s365"; + vana15-supply = <&ab3100_ldo_d_reg>; +}; diff --git a/arch/arm/mach-u300/regulator.c b/arch/arm/mach-u300/regulator.c index 9c53f01..8a67dc6 100644 --- a/arch/arm/mach-u300/regulator.c +++ b/arch/arm/mach-u300/regulator.c @@ -10,9 +10,14 @@ #include #include #include +#include +#include +#include +#include #include /* Those are just for writing in syscon */ #include +#include #include #include @@ -47,13 +52,17 @@ void u300_pm_poweroff(void) /* * Hog the regulators needed to power up the board. */ -static int __init u300_init_boardpower(void) +static int __init __u300_init_boardpower(struct platform_device *pdev) { int err; u32 val; pr_info("U300: setting up board power\n"); - main_power_15 = regulator_get(NULL, "vana15"); + if (pdev) + main_power_15 = regulator_get(&pdev->dev, "vana15"); + else + main_power_15 = regulator_get(NULL, "vana15"); + if (IS_ERR(main_power_15)) { pr_err("could not get vana15"); return PTR_ERR(main_power_15); @@ -82,7 +91,34 @@ static int __init u300_init_boardpower(void) return 0; } +static int __init s365_board_probe(struct platform_device *pdev) +{ + return __u300_init_boardpower(pdev); +} + +static const struct of_device_id s365_board_match[] = { + { .compatible = "stericsson,s365" }, + {}, +}; + +static struct platform_driver s365_board_driver = { + .driver = { + .name = "s365-board", + .owner = THIS_MODULE, + .of_match_table = s365_board_match, + }, +}; + /* * So at module init time we hog the regulator! */ -module_init(u300_init_boardpower); +static int __init u300_init_boardpower(void) +{ + if (of_have_populated_dt()) + return platform_driver_probe(&s365_board_driver, + s365_board_probe); + /* Only call this on non-DT boots */ + return __u300_init_boardpower(NULL); +} + +device_initcall(u300_init_boardpower);