18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Freescale MPC85xx/MPC86xx RapidIO support 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2009 Sysgo AG 68c2ecf20Sopenharmony_ci * Thomas Moll <thomas.moll@sysgo.com> 78c2ecf20Sopenharmony_ci * - fixed maintenance access routines, check for aligned access 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Copyright 2009 Integrated Device Technology, Inc. 108c2ecf20Sopenharmony_ci * Alex Bounine <alexandre.bounine@idt.com> 118c2ecf20Sopenharmony_ci * - Added Port-Write message handling 128c2ecf20Sopenharmony_ci * - Added Machine Check exception handling 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * Copyright (C) 2007, 2008, 2010, 2011 Freescale Semiconductor, Inc. 158c2ecf20Sopenharmony_ci * Zhang Wei <wei.zhang@freescale.com> 168c2ecf20Sopenharmony_ci * Lian Minghuan-B31939 <Minghuan.Lian@freescale.com> 178c2ecf20Sopenharmony_ci * Liu Gang <Gang.Liu@freescale.com> 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * Copyright 2005 MontaVista Software, Inc. 208c2ecf20Sopenharmony_ci * Matt Porter <mporter@kernel.crashing.org> 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#ifndef __FSL_RIO_H 248c2ecf20Sopenharmony_ci#define __FSL_RIO_H 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include <linux/rio.h> 278c2ecf20Sopenharmony_ci#include <linux/rio_drv.h> 288c2ecf20Sopenharmony_ci#include <linux/kfifo.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define RIO_REGS_WIN(mport) (((struct rio_priv *)(mport->priv))->regs_win) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define RIO_MAINT_WIN_SIZE 0x400000 338c2ecf20Sopenharmony_ci#define RIO_LTLEDCSR 0x0608 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_EN 0x80000000 368c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_TFLOWLV 0x08000000 /* highest priority level */ 378c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_PCI 0x02000000 /* PCI window */ 388c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_NREAD 0x00040000 /* NREAD */ 398c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_MAINTRD 0x00070000 /* maintenance read */ 408c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_RES 0x00002000 /* wrtpy: reserved */ 418c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_MAINTWD 0x00007000 428c2ecf20Sopenharmony_ci#define DOORBELL_ROWAR_SIZE 0x0000000b /* window size is 4k */ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define RIO_ATMU_REGS_PORT1_OFFSET 0x10c00 458c2ecf20Sopenharmony_ci#define RIO_ATMU_REGS_PORT2_OFFSET 0x10e00 468c2ecf20Sopenharmony_ci#define RIO_S_DBELL_REGS_OFFSET 0x13400 478c2ecf20Sopenharmony_ci#define RIO_S_PW_REGS_OFFSET 0x134e0 488c2ecf20Sopenharmony_ci#define RIO_ATMU_REGS_DBELL_OFFSET 0x10C40 498c2ecf20Sopenharmony_ci#define RIO_INB_ATMU_REGS_PORT1_OFFSET 0x10d60 508c2ecf20Sopenharmony_ci#define RIO_INB_ATMU_REGS_PORT2_OFFSET 0x10f60 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define MAX_MSG_UNIT_NUM 2 538c2ecf20Sopenharmony_ci#define MAX_PORT_NUM 4 548c2ecf20Sopenharmony_ci#define RIO_INB_ATMU_COUNT 4 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistruct rio_atmu_regs { 578c2ecf20Sopenharmony_ci u32 rowtar; 588c2ecf20Sopenharmony_ci u32 rowtear; 598c2ecf20Sopenharmony_ci u32 rowbar; 608c2ecf20Sopenharmony_ci u32 pad1; 618c2ecf20Sopenharmony_ci u32 rowar; 628c2ecf20Sopenharmony_ci u32 pad2[3]; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct rio_inb_atmu_regs { 668c2ecf20Sopenharmony_ci u32 riwtar; 678c2ecf20Sopenharmony_ci u32 pad1; 688c2ecf20Sopenharmony_ci u32 riwbar; 698c2ecf20Sopenharmony_ci u32 pad2; 708c2ecf20Sopenharmony_ci u32 riwar; 718c2ecf20Sopenharmony_ci u32 pad3[3]; 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistruct rio_dbell_ring { 758c2ecf20Sopenharmony_ci void *virt; 768c2ecf20Sopenharmony_ci dma_addr_t phys; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistruct rio_port_write_msg { 808c2ecf20Sopenharmony_ci void *virt; 818c2ecf20Sopenharmony_ci dma_addr_t phys; 828c2ecf20Sopenharmony_ci u32 msg_count; 838c2ecf20Sopenharmony_ci u32 err_count; 848c2ecf20Sopenharmony_ci u32 discard_count; 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistruct fsl_rio_dbell { 888c2ecf20Sopenharmony_ci struct rio_mport *mport[MAX_PORT_NUM]; 898c2ecf20Sopenharmony_ci struct device *dev; 908c2ecf20Sopenharmony_ci struct rio_dbell_regs __iomem *dbell_regs; 918c2ecf20Sopenharmony_ci struct rio_dbell_ring dbell_ring; 928c2ecf20Sopenharmony_ci int bellirq; 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistruct fsl_rio_pw { 968c2ecf20Sopenharmony_ci struct rio_mport *mport[MAX_PORT_NUM]; 978c2ecf20Sopenharmony_ci struct device *dev; 988c2ecf20Sopenharmony_ci struct rio_pw_regs __iomem *pw_regs; 998c2ecf20Sopenharmony_ci struct rio_port_write_msg port_write_msg; 1008c2ecf20Sopenharmony_ci int pwirq; 1018c2ecf20Sopenharmony_ci struct work_struct pw_work; 1028c2ecf20Sopenharmony_ci struct kfifo pw_fifo; 1038c2ecf20Sopenharmony_ci spinlock_t pw_fifo_lock; 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistruct rio_priv { 1078c2ecf20Sopenharmony_ci struct device *dev; 1088c2ecf20Sopenharmony_ci void __iomem *regs_win; 1098c2ecf20Sopenharmony_ci struct rio_atmu_regs __iomem *atmu_regs; 1108c2ecf20Sopenharmony_ci struct rio_atmu_regs __iomem *maint_atmu_regs; 1118c2ecf20Sopenharmony_ci struct rio_inb_atmu_regs __iomem *inb_atmu_regs; 1128c2ecf20Sopenharmony_ci void __iomem *maint_win; 1138c2ecf20Sopenharmony_ci void *rmm_handle; /* RapidIO message manager(unit) Handle */ 1148c2ecf20Sopenharmony_ci}; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciextern void __iomem *rio_regs_win; 1178c2ecf20Sopenharmony_ciextern void __iomem *rmu_regs_win; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ciextern resource_size_t rio_law_start; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciextern struct fsl_rio_dbell *dbell; 1228c2ecf20Sopenharmony_ciextern struct fsl_rio_pw *pw; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ciextern int fsl_rio_setup_rmu(struct rio_mport *mport, 1258c2ecf20Sopenharmony_ci struct device_node *node); 1268c2ecf20Sopenharmony_ciextern int fsl_rio_port_write_init(struct fsl_rio_pw *pw); 1278c2ecf20Sopenharmony_ciextern int fsl_rio_pw_enable(struct rio_mport *mport, int enable); 1288c2ecf20Sopenharmony_ciextern void fsl_rio_port_error_handler(int offset); 1298c2ecf20Sopenharmony_ciextern int fsl_rio_doorbell_init(struct fsl_rio_dbell *dbell); 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ciextern int fsl_rio_doorbell_send(struct rio_mport *mport, 1328c2ecf20Sopenharmony_ci int index, u16 destid, u16 data); 1338c2ecf20Sopenharmony_ciextern int fsl_add_outb_message(struct rio_mport *mport, 1348c2ecf20Sopenharmony_ci struct rio_dev *rdev, 1358c2ecf20Sopenharmony_ci int mbox, void *buffer, size_t len); 1368c2ecf20Sopenharmony_ciextern int fsl_open_outb_mbox(struct rio_mport *mport, 1378c2ecf20Sopenharmony_ci void *dev_id, int mbox, int entries); 1388c2ecf20Sopenharmony_ciextern void fsl_close_outb_mbox(struct rio_mport *mport, int mbox); 1398c2ecf20Sopenharmony_ciextern int fsl_open_inb_mbox(struct rio_mport *mport, 1408c2ecf20Sopenharmony_ci void *dev_id, int mbox, int entries); 1418c2ecf20Sopenharmony_ciextern void fsl_close_inb_mbox(struct rio_mport *mport, int mbox); 1428c2ecf20Sopenharmony_ciextern int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf); 1438c2ecf20Sopenharmony_ciextern void *fsl_get_inb_message(struct rio_mport *mport, int mbox); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci#endif 146