1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 26ec4bedbSLiu Gang /* 36ec4bedbSLiu Gang * Freescale MPC85xx/MPC86xx RapidIO support 46ec4bedbSLiu Gang * 56ec4bedbSLiu Gang * Copyright 2009 Sysgo AG 66ec4bedbSLiu Gang * Thomas Moll <thomas.moll@sysgo.com> 76ec4bedbSLiu Gang * - fixed maintenance access routines, check for aligned access 86ec4bedbSLiu Gang * 96ec4bedbSLiu Gang * Copyright 2009 Integrated Device Technology, Inc. 106ec4bedbSLiu Gang * Alex Bounine <alexandre.bounine@idt.com> 116ec4bedbSLiu Gang * - Added Port-Write message handling 126ec4bedbSLiu Gang * - Added Machine Check exception handling 136ec4bedbSLiu Gang * 146ec4bedbSLiu Gang * Copyright (C) 2007, 2008, 2010, 2011 Freescale Semiconductor, Inc. 156ec4bedbSLiu Gang * Zhang Wei <wei.zhang@freescale.com> 166ec4bedbSLiu Gang * Lian Minghuan-B31939 <Minghuan.Lian@freescale.com> 176ec4bedbSLiu Gang * Liu Gang <Gang.Liu@freescale.com> 186ec4bedbSLiu Gang * 196ec4bedbSLiu Gang * Copyright 2005 MontaVista Software, Inc. 206ec4bedbSLiu Gang * Matt Porter <mporter@kernel.crashing.org> 216ec4bedbSLiu Gang */ 226ec4bedbSLiu Gang 236ec4bedbSLiu Gang #ifndef __FSL_RIO_H 246ec4bedbSLiu Gang #define __FSL_RIO_H 256ec4bedbSLiu Gang 266ec4bedbSLiu Gang #include <linux/rio.h> 276ec4bedbSLiu Gang #include <linux/rio_drv.h> 286ec4bedbSLiu Gang #include <linux/kfifo.h> 296ec4bedbSLiu Gang 306ec4bedbSLiu Gang #define RIO_REGS_WIN(mport) (((struct rio_priv *)(mport->priv))->regs_win) 316ec4bedbSLiu Gang 326ec4bedbSLiu Gang #define RIO_MAINT_WIN_SIZE 0x400000 336ec4bedbSLiu Gang #define RIO_LTLEDCSR 0x0608 346ec4bedbSLiu Gang 35abc3aeaeSLiu Gang #define DOORBELL_ROWAR_EN 0x80000000 36abc3aeaeSLiu Gang #define DOORBELL_ROWAR_TFLOWLV 0x08000000 /* highest priority level */ 37abc3aeaeSLiu Gang #define DOORBELL_ROWAR_PCI 0x02000000 /* PCI window */ 38abc3aeaeSLiu Gang #define DOORBELL_ROWAR_NREAD 0x00040000 /* NREAD */ 39abc3aeaeSLiu Gang #define DOORBELL_ROWAR_MAINTRD 0x00070000 /* maintenance read */ 40a0837876SAlexandre Belloni #define DOORBELL_ROWAR_RES 0x00002000 /* wrtpy: reserved */ 41abc3aeaeSLiu Gang #define DOORBELL_ROWAR_MAINTWD 0x00007000 42abc3aeaeSLiu Gang #define DOORBELL_ROWAR_SIZE 0x0000000b /* window size is 4k */ 43abc3aeaeSLiu Gang 44abc3aeaeSLiu Gang #define RIO_ATMU_REGS_PORT1_OFFSET 0x10c00 45abc3aeaeSLiu Gang #define RIO_ATMU_REGS_PORT2_OFFSET 0x10e00 46abc3aeaeSLiu Gang #define RIO_S_DBELL_REGS_OFFSET 0x13400 47abc3aeaeSLiu Gang #define RIO_S_PW_REGS_OFFSET 0x134e0 48abc3aeaeSLiu Gang #define RIO_ATMU_REGS_DBELL_OFFSET 0x10C40 49e6a546fdSMartijn de Gouw #define RIO_INB_ATMU_REGS_PORT1_OFFSET 0x10d60 50e6a546fdSMartijn de Gouw #define RIO_INB_ATMU_REGS_PORT2_OFFSET 0x10f60 51abc3aeaeSLiu Gang 52abc3aeaeSLiu Gang #define MAX_MSG_UNIT_NUM 2 53abc3aeaeSLiu Gang #define MAX_PORT_NUM 4 54e6a546fdSMartijn de Gouw #define RIO_INB_ATMU_COUNT 4 55abc3aeaeSLiu Gang 566ec4bedbSLiu Gang struct rio_atmu_regs { 576ec4bedbSLiu Gang u32 rowtar; 586ec4bedbSLiu Gang u32 rowtear; 596ec4bedbSLiu Gang u32 rowbar; 60abc3aeaeSLiu Gang u32 pad1; 616ec4bedbSLiu Gang u32 rowar; 62abc3aeaeSLiu Gang u32 pad2[3]; 63abc3aeaeSLiu Gang }; 64abc3aeaeSLiu Gang 65e6a546fdSMartijn de Gouw struct rio_inb_atmu_regs { 66e6a546fdSMartijn de Gouw u32 riwtar; 67e6a546fdSMartijn de Gouw u32 pad1; 68e6a546fdSMartijn de Gouw u32 riwbar; 69e6a546fdSMartijn de Gouw u32 pad2; 70e6a546fdSMartijn de Gouw u32 riwar; 71e6a546fdSMartijn de Gouw u32 pad3[3]; 72e6a546fdSMartijn de Gouw }; 73e6a546fdSMartijn de Gouw 74abc3aeaeSLiu Gang struct rio_dbell_ring { 75abc3aeaeSLiu Gang void *virt; 76abc3aeaeSLiu Gang dma_addr_t phys; 776ec4bedbSLiu Gang }; 786ec4bedbSLiu Gang 796ec4bedbSLiu Gang struct rio_port_write_msg { 806ec4bedbSLiu Gang void *virt; 816ec4bedbSLiu Gang dma_addr_t phys; 826ec4bedbSLiu Gang u32 msg_count; 836ec4bedbSLiu Gang u32 err_count; 846ec4bedbSLiu Gang u32 discard_count; 856ec4bedbSLiu Gang }; 866ec4bedbSLiu Gang 87abc3aeaeSLiu Gang struct fsl_rio_dbell { 88abc3aeaeSLiu Gang struct rio_mport *mport[MAX_PORT_NUM]; 89abc3aeaeSLiu Gang struct device *dev; 90abc3aeaeSLiu Gang struct rio_dbell_regs __iomem *dbell_regs; 91abc3aeaeSLiu Gang struct rio_dbell_ring dbell_ring; 92abc3aeaeSLiu Gang int bellirq; 93abc3aeaeSLiu Gang }; 94abc3aeaeSLiu Gang 95abc3aeaeSLiu Gang struct fsl_rio_pw { 969a0b0627SAlexandre Bounine struct rio_mport *mport[MAX_PORT_NUM]; 97abc3aeaeSLiu Gang struct device *dev; 98abc3aeaeSLiu Gang struct rio_pw_regs __iomem *pw_regs; 99abc3aeaeSLiu Gang struct rio_port_write_msg port_write_msg; 100abc3aeaeSLiu Gang int pwirq; 101abc3aeaeSLiu Gang struct work_struct pw_work; 102abc3aeaeSLiu Gang struct kfifo pw_fifo; 103abc3aeaeSLiu Gang spinlock_t pw_fifo_lock; 104abc3aeaeSLiu Gang }; 105abc3aeaeSLiu Gang 1066ec4bedbSLiu Gang struct rio_priv { 1076ec4bedbSLiu Gang struct device *dev; 1086ec4bedbSLiu Gang void __iomem *regs_win; 1096ec4bedbSLiu Gang struct rio_atmu_regs __iomem *atmu_regs; 1106ec4bedbSLiu Gang struct rio_atmu_regs __iomem *maint_atmu_regs; 111e6a546fdSMartijn de Gouw struct rio_inb_atmu_regs __iomem *inb_atmu_regs; 1126ec4bedbSLiu Gang void __iomem *maint_win; 1136ec4bedbSLiu Gang void *rmm_handle; /* RapidIO message manager(unit) Handle */ 1146ec4bedbSLiu Gang }; 1156ec4bedbSLiu Gang 1166ec4bedbSLiu Gang extern void __iomem *rio_regs_win; 117abc3aeaeSLiu Gang extern void __iomem *rmu_regs_win; 118abc3aeaeSLiu Gang 119abc3aeaeSLiu Gang extern resource_size_t rio_law_start; 120abc3aeaeSLiu Gang 121abc3aeaeSLiu Gang extern struct fsl_rio_dbell *dbell; 122abc3aeaeSLiu Gang extern struct fsl_rio_pw *pw; 1236ec4bedbSLiu Gang 1246ec4bedbSLiu Gang extern int fsl_rio_setup_rmu(struct rio_mport *mport, 1256ec4bedbSLiu Gang struct device_node *node); 126abc3aeaeSLiu Gang extern int fsl_rio_port_write_init(struct fsl_rio_pw *pw); 1276ec4bedbSLiu Gang extern int fsl_rio_pw_enable(struct rio_mport *mport, int enable); 128abc3aeaeSLiu Gang extern void fsl_rio_port_error_handler(int offset); 129abc3aeaeSLiu Gang extern int fsl_rio_doorbell_init(struct fsl_rio_dbell *dbell); 130abc3aeaeSLiu Gang 131abc3aeaeSLiu Gang extern int fsl_rio_doorbell_send(struct rio_mport *mport, 132abc3aeaeSLiu Gang int index, u16 destid, u16 data); 133abc3aeaeSLiu Gang extern int fsl_add_outb_message(struct rio_mport *mport, 134abc3aeaeSLiu Gang struct rio_dev *rdev, 135abc3aeaeSLiu Gang int mbox, void *buffer, size_t len); 136abc3aeaeSLiu Gang extern int fsl_open_outb_mbox(struct rio_mport *mport, 137abc3aeaeSLiu Gang void *dev_id, int mbox, int entries); 138abc3aeaeSLiu Gang extern void fsl_close_outb_mbox(struct rio_mport *mport, int mbox); 139abc3aeaeSLiu Gang extern int fsl_open_inb_mbox(struct rio_mport *mport, 140abc3aeaeSLiu Gang void *dev_id, int mbox, int entries); 141abc3aeaeSLiu Gang extern void fsl_close_inb_mbox(struct rio_mport *mport, int mbox); 142abc3aeaeSLiu Gang extern int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf); 143abc3aeaeSLiu Gang extern void *fsl_get_inb_message(struct rio_mport *mport, int mbox); 1446ec4bedbSLiu Gang 1456ec4bedbSLiu Gang #endif 146