/*1* arch/arm/mach-netx/pfifo.c2*3* Copyright (c) 2005 Sascha Hauer <[email protected]>, Pengutronix4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 27* as published by the Free Software Foundation.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17*/1819#include <linux/init.h>20#include <linux/module.h>21#include <linux/mutex.h>22#include <linux/io.h>2324#include <mach/hardware.h>25#include <mach/netx-regs.h>26#include <mach/pfifo.h>2728static DEFINE_MUTEX(pfifo_lock);2930static unsigned int pfifo_used = 0;3132int pfifo_request(unsigned int pfifo_mask)33{34int err = 0;35unsigned int val;3637mutex_lock(&pfifo_lock);3839if (pfifo_mask & pfifo_used) {40err = -EBUSY;41goto out;42}4344pfifo_used |= pfifo_mask;4546val = readl(NETX_PFIFO_RESET);47writel(val | pfifo_mask, NETX_PFIFO_RESET);48writel(val, NETX_PFIFO_RESET);4950out:51mutex_unlock(&pfifo_lock);52return err;53}5455void pfifo_free(unsigned int pfifo_mask)56{57mutex_lock(&pfifo_lock);58pfifo_used &= ~pfifo_mask;59mutex_unlock(&pfifo_lock);60}6162EXPORT_SYMBOL(pfifo_push);63EXPORT_SYMBOL(pfifo_pop);64EXPORT_SYMBOL(pfifo_fill_level);65EXPORT_SYMBOL(pfifo_empty);66EXPORT_SYMBOL(pfifo_request);67EXPORT_SYMBOL(pfifo_free);686970