linux/drivers/pci/controller/pci-aardvark.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Driver for the Aardvark PCIe controller, used on Marvell Armada
 * 3700.
 *
 * Copyright (C) 2016 Marvell
 *
 * Author: Hezi Shahmoon <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/pci-ecam.h>
#include <linux/init.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/msi.h>
#include <linux/of_address.h>
#include <linux/of_pci.h>

#include "../pci.h"
#include "../pci-bridge-emul.h"

/* PCIe core registers */
#define PCIE_CORE_DEV_ID_REG
#define PCIE_CORE_CMD_STATUS_REG
#define PCIE_CORE_DEV_REV_REG
#define PCIE_CORE_SSDEV_ID_REG
#define PCIE_CORE_PCIEXP_CAP
#define PCIE_CORE_PCIERR_CAP
#define PCIE_CORE_ERR_CAPCTL_REG
#define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX
#define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN
#define PCIE_CORE_ERR_CAPCTL_ECRC_CHCK
#define PCIE_CORE_ERR_CAPCTL_ECRC_CHCK_RCV
/* PIO registers base address and register offsets */
#define PIO_BASE_ADDR
#define PIO_CTRL
#define PIO_CTRL_TYPE_MASK
#define PIO_CTRL_ADDR_WIN_DISABLE
#define PIO_STAT
#define PIO_COMPLETION_STATUS_SHIFT
#define PIO_COMPLETION_STATUS_MASK
#define PIO_COMPLETION_STATUS_OK
#define PIO_COMPLETION_STATUS_UR
#define PIO_COMPLETION_STATUS_RRS
#define PIO_COMPLETION_STATUS_CA
#define PIO_NON_POSTED_REQ
#define PIO_ERR_STATUS
#define PIO_ADDR_LS
#define PIO_ADDR_MS
#define PIO_WR_DATA
#define PIO_WR_DATA_STRB
#define PIO_RD_DATA
#define PIO_START
#define PIO_ISR
#define PIO_ISRM

/* Aardvark Control registers */
#define CONTROL_BASE_ADDR
#define PCIE_CORE_CTRL0_REG
#define PCIE_GEN_SEL_MSK
#define PCIE_GEN_SEL_SHIFT
#define SPEED_GEN_1
#define SPEED_GEN_2
#define SPEED_GEN_3
#define IS_RC_MSK
#define IS_RC_SHIFT
#define LANE_CNT_MSK
#define LANE_CNT_SHIFT
#define LANE_COUNT_1
#define LANE_COUNT_2
#define LANE_COUNT_4
#define LANE_COUNT_8
#define LINK_TRAINING_EN
#define LEGACY_INTA
#define LEGACY_INTB
#define LEGACY_INTC
#define LEGACY_INTD
#define PCIE_CORE_CTRL1_REG
#define HOT_RESET_GEN
#define PCIE_CORE_CTRL2_REG
#define PCIE_CORE_CTRL2_RESERVED
#define PCIE_CORE_CTRL2_TD_ENABLE
#define PCIE_CORE_CTRL2_STRICT_ORDER_ENABLE
#define PCIE_CORE_CTRL2_OB_WIN_ENABLE
#define PCIE_CORE_CTRL2_MSI_ENABLE
#define PCIE_CORE_REF_CLK_REG
#define PCIE_CORE_REF_CLK_TX_ENABLE
#define PCIE_CORE_REF_CLK_RX_ENABLE
#define PCIE_MSG_LOG_REG
#define PCIE_ISR0_REG
#define PCIE_MSG_PM_PME_MASK
#define PCIE_ISR0_MASK_REG
#define PCIE_ISR0_MSI_INT_PENDING
#define PCIE_ISR0_CORR_ERR
#define PCIE_ISR0_NFAT_ERR
#define PCIE_ISR0_FAT_ERR
#define PCIE_ISR0_ERR_MASK
#define PCIE_ISR0_INTX_ASSERT(val)
#define PCIE_ISR0_INTX_DEASSERT(val)
#define PCIE_ISR0_ALL_MASK
#define PCIE_ISR1_REG
#define PCIE_ISR1_MASK_REG
#define PCIE_ISR1_POWER_STATE_CHANGE
#define PCIE_ISR1_FLUSH
#define PCIE_ISR1_INTX_ASSERT(val)
#define PCIE_ISR1_ALL_MASK
#define PCIE_MSI_ADDR_LOW_REG
#define PCIE_MSI_ADDR_HIGH_REG
#define PCIE_MSI_STATUS_REG
#define PCIE_MSI_MASK_REG
#define PCIE_MSI_ALL_MASK
#define PCIE_MSI_PAYLOAD_REG
#define PCIE_MSI_DATA_MASK

