From patchwork Mon May 7 15:56:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 135103 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp3327290lji; Mon, 7 May 2018 08:57:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrE/JoPayAUtdq87HIk/wvfs+z3ZOdp6RVWnMn3s3wDgeootzlASFPV2OM+FZ8Ft0La4BBA X-Received: by 2002:a24:db57:: with SMTP id c84-v6mr1843143itg.60.1525708668417; Mon, 07 May 2018 08:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525708668; cv=none; d=google.com; s=arc-20160816; b=HGDyMXBsPf0MCeFEhMbvHC9osDnbXY2P5a4JzmR1S8CPRMyKkIxK+++I+nGrH4JV2X YUJWJNDp6L9vmzDcpmSC0HjOJ4g14B8hPOVs17U4wITKZqy2eMq0g+qU8x8sQ0dHU8dz zCSpmkDrokGXTtqmzCnOm0uantgMnpsr+7SIFLMD9v6C/nFCjDufBRrFZtJbsY0kIkRj 2jbL+tCcFxuPS5myE3b4bL/jBsGCyld+a9Jn7w6fk2d4MtXUy1oriai6z5LLzn+mErRc 8kyeNgAqEoB/FrQNVvyecbCBf29gq3ConA4kUilSFXKiMNzOXf5hV1ARZYEqS5v4/Bx8 OmXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dNIoprba70vAkU9SoCdchjOHDV4vtn8OxwqTXy5bNts=; b=jm4S0EKh3DqJE6uJuDlqeuMsS4HZpfMYgm67gJOBBKO627rzuTzB4rH6FZ42snSF+F h5Ur2qLy6iIytJOG/K6HJKGte+aQ2ITE1UMJ1wOhwlfuzx16dtEGdieCg8RkYYsiT8c9 Pm3oCHpx1hn9zO5tJTNGmz9ghRcLRvvyDzK9WS3IVIjr6FRvcJT1q2Yk/4+MVKmtVMIZ DSBpYvA+T+E7ehR6UrBgIAmOe9n6rYbnv8OaV9sOgRnacwS7BChD3zXNik5uXN/ZVs3o y0CAWP/aUc2ZAnyFakOzcckfLzSQIARlv1W/G7NVY6a+t3k2Hal17OkaPaQwtR1VLCcx v87g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NGnG/Dmj; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k124-v6si19537387iok.34.2018.05.07.08.57.48; Mon, 07 May 2018 08:57:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NGnG/Dmj; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752789AbeEGP5r (ORCPT + 6 others); Mon, 7 May 2018 11:57:47 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38869 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752790AbeEGP5p (ORCPT ); Mon, 7 May 2018 11:57:45 -0400 Received: by mail-wm0-f66.google.com with SMTP id m198-v6so15518462wmg.3 for ; Mon, 07 May 2018 08:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F+Mo6MdzVhD2+FTd/F2XxiErD8j/HTKIL2mSUsIIyqw=; b=NGnG/DmjbMiT/PFIiDDIrOjIilzTqm99Ww0mN6LO7kE8b86CYTyQ5MWaTYdtjW2v2o 3m4gIlhkW+Ye0OsIU7m1wuZBmNJUVxc0+Go1Q3p3t2KZjFjzKuTQ8HGb4vQrSCVSVqFB 0frnomMb95zyjhVMpsYrSCscj1igDZ9yzmDHk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F+Mo6MdzVhD2+FTd/F2XxiErD8j/HTKIL2mSUsIIyqw=; b=l9xipmaSefBuZH7m44O836dT05mEwBIBnt7i+PWEL67S96nOa0KjgGul4YLSoHcdUR n+JG6iJCt1Q6c14qQN0lt1pG8g6MQNoUB+dTVgxReJQfJHY58V/LKqoATancAaGLcjDW 1iUPrQOgXeExVsc1DQ5TYYyNvN8vOKvneECK0W3ASMpZJ3QsouHEhTwMckzwN+5QjaJ/ SXtDGnRGjkWOtbhqhgrNAq6PNBeBlytS0Mag+q0/3D4jF8rbavvJY/1eyAuMy9nDzGDm lVki0OdjWImE/M18rqQqwC0M3pQa5LA3b9Er5o6cJocMCn4TJ6fWX+LC1gWBCIXfo+wh oOvQ== X-Gm-Message-State: ALKqPwdPZZcE0Z+NwmFGb9rriQWLPtdhCn6M7RwNbGxPtQnp2mOt/f4x uuKqJ3kYk8kjzTG/A8g1rVzRgA== X-Received: by 2002:a1c:2084:: with SMTP id g126-v6mr1298917wmg.52.1525708663951; Mon, 07 May 2018 08:57:43 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id y42-v6sm32294807wry.21.2018.05.07.08.57.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 08:57:43 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, hverkuil@xs4all.nl, Rob Herring Cc: linux-media@vger.kernel.org, Fabio Estevam , devicetree@vger.kernel.org, Ryan Harkin , Rui Miguel Silva Subject: [PATCH 4/4] media: ov2680: add regulators to supply control Date: Mon, 7 May 2018 16:56:55 +0100 Message-Id: <20180507155655.1555-5-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180507155655.1555-1-rui.silva@linaro.org> References: <20180507155655.1555-1-rui.silva@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add the code to control the regulators for the analogue and digital power supplies. Signed-off-by: Rui Miguel Silva --- drivers/media/i2c/ov2680.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index 8962b397211a..07bb475c970c 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,14 @@ struct reg_value { u8 val; }; +static const char * const ov2680_supply_name[] = { + "DOVDD", + "DVDD", + "AVDD", +}; + +#define OV2680_NUM_SUPPLIES ARRAY_SIZE(ov2680_supply_name) + struct ov2680_mode_info { const char *name; enum ov2680_mode_id id; @@ -97,6 +106,7 @@ struct ov2680_dev { struct media_pad pad; struct clk *xvclk; u32 xvclk_freq; + struct regulator_bulk_data supplies[OV2680_NUM_SUPPLIES]; struct gpio_desc *reset_gpio; struct mutex lock; /* protect members */ @@ -522,6 +532,7 @@ static int ov2680_power_off(struct ov2680_dev *sensor) clk_disable_unprepare(sensor->xvclk); ov2680_power_down(sensor); + regulator_bulk_disable(OV2680_NUM_SUPPLIES, sensor->supplies); sensor->is_enabled = false; return 0; @@ -535,6 +546,12 @@ static int ov2680_power_on(struct ov2680_dev *sensor) if (sensor->is_enabled) return 0; + ret = regulator_bulk_enable(OV2680_NUM_SUPPLIES, sensor->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators: %d\n", ret); + return ret; + } + if (!sensor->reset_gpio) { ret = ov2680_write_reg(sensor, OV2680_REG_SOFT_RESET, 0x01); if (ret != 0) { @@ -962,6 +979,18 @@ static int ov2680_v4l2_init(struct ov2680_dev *sensor) return ret; } +static int ov2680_get_regulators(struct ov2680_dev *sensor) +{ + int i; + + for (i = 0; i < OV2680_NUM_SUPPLIES; i++) + sensor->supplies[i].supply = ov2680_supply_name[i]; + + return devm_regulator_bulk_get(&sensor->i2c_client->dev, + OV2680_NUM_SUPPLIES, + sensor->supplies); +} + static int ov2680_check_id(struct ov2680_dev *sensor) { struct device *dev = ov2680_to_dev(sensor); @@ -1034,6 +1063,12 @@ static int ov2680_probe(struct i2c_client *client) if (ret < 0) return ret; + ret = ov2680_get_regulators(sensor); + if (ret < 0) { + dev_err(dev, "failed to get regulators\n"); + return ret; + } + mutex_init(&sensor->lock); ret = ov2680_v4l2_init(sensor);