From patchwork Wed Mar 6 11:53:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaik Ameer Basha X-Patchwork-Id: 2225101 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 62D4540077 for ; Wed, 6 Mar 2013 11:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757781Ab3CFLzJ (ORCPT ); Wed, 6 Mar 2013 06:55:09 -0500 Received: from mail-pb0-f50.google.com ([209.85.160.50]:42423 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757805Ab3CFLzI (ORCPT ); Wed, 6 Mar 2013 06:55:08 -0500 Received: by mail-pb0-f50.google.com with SMTP id up1so5923566pbc.37 for ; Wed, 06 Mar 2013 03:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=eMjs4WvDjCiVMCJWnbONyJGx+idQSul8Wg0jkQCx8Us=; b=09n29om/3XkM9CZgQfC+aDmtXPJDx6YjAKWLFLxiA0K2tzc2lOPsAmu4rhgTdRNj1E 9viV5eC6egYE6wM/t1WqhkitNc2j5u5YVIwCPOYbfK+rM2ynM5+Up5i3P1GFRwyYsJZC HtdKz4QLAXLb0QATzuuUkxnO+WXx6Vfoe+DA5RbRHUB/sNefhoh+a0I/tP7dikKjAKfE 4nw6ZYIW3FI/gcTBCMdHC+qIcOHEbQzqLZK0vaK/5g0SCFd53vJ4cdSCA9fPAhbMI/LD cCRXkz9DVk7x2i1+xafhEjs1xlm9doEVh7zBYLAN3Kx3hie4Segyho1h+KhOaNRqLs3x QahA== X-Received: by 10.68.0.170 with SMTP id 10mr45884917pbf.59.1362570907019; Wed, 06 Mar 2013 03:55:07 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id ip8sm5358307pbc.39.2013.03.06.03.55.03 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 06 Mar 2013 03:55:06 -0800 (PST) From: Shaik Ameer Basha To: linux-media@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, linux-samsung-soc@vger.kernel.org Cc: s.nawrocki@samsung.com, shaik.samsung@gmail.com Subject: [RFC 11/12] media: m5mols: Adding dt support to m5mols driver Date: Wed, 6 Mar 2013 17:23:57 +0530 Message-Id: <1362570838-4737-12-git-send-email-shaik.ameer@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1362570838-4737-1-git-send-email-shaik.ameer@samsung.com> References: <1362570838-4737-1-git-send-email-shaik.ameer@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds the dt support to m5mols driver. Signed-off-by: Shaik Ameer Basha --- drivers/media/i2c/m5mols/m5mols_core.c | 54 +++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index d4e7567..21c66ef 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -926,13 +928,38 @@ static irqreturn_t m5mols_irq_handler(int irq, void *data) return IRQ_HANDLED; } +static const struct of_device_id m5mols_match[]; + static int m5mols_probe(struct i2c_client *client, const struct i2c_device_id *id) { - const struct m5mols_platform_data *pdata = client->dev.platform_data; + struct m5mols_platform_data *pdata; struct m5mols_info *info; + const struct of_device_id *of_id; struct v4l2_subdev *sd; int ret; + struct pinctrl *pctrl; + int eint_gpio = 0; + + if (client->dev.of_node) { + of_id = of_match_node(m5mols_match, client->dev.of_node); + if (of_id) + pdata = (struct m5mols_platform_data *)of_id->data; + client->dev.platform_data = pdata; + } else { + pdata = client->dev.platform_data; + } + + if (!pdata) + return -EINVAL; + + pctrl = devm_pinctrl_get_select_default(&client->dev); + if (client->dev.of_node) { + eint_gpio = of_get_named_gpio(client->dev.of_node, "gpios", 0); + client->irq = gpio_to_irq(eint_gpio); + pdata->gpio_reset = of_get_named_gpio(client->dev.of_node, + "gpios", 1); + } if (pdata == NULL) { dev_err(&client->dev, "No platform data\n"); @@ -1040,9 +1067,34 @@ static const struct i2c_device_id m5mols_id[] = { }; MODULE_DEVICE_TABLE(i2c, m5mols_id); +static int m5mols_set_power(struct device *dev, int on) +{ + struct m5mols_platform_data *pdata = + (struct m5mols_platform_data *)dev->platform_data; + gpio_set_value(pdata->gpio_reset, !on); + gpio_set_value(pdata->gpio_reset, !!on); + return 0; +} + +static struct m5mols_platform_data m5mols_drvdata = { + .gpio_reset = 0, + .reset_polarity = 0, + .set_power = m5mols_set_power, +}; + +static const struct of_device_id m5mols_match[] = { + { + .compatible = "fujitsu,m-5mols", + .data = &m5mols_drvdata, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, m5mols_match); + static struct i2c_driver m5mols_i2c_driver = { .driver = { .name = MODULE_NAME, + .of_match_table = m5mols_match, }, .probe = m5mols_probe, .remove = m5mols_remove,