linux/drivers/spi/spi-mtk-nor.c

// SPDX-License-Identifier: GPL-2.0
//
// Mediatek SPI NOR controller driver
//
// Copyright (C) 2020 Chuanhong Guo <[email protected]>

#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi-mem.h>
#include <linux/string.h>

#define DRIVER_NAME

#define MTK_NOR_REG_CMD
#define MTK_NOR_CMD_WRITE
#define MTK_NOR_CMD_PROGRAM
#define MTK_NOR_CMD_READ
#define MTK_NOR_CMD_MASK

#define MTK_NOR_REG_PRG_CNT
#define MTK_NOR_PRG_CNT_MAX
#define MTK_NOR_REG_RDATA

#define MTK_NOR_REG_RADR0
#define MTK_NOR_REG_RADR(n)
#define MTK_NOR_REG_RADR3

#define MTK_NOR_REG_WDATA

#define MTK_NOR_REG_PRGDATA0
#define MTK_NOR_REG_PRGDATA(n)
#define MTK_NOR_REG_PRGDATA_MAX

#define MTK_NOR_REG_SHIFT0
#define MTK_NOR_REG_SHIFT(n)
#define MTK_NOR_REG_SHIFT_MAX

#define MTK_NOR_REG_CFG1
#define MTK_NOR_FAST_READ

#define MTK_NOR_REG_CFG2
#define MTK_NOR_WR_CUSTOM_OP_EN
#define MTK_NOR_WR_BUF_EN

#define MTK_NOR_REG_PP_DATA

#define MTK_NOR_REG_IRQ_STAT
#define MTK_NOR_REG_IRQ_EN
#define MTK_NOR_IRQ_DMA
#define MTK_NOR_IRQ_MASK

#define MTK_NOR_REG_CFG3
#define MTK_NOR_DISABLE_WREN
#define MTK_NOR_DISABLE_SR_POLL

#define MTK_NOR_REG_WP
#define MTK_NOR_ENABLE_SF_CMD

#define MTK_NOR_REG_BUSCFG
#define MTK_NOR_4B_ADDR
#define MTK_NOR_QUAD_ADDR
#define MTK_NOR_QUAD_READ
#define MTK_NOR_DUAL_ADDR
#define MTK_NOR_DUAL_READ
#define MTK_NOR_BUS_MODE_MASK

#define MTK_NOR_REG_DMA_CTL
#define MTK_NOR_DMA_START

#define MTK_NOR_REG_DMA_FADR
#define MTK_NOR_REG_DMA_DADR
#define MTK_NOR_REG_DMA_END_DADR
#define MTK_NOR_REG_CG_DIS
#define MTK_NOR_SFC_SW_RST

#define MTK_NOR_REG_DMA_DADR_HB
#define MTK_NOR_REG_DMA_END_DADR_HB

#define MTK_NOR_PRG_MAX_SIZE
// Reading DMA src/dst addresses have to be 16-byte aligned
#define MTK_NOR_DMA_ALIGN
#define MTK_NOR_DMA_ALIGN_MASK
// and we allocate a bounce buffer if destination address isn't aligned.
#define MTK_NOR_BOUNCE_BUF_SIZE

// Buffered page program can do one 128-byte transfer
#define MTK_NOR_PP_SIZE

#define CLK_TO_US(sp, clkcnt)

struct mtk_nor_caps {};

struct mtk_nor {};

static inline void mtk_nor_rmw(struct mtk_nor *sp, u32 reg, u32 set, u32 clr)
{}

static inline int mtk_nor_cmd_exec(struct mtk_nor *sp, u32 cmd, ulong clk)
{}

static void mtk_nor_reset(struct mtk_nor *sp)
{}

static void mtk_nor_set_addr(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static bool need_bounce(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static bool mtk_nor_match_read(const struct spi_mem_op *op)
{}

static bool mtk_nor_match_prg(const struct spi_mem_op *op)
{}

static void mtk_nor_adj_prg_size(struct spi_mem_op *op)
{}

static int mtk_nor_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{}

static bool mtk_nor_supports_op(struct spi_mem *mem,
				const struct spi_mem_op *op)
{}

static void mtk_nor_setup_bus(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static int mtk_nor_dma_exec(struct mtk_nor *sp, u32 from, unsigned int length,
			    dma_addr_t dma_addr)
{}

static int mtk_nor_read_bounce(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static int mtk_nor_read_dma(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static int mtk_nor_read_pio(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static int mtk_nor_setup_write_buffer(struct mtk_nor *sp, bool on)
{}

static int mtk_nor_pp_buffered(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static int mtk_nor_pp_unbuffered(struct mtk_nor *sp,
				 const struct spi_mem_op *op)
{}

static int mtk_nor_spi_mem_prg(struct mtk_nor *sp, const struct spi_mem_op *op)
{}

static int mtk_nor_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{}

static int mtk_nor_setup(struct spi_device *spi)
{}

static int mtk_nor_transfer_one_message(struct spi_controller *host,
					struct spi_message *m)
{}

static void mtk_nor_disable_clk(struct mtk_nor *sp)
{}

static int mtk_nor_enable_clk(struct mtk_nor *sp)
{}

static void mtk_nor_init(struct mtk_nor *sp)
{}

static irqreturn_t mtk_nor_irq_handler(int irq, void *data)
{}

static size_t mtk_max_msg_size(struct spi_device *spi)
{}

static const struct spi_controller_mem_ops mtk_nor_mem_ops =;

static const struct mtk_nor_caps mtk_nor_caps_mt8173 =;

static const struct mtk_nor_caps mtk_nor_caps_mt8186 =;

static const struct mtk_nor_caps mtk_nor_caps_mt8192 =;

static const struct of_device_id mtk_nor_match[] =;
MODULE_DEVICE_TABLE(of, mtk_nor_match);

static int mtk_nor_probe(struct platform_device *pdev)
{}

static void mtk_nor_remove(struct platform_device *pdev)
{}

static int __maybe_unused mtk_nor_runtime_suspend(struct device *dev)
{}

static int __maybe_unused mtk_nor_runtime_resume(struct device *dev)
{}

static int __maybe_unused mtk_nor_suspend(struct device *dev)
{}

static int __maybe_unused mtk_nor_resume(struct device *dev)
{}

static const struct dev_pm_ops mtk_nor_pm_ops =;

static struct platform_driver mtk_nor_driver =;

module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_ALIAS();