summaryrefslogtreecommitdiff
path: root/board/nvidia/chromeos/power_management.c
blob: 118f5df6002d58c261d598cf164518a1bc2a591a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 */

/* Implementation of per-board power management function */

#include <common.h>
#include <i2c.h>

#include <chromeos/power_management.h>

#define PREFIX "cold_reboot: "

#define PMIC_I2C_BUS		0x00
#define PMIC_I2C_DEVICE_ADDRESS	0x34
#define TPS6586X_SUPPLYENE	0x14

/* This function never returns */
void cold_reboot(void)
{
	uint8_t byte;

	if (i2c_set_bus_num(PMIC_I2C_BUS)) {
		debug(PREFIX "i2c_set_bus_num fail\n");
		goto FATAL;
	}

	if (i2c_read(PMIC_I2C_DEVICE_ADDRESS, TPS6586X_SUPPLYENE, 1,
				&byte, sizeof(byte))) {
		debug(PREFIX "i2c_read fail\n");
		goto FATAL;
	}

	/* Set TPS6586X_SUPPLYENE bit0 to 1 */
	byte |= 1;

	if (i2c_write(PMIC_I2C_DEVICE_ADDRESS, TPS6586X_SUPPLYENE, 1,
				&byte, sizeof(byte))) {
		debug(PREFIX "i2c_write fail\n");
		goto FATAL;
	}

	/* The PMIC will reboot the whole system after 10 ms */
	udelay(100);

FATAL:
	/* The final solution of doing a cold reboot */
	printf("Please press cold reboot button\n");
	while (1);
}