/*
 * Copyright 2004 Freescale Semiconductor, Inc. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#ifndef __SPBA_H__
#define __SPBA_H__

/*!
 * @defgroup SPBA Shared Peripheral Bus Arbiter (SPBA)
 * @ingroup MSL
 */

/*!
 * @file spba.h
 * @brief This file contains the Shared Peripheral Bus Arbiter (spba) API.
 *
 * @ingroup SPBA
 */
#define MXC_SPBA_RAR_MASK       0x7
/*!
 * enumeration for SPBA modules
 */
enum spba_module {
        SPBA_SDHC1      = 0x04,
        SPBA_SDHC2      = 0x08,
        SPBA_UART3      = 0x0C,
        SPBA_CSPI2      = 0x10,
        SPBA_SSI2       = 0x14,
        SPBA_SIM        = 0x18,
        SPBA_IIM        = 0x1C,
        SPBA_CTI_SDMA   = 0x20,
        SPBA_USB_OTG    = 0x24,
        SPBA_IOMUX_COM  = 0x40,
        SPBA_CRM_COM    = 0x44,
        SPBA_MRCG       = 0x48,
        SPBA_UDPLL      = 0x4C,
        SPBA_ADPLL      = 0x50,
        SPBA_BDPLL      = 0x54,
        SPBA_CRM_AP     = 0x58,
};

/*!
 * Defines three SPBA masters: A - ARM, B - SC140, C - SDMA
 */
enum spba_masters {
        SPBA_MASTER_A           = 1,
        SPBA_MASTER_B           = 2,
        SPBA_MASTER_C           = 4,
};

/*!
 * This function allows the three masters (A, B, C) to take ownership of a 
 * shared peripheral.
 *
 * @param  mod          specified module as defined in \b enum \b #spba_module
 * @param  master       one of more (or-ed together) masters as defined in \b enum \b #spba_masters
 *
 * @return 0 if successful; -1 otherwise.
 */
int spba_take_ownership(enum spba_module mod, int master);

/*!
 * This function releases the ownership for a shared peripheral.
 *
 * @param  mod          specified module as defined in \b enum \b #spba_module
 * @param  master       one of more (or-ed together) masters as defined in \b enum \b #spba_masters
 *
 * @return 0 if successful; -1 otherwise.
 */
int spba_rel_ownership(enum spba_module mod, int master);

#endif /* __SPBA_H__ */
