18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/** 38c2ecf20Sopenharmony_ci * tpci200.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * driver for the carrier TEWS TPCI-200 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2009-2012 CERN (www.cern.ch) 88c2ecf20Sopenharmony_ci * Author: Nicolas Serafini, EIC2 SA 98c2ecf20Sopenharmony_ci * Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com> 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef _TPCI200_H_ 138c2ecf20Sopenharmony_ci#define _TPCI200_H_ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/limits.h> 168c2ecf20Sopenharmony_ci#include <linux/pci.h> 178c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 188c2ecf20Sopenharmony_ci#include <linux/swab.h> 198c2ecf20Sopenharmony_ci#include <linux/io.h> 208c2ecf20Sopenharmony_ci#include <linux/ipack.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define TPCI200_NB_SLOT 0x4 238c2ecf20Sopenharmony_ci#define TPCI200_NB_BAR 0x6 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define TPCI200_VENDOR_ID 0x1498 268c2ecf20Sopenharmony_ci#define TPCI200_DEVICE_ID 0x30C8 278c2ecf20Sopenharmony_ci#define TPCI200_SUBVENDOR_ID 0x1498 288c2ecf20Sopenharmony_ci#define TPCI200_SUBDEVICE_ID 0x300A 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define TPCI200_CFG_MEM_BAR 0 318c2ecf20Sopenharmony_ci#define TPCI200_IP_INTERFACE_BAR 2 328c2ecf20Sopenharmony_ci#define TPCI200_IO_ID_INT_SPACES_BAR 3 338c2ecf20Sopenharmony_ci#define TPCI200_MEM16_SPACE_BAR 4 348c2ecf20Sopenharmony_ci#define TPCI200_MEM8_SPACE_BAR 5 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistruct tpci200_regs { 378c2ecf20Sopenharmony_ci __le16 revision; 388c2ecf20Sopenharmony_ci /* writes to control should occur with the mutex held to protect 398c2ecf20Sopenharmony_ci * read-modify-write operations */ 408c2ecf20Sopenharmony_ci __le16 control[4]; 418c2ecf20Sopenharmony_ci __le16 reset; 428c2ecf20Sopenharmony_ci __le16 status; 438c2ecf20Sopenharmony_ci u8 reserved[242]; 448c2ecf20Sopenharmony_ci} __packed; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define TPCI200_IFACE_SIZE 0x100 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define TPCI200_IO_SPACE_OFF 0x0000 498c2ecf20Sopenharmony_ci#define TPCI200_IO_SPACE_INTERVAL 0x0100 508c2ecf20Sopenharmony_ci#define TPCI200_IO_SPACE_SIZE 0x0080 518c2ecf20Sopenharmony_ci#define TPCI200_ID_SPACE_OFF 0x0080 528c2ecf20Sopenharmony_ci#define TPCI200_ID_SPACE_INTERVAL 0x0100 538c2ecf20Sopenharmony_ci#define TPCI200_ID_SPACE_SIZE 0x0040 548c2ecf20Sopenharmony_ci#define TPCI200_INT_SPACE_OFF 0x00C0 558c2ecf20Sopenharmony_ci#define TPCI200_INT_SPACE_INTERVAL 0x0100 568c2ecf20Sopenharmony_ci#define TPCI200_INT_SPACE_SIZE 0x0040 578c2ecf20Sopenharmony_ci#define TPCI200_IOIDINT_SIZE 0x0400 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define TPCI200_MEM8_SPACE_INTERVAL 0x00400000 608c2ecf20Sopenharmony_ci#define TPCI200_MEM8_SPACE_SIZE 0x00400000 618c2ecf20Sopenharmony_ci#define TPCI200_MEM16_SPACE_INTERVAL 0x00800000 628c2ecf20Sopenharmony_ci#define TPCI200_MEM16_SPACE_SIZE 0x00800000 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* control field in tpci200_regs */ 658c2ecf20Sopenharmony_ci#define TPCI200_INT0_EN 0x0040 668c2ecf20Sopenharmony_ci#define TPCI200_INT1_EN 0x0080 678c2ecf20Sopenharmony_ci#define TPCI200_INT0_EDGE 0x0010 688c2ecf20Sopenharmony_ci#define TPCI200_INT1_EDGE 0x0020 698c2ecf20Sopenharmony_ci#define TPCI200_ERR_INT_EN 0x0008 708c2ecf20Sopenharmony_ci#define TPCI200_TIME_INT_EN 0x0004 718c2ecf20Sopenharmony_ci#define TPCI200_RECOVER_EN 0x0002 728c2ecf20Sopenharmony_ci#define TPCI200_CLK32 0x0001 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* reset field in tpci200_regs */ 758c2ecf20Sopenharmony_ci#define TPCI200_A_RESET 0x0001 768c2ecf20Sopenharmony_ci#define TPCI200_B_RESET 0x0002 778c2ecf20Sopenharmony_ci#define TPCI200_C_RESET 0x0004 788c2ecf20Sopenharmony_ci#define TPCI200_D_RESET 0x0008 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* status field in tpci200_regs */ 818c2ecf20Sopenharmony_ci#define TPCI200_A_TIMEOUT 0x1000 828c2ecf20Sopenharmony_ci#define TPCI200_B_TIMEOUT 0x2000 838c2ecf20Sopenharmony_ci#define TPCI200_C_TIMEOUT 0x4000 848c2ecf20Sopenharmony_ci#define TPCI200_D_TIMEOUT 0x8000 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define TPCI200_A_ERROR 0x0100 878c2ecf20Sopenharmony_ci#define TPCI200_B_ERROR 0x0200 888c2ecf20Sopenharmony_ci#define TPCI200_C_ERROR 0x0400 898c2ecf20Sopenharmony_ci#define TPCI200_D_ERROR 0x0800 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define TPCI200_A_INT0 0x0001 928c2ecf20Sopenharmony_ci#define TPCI200_A_INT1 0x0002 938c2ecf20Sopenharmony_ci#define TPCI200_B_INT0 0x0004 948c2ecf20Sopenharmony_ci#define TPCI200_B_INT1 0x0008 958c2ecf20Sopenharmony_ci#define TPCI200_C_INT0 0x0010 968c2ecf20Sopenharmony_ci#define TPCI200_C_INT1 0x0020 978c2ecf20Sopenharmony_ci#define TPCI200_D_INT0 0x0040 988c2ecf20Sopenharmony_ci#define TPCI200_D_INT1 0x0080 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define TPCI200_SLOT_INT_MASK 0x00FF 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci/* PCI Configuration registers. The PCI bridge is a PLX Technology PCI9030. */ 1038c2ecf20Sopenharmony_ci#define LAS1_DESC 0x2C 1048c2ecf20Sopenharmony_ci#define LAS2_DESC 0x30 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* Bits in the LAS?_DESC registers */ 1078c2ecf20Sopenharmony_ci#define LAS_BIT_BIGENDIAN 24 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define VME_IOID_SPACE "IOID" 1108c2ecf20Sopenharmony_ci#define VME_MEM_SPACE "MEM" 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/** 1138c2ecf20Sopenharmony_ci * struct slot_irq - slot IRQ definition. 1148c2ecf20Sopenharmony_ci * @vector Vector number 1158c2ecf20Sopenharmony_ci * @handler Handler called when IRQ arrives 1168c2ecf20Sopenharmony_ci * @arg Handler argument 1178c2ecf20Sopenharmony_ci * 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_cistruct slot_irq { 1208c2ecf20Sopenharmony_ci struct ipack_device *holder; 1218c2ecf20Sopenharmony_ci int vector; 1228c2ecf20Sopenharmony_ci irqreturn_t (*handler)(void *); 1238c2ecf20Sopenharmony_ci void *arg; 1248c2ecf20Sopenharmony_ci}; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci/** 1278c2ecf20Sopenharmony_ci * struct tpci200_slot - data specific to the tpci200 slot. 1288c2ecf20Sopenharmony_ci * @slot_id Slot identification gived to external interface 1298c2ecf20Sopenharmony_ci * @irq Slot IRQ infos 1308c2ecf20Sopenharmony_ci * @io_phys IO physical base address register of the slot 1318c2ecf20Sopenharmony_ci * @id_phys ID physical base address register of the slot 1328c2ecf20Sopenharmony_ci * @int_phys INT physical base address register of the slot 1338c2ecf20Sopenharmony_ci * @mem_phys MEM physical base address register of the slot 1348c2ecf20Sopenharmony_ci * 1358c2ecf20Sopenharmony_ci */ 1368c2ecf20Sopenharmony_cistruct tpci200_slot { 1378c2ecf20Sopenharmony_ci struct slot_irq *irq; 1388c2ecf20Sopenharmony_ci}; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci/** 1418c2ecf20Sopenharmony_ci * struct tpci200_infos - informations specific of the TPCI200 tpci200. 1428c2ecf20Sopenharmony_ci * @pci_dev PCI device 1438c2ecf20Sopenharmony_ci * @interface_regs Pointer to IP interface space (Bar 2) 1448c2ecf20Sopenharmony_ci * @ioidint_space Pointer to IP ID, IO and INT space (Bar 3) 1458c2ecf20Sopenharmony_ci * @mem8_space Pointer to MEM space (Bar 4) 1468c2ecf20Sopenharmony_ci * 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_cistruct tpci200_infos { 1498c2ecf20Sopenharmony_ci struct pci_dev *pdev; 1508c2ecf20Sopenharmony_ci struct pci_device_id *id_table; 1518c2ecf20Sopenharmony_ci struct tpci200_regs __iomem *interface_regs; 1528c2ecf20Sopenharmony_ci void __iomem *cfg_regs; 1538c2ecf20Sopenharmony_ci struct ipack_bus_device *ipack_bus; 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_cistruct tpci200_board { 1568c2ecf20Sopenharmony_ci unsigned int number; 1578c2ecf20Sopenharmony_ci struct mutex mutex; 1588c2ecf20Sopenharmony_ci spinlock_t regs_lock; 1598c2ecf20Sopenharmony_ci struct tpci200_slot *slots; 1608c2ecf20Sopenharmony_ci struct tpci200_infos *info; 1618c2ecf20Sopenharmony_ci phys_addr_t mod_mem[IPACK_SPACE_COUNT]; 1628c2ecf20Sopenharmony_ci}; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#endif /* _TPCI200_H_ */ 165