/* PCIe window configuration */
#define OB_WIN_BASE_ADDR
#define OB_WIN_BLOCK_SIZE
#define OB_WIN_COUNT
#define OB_WIN_REG_ADDR(win, offset)
#define OB_WIN_MATCH_LS(win)
#define OB_WIN_ENABLE
#define OB_WIN_MATCH_MS(win)
#define OB_WIN_REMAP_LS(win)
#define OB_WIN_REMAP_MS(win)
#define OB_WIN_MASK_LS(win)
#define OB_WIN_MASK_MS(win)
#define OB_WIN_ACTIONS(win)
#define OB_WIN_DEFAULT_ACTIONS
#define OB_WIN_FUNC_NUM_MASK
#define OB_WIN_FUNC_NUM_SHIFT
#define OB_WIN_FUNC_NUM_ENABLE
#define OB_WIN_BUS_NUM_BITS_MASK
#define OB_WIN_BUS_NUM_BITS_SHIFT
#define OB_WIN_MSG_CODE_ENABLE
#define OB_WIN_MSG_CODE_MASK
#define OB_WIN_MSG_CODE_SHIFT
#define OB_WIN_MSG_PAYLOAD_LEN
#define OB_WIN_ATTR_ENABLE
#define OB_WIN_ATTR_TC_MASK
#define OB_WIN_ATTR_TC_SHIFT
#define OB_WIN_ATTR_RELAXED
#define OB_WIN_ATTR_NOSNOOP
#define OB_WIN_ATTR_POISON
#define OB_WIN_ATTR_IDO
#define OB_WIN_TYPE_MASK
#define OB_WIN_TYPE_SHIFT
#define OB_WIN_TYPE_MEM
#define OB_WIN_TYPE_IO
#define OB_WIN_TYPE_CONFIG_TYPE0
#define OB_WIN_TYPE_CONFIG_TYPE1
#define OB_WIN_TYPE_MSG

/* LMI registers base address and register offsets */
#define LMI_BASE_ADDR
#define CFG_REG
#define LTSSM_SHIFT
#define LTSSM_MASK
#define RC_BAR_CONFIG

/* LTSSM values in CFG_REG */
enum {};

#define VENDOR_ID_REG

/* PCIe core controller registers */
#define CTRL_CORE_BASE_ADDR
#define CTRL_CONFIG_REG
#define CTRL_MODE_SHIFT
#define CTRL_MODE_MASK
#define PCIE_CORE_MODE_DIRECT
#define PCIE_CORE_MODE_COMMAND

/* PCIe Central Interrupts Registers */
#define CENTRAL_INT_BASE_ADDR
#define HOST_CTRL_INT_STATUS_REG
#define HOST_CTRL_INT_MASK_REG
#define PCIE_IRQ_CMDQ_INT
#define PCIE_IRQ_MSI_STATUS_INT
#define PCIE_IRQ_CMD_SENT_DONE
#define PCIE_IRQ_DMA_INT
#define PCIE_IRQ_IB_DXFERDONE
#define PCIE_IRQ_OB_DXFERDONE
#define PCIE_IRQ_OB_RXFERDONE
#define PCIE_IRQ_COMPQ_INT
#define PCIE_IRQ_DIR_RD_DDR_DET
#define PCIE_IRQ_DIR_WR_DDR_DET
#define PCIE_IRQ_CORE_INT
#define PCIE_IRQ_CORE_INT_PIO
#define PCIE_IRQ_DPMU_INT
#define PCIE_IRQ_PCIE_MIS_INT
#define PCIE_IRQ_MSI_INT1_DET
#define PCIE_IRQ_MSI_INT2_DET
#define PCIE_IRQ_RC_DBELL_DET
#define PCIE_IRQ_EP_STATUS
#define PCIE_IRQ_ALL_MASK
#define PCIE_IRQ_ENABLE_INTS_MASK

/* Transaction types */
#define PCIE_CONFIG_RD_TYPE0
#define PCIE_CONFIG_RD_TYPE1
#define PCIE_CONFIG_WR_TYPE0
#define PCIE_CONFIG_WR_TYPE1

#define PIO_RETRY_CNT
#define PIO_RETRY_DELAY

#define LINK_WAIT_MAX_RETRIES
#define LINK_WAIT_USLEEP_MIN
#define LINK_WAIT_USLEEP_MAX
#define RETRAIN_WAIT_MAX_RETRIES
#define RETRAIN_WAIT_USLEEP_US

#define MSI_IRQ_NUM

#define CFG_RD_RRS_VAL

struct advk_pcie {};

static inline void advk_writel(struct advk_pcie *pcie, u32 val, u64 reg)
{}

static inline u32 advk_readl(struct advk_pcie *pcie, u64 reg)
{}

static u8 advk_pcie_ltssm_state(struct advk_pcie *pcie)
{}

static inline bool advk_pcie_link_up(struct advk_pcie *pcie)
{}

static inline bool advk_pcie_link_active(struct advk_pcie *pcie)
{}

static inline bool advk_pcie_link_training(struct advk_pcie *pcie)
{}

static int advk_pcie_wait_for_link(struct advk_pcie *pcie)
{}

static void advk_pcie_wait_for_retrain(struct advk_pcie *pcie)
{}

