Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2013 Oliver Schinagl <oliver@schinagl.nl> |
| 3 | * |
| 4 | * X-Powers AXP221 Power Management IC driver |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #define AXP221_CHIP_ADDR 0x68 |
| 10 | #define AXP221_CTRL_ADDR 0x3e |
| 11 | #define AXP221_INIT_DATA 0x3e |
| 12 | |
Hans de Goede | 1dd334b | 2014-11-29 23:54:25 +0100 | [diff] [blame] | 13 | #define AXP223_DEVICE_ADDR 0x3a3 |
| 14 | #define AXP223_RUNTIME_ADDR 0x2d |
Hans de Goede | 1dd334b | 2014-11-29 23:54:25 +0100 | [diff] [blame] | 15 | |
Hans de Goede | 65142e9 | 2014-11-25 16:37:52 +0100 | [diff] [blame] | 16 | /* Page 0 addresses */ |
Chen-Yu Tsai | 54b6ab1 | 2015-03-09 15:44:15 +0800 | [diff] [blame] | 17 | #define AXP221_POWER_STATUS 0x00 |
| 18 | #define AXP221_POWER_STATUS_VBUS_AVAIL (1 << 5) |
| 19 | #define AXP221_POWER_STATUS_VBUS_USABLE (1 << 4) |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 20 | #define AXP221_CHIP_ID 0x03 |
| 21 | #define AXP221_OUTPUT_CTRL1 0x10 |
Hans de Goede | be4929c | 2014-12-13 14:02:38 +0100 | [diff] [blame] | 22 | #define AXP221_OUTPUT_CTRL1_DCDC0_EN (1 << 0) |
| 23 | #define AXP221_OUTPUT_CTRL1_DCDC1_EN (1 << 1) |
| 24 | #define AXP221_OUTPUT_CTRL1_DCDC2_EN (1 << 2) |
| 25 | #define AXP221_OUTPUT_CTRL1_DCDC3_EN (1 << 3) |
| 26 | #define AXP221_OUTPUT_CTRL1_DCDC4_EN (1 << 4) |
| 27 | #define AXP221_OUTPUT_CTRL1_DCDC5_EN (1 << 5) |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 28 | #define AXP221_OUTPUT_CTRL1_ALDO1_EN (1 << 6) |
| 29 | #define AXP221_OUTPUT_CTRL1_ALDO2_EN (1 << 7) |
| 30 | #define AXP221_OUTPUT_CTRL2 0x12 |
Siarhei Siamashka | 7e4eb6c | 2015-01-19 05:23:30 +0200 | [diff] [blame] | 31 | #define AXP221_OUTPUT_CTRL2_ELDO1_EN (1 << 0) |
| 32 | #define AXP221_OUTPUT_CTRL2_ELDO2_EN (1 << 1) |
| 33 | #define AXP221_OUTPUT_CTRL2_ELDO3_EN (1 << 2) |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 34 | #define AXP221_OUTPUT_CTRL2_DLDO1_EN (1 << 3) |
| 35 | #define AXP221_OUTPUT_CTRL2_DLDO2_EN (1 << 4) |
| 36 | #define AXP221_OUTPUT_CTRL2_DLDO3_EN (1 << 5) |
| 37 | #define AXP221_OUTPUT_CTRL2_DLDO4_EN (1 << 6) |
Hans de Goede | be4929c | 2014-12-13 14:02:38 +0100 | [diff] [blame] | 38 | #define AXP221_OUTPUT_CTRL2_DCDC1SW_EN (1 << 7) |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 39 | #define AXP221_OUTPUT_CTRL3 0x13 |
| 40 | #define AXP221_OUTPUT_CTRL3_ALDO3_EN (1 << 7) |
| 41 | #define AXP221_DLDO1_CTRL 0x15 |
| 42 | #define AXP221_DLDO2_CTRL 0x16 |
| 43 | #define AXP221_DLDO3_CTRL 0x17 |
| 44 | #define AXP221_DLDO4_CTRL 0x18 |
Siarhei Siamashka | 7e4eb6c | 2015-01-19 05:23:30 +0200 | [diff] [blame] | 45 | #define AXP221_ELDO1_CTRL 0x19 |
| 46 | #define AXP221_ELDO2_CTRL 0x1a |
| 47 | #define AXP221_ELDO3_CTRL 0x1b |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 48 | #define AXP221_DCDC1_CTRL 0x21 |
| 49 | #define AXP221_DCDC2_CTRL 0x22 |
| 50 | #define AXP221_DCDC3_CTRL 0x23 |
| 51 | #define AXP221_DCDC4_CTRL 0x24 |
| 52 | #define AXP221_DCDC5_CTRL 0x25 |
| 53 | #define AXP221_ALDO1_CTRL 0x28 |
Hans de Goede | 05060cc | 2015-01-05 16:41:49 +0100 | [diff] [blame] | 54 | #define AXP221_ALDO2_CTRL 0x29 |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 55 | #define AXP221_ALDO3_CTRL 0x2a |
Hans de Goede | 230fed4 | 2015-01-11 19:58:03 +0100 | [diff] [blame] | 56 | #define AXP221_VBUS_IPSOUT 0x30 |
| 57 | #define AXP221_VBUS_IPSOUT_DRIVEBUS (1 << 2) |
| 58 | #define AXP221_MISC_CTRL 0x8f |
| 59 | #define AXP221_MISC_CTRL_N_VBUSEN_FUNC (1 << 4) |
Hans de Goede | 65142e9 | 2014-11-25 16:37:52 +0100 | [diff] [blame] | 60 | #define AXP221_PAGE 0xff |
| 61 | |
| 62 | /* Page 1 addresses */ |
| 63 | #define AXP221_SID 0x20 |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 64 | |
Paul Kocialkowski | 6604a13 | 2015-03-22 18:07:09 +0100 | [diff] [blame] | 65 | #define AXP_GPIO |
Hans de Goede | 230fed4 | 2015-01-11 19:58:03 +0100 | [diff] [blame] | 66 | |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 67 | int axp221_set_dcdc1(unsigned int mvolt); |
| 68 | int axp221_set_dcdc2(unsigned int mvolt); |
| 69 | int axp221_set_dcdc3(unsigned int mvolt); |
| 70 | int axp221_set_dcdc4(unsigned int mvolt); |
| 71 | int axp221_set_dcdc5(unsigned int mvolt); |
| 72 | int axp221_set_dldo1(unsigned int mvolt); |
| 73 | int axp221_set_dldo2(unsigned int mvolt); |
| 74 | int axp221_set_dldo3(unsigned int mvolt); |
| 75 | int axp221_set_dldo4(unsigned int mvolt); |
| 76 | int axp221_set_aldo1(unsigned int mvolt); |
| 77 | int axp221_set_aldo2(unsigned int mvolt); |
| 78 | int axp221_set_aldo3(unsigned int mvolt); |
Siarhei Siamashka | 7e4eb6c | 2015-01-19 05:23:30 +0200 | [diff] [blame] | 79 | int axp221_set_eldo(int eldo_num, unsigned int mvolt); |
Oliver Schinagl | d3a558d | 2013-07-26 12:56:58 +0200 | [diff] [blame] | 80 | int axp221_init(void); |
Hans de Goede | 65142e9 | 2014-11-25 16:37:52 +0100 | [diff] [blame] | 81 | int axp221_get_sid(unsigned int *sid); |
Paul Kocialkowski | 6604a13 | 2015-03-22 18:07:09 +0100 | [diff] [blame] | 82 | |
| 83 | int axp_gpio_direction_input(unsigned int pin); |
| 84 | int axp_gpio_direction_output(unsigned int pin, unsigned int val); |
| 85 | int axp_gpio_get_value(unsigned int pin); |
| 86 | int axp_gpio_set_value(unsigned int pin, unsigned int val); |