Tom Rini | 4549e78 | 2018-05-06 18:27:01 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 6 | #ifndef __PMIC_STPMIC1_H_ |
| 7 | #define __PMIC_STPMIC1_H_ |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 8 | |
Simon Glass | cd93d62 | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 9 | #include <linux/bitops.h> |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 10 | #define STPMIC1_MAIN_CR 0x10 |
| 11 | #define STPMIC1_BUCKS_MRST_CR 0x18 |
| 12 | #define STPMIC1_LDOS_MRST_CR 0x1a |
| 13 | #define STPMIC1_BUCKX_MAIN_CR(buck) (0x20 + (buck)) |
| 14 | #define STPMIC1_REFDDR_MAIN_CR 0x24 |
| 15 | #define STPMIC1_LDOX_MAIN_CR(ldo) (0x25 + (ldo)) |
| 16 | #define STPMIC1_BST_SW_CR 0x40 |
| 17 | #define STPMIC1_NVM_SR 0xb8 |
| 18 | #define STPMIC1_NVM_CR 0xb9 |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 19 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 20 | /* Main PMIC Control Register (MAIN_CR) */ |
| 21 | #define STPMIC1_SWOFF BIT(0) |
| 22 | #define STPMIC1_RREQ_EN BIT(1) |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 23 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 24 | /* BUCKS_MRST_CR */ |
| 25 | #define STPMIC1_MRST_BUCK(buck) BIT(buck) |
Patrick Delaunay | 178a415 | 2019-07-30 19:16:20 +0200 | [diff] [blame] | 26 | #define STPMIC1_MRST_BUCK_DEBUG (STPMIC1_MRST_BUCK(STPMIC1_BUCK1) | \ |
| 27 | STPMIC1_MRST_BUCK(STPMIC1_BUCK3)) |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 28 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 29 | /* LDOS_MRST_CR */ |
| 30 | #define STPMIC1_MRST_LDO(ldo) BIT(ldo) |
Patrick Delaunay | 178a415 | 2019-07-30 19:16:20 +0200 | [diff] [blame] | 31 | #define STPMIC1_MRST_LDO_DEBUG 0 |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 32 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 33 | /* BUCKx_MAIN_CR (x=1...4) */ |
| 34 | #define STPMIC1_BUCK_ENA BIT(0) |
| 35 | #define STPMIC1_BUCK_PREG_MODE BIT(1) |
| 36 | #define STPMIC1_BUCK_VOUT_MASK GENMASK(7, 2) |
| 37 | #define STPMIC1_BUCK_VOUT_SHIFT 2 |
| 38 | #define STPMIC1_BUCK_VOUT(sel) (sel << STPMIC1_BUCK_VOUT_SHIFT) |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 39 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 40 | #define STPMIC1_BUCK2_1200000V STPMIC1_BUCK_VOUT(24) |
Patrick Delaunay | e9a20f8 | 2020-03-06 11:14:03 +0100 | [diff] [blame] | 41 | #define STPMIC1_BUCK2_1250000V STPMIC1_BUCK_VOUT(26) |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 42 | #define STPMIC1_BUCK2_1350000V STPMIC1_BUCK_VOUT(30) |
| 43 | |
| 44 | #define STPMIC1_BUCK3_1800000V STPMIC1_BUCK_VOUT(39) |
| 45 | |
| 46 | /* REFDDR_MAIN_CR */ |
| 47 | #define STPMIC1_VREF_ENA BIT(0) |
| 48 | |
| 49 | /* LDOX_MAIN_CR */ |
| 50 | #define STPMIC1_LDO_ENA BIT(0) |
| 51 | #define STPMIC1_LDO12356_VOUT_MASK GENMASK(6, 2) |
| 52 | #define STPMIC1_LDO12356_VOUT_SHIFT 2 |
| 53 | #define STPMIC1_LDO_VOUT(sel) (sel << STPMIC1_LDO12356_VOUT_SHIFT) |
| 54 | |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 55 | #define STPMIC1_LDO3_MODE BIT(7) |
| 56 | #define STPMIC1_LDO3_DDR_SEL 31 |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 57 | #define STPMIC1_LDO3_1800000 STPMIC1_LDO_VOUT(9) |
| 58 | |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 59 | #define STPMIC1_LDO4_UV 3300000 |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 60 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 61 | /* BST_SW_CR */ |
| 62 | #define STPMIC1_BST_ON BIT(0) |
| 63 | #define STPMIC1_VBUSOTG_ON BIT(1) |
| 64 | #define STPMIC1_SWOUT_ON BIT(2) |
| 65 | #define STPMIC1_PWR_SW_ON (STPMIC1_VBUSOTG_ON | STPMIC1_SWOUT_ON) |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 66 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 67 | /* NVM_SR */ |
| 68 | #define STPMIC1_NVM_BUSY BIT(0) |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 69 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 70 | /* NVM_CR */ |
| 71 | #define STPMIC1_NVM_CMD_PROGRAM 1 |
| 72 | #define STPMIC1_NVM_CMD_READ 2 |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 73 | |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 74 | /* Timeout */ |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 75 | #define STPMIC1_DEFAULT_START_UP_DELAY_MS 1 |
| 76 | #define STPMIC1_DEFAULT_STOP_DELAY_MS 5 |
| 77 | #define STPMIC1_USB_BOOST_START_UP_DELAY_MS 10 |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 78 | |
| 79 | enum { |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 80 | STPMIC1_BUCK1, |
| 81 | STPMIC1_BUCK2, |
| 82 | STPMIC1_BUCK3, |
| 83 | STPMIC1_BUCK4, |
| 84 | STPMIC1_MAX_BUCK, |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | enum { |
Patrick Delaunay | db4ff0d | 2019-02-04 11:26:18 +0100 | [diff] [blame] | 88 | STPMIC1_PREG_MODE_HP, |
| 89 | STPMIC1_PREG_MODE_LP, |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | enum { |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 93 | STPMIC1_LDO1, |
| 94 | STPMIC1_LDO2, |
| 95 | STPMIC1_LDO3, |
| 96 | STPMIC1_LDO4, |
| 97 | STPMIC1_LDO5, |
| 98 | STPMIC1_LDO6, |
| 99 | STPMIC1_MAX_LDO, |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | enum { |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 103 | STPMIC1_LDO_MODE_NORMAL, |
| 104 | STPMIC1_LDO_MODE_BYPASS, |
| 105 | STPMIC1_LDO_MODE_SINK_SOURCE, |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | enum { |
Patrick Delaunay | 42f01aa | 2019-02-04 11:26:17 +0100 | [diff] [blame] | 109 | STPMIC1_PWR_SW1, |
| 110 | STPMIC1_PWR_SW2, |
| 111 | STPMIC1_MAX_PWR_SW, |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 112 | }; |
Patrick Delaunay | 5d0c74e | 2018-03-12 10:46:12 +0100 | [diff] [blame] | 113 | #endif |