From patchwork Wed Jun 24 15:11:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 50281 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14EA4228FC for ; Wed, 24 Jun 2015 15:13:21 +0000 (UTC) Received: by lbcui10 with SMTP id ui10sf11705770lbc.0 for ; Wed, 24 Jun 2015 08:13:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=s5offiD3g0znSnHOAOygA2UCAdtMCZzVIn/TiYA25TE=; b=Sqgl72aoaTrqXM4uA/deA6SCxgrcg0Hp4RKREYsqTR98zKg3m62onGEEK97pgOG/nR 3Mxu94MRg1qP4XwOOMgygxOBwwO1eq1zPK229qYB3G+6GFPuvRKJ8IQ8lkenkzk/N91v SFy8jb9QuAhxv/mLCk+f8nQjq8yOls/fl7vRLLaymVnvilfFx7+mhmseo01vV5c+Qo6U 5Oh/iVS+5G1YjbxbmaTs59bn1XByyOpJ4BtMves0XWUv7hIlarmvMCo2lw9Zvrag0kR4 QxoCr/57AtA3BkGdvDrcXBO4JQ6Rh+x+y/+reYuJRBRGWBTt41CYyMJxsmB0a6sKVqy8 P7wA== X-Gm-Message-State: ALoCoQkeiU13bDD/Q2db+jiozPbSY+ZIlb5NjBC6GoDj4iCBkH6JM4HHX3FGUc2R1VfxRqjpIq8E X-Received: by 10.112.255.66 with SMTP id ao2mr30280561lbd.15.1435158800092; Wed, 24 Jun 2015 08:13:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.73 with SMTP id y9ls187525lay.18.gmail; Wed, 24 Jun 2015 08:13:19 -0700 (PDT) X-Received: by 10.152.6.132 with SMTP id b4mr38290793laa.53.1435158799945; Wed, 24 Jun 2015 08:13:19 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id b10si4308141laf.38.2015.06.24.08.13.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2015 08:13:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbwc1 with SMTP id wc1so28365630lbb.2 for ; Wed, 24 Jun 2015 08:13:19 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr40003497lag.112.1435158799847; Wed, 24 Jun 2015 08:13:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3857151lbb; Wed, 24 Jun 2015 08:13:18 -0700 (PDT) X-Received: by 10.68.65.6 with SMTP id t6mr11824758pbs.94.1435158794239; Wed, 24 Jun 2015 08:13:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si14735614pas.189.2015.06.24.08.13.13; Wed, 24 Jun 2015 08:13:14 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753553AbbFXPMI (ORCPT + 8 others); Wed, 24 Jun 2015 11:12:08 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:38368 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752941AbbFXPLb (ORCPT ); Wed, 24 Jun 2015 11:11:31 -0400 Received: by wibdq8 with SMTP id dq8so49718589wib.1 for ; Wed, 24 Jun 2015 08:11:30 -0700 (PDT) X-Received: by 10.180.14.193 with SMTP id r1mr5734116wic.47.1435158690249; Wed, 24 Jun 2015 08:11:30 -0700 (PDT) Received: from localhost.localdomain (cpc14-aztw22-2-0-cust189.18-1.cable.virginm.net. [82.45.1.190]) by mx.google.com with ESMTPSA id ju2sm3018019wid.12.2015.06.24.08.11.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Jun 2015 08:11:29 -0700 (PDT) From: Peter Griffin To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, srinivas.kandagatla@gmail.com, maxime.coquelin@st.com, patrice.chotard@st.com, mchehab@osg.samsung.com Cc: peter.griffin@linaro.org, lee.jones@linaro.org, hugues.fruchet@st.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 02/12] [media] dvb-pll: Add support for THOMSON DTT7546X tuner. Date: Wed, 24 Jun 2015 16:11:00 +0100 Message-Id: <1435158670-7195-3-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435158670-7195-1-git-send-email-peter.griffin@linaro.org> References: <1435158670-7195-1-git-send-email-peter.griffin@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.griffin@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This is used in conjunction with the STV0367 demodulator on the STV0367-NIM-V1.0 NIM card which can be used with the STi STB SoC's. This tuner has a fifth register, so some changes have been made to accommodate this. Signed-off-by: Peter Griffin --- drivers/media/dvb-frontends/dvb-pll.c | 74 +++++++++++++++++++++++++++++------ drivers/media/dvb-frontends/dvb-pll.h | 1 + 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/drivers/media/dvb-frontends/dvb-pll.c b/drivers/media/dvb-frontends/dvb-pll.c index 6d8fe88..f7381c7 100644 --- a/drivers/media/dvb-frontends/dvb-pll.c +++ b/drivers/media/dvb-frontends/dvb-pll.c @@ -141,6 +141,35 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = { }, }; +static void thomson_dtt7546x_bw(struct dvb_frontend *fe, u8 *buf) +{ + /* set CB2 reg - set ATC, XTO */ + buf[4] = 0xc3; +} + +static struct dvb_pll_desc dvb_pll_thomson_dtt7546x = { + .name = "Thomson dtt7546x", + .min = 44250000, + .max = 863250000, + .set = thomson_dtt7546x_bw, + .iffreq= 36166667, + .count = 12, + .entries = { + { 121000000, 166667, 0x88, 0x01 }, + { 141000000, 166667, 0x88, 0x41 }, + { 166000000, 166667, 0x88, 0x81 }, + { 182000000, 166667, 0x88, 0xc1 }, + { 286000000, 166667, 0x88, 0x02 }, + { 386000000, 166667, 0x88, 0x42 }, + { 446000000, 166667, 0x88, 0x82 }, + { 466000000, 166667, 0x88, 0xc2 }, + { 506000000, 166667, 0x88, 0x08 }, + { 761000000, 166667, 0x88, 0x48 }, + { 846000000, 166667, 0x88, 0x88 }, + { 905000000, 166667, 0x88, 0xc8 }, + }, +}; + static struct dvb_pll_desc dvb_pll_lg_z201 = { .name = "LG z201", .min = 174000000, @@ -537,6 +566,7 @@ static struct dvb_pll_desc dvb_pll_alps_tdee4 = { static struct dvb_pll_desc *pll_list[] = { [DVB_PLL_UNDEFINED] = NULL, [DVB_PLL_THOMSON_DTT7579] = &dvb_pll_thomson_dtt7579, + [DVB_PLL_THOMSON_DTT7546X] = &dvb_pll_thomson_dtt7546x, [DVB_PLL_THOMSON_DTT759X] = &dvb_pll_thomson_dtt759x, [DVB_PLL_THOMSON_DTT7520X] = &dvb_pll_thomson_dtt7520x, [DVB_PLL_LG_Z201] = &dvb_pll_lg_z201, @@ -561,7 +591,7 @@ static struct dvb_pll_desc *pll_list[] = { /* code */ static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf, - const u32 frequency) + const u32 frequency, const u32 len) { struct dvb_pll_priv *priv = fe->tuner_priv; struct dvb_pll_desc *desc = priv->pll_desc; @@ -593,11 +623,15 @@ static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf, if (desc->set) desc->set(fe, buf); - if (debug) - printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", - desc->name, div, buf[0], buf[1], buf[2], buf[3]); + if (debug) { + printk(KERN_DEBUG "pll: %s: div=%d | buf=", desc->name, div); + for (i = 0; i < len; i++) + printk(KERN_DEBUG "0x%02x,", buf[i]); - // calculate the frequency we set it to + printk(KERN_DEBUG "\n"); + } + + /* calculate the frequency we set it to */ return (div * desc->entries[i].stepsize) - desc->iffreq; } @@ -634,21 +668,39 @@ static int dvb_pll_sleep(struct dvb_frontend *fe) return -EINVAL; } +static int dvb_pll_get_num_regs(struct dvb_pll_priv *priv) +{ + int num_regs = 4; + + if (strncmp(priv->pll_desc->name, "Thomson dtt7546x", 16) == 0) + num_regs = 5; + + return num_regs; +} + static int dvb_pll_set_params(struct dvb_frontend *fe) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dvb_pll_priv *priv = fe->tuner_priv; - u8 buf[4]; - struct i2c_msg msg = - { .addr = priv->pll_i2c_address, .flags = 0, - .buf = buf, .len = sizeof(buf) }; + struct i2c_msg msg; + u8 *bufp; int result; u32 frequency = 0; + bufp = kzalloc(dvb_pll_get_num_regs(priv), GFP_KERNEL); + + if (!bufp) + return -ENOMEM; + + msg.addr = priv->pll_i2c_address; + msg.flags = 0; + msg.buf = bufp; + msg.len = dvb_pll_get_num_regs(priv); + if (priv->i2c == NULL) return -EINVAL; - result = dvb_pll_configure(fe, buf, c->frequency); + result = dvb_pll_configure(fe, bufp, c->frequency, msg.len); if (result < 0) return result; else @@ -677,7 +729,7 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, if (buf_len < 5) return -EINVAL; - result = dvb_pll_configure(fe, buf + 1, c->frequency); + result = dvb_pll_configure(fe, buf + 1, c->frequency, buf_len - 1); if (result < 0) return result; else diff --git a/drivers/media/dvb-frontends/dvb-pll.h b/drivers/media/dvb-frontends/dvb-pll.h index bf9602a..f523f42 100644 --- a/drivers/media/dvb-frontends/dvb-pll.h +++ b/drivers/media/dvb-frontends/dvb-pll.h @@ -28,6 +28,7 @@ #define DVB_PLL_SAMSUNG_TBMU24112 17 #define DVB_PLL_TDEE4 18 #define DVB_PLL_THOMSON_DTT7520X 19 +#define DVB_PLL_THOMSON_DTT7546X 20 /** * Attach a dvb-pll to the supplied frontend structure.