mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 10:00:51 +00:00
This is a straightforward conversion of existing tables into X-Macro style definitions for the GPIO alternate functions. This change in itself, is not particularly powerful, but having all GPIO settings in a single file makes a board easier to understand. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=make buildall -j Followed by manual testing of interrupt on change and UART functionality on STM32F0 based discovery board. Change-Id: Ib7f1f014f4bd289d7c0ac3100470ba2dc71ca579 Reviewed-on: https://chromium-review.googlesource.com/207987 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
124 lines
3.1 KiB
C
124 lines
3.1 KiB
C
/* Copyright (c) 2013 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.
|
|
*/
|
|
/* Pit board-specific configuration */
|
|
|
|
#include "battery.h"
|
|
#include "chipset.h"
|
|
#include "common.h"
|
|
#include "extpower.h"
|
|
#include "gpio.h"
|
|
#include "i2c.h"
|
|
#include "keyboard_scan.h"
|
|
#include "keyboard_raw.h"
|
|
#include "lid_switch.h"
|
|
#include "pmu_tpschrome.h"
|
|
#include "power.h"
|
|
#include "registers.h"
|
|
#include "spi.h"
|
|
#include "timer.h"
|
|
#include "task.h"
|
|
#include "util.h"
|
|
|
|
#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH)
|
|
#define GPIO_KB_OUTPUT GPIO_ODR_HIGH
|
|
|
|
#include "gpio_list.h"
|
|
|
|
/* Battery temperature ranges in degrees C */
|
|
static const struct battery_info info = {
|
|
.start_charging_min_c = 0,
|
|
.start_charging_max_c = 45,
|
|
.charging_min_c = 0,
|
|
.charging_max_c = 60,
|
|
.discharging_min_c = -20,
|
|
.discharging_max_c = 70,
|
|
};
|
|
|
|
const struct battery_info *battery_get_info(void)
|
|
{
|
|
return &info;
|
|
}
|
|
|
|
/* I2C ports */
|
|
const struct i2c_port_t i2c_ports[] = {
|
|
{"master", I2C_PORT_MASTER, 100, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
|
|
};
|
|
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
|
|
|
|
struct keyboard_scan_config keyscan_config = {
|
|
.output_settle_us = 40,
|
|
.debounce_down_us = 6 * MSEC,
|
|
.debounce_up_us = 30 * MSEC,
|
|
.scan_period_us = 1500,
|
|
.min_post_scan_delay_us = 1000,
|
|
.poll_timeout_us = SECOND,
|
|
.actual_key_mask = {
|
|
0x14, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff,
|
|
0xa4, 0xff, 0xf6, 0x55, 0xfa, 0xc8 /* full set */
|
|
},
|
|
};
|
|
|
|
int pmu_board_init(void)
|
|
{
|
|
int ver, failure = 0;
|
|
|
|
/* Set fast charging timeout to 6 hours*/
|
|
if (!failure)
|
|
failure = pmu_set_fastcharge(TIMEOUT_6HRS);
|
|
/* Enable external gpio CHARGER_EN control */
|
|
if (!failure)
|
|
failure = pmu_enable_ext_control(1);
|
|
/* Disable force charging */
|
|
if (!failure)
|
|
failure = pmu_enable_charger(0);
|
|
|
|
/* Set NOITERM bit */
|
|
if (!failure)
|
|
failure = pmu_low_current_charging(1);
|
|
|
|
/*
|
|
* High temperature charging
|
|
* termination voltage: 2.1V
|
|
* termination current: 100%
|
|
*/
|
|
if (!failure)
|
|
failure = pmu_set_term_voltage(RANGE_T34, TERM_V2100);
|
|
if (!failure)
|
|
failure = pmu_set_term_current(RANGE_T34, TERM_I1000);
|
|
/*
|
|
* Standard temperature charging
|
|
* termination voltage: 2.1V
|
|
* termination current: 100%
|
|
*/
|
|
if (!failure)
|
|
failure = pmu_set_term_voltage(RANGE_T23, TERM_V2100);
|
|
if (!failure)
|
|
failure = pmu_set_term_current(RANGE_T23, TERM_I1000);
|
|
|
|
/*
|
|
* Ignore TPSCHROME NTC reading in T40. This is snow board specific
|
|
* setting. Check:
|
|
* http://crosbug.com/p/12221
|
|
* http://crosbug.com/p/13171
|
|
*/
|
|
if (!failure)
|
|
failure = pmu_set_term_voltage(RANGE_T40, TERM_V2100);
|
|
if (!failure)
|
|
failure = pmu_set_term_current(RANGE_T40, TERM_I1000);
|
|
|
|
/* Workaround init values before ES3 */
|
|
if (pmu_version(&ver) || ver < 3) {
|
|
/* Termination current: 75% */
|
|
if (!failure)
|
|
failure = pmu_set_term_current(RANGE_T34, TERM_I0750);
|
|
if (!failure)
|
|
failure = pmu_set_term_current(RANGE_T23, TERM_I0750);
|
|
if (!failure)
|
|
failure = pmu_set_term_current(RANGE_T40, TERM_I0750);
|
|
}
|
|
|
|
return failure ? EC_ERROR_UNKNOWN : EC_SUCCESS;
|
|
}
|