2 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 * Qualcomm PMIC 8xxx driver header file
18 #ifndef __MFD_PM8XXX_CORE_H
19 #define __MFD_PM8XXX_CORE_H
21 #include <linux/mfd/core.h>
23 struct pm8xxx_drvdata
{
24 int (*pmic_readb
) (const struct device
*dev
, u16 addr
, u8
*val
);
25 int (*pmic_writeb
) (const struct device
*dev
, u16 addr
, u8 val
);
26 int (*pmic_read_buf
) (const struct device
*dev
, u16 addr
, u8
*buf
,
28 int (*pmic_write_buf
) (const struct device
*dev
, u16 addr
, u8
*buf
,
30 int (*pmic_read_irq_stat
) (const struct device
*dev
, int irq
);
34 static inline int pm8xxx_readb(const struct device
*dev
, u16 addr
, u8
*val
)
36 struct pm8xxx_drvdata
*dd
= dev_get_drvdata(dev
);
40 return dd
->pmic_readb(dev
, addr
, val
);
43 static inline int pm8xxx_writeb(const struct device
*dev
, u16 addr
, u8 val
)
45 struct pm8xxx_drvdata
*dd
= dev_get_drvdata(dev
);
49 return dd
->pmic_writeb(dev
, addr
, val
);
52 static inline int pm8xxx_read_buf(const struct device
*dev
, u16 addr
, u8
*buf
,
55 struct pm8xxx_drvdata
*dd
= dev_get_drvdata(dev
);
59 return dd
->pmic_read_buf(dev
, addr
, buf
, n
);
62 static inline int pm8xxx_write_buf(const struct device
*dev
, u16 addr
, u8
*buf
,
65 struct pm8xxx_drvdata
*dd
= dev_get_drvdata(dev
);
69 return dd
->pmic_write_buf(dev
, addr
, buf
, n
);
72 static inline int pm8xxx_read_irq_stat(const struct device
*dev
, int irq
)
74 struct pm8xxx_drvdata
*dd
= dev_get_drvdata(dev
);
78 return dd
->pmic_read_irq_stat(dev
, irq
);