Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9627393imu; Wed, 5 Dec 2018 07:50:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/VPVRHFZf7Tg5KWqJ2BSpVu4eh7/GVctRPtk4kdXIasBp7uNZbXDbXFTbp8LZIXukUx9P4H X-Received: by 2002:a65:560e:: with SMTP id l14mr20972144pgs.168.1544025003142; Wed, 05 Dec 2018 07:50:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544025003; cv=none; d=google.com; s=arc-20160816; b=jUzHQH38TbZx2InOBnquw6eMllEltwJdEV+vvVRQYS1oNb2wGQsgiiA2XVGiPVOI+I ziV0G1Wnm6To7sW7zPh0Ve6XQvVJpUAefQUAdoaJFIUxF9qe7DZvuBhqD+1KOXDA0tcT 2xrUv6NSRN2ZlRyOsFKadvyfKaBpgSDSLh1Ox6cEO32rV8S0PxVYhsfa9Pox8qmA9DfD jp4Dgs0ClR55XPI7Lp/WtHgG21TiHQtB7jC/ajYRpUDkTH/SIO2uTdX4l9/n5+ajrwuq 9IQOU7xiZNwLSvrnS+bVSLPsYrTuZ2dZ9cVbVzB3VgQlDdkOwY+AXoxV3+tSCpT4v9QC Utkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MgD/GG9O1K1FRD9ALik5jgeXm7lZuOo80znVVMI+qnU=; b=ueapD6q7sIE4JBYidl1D7Fa2poT5U+hQjhJPP4sHkqBru/nJkO+104RWxTDLcMc5CQ eW1JqXJn3fLko09TTt16En+N9xQ4OKJWkbO2lu/PK3sPURcCp/hNj8KkT3bRctszoLjy BIpxCvnlmuIpaac0VaBzvmUn5WKBhCvCPcXK0iVa/iAne7vvmZN7DI+iWFRJHXk5Lyay 8D5xFCb/y2sT9CV/5fmNDt7rhgk9RnimYSO3doYnpjWBr2mYiOI+TFSXUifG80CDo/rU KZRzawpnfVhwEQifZd5hkHvjXZD2xDd5wTlfJU7ZYkgGg6zd+E1aPmRQNA/buL2SlLEX 9Rzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aQDV+lJI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r81si23196725pfr.164.2018.12.05.07.49.48; Wed, 05 Dec 2018 07:50:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aQDV+lJI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728169AbeLEPtB (ORCPT + 99 others); Wed, 5 Dec 2018 10:49:01 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36561 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728051AbeLEPs6 (ORCPT ); Wed, 5 Dec 2018 10:48:58 -0500 Received: by mail-lf1-f68.google.com with SMTP id a16so15092205lfg.3; Wed, 05 Dec 2018 07:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MgD/GG9O1K1FRD9ALik5jgeXm7lZuOo80znVVMI+qnU=; b=aQDV+lJIgY/8SNhwMCQemfFnuO+lF29H+g23P9xVbo9uzCUi9cuEB1bEh29VYxuiul oich56jnVKd1fO02DmNFFlR+qQOLgXc3jzNAyqQqpibCd/gdsl8o4yYIv/yWo6hLJvTY OUbnkw9tVbSUramjMVmqvrxYEEMA9gOHHIMK3CzZv1ciUuSRMLZzINdVnJRbXETC+rze UfA5s68SUm+6q2uhanIPVPBXUU1w9P1WN6JpzmT4Gt1/AsZ3KLTwXXipmLytOwKR7HUi wYMlv8QLEDwpjkdI1eqLq1zCXM9NIijIJ7CWI/pT3ORjZ8yjRtCTlnjhqg63Lh48S/0x TLqg== 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:mime-version:content-transfer-encoding; bh=MgD/GG9O1K1FRD9ALik5jgeXm7lZuOo80znVVMI+qnU=; b=fK2vnJHCs94Hl9raRO9tBgIahA2REsQXq4faeW7WS4QRHYrxDbY8qmtdYMfxkmwZ+J 3Bc1snQhI3nWKEvwqx7GBD0b79WfnvCNDVC7C04US41udpSaFFAkEUk8uFtogWvHatG2 JLcCjb1RLCmKZzisU695KWgL+rwoGP+FgaBGPi6Fp+72jDEuNlHG4rSp4zqyUrl/9fVm 42IXe5cA+1Y7gmGQeLpxNECBThR28mZ2uwbSpoCZygXXqqaRvsENE1Nnehdi/zLnoSzK H6jyT5X2qMb3NiNAIXgv82/sCZDsxjWayij3qM/A7iZfcsXUu0H2lZhoormR8la1htIq eU4A== X-Gm-Message-State: AA+aEWbWkzfS19zIweJ03cwWaoRog/hXBnyY/oF2jfMHfTi0hC9ILNbH 3egNcZqZPVWWt/cSzX6XNsk= X-Received: by 2002:a19:41c4:: with SMTP id o187mr15409826lfa.32.1544024935664; Wed, 05 Dec 2018 07:48:55 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:41e8:260c:942a:b736]) by smtp.googlemail.com with ESMTPSA id t18sm3592517lft.93.2018.12.05.07.48.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 07:48:55 -0800 (PST) From: =?UTF-8?q?Pawe=C5=82=20Chmiel?= To: mchehab@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: hverkuil@xs4all.nl, fischerdouglasc@gmail.com, keescook@chromium.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, =?UTF-8?q?Pawe=C5=82=20Chmiel?= Subject: [PATCH 4/5] si470x-i2c: Add optional reset-gpio support Date: Wed, 5 Dec 2018 16:47:49 +0100 Message-Id: <20181205154750.17996-5-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181205154750.17996-1-pawel.mikolaj.chmiel@gmail.com> References: <20181205154750.17996-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If reset-gpio is defined, use it to bring device out of reset. Without this, it's not possible to access si470x registers. Signed-off-by: Paweł Chmiel --- drivers/media/radio/si470x/radio-si470x-i2c.c | 15 +++++++++++++++ drivers/media/radio/si470x/radio-si470x.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c index a7ac09c55188..15eea2b2c90f 100644 --- a/drivers/media/radio/si470x/radio-si470x-i2c.c +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "radio-si470x.h" @@ -392,6 +393,17 @@ static int si470x_i2c_probe(struct i2c_client *client, radio->videodev.release = video_device_release_empty; video_set_drvdata(&radio->videodev, radio); + radio->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(radio->gpio_reset)) { + retval = PTR_ERR(radio->gpio_reset); + dev_err(&client->dev, "Failed to request gpio: %d\n", retval); + goto err_all; + } + + if (radio->gpio_reset) + gpiod_set_value(radio->gpio_reset, 1); + /* power up : need 110ms */ radio->registers[POWERCFG] = POWERCFG_ENABLE; if (si470x_set_register(radio, POWERCFG) < 0) { @@ -478,6 +490,9 @@ static int si470x_i2c_remove(struct i2c_client *client) video_unregister_device(&radio->videodev); + if (radio->gpio_reset) + gpiod_set_value(radio->gpio_reset, 0); + return 0; } diff --git a/drivers/media/radio/si470x/radio-si470x.h b/drivers/media/radio/si470x/radio-si470x.h index 35fa0f3bbdd2..6fd6a399cb77 100644 --- a/drivers/media/radio/si470x/radio-si470x.h +++ b/drivers/media/radio/si470x/radio-si470x.h @@ -189,6 +189,7 @@ struct si470x_device { #if IS_ENABLED(CONFIG_I2C_SI470X) struct i2c_client *client; + struct gpio_desc *gpio_reset; #endif }; -- 2.17.1