Path: blob/master/drivers/media/video/cx18/cx18-io.c
17780 views
/*1* cx18 driver PCI memory mapped IO access routines2*3* Copyright (C) 2007 Hans Verkuil <[email protected]>4* Copyright (C) 2008 Andy Walls <[email protected]>5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA19* 02111-1307 USA20*/2122#include "cx18-driver.h"23#include "cx18-io.h"24#include "cx18-irq.h"2526void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count)27{28u8 __iomem *dst = addr;29u16 val2 = val | (val << 8);30u32 val4 = val2 | (val2 << 16);3132/* Align writes on the CX23418's addresses */33if ((count > 0) && ((unsigned long)dst & 1)) {34cx18_writeb(cx, (u8) val, dst);35count--;36dst++;37}38if ((count > 1) && ((unsigned long)dst & 2)) {39cx18_writew(cx, val2, dst);40count -= 2;41dst += 2;42}43while (count > 3) {44cx18_writel(cx, val4, dst);45count -= 4;46dst += 4;47}48if (count > 1) {49cx18_writew(cx, val2, dst);50count -= 2;51dst += 2;52}53if (count > 0)54cx18_writeb(cx, (u8) val, dst);55}5657void cx18_sw1_irq_enable(struct cx18 *cx, u32 val)58{59cx18_write_reg_expect(cx, val, SW1_INT_STATUS, ~val, val);60cx->sw1_irq_mask = cx18_read_reg(cx, SW1_INT_ENABLE_PCI) | val;61cx18_write_reg(cx, cx->sw1_irq_mask, SW1_INT_ENABLE_PCI);62}6364void cx18_sw1_irq_disable(struct cx18 *cx, u32 val)65{66cx->sw1_irq_mask = cx18_read_reg(cx, SW1_INT_ENABLE_PCI) & ~val;67cx18_write_reg(cx, cx->sw1_irq_mask, SW1_INT_ENABLE_PCI);68}6970void cx18_sw2_irq_enable(struct cx18 *cx, u32 val)71{72cx18_write_reg_expect(cx, val, SW2_INT_STATUS, ~val, val);73cx->sw2_irq_mask = cx18_read_reg(cx, SW2_INT_ENABLE_PCI) | val;74cx18_write_reg(cx, cx->sw2_irq_mask, SW2_INT_ENABLE_PCI);75}7677void cx18_sw2_irq_disable(struct cx18 *cx, u32 val)78{79cx->sw2_irq_mask = cx18_read_reg(cx, SW2_INT_ENABLE_PCI) & ~val;80cx18_write_reg(cx, cx->sw2_irq_mask, SW2_INT_ENABLE_PCI);81}8283void cx18_sw2_irq_disable_cpu(struct cx18 *cx, u32 val)84{85u32 r;86r = cx18_read_reg(cx, SW2_INT_ENABLE_CPU);87cx18_write_reg(cx, r & ~val, SW2_INT_ENABLE_CPU);88}8990void cx18_setup_page(struct cx18 *cx, u32 addr)91{92u32 val;93val = cx18_read_reg(cx, 0xD000F8);94val = (val & ~0x1f00) | ((addr >> 17) & 0x1f00);95cx18_write_reg(cx, val, 0xD000F8);96}979899