/*
 * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
 *
 * This document is the property of Apple Inc.
 * It is considered confidential and proprietary.
 *
 * This document may not be reproduced or transmitted in any form,
 * in whole or in part, without the express written permission of
 * Apple Inc.
 */

#ifndef __APPLE_DOCKCHANNEL_H
#define __APPLE_DOCKCHANNEL_H

#include <platform/soc/hwregbase.h>
#include SUB_PLATFORM_SPDS_HEADER(dock_channels)

#define DOCKCHANNEL_STRIDE									(0x10000)

// Macro names in SPDS are pretty bad for readability
// rdar://problem/20455612

#define rDOCKCHANNELS_GLOBAL(_p)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + DOCK_CHANNELS_DOCKCHANNELS_GLOBAL_OFFSET + _p)

#define rDOCKCHANNELS_AGENT_AP_INTR_CTRL			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + DOCK_CHANNELS_DOCKCHANNELS_AGENT1_AGENT1_INTR_CONTROL_OFFSET)
#define rDOCKCHANNELS_AGENT_AP_INTR_STATUS			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + DOCK_CHANNELS_DOCKCHANNELS_AGENT1_AGENT1_INTR_STATUS_OFFSET)
#define rDOCKCHANNELS_AGENT_AP_ERR_INTR_CTRL			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + DOCK_CHANNELS_DOCKCHANNELS_AGENT1_AGENT1_ERR_INTR_CONTROL_OFFSET)
#define rDOCKCHANNELS_AGENT_AP_ERR_INTR_STATUS			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + DOCK_CHANNELS_DOCKCHANNELS_AGENT1_AGENT1_ERR_INTR_STATUS_OFFSET)
#define rDOCKCHANNELS_AGENT_AP_ERR_CAUSE0			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + DOCK_CHANNELS_DOCKCHANNELS_AGENT1_AGENT1_ERR_CAUSE0_OFFSET)
#define rDOCKCHANNELS_AGENT_AP_ERR_CAUSE1			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + DOCK_CHANNELS_DOCKCHANNELS_AGENT1_AGENT1_ERR_CAUSE1_OFFSET)

// Device side config registers
#define rDOCKCHANNELS_DEV_CONFIG_WR_WATERMARK(_ch)		*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_CONFIG_DEV_WR_WATERMARK_OFFSET)
#define rDOCKCHANNELS_DEV_CONFIG_RD_WATERMARK(_ch)		*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_CONFIG_DEV_RD_WATERMARK_OFFSET)
#define rDOCKCHANNELS_DEV_DRAIN_CFG(_ch)			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_CONFIG_DEV_DRAIN_CFG_OFFSET)
#define rDOCKCHANNELS_DEV_ERROR_CFG(_ch)			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_CONFIG_DEV_ERROR_CFG_OFFSET)
#define rDOCKCHANNELS_DEV_FIFO_CTRL(_ch)			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_CONFIG_DEV_FIFO_CTRL_OFFSET)

// Device side fifo registers
#define rDOCKCHANNELS_DEV_WDATA1(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_WDATA_1_OFFSET)
#define rDOCKCHANNELS_DEV_WDATA2(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_WDATA_2_OFFSET)
#define rDOCKCHANNELS_DEV_WDATA3(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_WDATA_3_OFFSET)
#define rDOCKCHANNELS_DEV_WDATA4(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_WDATA_4_OFFSET)
#define rDOCKCHANNELS_DEV_WSTAT(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_WSTAT_OFFSET)
#define rDOCKCHANNELS_DEV_RDATA1(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_RDATA_1_OFFSET)
#define rDOCKCHANNELS_DEV_RDATA2(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_RDATA_2_OFFSET)
#define rDOCKCHANNELS_DEV_RDATA3(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_RDATA_3_OFFSET)
#define rDOCKCHANNELS_DEV_RDATA4(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_RDATA_4_OFFSET)
#define rDOCKCHANNELS_DEV_RSTAT(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DEV_DATA_DEV_RSTAT_OFFSET) 

// Dock side config registers
#define rDOCKCHANNELS_DOCK_CONFIG_WR_WATERMARK(_ch)		*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DOCK_CONFIG_DOCK_WR_WATERMARK_OFFSET)
#define rDOCKCHANNELS_DOCK_CONFIG_RD_WATERMARK(_ch)		*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DOCK_CONFIG_DOCK_RD_WATERMARK_OFFSET)
#define rDOCKCHANNELS_DOCK_DRAIN_CFG(_ch)			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DOCK_CONFIG_DOCK_DRAIN_CFG_OFFSET)
#define rDOCKCHANNELS_DOCK_ERROR_CFG(_ch)			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DOCK_CONFIG_DOCK_ERROR_CFG_OFFSET)
#define rDOCKCHANNELS_DOCK_FIFO_CTRL(_ch)			*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DOCK_CONFIG_DOCK_FIFO_CTRL_OFFSET)

// Dock side fifo registers
#define rDOCKCHANNELS_DOCK_RDATA1(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DOCK_DATA_DOCK_RDATA_1_OFFSET)
#define rDOCKCHANNELS_DOCK_RDATA3(_ch)				*(volatile uint32_t *)(DOCKCHANNELS_BASE_ADDR + ((_ch) * DOCKCHANNEL_STRIDE) + DOCK_CHANNELS_DOCKCHANNELS_CHANNEL0_DOCK_DATA_DOCK_RDATA_3_OFFSET)
#endif /* __APPLE_DOCKCHANNEL_H */
