root/drivers/media/dvb-frontends/cxd2880/cxd2880_io.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. cxd2880_io_common_write_one_reg
  2. cxd2880_io_set_reg_bits
  3. cxd2880_io_write_multi_regs

   1 // SPDX-License-Identifier: GPL-2.0
   2 /*
   3  * cxd2880_io.c
   4  * Sony CXD2880 DVB-T2/T tuner + demodulator driver
   5  * register I/O interface functions
   6  *
   7  * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation
   8  */
   9 
  10 #include "cxd2880_io.h"
  11 
  12 int cxd2880_io_common_write_one_reg(struct cxd2880_io *io,
  13                                     enum cxd2880_io_tgt tgt,
  14                                     u8 sub_address, u8 data)
  15 {
  16         if (!io)
  17                 return -EINVAL;
  18 
  19         return io->write_regs(io, tgt, sub_address, &data, 1);
  20 }
  21 
  22 int cxd2880_io_set_reg_bits(struct cxd2880_io *io,
  23                             enum cxd2880_io_tgt tgt,
  24                             u8 sub_address, u8 data, u8 mask)
  25 {
  26         int ret;
  27 
  28         if (!io)
  29                 return -EINVAL;
  30 
  31         if (mask == 0x00)
  32                 return 0;
  33 
  34         if (mask != 0xff) {
  35                 u8 rdata = 0x00;
  36 
  37                 ret = io->read_regs(io, tgt, sub_address, &rdata, 1);
  38                 if (ret)
  39                         return ret;
  40 
  41                 data = (data & mask) | (rdata & (mask ^ 0xff));
  42         }
  43 
  44         return io->write_reg(io, tgt, sub_address, data);
  45 }
  46 
  47 int cxd2880_io_write_multi_regs(struct cxd2880_io *io,
  48                              enum cxd2880_io_tgt tgt,
  49                              const struct cxd2880_reg_value reg_value[],
  50                              u8 size)
  51 {
  52         int ret;
  53         int i;
  54 
  55         if (!io)
  56                 return -EINVAL;
  57 
  58         for (i = 0; i < size ; i++) {
  59                 ret = io->write_reg(io, tgt, reg_value[i].addr,
  60                                     reg_value[i].value);
  61                 if (ret)
  62                         return ret;
  63         }
  64 
  65         return 0;
  66 }

/* [<][>][^][v][top][bottom][index][help] */