linux/include/linux/mfd/da9150/core.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-or-later */
   2/*
   3 * DA9150 MFD Driver - Core Data
   4 *
   5 * Copyright (c) 2014 Dialog Semiconductor
   6 *
   7 * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
   8 */
   9
  10#ifndef __DA9150_CORE_H
  11#define __DA9150_CORE_H
  12
  13#include <linux/device.h>
  14#include <linux/i2c.h>
  15#include <linux/interrupt.h>
  16#include <linux/regmap.h>
  17
  18/* I2C address paging */
  19#define DA9150_REG_PAGE_SHIFT   8
  20#define DA9150_REG_PAGE_MASK    0xFF
  21
  22/* IRQs */
  23#define DA9150_NUM_IRQ_REGS     4
  24#define DA9150_IRQ_VBUS         0
  25#define DA9150_IRQ_CHG          1
  26#define DA9150_IRQ_TCLASS       2
  27#define DA9150_IRQ_TJUNC        3
  28#define DA9150_IRQ_VFAULT       4
  29#define DA9150_IRQ_CONF         5
  30#define DA9150_IRQ_DAT          6
  31#define DA9150_IRQ_DTYPE        7
  32#define DA9150_IRQ_ID           8
  33#define DA9150_IRQ_ADP          9
  34#define DA9150_IRQ_SESS_END     10
  35#define DA9150_IRQ_SESS_VLD     11
  36#define DA9150_IRQ_FG           12
  37#define DA9150_IRQ_GP           13
  38#define DA9150_IRQ_TBAT         14
  39#define DA9150_IRQ_GPIOA        15
  40#define DA9150_IRQ_GPIOB        16
  41#define DA9150_IRQ_GPIOC        17
  42#define DA9150_IRQ_GPIOD        18
  43#define DA9150_IRQ_GPADC        19
  44#define DA9150_IRQ_WKUP         20
  45
  46/* I2C sub-device address */
  47#define DA9150_QIF_I2C_ADDR_LSB         0x5
  48
  49struct da9150_fg_pdata {
  50        u32 update_interval;    /* msecs */
  51        u8 warn_soc_lvl;        /* % value */
  52        u8 crit_soc_lvl;        /* % value */
  53};
  54
  55struct da9150_pdata {
  56        int irq_base;
  57        struct da9150_fg_pdata *fg_pdata;
  58};
  59
  60struct da9150 {
  61        struct device *dev;
  62        struct regmap *regmap;
  63        struct i2c_client *core_qif;
  64
  65        struct regmap_irq_chip_data *regmap_irq_data;
  66        int irq;
  67        int irq_base;
  68};
  69
  70/* Device I/O - Query Interface for FG and standard register access */
  71void da9150_read_qif(struct da9150 *da9150, u8 addr, int count, u8 *buf);
  72void da9150_write_qif(struct da9150 *da9150, u8 addr, int count, const u8 *buf);
  73
  74u8 da9150_reg_read(struct da9150 *da9150, u16 reg);
  75void da9150_reg_write(struct da9150 *da9150, u16 reg, u8 val);
  76void da9150_set_bits(struct da9150 *da9150, u16 reg, u8 mask, u8 val);
  77
  78void da9150_bulk_read(struct da9150 *da9150, u16 reg, int count, u8 *buf);
  79void da9150_bulk_write(struct da9150 *da9150, u16 reg, int count, const u8 *buf);
  80
  81#endif /* __DA9150_CORE_H */
  82