blob: b189a8b86b28ccd90680dfeddc4c7cc2208062b0 [file] [log] [blame]
Julius Werner0375d322019-02-20 17:33:23 -08001/*
2 * Copyright (c) 2020, Google LLC. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <drivers/delay_timer.h>
8
9#include <qti_plat.h>
10#include <spmi_arb.h>
11
12/*
13 * This driver implements PON support for PM8998-compatible PMICs. This can
14 * include other part numbers like PM6150.
15 */
16
17#define PON_PS_HOLD_RESET_CTL 0x85a
18#define RESET_TYPE_WARM_RESET 1
19#define RESET_TYPE_SHUTDOWN 4
20
21#define PON_PS_HOLD_RESET_CTL2 0x85b
22#define S2_RESET_EN BIT(7)
23
24static void configure_ps_hold(uint32_t reset_type)
25{
26 /* QTI recommends disabling reset for 10 cycles before reconfiguring. */
27 spmi_arb_write8(PON_PS_HOLD_RESET_CTL2, 0);
28 mdelay(1);
29
30 spmi_arb_write8(PON_PS_HOLD_RESET_CTL, reset_type);
31 spmi_arb_write8(PON_PS_HOLD_RESET_CTL2, S2_RESET_EN);
32 mdelay(1);
33}
34
35void qti_pmic_prepare_reset(void)
36{
37 configure_ps_hold(RESET_TYPE_WARM_RESET);
38}
39
40void qti_pmic_prepare_shutdown(void)
41{
42 configure_ps_hold(RESET_TYPE_SHUTDOWN);
43}