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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* Copyright 2015 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.
*/
/* Glados board-specific configuration */
#include "button.h"
#include "charger.h"
#include "console.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
#include "lid_switch.h"
#include "motion_sense.h"
#include "power.h"
#include "power_button.h"
#include "switch.h"
#include "task.h"
#include "timer.h"
#include "usb_pd_tcpm.h"
#include "util.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP)
#define GPIO_KB_OUTPUT (GPIO_ODR_HIGH)
#define I2C_ADDR_BD99992 0x60
/* Exchange status with PD MCU. */
static void pd_mcu_interrupt(enum gpio_signal signal)
{
hook_call_deferred(tcpc_alert, 0);
}
void vbus0_evt(enum gpio_signal signal)
{
CPRINTF("VBUS C0, %d\n", !gpio_get_level(signal));
task_wake(TASK_ID_PD_C0);
}
void vbus1_evt(enum gpio_signal signal)
{
CPRINTF("VBUS C1, %d\n", !gpio_get_level(signal));
task_wake(TASK_ID_PD_C1);
}
void usb0_evt(enum gpio_signal signal)
{
}
void usb1_evt(enum gpio_signal signal)
{
}
#include "gpio_list.h"
/* power signal list. Must match order of enum power_signal. */
const struct power_signal_info power_signal_list[] = {
{GPIO_RSMRST_L_PGOOD, 1, "RSMRST_N_PWRGD"},
{GPIO_PCH_SLP_S0_L, 1, "SLP_S0_DEASSERTED"},
{GPIO_PCH_SLP_S3_L, 1, "SLP_S3_DEASSERTED"},
{GPIO_PCH_SLP_S4_L, 1, "SLP_S4_DEASSERTED"},
{GPIO_PCH_SLP_SUS_L, 1, "SLP_SUS_DEASSERTED"},
{GPIO_PMIC_DPWROK, 1, "PMIC_DPWROK"},
};
BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
const struct i2c_port_t i2c_ports[] = {
{"batt", MEC1322_I2C0_0, 100, GPIO_I2C0_0_SCL, GPIO_I2C0_0_SDA},
{"muxes", MEC1322_I2C0_1, 100, GPIO_I2C0_1_SCL, GPIO_I2C0_1_SDA},
{"pd_mcu", MEC1322_I2C1, 1000, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
{"sensors", MEC1322_I2C2, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA },
{"pmic", MEC1322_I2C3, 400, GPIO_I2C3_SCL, GPIO_I2C3_SDA },
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/**
* Discharge battery when on AC power for factory test.
*/
int board_discharge_on_ac(int enable)
{
return charger_discharge_on_ac(enable);
}
/**
* Reset PD MCU
*/
void board_reset_pd_mcu(void)
{
gpio_set_level(GPIO_PD_RST_L, 0);
usleep(100);
gpio_set_level(GPIO_PD_RST_L, 1);
}
struct motion_sensor_t motion_sensors[] = {
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
const struct button_config buttons[CONFIG_BUTTON_COUNT] = {
{ 0 },
{ 0 },
};
static void pmic_init(void)
{
/*
* Set V085ACNT / V0.85A Control Register:
* Lower power mode = 0.7V.
* Nominal output = 1.0V.
*/
i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
}
DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, pmic_init, HOOK_PRIO_DEFAULT);
/* Initialize board. */
static void board_init(void)
{
/* Enable PD MCU interrupt */
gpio_enable_interrupt(GPIO_PD_MCU_INT);
/* Enable VBUS interrupt */
gpio_enable_interrupt(GPIO_USB_C0_VBUS_WAKE_L);
gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE_L);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
|