blob: 1493a677f048e6e8f5a90baa71c61def4b2f5dc8 [file] [log] [blame]
Tom Rini4549e782018-05-06 18:27:01 -04001/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +01002/*
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +01004 */
5
Patrick Delaunay42f01aa2019-02-04 11:26:17 +01006#ifndef __PMIC_STPMIC1_H_
7#define __PMIC_STPMIC1_H_
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +01008
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +01009#define STPMIC1_MAIN_CR 0x10
10#define STPMIC1_BUCKS_MRST_CR 0x18
11#define STPMIC1_LDOS_MRST_CR 0x1a
12#define STPMIC1_BUCKX_MAIN_CR(buck) (0x20 + (buck))
13#define STPMIC1_REFDDR_MAIN_CR 0x24
14#define STPMIC1_LDOX_MAIN_CR(ldo) (0x25 + (ldo))
15#define STPMIC1_BST_SW_CR 0x40
16#define STPMIC1_NVM_SR 0xb8
17#define STPMIC1_NVM_CR 0xb9
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010018
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010019/* Main PMIC Control Register (MAIN_CR) */
20#define STPMIC1_SWOFF BIT(0)
21#define STPMIC1_RREQ_EN BIT(1)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010022
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010023/* BUCKS_MRST_CR */
24#define STPMIC1_MRST_BUCK(buck) BIT(buck)
Patrick Delaunay178a4152019-07-30 19:16:20 +020025#define STPMIC1_MRST_BUCK_DEBUG (STPMIC1_MRST_BUCK(STPMIC1_BUCK1) | \
26 STPMIC1_MRST_BUCK(STPMIC1_BUCK3))
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010027
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010028/* LDOS_MRST_CR */
29#define STPMIC1_MRST_LDO(ldo) BIT(ldo)
Patrick Delaunay178a4152019-07-30 19:16:20 +020030#define STPMIC1_MRST_LDO_DEBUG 0
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010031
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010032/* BUCKx_MAIN_CR (x=1...4) */
33#define STPMIC1_BUCK_ENA BIT(0)
34#define STPMIC1_BUCK_PREG_MODE BIT(1)
35#define STPMIC1_BUCK_VOUT_MASK GENMASK(7, 2)
36#define STPMIC1_BUCK_VOUT_SHIFT 2
37#define STPMIC1_BUCK_VOUT(sel) (sel << STPMIC1_BUCK_VOUT_SHIFT)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010038
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010039#define STPMIC1_BUCK2_1200000V STPMIC1_BUCK_VOUT(24)
Patrick Delaunaye9a20f82020-03-06 11:14:03 +010040#define STPMIC1_BUCK2_1250000V STPMIC1_BUCK_VOUT(26)
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010041#define STPMIC1_BUCK2_1350000V STPMIC1_BUCK_VOUT(30)
42
43#define STPMIC1_BUCK3_1800000V STPMIC1_BUCK_VOUT(39)
44
45/* REFDDR_MAIN_CR */
46#define STPMIC1_VREF_ENA BIT(0)
47
48/* LDOX_MAIN_CR */
49#define STPMIC1_LDO_ENA BIT(0)
50#define STPMIC1_LDO12356_VOUT_MASK GENMASK(6, 2)
51#define STPMIC1_LDO12356_VOUT_SHIFT 2
52#define STPMIC1_LDO_VOUT(sel) (sel << STPMIC1_LDO12356_VOUT_SHIFT)
53
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010054#define STPMIC1_LDO3_MODE BIT(7)
55#define STPMIC1_LDO3_DDR_SEL 31
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010056#define STPMIC1_LDO3_1800000 STPMIC1_LDO_VOUT(9)
57
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010058#define STPMIC1_LDO4_UV 3300000
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010059
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010060/* BST_SW_CR */
61#define STPMIC1_BST_ON BIT(0)
62#define STPMIC1_VBUSOTG_ON BIT(1)
63#define STPMIC1_SWOUT_ON BIT(2)
64#define STPMIC1_PWR_SW_ON (STPMIC1_VBUSOTG_ON | STPMIC1_SWOUT_ON)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010065
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010066/* NVM_SR */
67#define STPMIC1_NVM_BUSY BIT(0)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010068
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010069/* NVM_CR */
70#define STPMIC1_NVM_CMD_PROGRAM 1
71#define STPMIC1_NVM_CMD_READ 2
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010072
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010073/* Timeout */
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010074#define STPMIC1_DEFAULT_START_UP_DELAY_MS 1
75#define STPMIC1_DEFAULT_STOP_DELAY_MS 5
76#define STPMIC1_USB_BOOST_START_UP_DELAY_MS 10
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010077
78enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010079 STPMIC1_BUCK1,
80 STPMIC1_BUCK2,
81 STPMIC1_BUCK3,
82 STPMIC1_BUCK4,
83 STPMIC1_MAX_BUCK,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010084};
85
86enum {
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010087 STPMIC1_PREG_MODE_HP,
88 STPMIC1_PREG_MODE_LP,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010089};
90
91enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010092 STPMIC1_LDO1,
93 STPMIC1_LDO2,
94 STPMIC1_LDO3,
95 STPMIC1_LDO4,
96 STPMIC1_LDO5,
97 STPMIC1_LDO6,
98 STPMIC1_MAX_LDO,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010099};
100
101enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +0100102 STPMIC1_LDO_MODE_NORMAL,
103 STPMIC1_LDO_MODE_BYPASS,
104 STPMIC1_LDO_MODE_SINK_SOURCE,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +0100105};
106
107enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +0100108 STPMIC1_PWR_SW1,
109 STPMIC1_PWR_SW2,
110 STPMIC1_MAX_PWR_SW,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +0100111};
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +0100112#endif