From patchwork Sun Apr 8 17:21:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 10328385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45F4060385 for ; Sun, 8 Apr 2018 17:22:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 357F0287BD for ; Sun, 8 Apr 2018 17:22:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A5A528A57; Sun, 8 Apr 2018 17:22:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1C91287BD for ; Sun, 8 Apr 2018 17:22:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752410AbeDHRWR (ORCPT ); Sun, 8 Apr 2018 13:22:17 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40115 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752396AbeDHRWR (ORCPT ); Sun, 8 Apr 2018 13:22:17 -0400 Received: by mail-pf0-f196.google.com with SMTP id y66so4321469pfi.7 for ; Sun, 08 Apr 2018 10:22:16 -0700 (PDT) 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; bh=6OYb+G8P7XoD40RdLZOCaXXCud5T+6XT+0OUpts4fqY=; b=KrzGyYqS8pL2OG71w9xMjxjSmPVXqDtYObn0AXYe03i1GIXoqF14jdGqD/mSlwTtsm OHJ+Oc3u1ErjGTpBvKENFlOkoq5cA358RsaqLKaXDKdUopy+36QspV/J5q85b7z1vJnZ Wp6bijsOYQwdGqMGqlqC82ylTtkzyLOhqvxiKNH+7WslQ4f3YKPxte/FPs4e0DS25/Ab 9xV+YJaJPGHYaYZsSLJMV35zkqsAZeJq9Djzg0+23eyiQE0LYTGb0VA15dUerdS0qMgs 7zYOM/sfJ+PXV/oCM+tTPV2QiTWwhURlrhubU+tvs2UYjL6xnHHn06RUiR3ZowiVWLE0 Buow== 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=6OYb+G8P7XoD40RdLZOCaXXCud5T+6XT+0OUpts4fqY=; b=B24zASHmhqKA1qZ7gZebGo+vSC8TRR6JWUwf1j4nQNztNsnr1SGYOn1mo9PM5VOO8b P2PC1vsfSV5z1SCYfZV0yqTL0MoD934nlvf0vvFCWAmdGNpUEEUzKeowMRCCx4uW1pz3 WaDceQp0k2P67VxE/0PziLxfWRJtOyBLQ7miY+t29+Ai0i6Zpa5+DYQT5f7R+vkTrBhn ZTH8VKIG0x6PHMKAdmflwQ3QJXKe2w8oQPIY239lDH4HYLpKiS5RhZKatmYiElsyNwO8 gNQ+EO7C029aGW3srlBffRCPPBx0QXNM8JtmPohK2yiPj0A53ogkcfX4WiQOk4P+AHwx 1cmQ== X-Gm-Message-State: AElRT7HXVRXhZ4uaE8Ybzmw30MatyXWHL6atso/MFEZG/cDVVY+IfnQ4 Z1IWbTt5Ql+ajUk6JT3FjIrzEA== X-Google-Smtp-Source: AIpwx4/hiu8pr3hL/2FUltqPL0bx8OecR9nIFnoVj7mcH40O/BnGoID08supoD8/A/6kn+I/++nvFg== X-Received: by 10.98.7.152 with SMTP id 24mr21995812pfh.94.1523208136344; Sun, 08 Apr 2018 10:22:16 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id j125sm33717026pfg.188.2018.04.08.10.22.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 10:22:15 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: mchehab@s-opensource.com, Akihiro Tsukada , crope@iki.fi Subject: [PATCH v5 1/5] dvb-frontends/dvb-pll: add i2c driver support Date: Mon, 9 Apr 2018 02:21:34 +0900 Message-Id: <20180408172138.9974-2-tskd08@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180408172138.9974-1-tskd08@gmail.com> References: <20180408172138.9974-1-tskd08@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Akihiro Tsukada registers the module as an i2c driver, but keeps dvb_pll_attach() untouched for compatibility. Signed-off-by: Akihiro Tsukada --- Changes since v4: - do not #define chip name constants Changes since v3: - use standard i2c_device_id instead of dvb_pll_config drivers/media/dvb-frontends/dvb-pll.c | 67 +++++++++++++++++++++++++++ drivers/media/dvb-frontends/dvb-pll.h | 4 ++ 2 files changed, 71 insertions(+) diff --git a/drivers/media/dvb-frontends/dvb-pll.c b/drivers/media/dvb-frontends/dvb-pll.c index 5553b89b804..ff0f477276a 100644 --- a/drivers/media/dvb-frontends/dvb-pll.c +++ b/drivers/media/dvb-frontends/dvb-pll.c @@ -827,6 +827,73 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, } EXPORT_SYMBOL(dvb_pll_attach); + +static int +dvb_pll_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct dvb_pll_config *cfg; + struct dvb_frontend *fe; + unsigned int desc_id; + + cfg = client->dev.platform_data; + fe = cfg->fe; + i2c_set_clientdata(client, fe); + desc_id = (unsigned int) id->driver_data; + + if (!dvb_pll_attach(fe, client->addr, client->adapter, desc_id)) + return -ENOMEM; + + dev_info(&client->dev, "DVB Simple Tuner attached.\n"); + return 0; +} + +static int dvb_pll_remove(struct i2c_client *client) +{ + struct dvb_frontend *fe; + + fe = i2c_get_clientdata(client); + dvb_pll_release(fe); + return 0; +} + + +static const struct i2c_device_id dvb_pll_id[] = { + {"dtt7579", DVB_PLL_THOMSON_DTT7579}, + {"dtt759x", DVB_PLL_THOMSON_DTT759X}, + {"z201", DVB_PLL_LG_Z201}, + {"unknown_1", DVB_PLL_UNKNOWN_1}, + {"tua6010xs", DVB_PLL_TUA6010XS}, + {"env57h1xd5", DVB_PLL_ENV57H1XD5}, + {"tua6034", DVB_PLL_TUA6034}, + {"tda665x", DVB_PLL_TDA665X}, + {"tded4", DVB_PLL_TDED4}, + {"tdhu2", DVB_PLL_TDHU2}, + {"tbmv", DVB_PLL_SAMSUNG_TBMV}, + {"sd1878_tda8261", DVB_PLL_PHILIPS_SD1878_TDA8261}, + {"opera1", DVB_PLL_OPERA1}, + {"dtos403ih102a", DVB_PLL_SAMSUNG_DTOS403IH102A}, + {"tdtc9251dh0", DVB_PLL_SAMSUNG_TDTC9251DH0}, + {"tbdu18132", DVB_PLL_SAMSUNG_TBDU18132}, + {"tbmu24112", DVB_PLL_SAMSUNG_TBMU24112}, + {"tdee4", DVB_PLL_TDEE4}, + {"dtt7520x", DVB_PLL_THOMSON_DTT7520X}, + {} +}; + + +MODULE_DEVICE_TABLE(i2c, dvb_pll_id); + +static struct i2c_driver dvb_pll_driver = { + .driver = { + .name = "dvb_pll", + }, + .probe = dvb_pll_probe, + .remove = dvb_pll_remove, + .id_table = dvb_pll_id, +}; + +module_i2c_driver(dvb_pll_driver); + MODULE_DESCRIPTION("dvb pll library"); MODULE_AUTHOR("Gerd Knorr"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb-frontends/dvb-pll.h b/drivers/media/dvb-frontends/dvb-pll.h index ca885e71d2f..101537ae4ef 100644 --- a/drivers/media/dvb-frontends/dvb-pll.h +++ b/drivers/media/dvb-frontends/dvb-pll.h @@ -30,6 +30,10 @@ #define DVB_PLL_TDEE4 18 #define DVB_PLL_THOMSON_DTT7520X 19 +struct dvb_pll_config { + struct dvb_frontend *fe; +}; + #if IS_REACHABLE(CONFIG_DVB_PLL) /** * Attach a dvb-pll to the supplied frontend structure.