summaryrefslogtreecommitdiff
path: root/chip/mec1322/dma.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/mec1322/dma.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14345.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/mec1322/dma.c')
-rw-r--r--chip/mec1322/dma.c159
1 files changed, 0 insertions, 159 deletions
diff --git a/chip/mec1322/dma.c b/chip/mec1322/dma.c
deleted file mode 100644
index a6c6fed5ad..0000000000
--- a/chip/mec1322/dma.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Copyright 2014 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.
- */
-
-#include "common.h"
-#include "console.h"
-#include "dma.h"
-#include "hooks.h"
-#include "registers.h"
-#include "task.h"
-#include "timer.h"
-#include "util.h"
-
-/* Console output macros */
-#define CPUTS(outstr) cputs(CC_DMA, outstr)
-#define CPRINTS(format, args...) cprints(CC_DMA, format, ## args)
-
-mec1322_dma_chan_t *dma_get_channel(enum dma_channel channel)
-{
- mec1322_dma_regs_t *dma = MEC1322_DMA_REGS;
-
- return &dma->chan[channel];
-}
-
-void dma_disable(enum dma_channel channel)
-{
- mec1322_dma_chan_t *chan = dma_get_channel(channel);
-
- if (chan->ctrl & BIT(0))
- chan->ctrl &= ~BIT(0);
-
- if (chan->act == 1)
- chan->act = 0;
-}
-
-void dma_disable_all(void)
-{
- int ch;
- mec1322_dma_regs_t *dma;
-
- for (ch = 0; ch < MEC1322_DMAC_COUNT; ch++) {
- mec1322_dma_chan_t *chan = dma_get_channel(ch);
- /* Abort any current transfer. */
- chan->ctrl |= BIT(25);
- /* Disable the channel. */
- chan->ctrl &= ~BIT(0);
- chan->act = 0;
- }
-
- /* Soft-reset the block. */
- dma = MEC1322_DMA_REGS;
- dma->ctrl |= 0x2;
-}
-
-/**
- * Prepare a channel for use and start it
- *
- * @param chan Channel to read
- * @param count Number of bytes to transfer
- * @param periph Pointer to peripheral data register
- * @param memory Pointer to memory address for receive/transmit
- * @param flags DMA flags for the control register, normally:
- * MEC1322_DMA_INC_MEM | MEC1322_DMA_TO_DEV for tx
- * MEC1322_DMA_INC_MEM for rx
- */
-static void prepare_channel(mec1322_dma_chan_t *chan, unsigned count,
- void *periph, void *memory, unsigned flags)
-{
- int xfer_size = (flags >> 20) & 0x7;
-
- if (chan->ctrl & BIT(0))
- chan->ctrl &= ~BIT(0);
-
- chan->act |= 0x1;
- chan->dev = (uint32_t)periph;
- chan->mem_start = MEC1322_RAM_ALIAS((uint32_t)memory);
- chan->mem_end = MEC1322_RAM_ALIAS((uint32_t)memory) + xfer_size * count;
- chan->ctrl = flags;
-}
-
-void dma_go(mec1322_dma_chan_t *chan)
-{
- /* Flush data in write buffer so that DMA can get the latest data */
- asm volatile("dsb;");
-
- /* Fire it up */
- chan->ctrl |= MEC1322_DMA_RUN;
-}
-
-void dma_prepare_tx(const struct dma_option *option, unsigned count,
- const void *memory)
-{
- mec1322_dma_chan_t *chan = dma_get_channel(option->channel);
-
- /*
- * Cast away const for memory pointer; this is ok because we know
- * we're preparing the channel for transmit.
- */
- prepare_channel(chan, count, option->periph, (void *)memory,
- MEC1322_DMA_INC_MEM | MEC1322_DMA_TO_DEV |
- MEC1322_DMA_DEV(option->channel) | option->flags);
-}
-
-void dma_start_rx(const struct dma_option *option, unsigned count,
- void *memory)
-{
- mec1322_dma_chan_t *chan;
-
- chan = dma_get_channel(option->channel);
-
- prepare_channel(chan, count, option->periph, memory,
- MEC1322_DMA_INC_MEM | MEC1322_DMA_DEV(option->channel) |
- option->flags);
- dma_go(chan);
-}
-
-int dma_bytes_done(mec1322_dma_chan_t *chan, int orig_count)
-{
- int xfer_size = (chan->ctrl >> 20) & 0x7;
-
- return orig_count - (chan->mem_end - chan->mem_start) / xfer_size;
-}
-
-bool dma_is_enabled(mec1322_dma_chan_t *chan)
-{
- return (chan->ctrl & MEC1322_DMA_RUN);
-}
-
-void dma_init(void)
-{
- mec1322_dma_regs_t *dma = MEC1322_DMA_REGS;
- dma->ctrl |= 0x1;
-}
-
-int dma_wait(enum dma_channel channel)
-{
- mec1322_dma_chan_t *chan = dma_get_channel(channel);
- timestamp_t deadline;
-
- if (chan->act == 0)
- return EC_SUCCESS;
-
- deadline.val = get_time().val + DMA_TRANSFER_TIMEOUT_US;
- while (!(chan->int_status & 0x4)) {
- if (deadline.val <= get_time().val)
- return EC_ERROR_TIMEOUT;
-
- udelay(DMA_POLLING_INTERVAL_US);
- }
- return EC_SUCCESS;
-}
-
-void dma_clear_isr(enum dma_channel channel)
-{
- mec1322_dma_chan_t *chan = dma_get_channel(channel);
-
- chan->int_status |= 0x4;
-}