Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752646AbdDNCOc (ORCPT ); Thu, 13 Apr 2017 22:14:32 -0400 Received: from mail-co1nam03on0103.outbound.protection.outlook.com ([104.47.40.103]:62053 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751438AbdDNCO3 (ORCPT ); Thu, 13 Apr 2017 22:14:29 -0400 Authentication-Results: spf=pass (sender IP is 117.103.190.43) smtp.mailfrom=sony.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sony.com; From: To: , , CC: , , Yasunari Takiguchi , Masayuki Yamamoto , Hideki Nozawa , "Kota Yonezawa" , Toshihiko Matsumoto , Satoshi Watanabe Subject: [PATCH v2 03/15] [media] cxd2880: Add common files for the driver Date: Fri, 14 Apr 2017 11:17:01 +0900 Message-ID: <20170414021701.17133-1-Yasunari.Takiguchi@sony.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170414015043.16731-1-Yasunari.Takiguchi@sony.com> References: <20170414015043.16731-1-Yasunari.Takiguchi@sony.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [43.25.42.176] X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:117.103.190.43;IPV:NLI;CTRY:JP;EFV:NLI;SFV:NSPM;SFS:(10019020)(979002)(6009001)(39450400003)(39840400002)(39860400002)(39850400002)(39410400002)(39400400002)(2980300002)(438002)(199003)(189002)(8676002)(3846002)(6116002)(4326008)(2906002)(5660300001)(39060400002)(1076002)(50986999)(50226002)(2950100002)(305945005)(7736002)(7636002)(2876002)(6666003)(36756003)(38730400002)(107886003)(76176999)(5003940100001)(512794004)(356003)(8936002)(54906002)(5890100001)(86152003)(66066001)(106466001)(189998001)(49486002)(2201001)(86362001)(575784001)(6306002)(48376002)(50466002)(47776003)(2004002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR13MB1488;H:JPYOKXEG103.jp.sony.com;FPR:;SPF:Pass;MLV:ovrnspm;A:1;MX:1;PTR:jpyokxeg103.jp.sony.com;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT021;1:FK/ukHY9mfPVF5KrRZ11YT9mxqTgesxy8TsV/J6CAtNyx4NdHi6l0bI7DxeLZvsVcqOn09hbvjOpF+spELwR9Rde4t+5bpnIQfdFLa5Rvc8g8wF6gxrnm7ct1MHu1CRpoJB0THLdo+UPGnFwLFjoQkIk0cp+tsfbTMWMBpbVksGtvdz8hF5FMNNVHDPUsJrNjs3V5x7D2NDEgZphdUOJfkbantD2xcZ+gWfMYW/Q5BU0CY/Oq1GJSm+akIRgUOV3CGD0iMOCIBfX3XQSxfpfXFbR6FShJjZBcHqPN2gAPqA6ZTPZPwrczU/mSLz//DtpHKAlx8z+WGt/Ua9zKmZ+DG0UpWVqYv1P2hF/P53uy9LLzrEenl1e06FTIWLKhGGK5sZphE3SeRyA8LK345WGLDcBCWvC9AWt4EJc5GWcJHcKOmTSVtTkR9qwXszWia7dXpsadfIw1plgYDZy6PjlM804PsVHZUkXjzrcGDB2JoMfoan3IziBY6MCdteRmzHNLa7pEkp5ZPj8vIsSx+kUfCPHS/+utl2xxk6iVxBeFV4= X-MS-Office365-Filtering-Correlation-Id: 23a8ac77-b662-43b6-3ec1-08d482dbf973 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075);SRVR:MWHPR13MB1488; X-Microsoft-Exchange-Diagnostics: 1;MWHPR13MB1488;3:Gcllbz/orYAdusTHoK00aZ7nlnGNA/yhBFHJQIly43oRwTI3IV9pnpbI9uH3KfZFJ/n+BB1CcCctx/ZWCgsqNH4mhBOuRlNNnHT+SHmwSCb/7hkxuwxjQhOUPDEPAZaIuD5fwsvaNRGldm9ZQgeDTL0L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F01OZbFeWQhncm5kDXPoMGrEzNIcql5Ic6hW0mjwUVmgeR0YVHCnsC1QFvgJoiFEULHSqx2rUe94GQfQViETIMeg86M9Lg= X-Microsoft-Exchange-Diagnostics: 1;MWHPR13MB1488;20:ijliSebXh48RtuHuHvKJO1Uh2rP4f67TEPut+kscYQJHpTVqz1tyUzrpTnXJ76mNyjcm50F6Ps3YrfGvZxW2D/jMCGid83sdd4dwTpL82M+lIr0e0NXZKcU8xLFgSNi9sBPbC9qtOTLOXhR6Yz3dgK4VgWVvVrnGNm/8N7FQbqTYCco1+xNhV6eR7ghBOJqNVdktg8gxOt2m5SiNTivjvQIrPMJ3ntx9aK94D/NU6w3lF4QnROCWWI3xckFXmuD4pj0mQPQuYhs/B1Yugb9g/jmdt9ikIJZ+c+2Y6FSE5+OSzbMk4+9e3rJ1x/Quqyel9gIriUkvjI8hj1BodNFTUMR71WhYYCYi5LbiA2LhcD2Mur+FW5d1cfLP2qss82v+WXwrYuGThXJ2sV32rJnFg3oMgpGGhe5jglmKB4S01kfhmOx3TLSekdAQQRZ2+mmmU2/ydCa72g26/jcEy9y5Jcrg53wYAd2AniMnPnEcyb0GdQFJbiMt3Fppmjl1jIRv X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(182409339516656)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(13016025)(13018025)(13024025)(13023025)(93006095)(93004095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(6072148);SRVR:MWHPR13MB1488;BCL:0;PCL:0;RULEID:;SRVR:MWHPR13MB1488; X-Microsoft-Exchange-Diagnostics: 1;MWHPR13MB1488;4:sI+ZwpFU3VnM4tF/6rjJLDSCVoyr6a6Re5rc8LJOHSX1waOViXtXIgjzbZqa0NQCmzTQGxb32ovi8j2ShZg37sKC8jBUCAL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MKD4zt5PflGLhyEnWP6eOqG+AoU=;24:xRinOtGyfnIuGryRUHKu3XY28tm7BDK+FP7PIIKbupEph1hwi8a0d+SBuiFXKMagRcLa5W7lT9Qk3qcQi9VOq9GI1JG9JFoy+h2oBaHBz60= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR13MB1488;7:th1Cp9wPTT1LgPScTA60n4+PnGswkD3CjMyex80xqlW5KEa+UETXdsXjO5CUHTEvlsqaufD1fp9Bs1/ui5rderL4TeaRB1QgsTtQ5B+4crjYweAdqWczGhC5zMJ4RwIVCpnOL3BXB5IkHsswlz7tOtyFhSF2OV+pBEJciWkU2lVCj7YKdZAFNrcsbsklFCUeWzAA382G9d9K4m9IXAGM/P0ge7oswr5MmZMZm0diZR5ezA1WqpPfrVJIMHaHRmhHt7Sl9T0f/oUkq1JufFnNpbZz2Z1VzOAS3AUIylhnQyuqh36y1g/G22JoJFdLJivsdvGT8b1+tIV1lPC+RFgh5Q== X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2017 02:14:25.4048 (UTC) X-MS-Exchange-CrossTenant-Id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=66c65d8a-9158-4521-a2d8-664963db48e4;Ip=[117.103.190.43];Helo=[JPYOKXEG103.jp.sony.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR13MB1488 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 18735 Lines: 525 From: Yasunari Takiguchi These are common files for the driver for the Sony CXD2880 DVB-T2/T tuner + demodulator. These contains helper functions for the driver. Signed-off-by: Yasunari Takiguchi Signed-off-by: Masayuki Yamamoto Signed-off-by: Hideki Nozawa Signed-off-by: Kota Yonezawa Signed-off-by: Toshihiko Matsumoto Signed-off-by: Satoshi Watanabe --- drivers/media/dvb-frontends/cxd2880/cxd2880.h | 46 ++++++++++++ .../media/dvb-frontends/cxd2880/cxd2880_common.c | 84 +++++++++++++++++++++ .../media/dvb-frontends/cxd2880/cxd2880_common.h | 86 ++++++++++++++++++++++ drivers/media/dvb-frontends/cxd2880/cxd2880_io.c | 68 +++++++++++++++++ drivers/media/dvb-frontends/cxd2880/cxd2880_io.h | 62 ++++++++++++++++ .../media/dvb-frontends/cxd2880/cxd2880_stdlib.h | 35 +++++++++ .../dvb-frontends/cxd2880/cxd2880_stopwatch_port.c | 71 ++++++++++++++++++ 7 files changed, 452 insertions(+) create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880.h create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_common.c create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_common.h create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_io.c create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_io.h create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880.h b/drivers/media/dvb-frontends/cxd2880/cxd2880.h new file mode 100644 index 000000000000..281f9a784eb5 --- /dev/null +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880.h @@ -0,0 +1,46 @@ +/* + * cxd2880.h + * Sony CXD2880 DVB-T2/T tuner + demodulator driver public definitions + * + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef CXD2880_H +#define CXD2880_H + +struct cxd2880_config { + struct spi_device *spi; + struct mutex *spi_mutex; /* For SPI access exclusive control */ +}; + +#if IS_REACHABLE(CONFIG_DVB_CXD2880) +extern struct dvb_frontend *cxd2880_attach(struct dvb_frontend *fe, + struct cxd2880_config *cfg); +#else +static inline struct dvb_frontend *cxd2880_attach(struct dvb_frontend *fe, + struct cxd2880_config *cfg) +{ + pr_warn("%s: driver disabled by Kconfig\n", __func__); + return NULL; +} +#endif /* CONFIG_DVB_CXD2880 */ + +#endif /* CXD2880_H */ diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c new file mode 100644 index 000000000000..850f3a76b2c7 --- /dev/null +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c @@ -0,0 +1,84 @@ +/* + * cxd2880_common.c + * Sony CXD2880 DVB-T2/T tuner + demodulator driver + * common functions + * + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "cxd2880_common.h" + +#define MASKUPPER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU << (32 - (n)))) +#define MASKLOWER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU >> (32 - (n)))) + +int cxd2880_convert2s_complement(u32 value, u32 bitlen) +{ + if ((bitlen == 0) || (bitlen >= 32)) + return (int)value; + + if (value & (u32)(1 << (bitlen - 1))) + return (int)(MASKUPPER(32 - bitlen) | value); + else + return (int)(MASKLOWER(bitlen) & value); +} + +u32 cxd2880_bit_split_from_byte_array(u8 *array, u32 start_bit, u32 bit_num) +{ + u32 value = 0; + u8 *array_read; + u8 bit_read; + u32 len_remain; + + if (!array) + return 0; + if ((bit_num == 0) || (bit_num > 32)) + return 0; + + array_read = array + (start_bit / 8); + bit_read = (u8)(start_bit % 8); + len_remain = bit_num; + + if (bit_read != 0) { + if (((int)len_remain) <= 8 - bit_read) { + value = (*array_read) >> ((8 - bit_read) - len_remain); + len_remain = 0; + } else { + value = *array_read++; + len_remain -= 8 - bit_read; + } + } + + while (len_remain > 0) { + if (len_remain < 8) { + value <<= len_remain; + value |= (*array_read++ >> (8 - len_remain)); + len_remain = 0; + } else { + value <<= 8; + value |= (u32)(*array_read++); + len_remain -= 8; + } + } + + value &= MASKLOWER(bit_num); + + return value; +} diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_common.h b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.h new file mode 100644 index 000000000000..b1ecb44bca10 --- /dev/null +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.h @@ -0,0 +1,86 @@ +/* + * cxd2880_common.h + * Sony CXD2880 DVB-T2/T tuner + demodulator driver common definitions + * + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef CXD2880_COMMON_H +#define CXD2880_COMMON_H + +#include + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#include +#define CXD2880_SLEEP(n) msleep(n) +#ifndef CXD2880_SLEEP_IN_MON +#define CXD2880_SLEEP_IN_MON(n, obj) CXD2880_SLEEP(n) +#endif + +#define CXD2880_ARG_UNUSED(arg) ((void)(arg)) + +enum cxd2880_ret { + CXD2880_RESULT_OK, + CXD2880_RESULT_ERROR_ARG, + CXD2880_RESULT_ERROR_IO, + CXD2880_RESULT_ERROR_SW_STATE, + CXD2880_RESULT_ERROR_HW_STATE, + CXD2880_RESULT_ERROR_TIMEOUT, + CXD2880_RESULT_ERROR_UNLOCK, + CXD2880_RESULT_ERROR_RANGE, + CXD2880_RESULT_ERROR_NOSUPPORT, + CXD2880_RESULT_ERROR_CANCEL, + CXD2880_RESULT_ERROR_OTHER, + CXD2880_RESULT_ERROR_OVERFLOW, + CXD2880_RESULT_OK_CONFIRM +}; + +int cxd2880_convert2s_complement(u32 value, u32 bitlen); + +u32 cxd2880_bit_split_from_byte_array(u8 *array, u32 start_bit, u32 bit_num); + +struct cxd2880_atomic { + int counter; +}; + +#define cxd2880_atomic_set(a, i) ((a)->counter = i) +#define cxd2880_atomic_read(a) ((a)->counter) + +struct cxd2880_stopwatch { + u32 start_time; +}; + +enum cxd2880_ret cxd2880_stopwatch_start(struct cxd2880_stopwatch *stopwatch); + +enum cxd2880_ret cxd2880_stopwatch_sleep(struct cxd2880_stopwatch *stopwatch, + u32 ms); + +enum cxd2880_ret cxd2880_stopwatch_elapsed(struct cxd2880_stopwatch *stopwatch, + u32 *elapsed); + +#endif diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_io.c b/drivers/media/dvb-frontends/cxd2880/cxd2880_io.c new file mode 100644 index 000000000000..f0f82055a953 --- /dev/null +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_io.c @@ -0,0 +1,68 @@ +/* + * cxd2880_io.c + * Sony CXD2880 DVB-T2/T tuner + demodulator driver + * register I/O interface functions + * + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "cxd2880_io.h" + +enum cxd2880_ret cxd2880_io_common_write_one_reg(struct cxd2880_io *io, + enum cxd2880_io_tgt tgt, + u8 sub_address, u8 data) +{ + enum cxd2880_ret ret = CXD2880_RESULT_OK; + + if (!io) + return CXD2880_RESULT_ERROR_ARG; + + ret = io->write_regs(io, tgt, sub_address, &data, 1); + + return ret; +} + +enum cxd2880_ret cxd2880_io_set_reg_bits(struct cxd2880_io *io, + enum cxd2880_io_tgt tgt, + u8 sub_address, u8 data, u8 mask) +{ + enum cxd2880_ret ret = CXD2880_RESULT_OK; + + if (!io) + return CXD2880_RESULT_ERROR_ARG; + + if (mask == 0x00) + return CXD2880_RESULT_OK; + + if (mask != 0xFF) { + u8 rdata = 0x00; + + ret = io->read_regs(io, tgt, sub_address, &rdata, 1); + if (ret != CXD2880_RESULT_OK) + return ret; + + data = (u8)((data & mask) | (rdata & (mask ^ 0xFF))); + } + + ret = io->write_reg(io, tgt, sub_address, data); + + return ret; +} diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_io.h b/drivers/media/dvb-frontends/cxd2880/cxd2880_io.h new file mode 100644 index 000000000000..4d6db13cf910 --- /dev/null +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_io.h @@ -0,0 +1,62 @@ +/* + * cxd2880_io.h + * Sony CXD2880 DVB-T2/T tuner + demodulator driver + * register I/O interface definitions + * + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef CXD2880_IO_H +#define CXD2880_IO_H + +#include "cxd2880_common.h" + +enum cxd2880_io_tgt { + CXD2880_IO_TGT_SYS, + CXD2880_IO_TGT_DMD +}; + +struct cxd2880_io { + enum cxd2880_ret (*read_regs)(struct cxd2880_io *io, + enum cxd2880_io_tgt tgt, u8 sub_address, + u8 *data, u32 size); + enum cxd2880_ret (*write_regs)(struct cxd2880_io *io, + enum cxd2880_io_tgt tgt, u8 sub_address, + const u8 *data, u32 size); + enum cxd2880_ret (*write_reg)(struct cxd2880_io *io, + enum cxd2880_io_tgt tgt, u8 sub_address, + u8 data); + void *if_object; + u8 i2c_address_sys; + u8 i2c_address_demod; + u8 slave_select; + void *user; +}; + +enum cxd2880_ret cxd2880_io_common_write_one_reg(struct cxd2880_io *io, + enum cxd2880_io_tgt tgt, + u8 sub_address, u8 data); + +enum cxd2880_ret cxd2880_io_set_reg_bits(struct cxd2880_io *io, + enum cxd2880_io_tgt tgt, + u8 sub_address, u8 data, u8 mask); + +#endif diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h b/drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h new file mode 100644 index 000000000000..b9ca1b9df110 --- /dev/null +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h @@ -0,0 +1,35 @@ +/* + * cxd2880_stdlib.h + * Sony CXD2880 DVB-T2/T tuner + demodulator driver + * standard lib function aliases + * + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef CXD2880_STDLIB_H +#define CXD2880_STDLIB_H + +#include + +#define cxd2880_memcpy memcpy +#define cxd2880_memset memset + +#endif diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c b/drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c new file mode 100644 index 000000000000..14ad6aa6c4c0 --- /dev/null +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c @@ -0,0 +1,71 @@ +/* + * cxd2880_stopwatch_port.c + * Sony CXD2880 DVB-T2/T tuner + demodulator driver + * time measurement functions + * + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "cxd2880_common.h" + +#include +#include +#include + +static u32 get_time_count(void) +{ + struct timespec tp; + + getnstimeofday(&tp); + + return (u32)((tp.tv_sec * 1000) + (tp.tv_nsec / 1000000)); +} + +enum cxd2880_ret cxd2880_stopwatch_start(struct cxd2880_stopwatch *stopwatch) +{ + if (!stopwatch) + return CXD2880_RESULT_ERROR_ARG; + + stopwatch->start_time = get_time_count(); + + return CXD2880_RESULT_OK; +} + +enum cxd2880_ret cxd2880_stopwatch_sleep(struct cxd2880_stopwatch *stopwatch, + u32 ms) +{ + if (!stopwatch) + return CXD2880_RESULT_ERROR_ARG; + CXD2880_ARG_UNUSED(*stopwatch); + CXD2880_SLEEP(ms); + + return CXD2880_RESULT_OK; +} + +enum cxd2880_ret cxd2880_stopwatch_elapsed(struct cxd2880_stopwatch *stopwatch, + u32 *elapsed) +{ + if (!stopwatch || !elapsed) + return CXD2880_RESULT_ERROR_ARG; + *elapsed = get_time_count() - stopwatch->start_time; + + return CXD2880_RESULT_OK; +} -- 2.11.0