Path: blob/master/drivers/char/xilinx_hwicap/xilinx_hwicap.h
26288 views
/*****************************************************************************1*2* Author: Xilinx, Inc.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License as published by the6* Free Software Foundation; either version 2 of the License, or (at your7* option) any later version.8*9* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"10* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND11* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,12* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,13* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION14* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,15* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE16* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY17* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE18* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR19* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF20* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS21* FOR A PARTICULAR PURPOSE.22*23* (c) Copyright 2003-2007 Xilinx Inc.24* All rights reserved.25*26* You should have received a copy of the GNU General Public License along27* with this program; if not, write to the Free Software Foundation, Inc.,28* 675 Mass Ave, Cambridge, MA 02139, USA.29*30*****************************************************************************/3132#ifndef XILINX_HWICAP_H_ /* prevent circular inclusions */33#define XILINX_HWICAP_H_ /* by using protection macros */3435#include <linux/types.h>36#include <linux/cdev.h>37#include <linux/platform_device.h>3839#include <linux/io.h>4041struct hwicap_drvdata {42u32 write_buffer_in_use; /* Always in [0,3] */43u8 write_buffer[4];44u32 read_buffer_in_use; /* Always in [0,3] */45u8 read_buffer[4];46resource_size_t mem_start;/* phys. address of the control registers */47resource_size_t mem_end; /* phys. address of the control registers */48resource_size_t mem_size;49void __iomem *base_address;/* virt. address of the control registers */5051struct device *dev;52struct cdev cdev; /* Char device structure */53dev_t devt;5455const struct hwicap_driver_config *config;56const struct config_registers *config_regs;57void *private_data;58bool is_open;59struct mutex sem;60};6162struct hwicap_driver_config {63/* Read configuration data given by size into the data buffer.64* Return 0 if successful.65*/66int (*get_configuration)(struct hwicap_drvdata *drvdata, u32 *data,67u32 size);68/* Write configuration data given by size from the data buffer.69* Return 0 if successful.70*/71int (*set_configuration)(struct hwicap_drvdata *drvdata, u32 *data,72u32 size);73/* Get the status register, bit pattern given by:74* D8 - 0 = configuration error75* D7 - 1 = alignment found76* D6 - 1 = readback in progress77* D5 - 0 = abort in progress78* D4 - Always 179* D3 - Always 180* D2 - Always 181* D1 - Always 182* D0 - 1 = operation completed83*/84u32 (*get_status)(struct hwicap_drvdata *drvdata);85/* Reset the hw */86void (*reset)(struct hwicap_drvdata *drvdata);87};8889/* Number of times to poll the done register. This has to be large90* enough to allow an entire configuration to complete. If an entire91* page (4kb) is configured at once, that could take up to 4k cycles92* with a byte-wide icap interface. In most cases, this driver is93* used with a much smaller fifo, but this should be sufficient in the94* worst case.95*/96#define XHI_MAX_RETRIES 50009798/************ Constant Definitions *************/99100#define XHI_PAD_FRAMES 0x1101102/* Mask for calculating configuration packet headers */103#define XHI_WORD_COUNT_MASK_TYPE_1 0x7FFUL104#define XHI_WORD_COUNT_MASK_TYPE_2 0x1FFFFFUL105#define XHI_TYPE_MASK 0x7106#define XHI_REGISTER_MASK 0xF107#define XHI_OP_MASK 0x3108109#define XHI_TYPE_SHIFT 29110#define XHI_REGISTER_SHIFT 13111#define XHI_OP_SHIFT 27112113#define XHI_TYPE_1 1114#define XHI_TYPE_2 2115#define XHI_OP_WRITE 2116#define XHI_OP_READ 1117118/* Address Block Types */119#define XHI_FAR_CLB_BLOCK 0120#define XHI_FAR_BRAM_BLOCK 1121#define XHI_FAR_BRAM_INT_BLOCK 2122123struct config_registers {124u32 CRC;125u32 FAR;126u32 FDRI;127u32 FDRO;128u32 CMD;129u32 CTL;130u32 MASK;131u32 STAT;132u32 LOUT;133u32 COR;134u32 MFWR;135u32 FLR;136u32 KEY;137u32 CBC;138u32 IDCODE;139u32 AXSS;140u32 C0R_1;141u32 CSOB;142u32 WBSTAR;143u32 TIMER;144u32 BOOTSTS;145u32 CTL_1;146};147148/* Configuration Commands */149#define XHI_CMD_NULL 0150#define XHI_CMD_WCFG 1151#define XHI_CMD_MFW 2152#define XHI_CMD_DGHIGH 3153#define XHI_CMD_RCFG 4154#define XHI_CMD_START 5155#define XHI_CMD_RCAP 6156#define XHI_CMD_RCRC 7157#define XHI_CMD_AGHIGH 8158#define XHI_CMD_SWITCH 9159#define XHI_CMD_GRESTORE 10160#define XHI_CMD_SHUTDOWN 11161#define XHI_CMD_GCAPTURE 12162#define XHI_CMD_DESYNCH 13163#define XHI_CMD_IPROG 15 /* Only in Virtex5 */164#define XHI_CMD_CRCC 16 /* Only in Virtex5 */165#define XHI_CMD_LTIMER 17 /* Only in Virtex5 */166167/* Packet constants */168#define XHI_SYNC_PACKET 0xAA995566UL169#define XHI_DUMMY_PACKET 0xFFFFFFFFUL170#define XHI_NOOP_PACKET (XHI_TYPE_1 << XHI_TYPE_SHIFT)171#define XHI_TYPE_2_READ ((XHI_TYPE_2 << XHI_TYPE_SHIFT) | \172(XHI_OP_READ << XHI_OP_SHIFT))173174#define XHI_TYPE_2_WRITE ((XHI_TYPE_2 << XHI_TYPE_SHIFT) | \175(XHI_OP_WRITE << XHI_OP_SHIFT))176177#define XHI_TYPE2_CNT_MASK 0x07FFFFFF178179#define XHI_TYPE_1_PACKET_MAX_WORDS 2047UL180#define XHI_TYPE_1_HEADER_BYTES 4181#define XHI_TYPE_2_HEADER_BYTES 8182183/* Constant to use for CRC check when CRC has been disabled */184#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL185186/* Meanings of the bits returned by get_status */187#define XHI_SR_CFGERR_N_MASK 0x00000100 /* Config Error Mask */188#define XHI_SR_DALIGN_MASK 0x00000080 /* Data Alignment Mask */189#define XHI_SR_RIP_MASK 0x00000040 /* Read back Mask */190#define XHI_SR_IN_ABORT_N_MASK 0x00000020 /* Select Map Abort Mask */191#define XHI_SR_DONE_MASK 0x00000001 /* Done bit Mask */192193/**194* hwicap_type_1_read - Generates a Type 1 read packet header.195* @reg: is the address of the register to be read back.196*197* Return:198* Generates a Type 1 read packet header, which is used to indirectly199* read registers in the configuration logic. This packet must then200* be sent through the icap device, and a return packet received with201* the information.202*/203static inline u32 hwicap_type_1_read(u32 reg)204{205return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |206(reg << XHI_REGISTER_SHIFT) |207(XHI_OP_READ << XHI_OP_SHIFT);208}209210/**211* hwicap_type_1_write - Generates a Type 1 write packet header212* @reg: is the address of the register to be read back.213*214* Return: Type 1 write packet header215*/216static inline u32 hwicap_type_1_write(u32 reg)217{218return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |219(reg << XHI_REGISTER_SHIFT) |220(XHI_OP_WRITE << XHI_OP_SHIFT);221}222223#endif224225226