16ec4bedbSLiu Gang /* 26ec4bedbSLiu Gang * Freescale MPC85xx/MPC86xx RapidIO support 36ec4bedbSLiu Gang * 46ec4bedbSLiu Gang * Copyright 2009 Sysgo AG 56ec4bedbSLiu Gang * Thomas Moll <thomas.moll@sysgo.com> 66ec4bedbSLiu Gang * - fixed maintenance access routines, check for aligned access 76ec4bedbSLiu Gang * 86ec4bedbSLiu Gang * Copyright 2009 Integrated Device Technology, Inc. 96ec4bedbSLiu Gang * Alex Bounine <alexandre.bounine@idt.com> 106ec4bedbSLiu Gang * - Added Port-Write message handling 116ec4bedbSLiu Gang * - Added Machine Check exception handling 126ec4bedbSLiu Gang * 136ec4bedbSLiu Gang * Copyright (C) 2007, 2008, 2010, 2011 Freescale Semiconductor, Inc. 146ec4bedbSLiu Gang * Zhang Wei <wei.zhang@freescale.com> 156ec4bedbSLiu Gang * Lian Minghuan-B31939 <Minghuan.Lian@freescale.com> 166ec4bedbSLiu Gang * Liu Gang <Gang.Liu@freescale.com> 176ec4bedbSLiu Gang * 186ec4bedbSLiu Gang * Copyright 2005 MontaVista Software, Inc. 196ec4bedbSLiu Gang * Matt Porter <mporter@kernel.crashing.org> 206ec4bedbSLiu Gang * 216ec4bedbSLiu Gang * This program is free software; you can redistribute it and/or modify it 226ec4bedbSLiu Gang * under the terms of the GNU General Public License as published by the 236ec4bedbSLiu Gang * Free Software Foundation; either version 2 of the License, or (at your 246ec4bedbSLiu Gang * option) any later version. 256ec4bedbSLiu Gang */ 266ec4bedbSLiu Gang 276ec4bedbSLiu Gang #ifndef __FSL_RIO_H 286ec4bedbSLiu Gang #define __FSL_RIO_H 296ec4bedbSLiu Gang 306ec4bedbSLiu Gang #include <linux/rio.h> 316ec4bedbSLiu Gang #include <linux/rio_drv.h> 326ec4bedbSLiu Gang #include <linux/kfifo.h> 336ec4bedbSLiu Gang 346ec4bedbSLiu Gang #define RIO_REGS_WIN(mport) (((struct rio_priv *)(mport->priv))->regs_win) 356ec4bedbSLiu Gang 366ec4bedbSLiu Gang #define RIO_MAINT_WIN_SIZE 0x400000 376ec4bedbSLiu Gang #define RIO_LTLEDCSR 0x0608 386ec4bedbSLiu Gang 39abc3aeaeSLiu Gang #define DOORBELL_ROWAR_EN 0x80000000 40abc3aeaeSLiu Gang #define DOORBELL_ROWAR_TFLOWLV 0x08000000 /* highest priority level */ 41abc3aeaeSLiu Gang #define DOORBELL_ROWAR_PCI 0x02000000 /* PCI window */ 42abc3aeaeSLiu Gang #define DOORBELL_ROWAR_NREAD 0x00040000 /* NREAD */ 43abc3aeaeSLiu Gang #define DOORBELL_ROWAR_MAINTRD 0x00070000 /* maintenance read */ 44*a0837876SAlexandre Belloni #define DOORBELL_ROWAR_RES 0x00002000 /* wrtpy: reserved */ 45abc3aeaeSLiu Gang #define DOORBELL_ROWAR_MAINTWD 0x00007000 46abc3aeaeSLiu Gang #define DOORBELL_ROWAR_SIZE 0x0000000b /* window size is 4k */ 47abc3aeaeSLiu Gang 48abc3aeaeSLiu Gang #define RIO_ATMU_REGS_PORT1_OFFSET 0x10c00 49abc3aeaeSLiu Gang #define RIO_ATMU_REGS_PORT2_OFFSET 0x10e00 50abc3aeaeSLiu Gang #define RIO_S_DBELL_REGS_OFFSET 0x13400 51abc3aeaeSLiu Gang #define RIO_S_PW_REGS_OFFSET 0x134e0 52abc3aeaeSLiu Gang #define RIO_ATMU_REGS_DBELL_OFFSET 0x10C40 53e6a546fdSMartijn de Gouw #define RIO_INB_ATMU_REGS_PORT1_OFFSET 0x10d60 54e6a546fdSMartijn de Gouw #define RIO_INB_ATMU_REGS_PORT2_OFFSET 0x10f60 55abc3aeaeSLiu Gang 56abc3aeaeSLiu Gang #define MAX_MSG_UNIT_NUM 2 57abc3aeaeSLiu Gang #define MAX_PORT_NUM 4 58e6a546fdSMartijn de Gouw #define RIO_INB_ATMU_COUNT 4 59abc3aeaeSLiu Gang 606ec4bedbSLiu Gang struct rio_atmu_regs { 616ec4bedbSLiu Gang u32 rowtar; 626ec4bedbSLiu Gang u32 rowtear; 636ec4bedbSLiu Gang u32 rowbar; 64abc3aeaeSLiu Gang u32 pad1; 656ec4bedbSLiu Gang u32 rowar; 66abc3aeaeSLiu Gang u32 pad2[3]; 67abc3aeaeSLiu Gang }; 68abc3aeaeSLiu Gang 69e6a546fdSMartijn de Gouw struct rio_inb_atmu_regs { 70e6a546fdSMartijn de Gouw u32 riwtar; 71e6a546fdSMartijn de Gouw u32 pad1; 72e6a546fdSMartijn de Gouw u32 riwbar; 73e6a546fdSMartijn de Gouw u32 pad2; 74e6a546fdSMartijn de Gouw u32 riwar; 75e6a546fdSMartijn de Gouw u32 pad3[3]; 76e6a546fdSMartijn de Gouw }; 77e6a546fdSMartijn de Gouw 78abc3aeaeSLiu Gang struct rio_dbell_ring { 79abc3aeaeSLiu Gang void *virt; 80abc3aeaeSLiu Gang dma_addr_t phys; 816ec4bedbSLiu Gang }; 826ec4bedbSLiu Gang 836ec4bedbSLiu Gang struct rio_port_write_msg { 846ec4bedbSLiu Gang void *virt; 856ec4bedbSLiu Gang dma_addr_t phys; 866ec4bedbSLiu Gang u32 msg_count; 876ec4bedbSLiu Gang u32 err_count; 886ec4bedbSLiu Gang u32 discard_count; 896ec4bedbSLiu Gang }; 906ec4bedbSLiu Gang 91abc3aeaeSLiu Gang struct fsl_rio_dbell { 92abc3aeaeSLiu Gang struct rio_mport *mport[MAX_PORT_NUM]; 93abc3aeaeSLiu Gang struct device *dev; 94abc3aeaeSLiu Gang struct rio_dbell_regs __iomem *dbell_regs; 95abc3aeaeSLiu Gang struct rio_dbell_ring dbell_ring; 96abc3aeaeSLiu Gang int bellirq; 97abc3aeaeSLiu Gang }; 98abc3aeaeSLiu Gang 99abc3aeaeSLiu Gang struct fsl_rio_pw { 1009a0b0627SAlexandre Bounine struct rio_mport *mport[MAX_PORT_NUM]; 101abc3aeaeSLiu Gang struct device *dev; 102abc3aeaeSLiu Gang struct rio_pw_regs __iomem *pw_regs; 103abc3aeaeSLiu Gang struct rio_port_write_msg port_write_msg; 104abc3aeaeSLiu Gang int pwirq; 105abc3aeaeSLiu Gang struct work_struct pw_work; 106abc3aeaeSLiu Gang struct kfifo pw_fifo; 107abc3aeaeSLiu Gang spinlock_t pw_fifo_lock; 108abc3aeaeSLiu Gang }; 109abc3aeaeSLiu Gang 1106ec4bedbSLiu Gang struct rio_priv { 1116ec4bedbSLiu Gang struct device *dev; 1126ec4bedbSLiu Gang void __iomem *regs_win; 1136ec4bedbSLiu Gang struct rio_atmu_regs __iomem *atmu_regs; 1146ec4bedbSLiu Gang struct rio_atmu_regs __iomem *maint_atmu_regs; 115e6a546fdSMartijn de Gouw struct rio_inb_atmu_regs __iomem *inb_atmu_regs; 1166ec4bedbSLiu Gang void __iomem *maint_win; 1176ec4bedbSLiu Gang void *rmm_handle; /* RapidIO message manager(unit) Handle */ 1186ec4bedbSLiu Gang }; 1196ec4bedbSLiu Gang 1206ec4bedbSLiu Gang extern void __iomem *rio_regs_win; 121abc3aeaeSLiu Gang extern void __iomem *rmu_regs_win; 122abc3aeaeSLiu Gang 123abc3aeaeSLiu Gang extern resource_size_t rio_law_start; 124abc3aeaeSLiu Gang 125abc3aeaeSLiu Gang extern struct fsl_rio_dbell *dbell; 126abc3aeaeSLiu Gang extern struct fsl_rio_pw *pw; 1276ec4bedbSLiu Gang 1286ec4bedbSLiu Gang extern int fsl_rio_setup_rmu(struct rio_mport *mport, 1296ec4bedbSLiu Gang struct device_node *node); 130abc3aeaeSLiu Gang extern int fsl_rio_port_write_init(struct fsl_rio_pw *pw); 1316ec4bedbSLiu Gang extern int fsl_rio_pw_enable(struct rio_mport *mport, int enable); 132abc3aeaeSLiu Gang extern void fsl_rio_port_error_handler(int offset); 133abc3aeaeSLiu Gang extern int fsl_rio_doorbell_init(struct fsl_rio_dbell *dbell); 134abc3aeaeSLiu Gang 135abc3aeaeSLiu Gang extern int fsl_rio_doorbell_send(struct rio_mport *mport, 136abc3aeaeSLiu Gang int index, u16 destid, u16 data); 137abc3aeaeSLiu Gang extern int fsl_add_outb_message(struct rio_mport *mport, 138abc3aeaeSLiu Gang struct rio_dev *rdev, 139abc3aeaeSLiu Gang int mbox, void *buffer, size_t len); 140abc3aeaeSLiu Gang extern int fsl_open_outb_mbox(struct rio_mport *mport, 141abc3aeaeSLiu Gang void *dev_id, int mbox, int entries); 142abc3aeaeSLiu Gang extern void fsl_close_outb_mbox(struct rio_mport *mport, int mbox); 143abc3aeaeSLiu Gang extern int fsl_open_inb_mbox(struct rio_mport *mport, 144abc3aeaeSLiu Gang void *dev_id, int mbox, int entries); 145abc3aeaeSLiu Gang extern void fsl_close_inb_mbox(struct rio_mport *mport, int mbox); 146abc3aeaeSLiu Gang extern int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf); 147abc3aeaeSLiu Gang extern void *fsl_get_inb_message(struct rio_mport *mport, int mbox); 1486ec4bedbSLiu Gang 1496ec4bedbSLiu Gang #endif 150