From patchwork Thu Jun 13 20:20:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 17916 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6EC7C25BE0 for ; Thu, 13 Jun 2013 20:21:10 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id a1sf7753159qcx.6 for ; Thu, 13 Jun 2013 13:21:10 -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: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=WNMZ3ncdo1oCJTNfb34LIQeizoELQxVXN/YMbV4pbXQ=; b=hotAU9Xbd+uQk2xreI1XsXukN1RGrC/d2vXi9R9aBXB3eTq1+sY7woIJQv07iM4vVB kjJsi30sAVs7/iRuzq79k/sdiWuOdLxss/KgOS+IMipXO8tFmAYObr+Iko12qONYpyX6 bLRLw5+ewtvrePos1vNMlzrQPjUYtPBYi0IhXCeFP5DDJN+zrBocvhZaKtO3+tXl0o3Q smAntX3p5GVWDWXUk7uTUwfyVfeXHcRlLa93vcieJCWRU0atMnZk39ljgQ1nvbqK1xt2 Zx5mMHEf6xTwTElmY31syTOV6q6KKFvWNnNq+bFH1lRBh4mubXazT3PvugHQoipnu6ZA cY7g== X-Received: by 10.236.170.161 with SMTP id p21mr1202560yhl.33.1371154869839; Thu, 13 Jun 2013 13:21:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.105.7 with SMTP id gi7ls4146376qeb.56.gmail; Thu, 13 Jun 2013 13:21:09 -0700 (PDT) X-Received: by 10.58.219.68 with SMTP id pm4mr561065vec.49.1371154869667; Thu, 13 Jun 2013 13:21:09 -0700 (PDT) Received: from mail-vb0-x236.google.com (mail-vb0-x236.google.com [2607:f8b0:400c:c02::236]) by mx.google.com with ESMTPS id ff9si11222156vcb.37.2013.06.13.13.21.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 13:21:09 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::236 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::236; Received: by mail-vb0-f54.google.com with SMTP id q12so4409142vbe.13 for ; Thu, 13 Jun 2013 13:21:09 -0700 (PDT) X-Received: by 10.52.171.80 with SMTP id as16mr903241vdc.90.1371154869512; Thu, 13 Jun 2013 13:21:09 -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.191.99 with SMTP id gx3csp36793vec; Thu, 13 Jun 2013 13:21:08 -0700 (PDT) X-Received: by 10.14.208.131 with SMTP id q3mr3049250eeo.111.1371154868296; Thu, 13 Jun 2013 13:21:08 -0700 (PDT) Received: from eu1sys200aog113.obsmtp.com (eu1sys200aog113.obsmtp.com [207.126.144.135]) by mx.google.com with SMTP id g7si19997530eew.135.2013.06.13.13.20.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Jun 2013 13:21:08 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.135 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.135; Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob113.postini.com ([207.126.147.11]) with SMTP ID DSNKUbopl+20j3GLqxNVg/jW3KP1103l7Uvz@postini.com; Thu, 13 Jun 2013 20:21:07 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 E44E5BD; Thu, 13 Jun 2013 20:20:36 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 3FAA3410; Thu, 13 Jun 2013 20:20:36 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 1A7F624C080; Thu, 13 Jun 2013 22:20:25 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.279.5; Thu, 13 Jun 2013 22:20:35 +0200 From: Linus Walleij To: , Arnd Bergmann , Mark Brown Cc: Linus Walleij Subject: [PATCH 2/2] regulators: ab3100: bootstrap board power Date: Thu, 13 Jun 2013 22:20:28 +0200 Message-ID: <1371154828-28117-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: ALoCoQntg9+DabA2fIApFhQFr5TITlDdLCjqv3KvZQORHXDhwFkQY6euxXdRzgIGjXbflPOf4Iso X-Original-Sender: linus.walleij@stericsson.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::236 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 moves the code from the platform that is bootstrapping the power on the U300 platform out from the machine directory and the special-purpose board node and module and into the regulator node and driver itself. Cc: Mark Brown Suggested-by: Arnd Bergmann Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/arm/ste-u300.txt | 18 --- arch/arm/boot/dts/ste-u300.dts | 9 +- arch/arm/mach-u300/Makefile | 1 - arch/arm/mach-u300/regulator.c | 133 --------------------- drivers/regulator/ab3100.c | 73 +++++++++++ 5 files changed, 76 insertions(+), 158 deletions(-) delete mode 100644 arch/arm/mach-u300/regulator.c diff --git a/Documentation/devicetree/bindings/arm/ste-u300.txt b/Documentation/devicetree/bindings/arm/ste-u300.txt index 69b5ab0..5ae045f 100644 --- a/Documentation/devicetree/bindings/arm/ste-u300.txt +++ b/Documentation/devicetree/bindings/arm/ste-u300.txt @@ -13,18 +13,6 @@ 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: / { @@ -33,12 +21,6 @@ Example: #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 8a1032c..fecc72a 100644 --- a/arch/arm/boot/dts/ste-u300.dts +++ b/arch/arm/boot/dts/ste-u300.dts @@ -24,12 +24,6 @@ reg = <0x48000000 0x03c00000>; }; - s365 { - compatible = "stericsson,s365"; - vana15-supply = <&ab3100_ldo_d_reg>; - syscon = <&syscon>; - }; - syscon: syscon@c0011000 { compatible = "stericsson,u300-syscon", "syscon"; reg = <0xc0011000 0x1000>; @@ -314,6 +308,9 @@ interrupts = <0>; /* EXT0 IRQ */ ab3100-regulators { compatible = "stericsson,ab3100-regulators"; + /* This is for powering the board */ + vana15-supply = <&ab3100_ldo_d_reg>; + syscon = <&syscon>; ab3100_ldo_a_reg: ab3100_ldo_a { regulator-compatible = "ab3100_ldo_a"; startup-delay-us = <200>; diff --git a/arch/arm/mach-u300/Makefile b/arch/arm/mach-u300/Makefile index 0f362b6..fcaa301 100644 --- a/arch/arm/mach-u300/Makefile +++ b/arch/arm/mach-u300/Makefile @@ -8,4 +8,3 @@ obj-n := obj- := obj-$(CONFIG_MACH_U300_SPIDUMMY) += dummyspichip.o -obj-$(CONFIG_REGULATOR_AB3100) += regulator.o diff --git a/arch/arm/mach-u300/regulator.c b/arch/arm/mach-u300/regulator.c deleted file mode 100644 index bf40cd4..0000000 --- a/arch/arm/mach-u300/regulator.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * arch/arm/mach-u300/regulator.c - * - * Copyright (C) 2009 ST-Ericsson AB - * License terms: GNU General Public License (GPL) version 2 - * Handle board-bound regulators and board power not related - * to any devices. - * Author: Linus Walleij - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Power Management Control 16bit (R/W) */ -#define U300_SYSCON_PMCR (0x50) -#define U300_SYSCON_PMCR_DCON_ENABLE (0x0002) -#define U300_SYSCON_PMCR_PWR_MGNT_ENABLE (0x0001) - -/* - * Regulators that power the board and chip and which are - * not copuled to specific drivers are hogged in these - * instances. - */ -static struct regulator *main_power_15; - -/* - * This function is used from pm.h to shut down the system by - * resetting all regulators in turn and then disable regulator - * LDO D (main power). - */ -void u300_pm_poweroff(void) -{ - sigset_t old, all; - - sigfillset(&all); - if (!sigprocmask(SIG_BLOCK, &all, &old)) { - /* Disable LDO D to shut down the system */ - if (main_power_15) - regulator_disable(main_power_15); - else - pr_err("regulator not available to shut down system\n"); - (void) sigprocmask(SIG_SETMASK, &old, NULL); - } - return; -} - -/* - * Hog the regulators needed to power up the board. - */ -static int __init __u300_init_boardpower(struct platform_device *pdev) -{ - struct device_node *np = pdev->dev.of_node; - struct device_node *syscon_np; - struct regmap *regmap; - int err; - - 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; - } - regmap = syscon_node_to_regmap(syscon_np); - if (!regmap) { - pr_crit("U300: could not locate syscon regmap\n"); - return -ENODEV; - } - - main_power_15 = regulator_get(&pdev->dev, "vana15"); - - if (IS_ERR(main_power_15)) { - pr_err("could not get vana15"); - return PTR_ERR(main_power_15); - } - err = regulator_enable(main_power_15); - if (err) { - pr_err("could not enable vana15\n"); - return err; - } - - /* - * On U300 a special system controller register pulls up the DC - * until the vana15 (LDO D) regulator comes up. At this point, all - * regulators are set and we do not need power control via - * DC ON anymore. This function will likely be moved whenever - * the rest of the U300 power management is implemented. - */ - pr_info("U300: disable system controller pull-up\n"); - regmap_update_bits(regmap, U300_SYSCON_PMCR, - U300_SYSCON_PMCR_DCON_ENABLE, 0); - - /* Register globally exported PM poweroff hook */ - pm_power_off = u300_pm_poweroff; - - 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! - */ -static int __init u300_init_boardpower(void) -{ - return platform_driver_probe(&s365_board_driver, - s365_board_probe); -} - -device_initcall(u300_init_boardpower); diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 3be9e46..7004f6e 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c @@ -19,6 +19,11 @@ #include #include #include +/* These are for powering the board */ +#include +#include +#include +#include /* LDO registers and some handy masking definitions for AB3100 */ #define AB3100_LDO_A 0x40 @@ -622,9 +627,40 @@ static int ab3100_regulators_remove(struct platform_device *pdev) return 0; } +/* Power Management Control 16bit (R/W) */ +#define U300_SYSCON_PMCR (0x50) +#define U300_SYSCON_PMCR_DCON_ENABLE (0x0002) +#define U300_SYSCON_PMCR_PWR_MGNT_ENABLE (0x0001) + +static struct regulator *main_power_15; + +/* + * This function is used from pm.h to shut down the system by + * resetting all regulators in turn and then disable regulator + * LDO D (main power). + */ +void ab3100_pm_poweroff(void) +{ + sigset_t old, all; + + sigfillset(&all); + if (!sigprocmask(SIG_BLOCK, &all, &old)) { + /* Disable LDO D to shut down the system */ + if (main_power_15) + regulator_disable(main_power_15); + else + pr_err("regulator not available to shut down system\n"); + (void) sigprocmask(SIG_SETMASK, &old, NULL); + } + return; +} + + static int ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) { + struct device_node *syscon_np; + struct regmap *regmap; int err, i; /* @@ -654,6 +690,43 @@ ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) } } + dev_notice(&pdev->dev, "setting up board power\n"); + + main_power_15 = regulator_get(&pdev->dev, "vana15"); + if (IS_ERR(main_power_15)) { + dev_err(&pdev->dev, "could not get vana15"); + return PTR_ERR(main_power_15); + } + err = regulator_enable(main_power_15); + if (err) { + dev_err(&pdev->dev, "could not enable vana15\n"); + return err; + } + + /* + * On U300 a special system controller register pulls up the DC + * until the vana15 (LDO D) regulator comes up. At this point, all + * regulators are set and we do not need power control via + * DC ON anymore. This function will likely be moved whenever + * the rest of the U300 power management is implemented. + */ + syscon_np = of_parse_phandle(np, "syscon", 0); + if (!syscon_np) { + dev_crit(&pdev->dev, "no syscon node\n"); + return -ENODEV; + } + regmap = syscon_node_to_regmap(syscon_np); + if (!regmap) { + dev_crit(&pdev->dev, "could not locate syscon regmap\n"); + return -ENODEV; + } + dev_info(&pdev->dev, "disable system controller pull-up\n"); + regmap_update_bits(regmap, U300_SYSCON_PMCR, + U300_SYSCON_PMCR_DCON_ENABLE, 0); + + /* Register globally exported PM poweroff hook */ + pm_power_off = ab3100_pm_poweroff; + return 0; }