From patchwork Thu Oct 31 10:20:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 3119911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8793C9F3E2 for ; Thu, 31 Oct 2013 10:21:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3EC22039F for ; Thu, 31 Oct 2013 10:21:32 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD1F32026C for ; Thu, 31 Oct 2013 10:21:27 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbpNU-0001cr-7S; Thu, 31 Oct 2013 10:21:24 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbpNR-0004dQ-Re; Thu, 31 Oct 2013 10:21:21 +0000 Received: from moutng.kundenserver.de ([212.227.17.8]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbpNP-0004d6-0u for linux-arm-kernel@lists.infradead.org; Thu, 31 Oct 2013 10:21:19 +0000 Received: from axis700.grange (dslb-146-060-124-255.pools.arcor-ip.net [146.60.124.255]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0Ls7Kh-1VnoCP448F-013edU; Thu, 31 Oct 2013 11:20:47 +0100 Received: by axis700.grange (Postfix, from userid 1000) id 5C42540BB4; Thu, 31 Oct 2013 11:20:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 54B8840BB3; Thu, 31 Oct 2013 11:20:46 +0100 (CET) Date: Thu, 31 Oct 2013 11:20:46 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: pcm037: convert custom GPIO-based power function to a regulator Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:mhw7rhm3uiIzdoAxHkncGGWGL7p5XNMsloVQm89xpuQ IdVlD6z0QBRCOjsasttpDTVahi06GfuqVkNBEpaTHFz8L0u+mn gUB2QAm4DqAfByR4cJwOzznny/UgzxQ3ScOSVZo5TGRffWjb5i WXvpdqEf3RS672p1bFmFE9vtGh1+61vkbOqJiewMXGKHd7c5O8 kmBe+GfpdchN3br4UP8hApY8AoRv0YlkuVT6+4mdthjYyhhM2H G3Q9/7sXQ6KajXwCZDbTU/sbSu71+duhX8+WFNuvosNCYg79/G kTJ2T5kxy34lKCqGjOPc5kBeKmYFirrNyL+KI2iIVGk2w9mAPB mGAuqH6Fhp1qjVOa1he3ClOS+hqkwy8v00/9G3WJ/6PXasgNu8 FYzva5nrPbH3g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131031_062119_264367_2F4DBCBD X-CRM114-Status: GOOD ( 14.51 ) X-Spam-Score: -2.4 (--) Cc: Sascha Hauer X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Add a fixed-voltage GPIO-enabled regulator to switch the camera on and off instead of using a .power() platform callback. Signed-off-by: Guennadi Liakhovetski --- Only tested to grab the regulator during probing, couldn't test functionality due to the lack of an mt9t031 sensor. arch/arm/mach-imx/mach-pcm037.c | 50 ++++++++++++++++++++++++++++----------- 1 files changed, 36 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-imx/mach-pcm037.c b/arch/arm/mach-imx/mach-pcm037.c index 639a3df..6c19eb1 100644 --- a/arch/arm/mach-imx/mach-pcm037.c +++ b/arch/arm/mach-imx/mach-pcm037.c @@ -288,12 +288,39 @@ static struct at24_platform_data board_eeprom = { .flags = AT24_FLAG_ADDR16, }; -static int pcm037_camera_power(struct device *dev, int on) -{ - /* disable or enable the camera in X7 or X8 PCM970 connector */ - gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), !on); - return 0; -} +/* Fixed 3.3V regulator to be used by cameras */ +static struct regulator_consumer_supply vcc_cam_consumers[] = { + REGULATOR_SUPPLY("vcc", "soc-camera-pdrv.0"), +}; + +static struct regulator_init_data vcc_cam_init_data = { + .constraints = { + .valid_ops_mask = REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = ARRAY_SIZE(vcc_cam_consumers), + .consumer_supplies = vcc_cam_consumers, +}; + +static struct fixed_voltage_config vcc_cam_info = { + .supply_name = "Camera Vcc", + .microvolts = 2800000, + .gpio = IOMUX_TO_GPIO(MX31_PIN_CSI_D5), + .init_data = &vcc_cam_init_data, +}; + +static struct platform_device vcc_cam = { + .name = "reg-fixed-voltage", + .id = 1, + .dev = { + .platform_data = &vcc_cam_info, + }, +}; + +static struct regulator_bulk_data cam_supply[] = { + { + .supply = "vcc", + }, +}; static struct i2c_board_info pcm037_i2c_camera[] = { { @@ -311,7 +338,8 @@ static struct soc_camera_link iclink_mt9v022 = { static struct soc_camera_link iclink_mt9t031 = { .bus_id = 0, /* Must match with the camera ID */ - .power = pcm037_camera_power, + .num_regulators = ARRAY_SIZE(cam_supply), + .regulators = cam_supply, .board_info = &pcm037_i2c_camera[0], .i2c_adapter_id = 2, }; @@ -436,6 +464,7 @@ err: static struct platform_device *devices[] __initdata = { &pcm037_flash, &pcm037_sram_device, + &vcc_cam, &pcm037_mt9t031, &pcm037_mt9v022, }; @@ -647,13 +676,6 @@ static void __init pcm037_init(void) imx31_add_mx3_sdc_fb(&mx3fb_pdata); /* CSI */ - /* Camera power: default - off */ - ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), "mt9t031-power"); - if (!ret) - gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), 1); - else - iclink_mt9t031.power = NULL; - pcm037_init_camera(); pcm970_sja1000_resources[1].start =