From patchwork Thu Dec 13 13:22:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13534 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 17BB523E1F for ; Thu, 13 Dec 2012 13:22:37 +0000 (UTC) Received: from mail-ia0-f172.google.com (mail-ia0-f172.google.com [209.85.210.172]) by fiordland.canonical.com (Postfix) with ESMTP id 9B8A3A1948C for ; Thu, 13 Dec 2012 13:22:36 +0000 (UTC) Received: by mail-ia0-f172.google.com with SMTP id z13so2035167iaz.3 for ; Thu, 13 Dec 2012 05:22:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=oVXMutw1PJgChULWgDNxTwup35mJpQJ5x+Ih3iM7jz4=; b=bh72Pb5pJmvmXGhQYmYJG9vbT5ix1vuh13gXqQSnwK0fnNq4NBEZBSxmS64RyA4ylo 4lKMF4lNQ+So2KjiZ2VVC7GvFrunc1SgDoofEUzHjOR65WnJNnZjlC1GNk2O3z2DE+TP bm2U4DoDD/zMu5dm1xvhLdnnQ///p+4gtV8h7hm6F7GFZlOWLEtRcxGPiGQH8BL0t9Cl F0RUNuaCRDkjM2erhPveS5CKEVEvmmoSXU+YROaHa2BCPHHs3E3dFANxDrYmTOcB72Zx p0k5ASTj7h6RaSQgXVDRUmYkVY1ckY6cvYnB3aYsUOqe3aUWHuRx/M5Wgn9nONh+M/om 137g== Received: by 10.50.161.169 with SMTP id xt9mr16481845igb.62.1355404956017; Thu, 13 Dec 2012 05:22:36 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp9217igt; Thu, 13 Dec 2012 05:22:35 -0800 (PST) Received: by 10.181.13.75 with SMTP id ew11mr3352374wid.9.1355404954477; Thu, 13 Dec 2012 05:22:34 -0800 (PST) Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by mx.google.com with ESMTPS id gg4si12004963wjb.40.2012.12.13.05.22.34 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Dec 2012 05:22:34 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.175 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.175; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.175 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f175.google.com with SMTP id z53so848690wey.6 for ; Thu, 13 Dec 2012 05:22:34 -0800 (PST) Received: by 10.194.80.135 with SMTP id r7mr8353539wjx.58.1355404954025; Thu, 13 Dec 2012 05:22:34 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id g2sm2568128wiy.0.2012.12.13.05.22.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Dec 2012 05:22:33 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, ulf.hansson@linaro.org, Lee Jones Subject: [PATCH 7/8] ARM: ux500: Use the GPIO regulator framework for SDI0's 'en' and 'vsel' Date: Thu, 13 Dec 2012 13:22:09 +0000 Message-Id: <1355404930-5691-8-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1355404930-5691-1-git-send-email-lee.jones@linaro.org> References: <1355404930-5691-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQmUSAUSpA6X+33fu5/orQU1MOJ4l+GSAdNbDhZsUxoszDIXB5EsEi18uqusq+iLzZfpAMf2 To prevent lots of unnecessary call-backs into platform code, we're now using the GPIO regulator framework to control the 'enable' (en) and 'voltage select' (vsel) GPIO pins which in turn control the MMCI's secondary regulator settings. This already works with Device Tree, but when booting with ATAGs we need to register it as a platform device. Signed-off-by: Lee Jones --- arch/arm/mach-ux500/board-mop500-regulators.c | 14 ++++++++ arch/arm/mach-ux500/board-mop500-regulators.h | 1 + arch/arm/mach-ux500/board-mop500.c | 44 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/arch/arm/mach-ux500/board-mop500-regulators.c b/arch/arm/mach-ux500/board-mop500-regulators.c index 2a17bc5..cb75405 100644 --- a/arch/arm/mach-ux500/board-mop500-regulators.c +++ b/arch/arm/mach-ux500/board-mop500-regulators.c @@ -28,6 +28,20 @@ struct regulator_init_data gpio_en_3v3_regulator = { .consumer_supplies = gpio_en_3v3_consumers, }; +static struct regulator_consumer_supply sdi0_reg_consumers[] = { + REGULATOR_SUPPLY("vqmmc", "sdi0"), +}; + +struct regulator_init_data sdi0_reg_init_data = { + .constraints = { + .min_uV = 1800000, + .max_uV = 2900000, + .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE|REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = ARRAY_SIZE(sdi0_reg_consumers), + .consumer_supplies = sdi0_reg_consumers, +}; + /* * TPS61052 regulator */ diff --git a/arch/arm/mach-ux500/board-mop500-regulators.h b/arch/arm/mach-ux500/board-mop500-regulators.h index 78a0642..0c79d90 100644 --- a/arch/arm/mach-ux500/board-mop500-regulators.h +++ b/arch/arm/mach-ux500/board-mop500-regulators.h @@ -19,5 +19,6 @@ ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS]; extern struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS]; extern struct regulator_init_data tps61052_regulator; extern struct regulator_init_data gpio_en_3v3_regulator; +extern struct regulator_init_data sdi0_reg_init_data; #endif diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index daa4237..e934176 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -91,6 +93,37 @@ static struct platform_device snowball_gpio_en_3v3_regulator_dev = { }, }; +/* Dynamically populated. */ +static struct gpio sdi0_reg_gpios[] = { + { 0, GPIOF_OUT_INIT_LOW, "mmci_vsel" }, +}; + +static struct gpio_regulator_state sdi0_reg_states[] = { + { .value = 2900000, .gpios = (0 << 0) }, + { .value = 1800000, .gpios = (1 << 0) }, +}; + +static struct gpio_regulator_config sdi0_reg_info = { + .supply_name = "ext-mmc-level-shifter", + .gpios = sdi0_reg_gpios, + .nr_gpios = ARRAY_SIZE(sdi0_reg_gpios), + .states = sdi0_reg_states, + .nr_states = ARRAY_SIZE(sdi0_reg_states), + .type = REGULATOR_VOLTAGE, + .enable_high = 1, + .enabled_at_boot = 0, + .init_data = &sdi0_reg_init_data, + .startup_delay = 100, +}; + +static struct platform_device sdi0_regulator = { + .name = "gpio-regulator", + .id = -1, + .dev = { + .platform_data = &sdi0_reg_info, + }, +}; + static struct ab8500_gpio_platform_data ab8500_gpio_pdata = { .gpio_base = MOP500_AB8500_PIN_GPIO(1), .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE, @@ -440,6 +473,7 @@ static struct hash_platform_data u8500_hash1_platform_data = { /* add any platform devices here - TODO */ static struct platform_device *mop500_platform_devs[] __initdata = { &mop500_gpio_keys_device, + &sdi0_regulator, }; #ifdef CONFIG_STE_DMA40 @@ -581,6 +615,7 @@ static struct platform_device *snowball_platform_devs[] __initdata = { &snowball_key_dev, &snowball_sbnet_dev, &snowball_gpio_en_3v3_regulator_dev, + &sdi0_regulator, }; static void __init mop500_init_machine(void) @@ -591,6 +626,9 @@ static void __init mop500_init_machine(void) mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR; + sdi0_reg_info.enable_gpio = GPIO_SDMMC_EN; + sdi0_reg_info.gpios[0].gpio = GPIO_SDMMC_1V8_3V_SEL; + mop500_pinmaps_init(); parent = u8500_init_devices(&ab8500_platdata); @@ -623,6 +661,9 @@ static void __init snowball_init_machine(void) struct device *parent = NULL; int i; + sdi0_reg_info.enable_gpio = SNOWBALL_SDMMC_EN_GPIO; + sdi0_reg_info.gpios[0].gpio = SNOWBALL_SDMMC_1V8_3V_GPIO; + snowball_pinmaps_init(); parent = u8500_init_devices(&ab8500_platdata); @@ -655,6 +696,9 @@ static void __init hrefv60_init_machine(void) */ mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO; + sdi0_reg_info.enable_gpio = HREFV60_SDMMC_EN_GPIO; + sdi0_reg_info.gpios[0].gpio = HREFV60_SDMMC_1V8_3V_GPIO; + hrefv60_pinmaps_init(); parent = u8500_init_devices(&ab8500_platdata);