blob: 201b1df762e39618b8ee2ff34f5395a0364f0951 [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
Simon Glasscd93d622020-05-10 11:40:13 -06009#include <linux/bitops.h>
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010010#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 Delaunay5d0c74e2018-03-12 10:46:12 +010019
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010020/* Main PMIC Control Register (MAIN_CR) */
21#define STPMIC1_SWOFF BIT(0)
22#define STPMIC1_RREQ_EN BIT(1)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010023
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010024/* BUCKS_MRST_CR */
25#define STPMIC1_MRST_BUCK(buck) BIT(buck)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010026
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010027/* LDOS_MRST_CR */
28#define STPMIC1_MRST_LDO(ldo) BIT(ldo)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010029
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010030/* BUCKx_MAIN_CR (x=1...4) */
31#define STPMIC1_BUCK_ENA BIT(0)
32#define STPMIC1_BUCK_PREG_MODE BIT(1)
33#define STPMIC1_BUCK_VOUT_MASK GENMASK(7, 2)
34#define STPMIC1_BUCK_VOUT_SHIFT 2
35#define STPMIC1_BUCK_VOUT(sel) (sel << STPMIC1_BUCK_VOUT_SHIFT)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010036
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010037#define STPMIC1_BUCK2_1200000V STPMIC1_BUCK_VOUT(24)
Patrick Delaunaye9a20f82020-03-06 11:14:03 +010038#define STPMIC1_BUCK2_1250000V STPMIC1_BUCK_VOUT(26)
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010039#define STPMIC1_BUCK2_1350000V STPMIC1_BUCK_VOUT(30)
40
41#define STPMIC1_BUCK3_1800000V STPMIC1_BUCK_VOUT(39)
42
43/* REFDDR_MAIN_CR */
44#define STPMIC1_VREF_ENA BIT(0)
45
46/* LDOX_MAIN_CR */
47#define STPMIC1_LDO_ENA BIT(0)
48#define STPMIC1_LDO12356_VOUT_MASK GENMASK(6, 2)
49#define STPMIC1_LDO12356_VOUT_SHIFT 2
50#define STPMIC1_LDO_VOUT(sel) (sel << STPMIC1_LDO12356_VOUT_SHIFT)
51
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010052#define STPMIC1_LDO3_MODE BIT(7)
53#define STPMIC1_LDO3_DDR_SEL 31
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010054#define STPMIC1_LDO3_1800000 STPMIC1_LDO_VOUT(9)
55
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010056#define STPMIC1_LDO4_UV 3300000
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010057
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010058/* BST_SW_CR */
59#define STPMIC1_BST_ON BIT(0)
60#define STPMIC1_VBUSOTG_ON BIT(1)
61#define STPMIC1_SWOUT_ON BIT(2)
62#define STPMIC1_PWR_SW_ON (STPMIC1_VBUSOTG_ON | STPMIC1_SWOUT_ON)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010063
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010064/* NVM_SR */
65#define STPMIC1_NVM_BUSY BIT(0)
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010066
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010067/* NVM_CR */
68#define STPMIC1_NVM_CMD_PROGRAM 1
69#define STPMIC1_NVM_CMD_READ 2
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010070
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010071/* Timeout */
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010072#define STPMIC1_DEFAULT_START_UP_DELAY_MS 1
73#define STPMIC1_DEFAULT_STOP_DELAY_MS 5
74#define STPMIC1_USB_BOOST_START_UP_DELAY_MS 10
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010075
76enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010077 STPMIC1_BUCK1,
78 STPMIC1_BUCK2,
79 STPMIC1_BUCK3,
80 STPMIC1_BUCK4,
81 STPMIC1_MAX_BUCK,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010082};
83
84enum {
Patrick Delaunaydb4ff0d2019-02-04 11:26:18 +010085 STPMIC1_PREG_MODE_HP,
86 STPMIC1_PREG_MODE_LP,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010087};
88
89enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010090 STPMIC1_LDO1,
91 STPMIC1_LDO2,
92 STPMIC1_LDO3,
93 STPMIC1_LDO4,
94 STPMIC1_LDO5,
95 STPMIC1_LDO6,
96 STPMIC1_MAX_LDO,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +010097};
98
99enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +0100100 STPMIC1_LDO_MODE_NORMAL,
101 STPMIC1_LDO_MODE_BYPASS,
102 STPMIC1_LDO_MODE_SINK_SOURCE,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +0100103};
104
105enum {
Patrick Delaunay42f01aa2019-02-04 11:26:17 +0100106 STPMIC1_PWR_SW1,
107 STPMIC1_PWR_SW2,
108 STPMIC1_MAX_PWR_SW,
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +0100109};
Patrick Delaunay5d0c74e2018-03-12 10:46:12 +0100110#endif