From patchwork Tue May 15 02:05:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Katsuhiro Suzuki X-Patchwork-Id: 135804 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp374509lji; Mon, 14 May 2018 19:05:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrdh7USLLhIZ1HUTFOxdG0iBwqasCnhTabvQfUXmv5ygEw1nXY2V1ZPkWJZHRwTJhmh0rlg X-Received: by 2002:a17:902:680c:: with SMTP id h12-v6mr12527580plk.113.1526349936893; Mon, 14 May 2018 19:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526349936; cv=none; d=google.com; s=arc-20160816; b=zUIkZOHtDFa7/yQI2eUUTwK74teHsUabPo0w4iDPKHfroehY78YyoDb8eeccm9fIyG VBZz6mQH2DEJitwEAPWT2IRnrQGMspyW4W1ponzxLP2c5ppsYv6pMcehpb8ELB1mBA5L 6ZcbrtjOlLiPqbjXyaLLafCNjsaMh+6djywogGQ+Nh8aSu84GuMpewm0wPDWbSM8uf0P QVJ+yytEgIbJQPXWsQKDAFh0glitjHPtyC7OTJ766FBmYtfFxI7UqAvm1XhcH89ngVPs WN/87COQLWgxIKYiLOox0mNwq2P0mvDNIbuPsK6HohwRAK3PxWGzdJTAQQlA8xxosl6r ws6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NaBdpNsC9FoRzB1HsVbFAhSQGQMk/pZjU92ttAWO5Bs=; b=Ch/aU0y8GG4bq8WvAx7I1ACHw9HEyKpLn5AGvINpQ74ewWVbk7qn5wOxsPrLOlO3FT Bhcs2v1YIsQDjaMEY4fmA+joKPknOkqoSU4v/MsunuwT/6UqhBhoRJJEmvNy7iUztetm RL60MvrTnhpF0oFCDBRAKcpMkz9wi/K3oUThQ3iP5lVvXedxq0JcwZ1HkllWP/6vhyeD FDgoWQtg+jqYkkLIjg9NNSkNeCGjTQyum6ShFTvfg4i+fv0YwvSidRco4xhJJMxtc4Aw WRsxWwszH7w7f20mm/P7C3Tx6SMlLSlLbE2wxltUyi3APuXc+zwVo0aq9pjAO1OEhJ8L jlxA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si10537640plb.77.2018.05.14.19.05.36; Mon, 14 May 2018 19:05:36 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752489AbeEOCFe (ORCPT + 29 others); Mon, 14 May 2018 22:05:34 -0400 Received: from mx.socionext.com ([202.248.49.38]:43662 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222AbeEOCFc (ORCPT ); Mon, 14 May 2018 22:05:32 -0400 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 15 May 2018 11:05:31 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 574D21800ED; Tue, 15 May 2018 11:05:31 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Tue, 15 May 2018 11:05:31 +0900 Received: from yuzu.css.socionext.com (yuzu [172.31.8.45]) by kinkan.css.socionext.com (Postfix) with ESMTP id 2FFC91A01CB; Tue, 15 May 2018 11:05:31 +0900 (JST) Received: from aegis.e01.socionext.com (unknown [10.213.134.210]) by yuzu.css.socionext.com (Postfix) with ESMTP id EF397120437; Tue, 15 May 2018 11:05:30 +0900 (JST) From: Katsuhiro Suzuki To: Abylay Ospan , Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: Masami Hiramatsu , Jassi Brar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Katsuhiro Suzuki Subject: [PATCH] media: helene: add I2C device probe function Date: Tue, 15 May 2018 11:05:20 +0900 Message-Id: <20180515020520.31676-1-suzuki.katsuhiro@socionext.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds I2C probe function to use dvb_module_probe() with this driver. Signed-off-by: Katsuhiro Suzuki --- drivers/media/dvb-frontends/helene.c | 88 ++++++++++++++++++++++++++-- drivers/media/dvb-frontends/helene.h | 2 + 2 files changed, 86 insertions(+), 4 deletions(-) -- 2.17.0 diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c index a0d0b53c91d7..04033f0c278b 100644 --- a/drivers/media/dvb-frontends/helene.c +++ b/drivers/media/dvb-frontends/helene.c @@ -666,7 +666,7 @@ static int helene_set_params_s(struct dvb_frontend *fe) return 0; } -static int helene_set_params(struct dvb_frontend *fe) +static int helene_set_params_t(struct dvb_frontend *fe) { u8 data[MAX_WRITE_REGSIZE]; u32 frequency; @@ -835,6 +835,19 @@ static int helene_set_params(struct dvb_frontend *fe) return 0; } +static int helene_set_params(struct dvb_frontend *fe) +{ + struct dtv_frontend_properties *p = &fe->dtv_property_cache; + + if (p->delivery_system == SYS_DVBT || + p->delivery_system == SYS_DVBT2 || + p->delivery_system == SYS_ISDBT || + p->delivery_system == SYS_DVBC_ANNEX_A) + return helene_set_params_t(fe); + + return helene_set_params_s(fe); +} + static int helene_get_frequency(struct dvb_frontend *fe, u32 *frequency) { struct helene_priv *priv = fe->tuner_priv; @@ -843,7 +856,7 @@ static int helene_get_frequency(struct dvb_frontend *fe, u32 *frequency) return 0; } -static const struct dvb_tuner_ops helene_tuner_ops = { +static const struct dvb_tuner_ops helene_tuner_ops_t = { .info = { .name = "Sony HELENE Ter tuner", .frequency_min = 1000000, @@ -853,7 +866,7 @@ static const struct dvb_tuner_ops helene_tuner_ops = { .init = helene_init, .release = helene_release, .sleep = helene_sleep, - .set_params = helene_set_params, + .set_params = helene_set_params_t, .get_frequency = helene_get_frequency, }; @@ -871,6 +884,20 @@ static const struct dvb_tuner_ops helene_tuner_ops_s = { .get_frequency = helene_get_frequency, }; +static const struct dvb_tuner_ops helene_tuner_ops = { + .info = { + .name = "Sony HELENE Sat/Ter tuner", + .frequency_min = 500000, + .frequency_max = 1200000000, + .frequency_step = 1000, + }, + .init = helene_init, + .release = helene_release, + .sleep = helene_sleep, + .set_params = helene_set_params, + .get_frequency = helene_get_frequency, +}; + /* power-on tuner * call once after reset */ @@ -1032,7 +1059,7 @@ struct dvb_frontend *helene_attach(struct dvb_frontend *fe, if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); - memcpy(&fe->ops.tuner_ops, &helene_tuner_ops, + memcpy(&fe->ops.tuner_ops, &helene_tuner_ops_t, sizeof(struct dvb_tuner_ops)); fe->tuner_priv = priv; dev_info(&priv->i2c->dev, @@ -1042,6 +1069,59 @@ struct dvb_frontend *helene_attach(struct dvb_frontend *fe, } EXPORT_SYMBOL(helene_attach); +static int helene_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct helene_config *config = client->dev.platform_data; + struct dvb_frontend *fe = config->fe; + struct device *dev = &client->dev; + struct helene_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->i2c_address = client->addr; + priv->i2c = client->adapter; + priv->set_tuner_data = config->set_tuner_priv; + priv->set_tuner = config->set_tuner_callback; + priv->xtal = config->xtal; + + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); + + if (helene_x_pon(priv) != 0) + return -EINVAL; + + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); + + memcpy(&fe->ops.tuner_ops, &helene_tuner_ops, + sizeof(struct dvb_tuner_ops)); + fe->tuner_priv = priv; + i2c_set_clientdata(client, priv); + + dev_info(dev, "Sony HELENE attached on addr=%x at I2C adapter %p\n", + priv->i2c_address, priv->i2c); + + return 0; +} + +static const struct i2c_device_id helene_id[] = { + { "helene", }, + {} +}; +MODULE_DEVICE_TABLE(i2c, helene_id); + +static struct i2c_driver helene_driver = { + .driver = { + .name = "helene", + }, + .probe = helene_probe, + .id_table = helene_id, +}; +module_i2c_driver(helene_driver); + MODULE_DESCRIPTION("Sony HELENE Sat/Ter tuner driver"); MODULE_AUTHOR("Abylay Ospan "); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb-frontends/helene.h b/drivers/media/dvb-frontends/helene.h index c9fc81c7e4e7..ceaa283708cb 100644 --- a/drivers/media/dvb-frontends/helene.h +++ b/drivers/media/dvb-frontends/helene.h @@ -46,6 +46,8 @@ struct helene_config { void *set_tuner_priv; int (*set_tuner_callback)(void *, int); enum helene_xtal xtal; + + struct dvb_frontend *fe; }; #if IS_REACHABLE(CONFIG_DVB_HELENE)