162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Freescale MPC85xx/MPC86xx RapidIO support 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright 2009 Sysgo AG 662306a36Sopenharmony_ci * Thomas Moll <thomas.moll@sysgo.com> 762306a36Sopenharmony_ci * - fixed maintenance access routines, check for aligned access 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Copyright 2009 Integrated Device Technology, Inc. 1062306a36Sopenharmony_ci * Alex Bounine <alexandre.bounine@idt.com> 1162306a36Sopenharmony_ci * - Added Port-Write message handling 1262306a36Sopenharmony_ci * - Added Machine Check exception handling 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * Copyright (C) 2007, 2008, 2010, 2011 Freescale Semiconductor, Inc. 1562306a36Sopenharmony_ci * Zhang Wei <wei.zhang@freescale.com> 1662306a36Sopenharmony_ci * Lian Minghuan-B31939 <Minghuan.Lian@freescale.com> 1762306a36Sopenharmony_ci * Liu Gang <Gang.Liu@freescale.com> 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * Copyright 2005 MontaVista Software, Inc. 2062306a36Sopenharmony_ci * Matt Porter <mporter@kernel.crashing.org> 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#ifndef __FSL_RIO_H 2462306a36Sopenharmony_ci#define __FSL_RIO_H 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#include <linux/rio.h> 2762306a36Sopenharmony_ci#include <linux/rio_drv.h> 2862306a36Sopenharmony_ci#include <linux/kfifo.h> 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define RIO_REGS_WIN(mport) (((struct rio_priv *)(mport->priv))->regs_win) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define RIO_MAINT_WIN_SIZE 0x400000 3362306a36Sopenharmony_ci#define RIO_LTLEDCSR 0x0608 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define DOORBELL_ROWAR_EN 0x80000000 3662306a36Sopenharmony_ci#define DOORBELL_ROWAR_TFLOWLV 0x08000000 /* highest priority level */ 3762306a36Sopenharmony_ci#define DOORBELL_ROWAR_PCI 0x02000000 /* PCI window */ 3862306a36Sopenharmony_ci#define DOORBELL_ROWAR_NREAD 0x00040000 /* NREAD */ 3962306a36Sopenharmony_ci#define DOORBELL_ROWAR_MAINTRD 0x00070000 /* maintenance read */ 4062306a36Sopenharmony_ci#define DOORBELL_ROWAR_RES 0x00002000 /* wrtpy: reserved */ 4162306a36Sopenharmony_ci#define DOORBELL_ROWAR_MAINTWD 0x00007000 4262306a36Sopenharmony_ci#define DOORBELL_ROWAR_SIZE 0x0000000b /* window size is 4k */ 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define RIO_ATMU_REGS_PORT1_OFFSET 0x10c00 4562306a36Sopenharmony_ci#define RIO_ATMU_REGS_PORT2_OFFSET 0x10e00 4662306a36Sopenharmony_ci#define RIO_S_DBELL_REGS_OFFSET 0x13400 4762306a36Sopenharmony_ci#define RIO_S_PW_REGS_OFFSET 0x134e0 4862306a36Sopenharmony_ci#define RIO_ATMU_REGS_DBELL_OFFSET 0x10C40 4962306a36Sopenharmony_ci#define RIO_INB_ATMU_REGS_PORT1_OFFSET 0x10d60 5062306a36Sopenharmony_ci#define RIO_INB_ATMU_REGS_PORT2_OFFSET 0x10f60 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define MAX_MSG_UNIT_NUM 2 5362306a36Sopenharmony_ci#define MAX_PORT_NUM 4 5462306a36Sopenharmony_ci#define RIO_INB_ATMU_COUNT 4 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cistruct rio_atmu_regs { 5762306a36Sopenharmony_ci u32 rowtar; 5862306a36Sopenharmony_ci u32 rowtear; 5962306a36Sopenharmony_ci u32 rowbar; 6062306a36Sopenharmony_ci u32 pad1; 6162306a36Sopenharmony_ci u32 rowar; 6262306a36Sopenharmony_ci u32 pad2[3]; 6362306a36Sopenharmony_ci}; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_cistruct rio_inb_atmu_regs { 6662306a36Sopenharmony_ci u32 riwtar; 6762306a36Sopenharmony_ci u32 pad1; 6862306a36Sopenharmony_ci u32 riwbar; 6962306a36Sopenharmony_ci u32 pad2; 7062306a36Sopenharmony_ci u32 riwar; 7162306a36Sopenharmony_ci u32 pad3[3]; 7262306a36Sopenharmony_ci}; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_cistruct rio_dbell_ring { 7562306a36Sopenharmony_ci void *virt; 7662306a36Sopenharmony_ci dma_addr_t phys; 7762306a36Sopenharmony_ci}; 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_cistruct rio_port_write_msg { 8062306a36Sopenharmony_ci void *virt; 8162306a36Sopenharmony_ci dma_addr_t phys; 8262306a36Sopenharmony_ci u32 msg_count; 8362306a36Sopenharmony_ci u32 err_count; 8462306a36Sopenharmony_ci u32 discard_count; 8562306a36Sopenharmony_ci}; 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_cistruct fsl_rio_dbell { 8862306a36Sopenharmony_ci struct rio_mport *mport[MAX_PORT_NUM]; 8962306a36Sopenharmony_ci struct device *dev; 9062306a36Sopenharmony_ci struct rio_dbell_regs __iomem *dbell_regs; 9162306a36Sopenharmony_ci struct rio_dbell_ring dbell_ring; 9262306a36Sopenharmony_ci int bellirq; 9362306a36Sopenharmony_ci}; 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_cistruct fsl_rio_pw { 9662306a36Sopenharmony_ci struct rio_mport *mport[MAX_PORT_NUM]; 9762306a36Sopenharmony_ci struct device *dev; 9862306a36Sopenharmony_ci struct rio_pw_regs __iomem *pw_regs; 9962306a36Sopenharmony_ci struct rio_port_write_msg port_write_msg; 10062306a36Sopenharmony_ci int pwirq; 10162306a36Sopenharmony_ci struct work_struct pw_work; 10262306a36Sopenharmony_ci struct kfifo pw_fifo; 10362306a36Sopenharmony_ci spinlock_t pw_fifo_lock; 10462306a36Sopenharmony_ci}; 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_cistruct rio_priv { 10762306a36Sopenharmony_ci struct device *dev; 10862306a36Sopenharmony_ci void __iomem *regs_win; 10962306a36Sopenharmony_ci struct rio_atmu_regs __iomem *atmu_regs; 11062306a36Sopenharmony_ci struct rio_atmu_regs __iomem *maint_atmu_regs; 11162306a36Sopenharmony_ci struct rio_inb_atmu_regs __iomem *inb_atmu_regs; 11262306a36Sopenharmony_ci void __iomem *maint_win; 11362306a36Sopenharmony_ci void *rmm_handle; /* RapidIO message manager(unit) Handle */ 11462306a36Sopenharmony_ci}; 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ciextern void __iomem *rio_regs_win; 11762306a36Sopenharmony_ciextern void __iomem *rmu_regs_win; 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ciextern resource_size_t rio_law_start; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ciextern struct fsl_rio_dbell *dbell; 12262306a36Sopenharmony_ciextern struct fsl_rio_pw *pw; 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ciextern int fsl_rio_setup_rmu(struct rio_mport *mport, 12562306a36Sopenharmony_ci struct device_node *node); 12662306a36Sopenharmony_ciextern int fsl_rio_port_write_init(struct fsl_rio_pw *pw); 12762306a36Sopenharmony_ciextern int fsl_rio_pw_enable(struct rio_mport *mport, int enable); 12862306a36Sopenharmony_ciextern void fsl_rio_port_error_handler(int offset); 12962306a36Sopenharmony_ciextern int fsl_rio_doorbell_init(struct fsl_rio_dbell *dbell); 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ciextern int fsl_rio_doorbell_send(struct rio_mport *mport, 13262306a36Sopenharmony_ci int index, u16 destid, u16 data); 13362306a36Sopenharmony_ciextern int fsl_add_outb_message(struct rio_mport *mport, 13462306a36Sopenharmony_ci struct rio_dev *rdev, 13562306a36Sopenharmony_ci int mbox, void *buffer, size_t len); 13662306a36Sopenharmony_ciextern int fsl_open_outb_mbox(struct rio_mport *mport, 13762306a36Sopenharmony_ci void *dev_id, int mbox, int entries); 13862306a36Sopenharmony_ciextern void fsl_close_outb_mbox(struct rio_mport *mport, int mbox); 13962306a36Sopenharmony_ciextern int fsl_open_inb_mbox(struct rio_mport *mport, 14062306a36Sopenharmony_ci void *dev_id, int mbox, int entries); 14162306a36Sopenharmony_ciextern void fsl_close_inb_mbox(struct rio_mport *mport, int mbox); 14262306a36Sopenharmony_ciextern int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf); 14362306a36Sopenharmony_ciextern void *fsl_get_inb_message(struct rio_mport *mport, int mbox); 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci#endif 146