// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
/* Disable MMIO tracing to prevent excessive logging of unwanted MMIO traces */
#define __DISABLE_TRACE_MMIO__
#include <linux/acpi.h>
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/firmware.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/soc/qcom/geni-se.h>
/**
* DOC: Overview
*
* Generic Interface (GENI) Serial Engine (SE) Wrapper driver is introduced
* to manage GENI firmware based Qualcomm Universal Peripheral (QUP) Wrapper
* controller. QUP Wrapper is designed to support various serial bus protocols
* like UART, SPI, I2C, I3C, etc.
*/
/**
* DOC: Hardware description
*
* GENI based QUP is a highly-flexible and programmable module for supporting
* a wide range of serial interfaces like UART, SPI, I2C, I3C, etc. A single
* QUP module can provide upto 8 serial interfaces, using its internal
* serial engines. The actual configuration is determined by the target
* platform configuration. The protocol supported by each interface is
* determined by the firmware loaded to the serial engine. Each SE consists
* of a DMA Engine and GENI sub modules which enable serial engines to
* support FIFO and DMA modes of operation.
*
*
* +-----------------------------------------+
* |QUP Wrapper |
* | +----------------------------+ |
* --QUP & SE Clocks--> | Serial Engine N | +-IO------>
* | | ... | | Interface
* <---Clock Perf.----+ +----+-----------------------+ | |
* State Interface | | Serial Engine 1 | | |
* | | | | |
* | | | | |
* <--------AHB-------> | | | |
* | | +----+ |
* | | | |
* | | | |
* <------SE IRQ------+ +----------------------------+ |
* | |
* +-----------------------------------------+
*
* Figure 1: GENI based QUP Wrapper
*
* The GENI submodules include primary and secondary sequencers which are
* used to drive TX & RX operations. On serial interfaces that operate using
* master-slave model, primary sequencer drives both TX & RX operations. On
* serial interfaces that operate using peer-to-peer model, primary sequencer
* drives TX operation and secondary sequencer drives RX operation.
*/
/**
* DOC: Software description
*
* GENI SE Wr