summaryrefslogtreecommitdiff
path: root/chip/mt_scp/mt8183/gpio.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /chip/mt_scp/mt8183/gpio.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-voshyr-14637.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'chip/mt_scp/mt8183/gpio.c')
-rw-r--r--chip/mt_scp/mt8183/gpio.c180
1 files changed, 0 insertions, 180 deletions
diff --git a/chip/mt_scp/mt8183/gpio.c b/chip/mt_scp/mt8183/gpio.c
deleted file mode 100644
index a4896aae72..0000000000
--- a/chip/mt_scp/mt8183/gpio.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* Copyright 2018 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.
- */
-
-/* GPIO module */
-
-#include "gpio.h"
-#include "hooks.h"
-#include "registers.h"
-#include "system.h"
-#include "task.h"
-#include "util.h"
-
-void gpio_set_alternate_function(uint32_t port, uint32_t mask,
- enum gpio_alternate_func func)
-{
- int bit, mode_reg_index, shift;
- uint32_t mode_bits, mode_mask;
-
- /* Up to 8 alt functions per port */
- if (func > GPIO_ALT_FUNC_7)
- return;
-
- if (func == GPIO_ALT_FUNC_NONE)
- func = GPIO_ALT_FUNC_DEFAULT;
-
- while (mask) {
- /* 32 gpio per port */
- bit = get_next_bit(&mask);
- /* 8 gpio per mode reg */
- mode_reg_index = (port << 2) | (bit >> 3);
- /*
- * b[3] - write enable(?)
- * b[2:0] - mode
- */
- shift = (bit & 7) << 2;
- mode_bits = func << shift;
- mode_mask = ~(0xf << shift);
- AP_GPIO_MODE(mode_reg_index) = (AP_GPIO_MODE(mode_reg_index) &
- mode_mask) | mode_bits;
- }
-}
-
-test_mockable int gpio_get_level(enum gpio_signal signal)
-{
- return !!(AP_GPIO_DIN(gpio_list[signal].port) &
- gpio_list[signal].mask);
-}
-
-
-void gpio_set_level(enum gpio_signal signal, int value)
-{
- if (value)
- AP_GPIO_DOUT(gpio_list[signal].port) |= gpio_list[signal].mask;
- else
- AP_GPIO_DOUT(gpio_list[signal].port) &= ~gpio_list[signal].mask;
-}
-
-void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
-{
- /* Set input/output mode */
- if (flags & GPIO_OUTPUT) {
- /* Set level before changing to output mode */
- if (flags & GPIO_HIGH)
- AP_GPIO_DOUT(port) |= mask;
- if (flags & GPIO_LOW)
- AP_GPIO_DOUT(port) &= ~mask;
- AP_GPIO_DIR(port) |= mask;
- } else {
- AP_GPIO_DIR(port) &= ~mask;
- }
-
- if (flags & (GPIO_INT_F_RISING | GPIO_INT_F_HIGH))
- SCP_EINT_POLARITY_SET[port] = mask;
-
- if (flags & (GPIO_INT_F_FALLING | GPIO_INT_F_LOW))
- SCP_EINT_POLARITY_CLR[port] = mask;
- else
- SCP_EINT_POLARITY_SET[port] = mask;
-
- /* Set sensitivity register on edge trigger */
- if (flags & (GPIO_INT_F_RISING | GPIO_INT_F_FALLING))
- SCP_EINT_SENS_SET[port] = mask;
- else
- SCP_EINT_SENS_CLR[port] = mask;
-}
-
-int gpio_get_flags_by_mask(uint32_t port, uint32_t mask)
-{
- /* TODO(b/120167145): implement get flags */
- return 0;
-}
-
-int gpio_enable_interrupt(enum gpio_signal signal)
-{
- const struct gpio_info *g = gpio_list + signal;
-
- if (signal >= GPIO_IH_COUNT || !g->mask)
- return EC_ERROR_INVAL;
-
- SCP_EINT_MASK_CLR[g->port] = g->mask;
-
- return EC_SUCCESS;
-}
-
-int gpio_disable_interrupt(enum gpio_signal signal)
-{
- const struct gpio_info *g = gpio_list + signal;
-
- if (signal >= GPIO_IH_COUNT || !g->mask)
- return EC_ERROR_INVAL;
-
- SCP_EINT_MASK_SET[g->port] = g->mask;
-
- return EC_SUCCESS;
-}
-
-int gpio_clear_pending_interrupt(enum gpio_signal signal)
-{
- const struct gpio_info *g = gpio_list + signal;
-
- if (signal >= GPIO_IH_COUNT || !g->mask)
- return EC_ERROR_INVAL;
-
- SCP_EINT_ACK[g->port] = g->mask;
-
- return EC_SUCCESS;
-}
-
-void gpio_pre_init(void)
-{
- const struct gpio_info *g = gpio_list;
- int i;
- int is_warm = system_is_reboot_warm();
-
- for (i = 0; i < GPIO_COUNT; i++, g++) {
- int flags = g->flags;
-
- if (flags & GPIO_DEFAULT)
- continue;
-
- if (is_warm)
- flags &= ~(GPIO_LOW | GPIO_HIGH);
-
- gpio_set_flags_by_mask(g->port, g->mask, flags);
- }
-}
-
-void gpio_init(void)
-{
- /* Enable EINT IRQ */
- task_enable_irq(SCP_IRQ_EINT);
-}
-DECLARE_HOOK(HOOK_INIT, gpio_init, HOOK_PRIO_DEFAULT);
-
-/* Interrupt handler */
-void __keep gpio_interrupt(void)
-{
- int bit, port;
- uint32_t pending;
- enum gpio_signal signal;
-
- for (port = 0; port <= MAX_EINT_PORT; port++) {
- pending = SCP_EINT_STATUS[port];
-
- while (pending) {
- bit = get_next_bit(&pending);
- SCP_EINT_ACK[port] = BIT(bit);
- /* Skip masked gpio */
- if (SCP_EINT_MASK_GET[port] & BIT(bit))
- continue;
- /* Call handler */
- signal = port * 32 + bit;
- if (signal < GPIO_IH_COUNT)
- gpio_irq_handlers[signal](signal);
- }
- }
-}
-DECLARE_IRQ(SCP_IRQ_EINT, gpio_interrupt, 1);