summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2022-04-19 21:31:46 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-05 16:22:56 +0000
commit8f7ec2f4d15b811d37dddad4f25334a41fc5f113 (patch)
tree63c0f04922a8dfe9a2dea91c7db4220381914949
parent3aa77af645c9d5971271a911e3978ec6e73b9b83 (diff)
downloadchrome-ec-8f7ec2f4d15b811d37dddad4f25334a41fc5f113.tar.gz
Brask: Enable Qi charging
CPS8100 is a Qi wireless power transmitter. This patch enables it for Brask. BUG=b:191418683, b:207658344 BRANCH=Brask TEST=On Brask. /sys/class/power_supply/PCHG0/capacity, charge_type, status change as a PRx is placed on or removed from the coil. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I66df4ec473517de1707a0dbb74dd699497daeb6d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3595283 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r--board/brask/board.c25
-rw-r--r--board/brask/board.h6
-rw-r--r--board/brask/ec.tasklist1
-rw-r--r--board/brask/gpio.inc11
4 files changed, 39 insertions, 4 deletions
diff --git a/board/brask/board.c b/board/brask/board.c
index 304fe58ce6..7b22e37e29 100644
--- a/board/brask/board.c
+++ b/board/brask/board.c
@@ -2,6 +2,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include <stdbool.h>
#include "adc.h"
#include "assert.h"
@@ -16,6 +17,7 @@
#include "gpio_signal.h"
#include "power_button.h"
#include "hooks.h"
+#include "peripheral_charger.h"
#include "power.h"
#include "switch.h"
#include "throttle_ap.h"
@@ -39,6 +41,29 @@ const int usb_port_enable[USB_PORT_COUNT] = {
};
BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT);
+extern struct pchg_drv cps8100_drv;
+struct pchg pchgs[] = {
+ [0] = {
+ .cfg = &(const struct pchg_config) {
+ .drv = &cps8100_drv,
+ .i2c_port = I2C_PORT_QI,
+ .irq_pin = GPIO_QI_INT_ODL,
+ .full_percent = 96,
+ .block_size = 128,
+ },
+ .events = QUEUE_NULL(PCHG_EVENT_QUEUE_SIZE, enum pchg_event),
+ },
+};
+const int pchg_count = ARRAY_SIZE(pchgs);
+
+__override void board_pchg_power_on(int port, bool on)
+{
+ if (port == 0)
+ gpio_set_level(GPIO_EC_QI_PWR, on);
+ else
+ CPRINTS("%s: Invalid port=%d", __func__, port);
+}
+
/******************************************************************************/
int board_set_active_charge_port(int port)
diff --git a/board/brask/board.h b/board/brask/board.h
index a19af9d0a3..1599749a07 100644
--- a/board/brask/board.h
+++ b/board/brask/board.h
@@ -145,6 +145,12 @@
/* Include math_util for bitmask_uint64 used in pd_timers */
#define CONFIG_MATH_UTIL
+/* WPC/Qi charger */
+#ifdef SECTION_IS_RW
+#define CONFIG_PERIPHERAL_CHARGER
+#define CONFIG_CPS8100
+#endif
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h" /* needed by registers.h */
diff --git a/board/brask/ec.tasklist b/board/brask/ec.tasklist
index e63ed3ff86..a366e05682 100644
--- a/board/brask/ec.tasklist
+++ b/board/brask/ec.tasklist
@@ -12,6 +12,7 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS_RW(PCHG, pchg_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P2, usb_charger_task, 0, TASK_STACK_SIZE) \
diff --git a/board/brask/gpio.inc b/board/brask/gpio.inc
index 90beebe51e..5bd13beaee 100644
--- a/board/brask/gpio.inc
+++ b/board/brask/gpio.inc
@@ -34,6 +34,11 @@ GPIO_INT(USB_A0_OC_ODL, PIN(3, 1), GPIO_INPUT | GPIO_PULL_UP | GPIO
GPIO_INT(USB_A1_OC_ODL, PIN(3, 0), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A2_OC_ODL, PIN(2, 7), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A3_OC_ODL, PIN(2, 6), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt)
+#ifdef SECTION_IS_RW
+GPIO_INT(QI_INT_ODL, PIN(9, 6), GPIO_INT_FALLING, pchg_irq)
+#else
+UNIMPLEMENTED(QI_INT_ODL)
+#endif
/* CCD */
GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT)
@@ -82,10 +87,8 @@ GPIO(NFC_CARD_DET_L, PIN(A, 3), GPIO_INPUT)
GPIO(EN_NFC_BUZZER, PIN(0, 5), GPIO_OUT_LOW)
/* Wireless Charger */
-/* TODO(b/191418683): Implement Qi Driver */
-GPIO(EC_QI_PWR, PIN(D, 2), GPIO_OUT_HIGH)
-GPIO(EC_I2C_QI_RESET_L, PIN(9, 3), GPIO_OUT_HIGH)
-GPIO(EC_I2C_QI_INT_ODL, PIN(9, 6), GPIO_INPUT)
+GPIO(EC_QI_PWR, PIN(D, 2), GPIO_OUT_LOW)
+GPIO(QI_RESET_L, PIN(9, 3), GPIO_OUT_HIGH)
/* HDMI CEC */
/* TODO(b/197474873): Enable HDMI CEC */