Łukasz Majewski | 16db062 | 2011-10-06 02:37:34 +0000 | [diff] [blame] | 1 | /* |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 Samsung Electronics |
Łukasz Majewski | 16db062 | 2011-10-06 02:37:34 +0000 | [diff] [blame] | 3 | * Lukasz Majewski <l.majewski@samsung.com> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #ifndef __CORE_PMIC_H_ |
| 25 | #define __CORE_PMIC_H_ |
| 26 | |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 27 | #include <common.h> |
| 28 | #include <linux/list.h> |
| 29 | #include <i2c.h> |
| 30 | |
Łukasz Majewski | 16db062 | 2011-10-06 02:37:34 +0000 | [diff] [blame] | 31 | enum { PMIC_I2C, PMIC_SPI, }; |
| 32 | enum { I2C_PMIC, I2C_NUM, }; |
| 33 | enum { PMIC_READ, PMIC_WRITE, }; |
Łukasz Majewski | 40f5ca0 | 2012-11-13 03:21:53 +0000 | [diff] [blame] | 34 | enum { PMIC_SENSOR_BYTE_ORDER_LITTLE, PMIC_SENSOR_BYTE_ORDER_BIG, }; |
Łukasz Majewski | 16db062 | 2011-10-06 02:37:34 +0000 | [diff] [blame] | 35 | |
| 36 | struct p_i2c { |
| 37 | unsigned char addr; |
| 38 | unsigned char *buf; |
| 39 | unsigned char tx_num; |
| 40 | }; |
| 41 | |
| 42 | struct p_spi { |
| 43 | unsigned int cs; |
| 44 | unsigned int mode; |
| 45 | unsigned int bitlen; |
| 46 | unsigned int clk; |
| 47 | unsigned int flags; |
| 48 | u32 (*prepare_tx)(u32 reg, u32 *val, u32 write); |
| 49 | }; |
| 50 | |
| 51 | struct pmic { |
| 52 | const char *name; |
| 53 | unsigned char bus; |
| 54 | unsigned char interface; |
Łukasz Majewski | 40f5ca0 | 2012-11-13 03:21:53 +0000 | [diff] [blame] | 55 | unsigned char sensor_byte_order; |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 56 | unsigned int number_of_regs; |
Łukasz Majewski | 16db062 | 2011-10-06 02:37:34 +0000 | [diff] [blame] | 57 | union hw { |
| 58 | struct p_i2c i2c; |
| 59 | struct p_spi spi; |
| 60 | } hw; |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 61 | |
| 62 | struct list_head list; |
Łukasz Majewski | 16db062 | 2011-10-06 02:37:34 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 65 | int pmic_init(unsigned char bus); |
| 66 | int pmic_dialog_init(unsigned char bus); |
| 67 | int check_reg(struct pmic *p, u32 reg); |
| 68 | struct pmic *pmic_alloc(void); |
| 69 | struct pmic *pmic_get(const char *s); |
Łukasz Majewski | 16db062 | 2011-10-06 02:37:34 +0000 | [diff] [blame] | 70 | int pmic_probe(struct pmic *p); |
| 71 | int pmic_reg_read(struct pmic *p, u32 reg, u32 *val); |
| 72 | int pmic_reg_write(struct pmic *p, u32 reg, u32 val); |
| 73 | int pmic_set_output(struct pmic *p, u32 reg, int ldo, int on); |
| 74 | |
| 75 | #define pmic_i2c_addr (p->hw.i2c.addr) |
| 76 | #define pmic_i2c_tx_num (p->hw.i2c.tx_num) |
| 77 | |
| 78 | #define pmic_spi_bitlen (p->hw.spi.bitlen) |
| 79 | #define pmic_spi_flags (p->hw.spi.flags) |
| 80 | |
| 81 | #endif /* __CORE_PMIC_H_ */ |