mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 23:15:24 +07:00
47ebe00b68
- Add support in dmaengine core to do device node checks for DT devices and update bunch of drivers to use that and remove open coding from drivers - New driver/driver support for new hardware, namely: - MediaTek UART APDMA - Freescale i.mx7ulp edma2 - Synopsys eDMA IP core version 0 - Allwinner H6 DMA - Updates to axi-dma and support for interleaved cyclic transfers - Greg's debugfs return value check removals on drivers - Updates to stm32-dma, hsu, dw, pl330, tegra drivers -----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJdLKxYAAoJEHwUBw8lI4NHsH8P/AqYZpUlLthe5L4qItzM1Uf0 HqxsJYs0xworjSRml8uptx/TzjIgJnJfEk2PV5VA+0zJNz/HnH7lDH85wKDx1Ydl AatUuyAFRO3GZOup/hY0AEIPhoIMdg/3zS2aapjJmaEZCVK2eVKmcj0KMvO5g0cw tsmXm3O0xd2Na1ToslNyYgFfCn8ortuAeoKiXJxhivMbGjRfw4LW/RPgS17Vspvh mEuxNXFWAZ+DorgPF5BmDPZ+LXcGgCXGNIoj64W+VHaXU5yXnlky+6/0f7cEcFEd yl3hjXVwyAq5zIItIOmiuozZidi5yfoizXg4S2ZD3P4xXKZ5OZ9Gf/0SMyXUIErU pwGxo6ZgsBcEpAHtqySELQedttttID+jYYeWU6oDr2LOy3W3F7AHOEGg9l9ZllLh gRdIoz3PrMK1wy/9Ytl37xklZyBk+HJLkeoIAvjrNgNJ1YRKqcysUCwsmqO7SG3N HnIGx74sG8ChljT/yX5pElq3ip6qLdb4pJcsfxKJ9VSxsTZ3JNINGNQtvI19hKR/ 6sn/c1Rb5/S1WxINGr+2FxChxXF8OESCN6GIEu6mNYVBzQnNPzwgPxfAGCqdoOOH mqXXgYNePMaBGYXBkdgvP1CnqenRRmTYo/1L4QmI4Mve4xpd5zhx5cZt9FlQJ2Im /hVT8gZ6bIrutsVOy4rg =R+aC -----END PGP SIGNATURE----- Merge tag 'dmaengine-5.3-rc1' of git://git.infradead.org/users/vkoul/slave-dma Pull dmaengine updates from Vinod Koul: - Add support in dmaengine core to do device node checks for DT devices and update bunch of drivers to use that and remove open coding from drivers - New driver/driver support for new hardware, namely: - MediaTek UART APDMA - Freescale i.mx7ulp edma2 - Synopsys eDMA IP core version 0 - Allwinner H6 DMA - Updates to axi-dma and support for interleaved cyclic transfers - Greg's debugfs return value check removals on drivers - Updates to stm32-dma, hsu, dw, pl330, tegra drivers * tag 'dmaengine-5.3-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (68 commits) dmaengine: Revert "dmaengine: fsl-edma: add i.mx7ulp edma2 version support" dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback Documentation: dmaengine: clean up description of dmatest usage dmaengine: tegra210-adma: remove PM_CLK dependency dmaengine: fsl-edma: add i.mx7ulp edma2 version support dt-bindings: dma: fsl-edma: add new i.mx7ulp-edma dmaengine: fsl-edma-common: version check for v2 instead dmaengine: fsl-edma-common: move dmamux register to another single function dmaengine: fsl-edma: add drvdata for fsl-edma dmaengine: Revert "dmaengine: fsl-edma: support little endian for edma driver" dmaengine: rcar-dmac: Reject zero-length slave DMA requests dmaengine: dw: Enable iDMA 32-bit on Intel Elkhart Lake dmaengine: dw-edma: fix semicolon.cocci warnings dmaengine: sh: usb-dmac: Use [] to denote a flexible array member dmaengine: dmatest: timeout value of -1 should specify infinite wait dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit dmaengine: fsl-edma: support little endian for edma driver dmaengine: hsu: Revert "set HSU_CH_MTSR to memory width" dmagengine: pl330: add code to get reset property dt-bindings: pl330: document the optional resets property ...
168 lines
4.1 KiB
C
168 lines
4.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* Based on drivers/misc/eeprom/sunxi_sid.c
|
|
*/
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/clk.h>
|
|
#include <linux/completion.h>
|
|
#include <linux/dmaengine.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/err.h>
|
|
#include <linux/io.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/random.h>
|
|
|
|
#include <soc/tegra/fuse.h>
|
|
|
|
#include "fuse.h"
|
|
|
|
#define FUSE_BEGIN 0x100
|
|
#define FUSE_UID_LOW 0x08
|
|
#define FUSE_UID_HIGH 0x0c
|
|
|
|
static u32 tegra20_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset)
|
|
{
|
|
return readl_relaxed(fuse->base + FUSE_BEGIN + offset);
|
|
}
|
|
|
|
static void apb_dma_complete(void *args)
|
|
{
|
|
struct tegra_fuse *fuse = args;
|
|
|
|
complete(&fuse->apbdma.wait);
|
|
}
|
|
|
|
static u32 tegra20_fuse_read(struct tegra_fuse *fuse, unsigned int offset)
|
|
{
|
|
unsigned long flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
|
|
struct dma_async_tx_descriptor *dma_desc;
|
|
unsigned long time_left;
|
|
u32 value = 0;
|
|
int err;
|
|
|
|
mutex_lock(&fuse->apbdma.lock);
|
|
|
|
fuse->apbdma.config.src_addr = fuse->phys + FUSE_BEGIN + offset;
|
|
|
|
err = dmaengine_slave_config(fuse->apbdma.chan, &fuse->apbdma.config);
|
|
if (err)
|
|
goto out;
|
|
|
|
dma_desc = dmaengine_prep_slave_single(fuse->apbdma.chan,
|
|
fuse->apbdma.phys,
|
|
sizeof(u32), DMA_DEV_TO_MEM,
|
|
flags);
|
|
if (!dma_desc)
|
|
goto out;
|
|
|
|
dma_desc->callback = apb_dma_complete;
|
|
dma_desc->callback_param = fuse;
|
|
|
|
reinit_completion(&fuse->apbdma.wait);
|
|
|
|
clk_prepare_enable(fuse->clk);
|
|
|
|
dmaengine_submit(dma_desc);
|
|
dma_async_issue_pending(fuse->apbdma.chan);
|
|
time_left = wait_for_completion_timeout(&fuse->apbdma.wait,
|
|
msecs_to_jiffies(50));
|
|
|
|
if (WARN(time_left == 0, "apb read dma timed out"))
|
|
dmaengine_terminate_all(fuse->apbdma.chan);
|
|
else
|
|
value = *fuse->apbdma.virt;
|
|
|
|
clk_disable_unprepare(fuse->clk);
|
|
|
|
out:
|
|
mutex_unlock(&fuse->apbdma.lock);
|
|
return value;
|
|
}
|
|
|
|
static bool dma_filter(struct dma_chan *chan, void *filter_param)
|
|
{
|
|
struct device_node *np = chan->device->dev->of_node;
|
|
|
|
return of_device_is_compatible(np, "nvidia,tegra20-apbdma");
|
|
}
|
|
|
|
static int tegra20_fuse_probe(struct tegra_fuse *fuse)
|
|
{
|
|
dma_cap_mask_t mask;
|
|
|
|
dma_cap_zero(mask);
|
|
dma_cap_set(DMA_SLAVE, mask);
|
|
|
|
fuse->apbdma.chan = dma_request_channel(mask, dma_filter, NULL);
|
|
if (!fuse->apbdma.chan)
|
|
return -EPROBE_DEFER;
|
|
|
|
fuse->apbdma.virt = dma_alloc_coherent(fuse->dev, sizeof(u32),
|
|
&fuse->apbdma.phys,
|
|
GFP_KERNEL);
|
|
if (!fuse->apbdma.virt) {
|
|
dma_release_channel(fuse->apbdma.chan);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
fuse->apbdma.config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
|
fuse->apbdma.config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
|
fuse->apbdma.config.src_maxburst = 1;
|
|
fuse->apbdma.config.dst_maxburst = 1;
|
|
fuse->apbdma.config.direction = DMA_DEV_TO_MEM;
|
|
fuse->apbdma.config.device_fc = false;
|
|
|
|
init_completion(&fuse->apbdma.wait);
|
|
mutex_init(&fuse->apbdma.lock);
|
|
fuse->read = tegra20_fuse_read;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct tegra_fuse_info tegra20_fuse_info = {
|
|
.read = tegra20_fuse_read,
|
|
.size = 0x1f8,
|
|
.spare = 0x100,
|
|
};
|
|
|
|
/* Early boot code. This code is called before the devices are created */
|
|
|
|
static void __init tegra20_fuse_add_randomness(void)
|
|
{
|
|
u32 randomness[7];
|
|
|
|
randomness[0] = tegra_sku_info.sku_id;
|
|
randomness[1] = tegra_read_straps();
|
|
randomness[2] = tegra_read_chipid();
|
|
randomness[3] = tegra_sku_info.cpu_process_id << 16;
|
|
randomness[3] |= tegra_sku_info.soc_process_id;
|
|
randomness[4] = tegra_sku_info.cpu_speedo_id << 16;
|
|
randomness[4] |= tegra_sku_info.soc_speedo_id;
|
|
randomness[5] = tegra_fuse_read_early(FUSE_UID_LOW);
|
|
randomness[6] = tegra_fuse_read_early(FUSE_UID_HIGH);
|
|
|
|
add_device_randomness(randomness, sizeof(randomness));
|
|
}
|
|
|
|
static void __init tegra20_fuse_init(struct tegra_fuse *fuse)
|
|
{
|
|
fuse->read_early = tegra20_fuse_read_early;
|
|
|
|
tegra_init_revision();
|
|
fuse->soc->speedo_init(&tegra_sku_info);
|
|
tegra20_fuse_add_randomness();
|
|
}
|
|
|
|
const struct tegra_fuse_soc tegra20_fuse_soc = {
|
|
.init = tegra20_fuse_init,
|
|
.speedo_init = tegra20_init_speedo_data,
|
|
.probe = tegra20_fuse_probe,
|
|
.info = &tegra20_fuse_info,
|
|
};
|