static void advk_pcie_issue_perst(struct advk_pcie *pcie)
{}

static void advk_pcie_train_link(struct advk_pcie *pcie)
{}

/*
 * Set PCIe address window register which could be used for memory
 * mapping.
 */
static void advk_pcie_set_ob_win(struct advk_pcie *pcie, u8 win_num,
				 phys_addr_t match, phys_addr_t remap,
				 phys_addr_t mask, u32 actions)
{}

static void advk_pcie_disable_ob_win(struct advk_pcie *pcie, u8 win_num)
{}

static void advk_pcie_setup_hw(struct advk_pcie *pcie)
{}

static int advk_pcie_check_pio_status(struct advk_pcie *pcie, bool allow_rrs, u32 *val)
{}

static int advk_pcie_wait_pio(struct advk_pcie *pcie)
{}

static pci_bridge_emul_read_status_t
advk_pci_bridge_emul_base_conf_read(struct pci_bridge_emul *bridge,
				    int reg, u32 *value)
{}

static void
advk_pci_bridge_emul_base_conf_write(struct pci_bridge_emul *bridge,
				     int reg, u32 old, u32 new, u32 mask)
{}

static pci_bridge_emul_read_status_t
advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,
				    int reg, u32 *value)
{}

static void
advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge,
				     int reg, u32 old, u32 new, u32 mask)
{}

static pci_bridge_emul_read_status_t
advk_pci_bridge_emul_ext_conf_read(struct pci_bridge_emul *bridge,
				   int reg, u32 *value)
{}

static void
advk_pci_bridge_emul_ext_conf_write(struct pci_bridge_emul *bridge,
				    int reg, u32 old, u32 new, u32 mask)
{}

static const struct pci_bridge_emul_ops advk_pci_bridge_emul_ops =;

/*
 * Initialize the configuration space of the PCI-to-PCI bridge
 * associated with the given PCIe interface.
 */
static int advk_sw_pci_bridge_init(struct advk_pcie *pcie)
{}

static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
				  int devfn)
{}

static bool advk_pcie_pio_is_running(struct advk_pcie *pcie)
{}

static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
			     int where, int size, u32 *val)
{}

static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
				int where, int size, u32 val)
{}

static struct pci_ops advk_pcie_ops =;

static void advk_msi_irq_compose_msi_msg(struct irq_data *data,
					 struct msi_msg *msg)
{}

static void advk_msi_irq_mask(struct irq_data *d)
{}

static void advk_msi_irq_unmask(struct irq_data *d)
{}

static void advk_msi_top_irq_mask(struct irq_data *d)
{}

static void advk_msi_top_irq_unmask(struct irq_data *d)
{}

static struct irq_chip advk_msi_bottom_irq_chip =;

static int advk_msi_irq_domain_alloc(struct irq_domain *domain,
				     unsigned int virq,
				     unsigned int nr_irqs, void *args)
{}

static void advk_msi_irq_domain_free(struct irq_domain *domain,
				     unsigned int virq, unsigned int nr_irqs)
{}

static const struct irq_domain_ops advk_msi_domain_ops =;

static void advk_pcie_irq_mask(struct irq_data *d)
{}

static void advk_pcie_irq_unmask(struct irq_data *d)
{}

static int advk_pcie_irq_map(struct irq_domain *h,
			     unsigned int virq, irq_hw_number_t hwirq)
{}

static const struct irq_domain_ops advk_pcie_irq_domain_ops =;

static struct irq_chip advk_msi_irq_chip =;

static struct msi_domain_info advk_msi_domain_info =;

static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie)
{}

static void advk_pcie_remove_msi_irq_domain(struct advk_pcie *pcie)
{}

static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
{}

static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie)
{}

static struct irq_chip advk_rp_irq_chip =;

static int advk_pcie_rp_irq_map(struct irq_domain *h,
				unsigned int virq, irq_hw_number_t hwirq)
{}

static const struct irq_domain_ops advk_pcie_rp_irq_domain_ops =;

static int advk_pcie_init_rp_irq_domain(struct advk_pcie *pcie)
{}

static void advk_pcie_remove_rp_irq_domain(struct advk_pcie *pcie)
{}

static void advk_pcie_handle_pme(struct advk_pcie *pcie)
{}

static void advk_pcie_handle_msi(struct advk_pcie *pcie)
{}

static void advk_pcie_handle_int(struct advk_pcie *pcie)
{}

static irqreturn_t advk_pcie_irq_handler(int irq, void *arg)
{}

static int advk_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
{}

static void advk_pcie_disable_phy(struct advk_pcie *pcie)
{}

static int advk_pcie_enable_phy(struct advk_pcie *pcie)
{}

static int advk_pcie_setup_phy(struct advk_pcie *pcie)
{}

static int advk_pcie_probe(struct platform_device *pdev)
{}

static void advk_pcie_remove(struct platform_device *pdev)
{}

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

static struct platform_driver advk_pcie_driver =;
module_platform_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();