/*1* Copyright 2003 PMC-Sierra2* Author: Manish Lachwani ([email protected])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* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED10* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF11* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN12* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,13* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT14* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF15* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON16* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT17* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF18* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.19*20* You should have received a copy of the GNU General Public License along21* with this program; if not, write to the Free Software Foundation, Inc.,22* 675 Mass Ave, Cambridge, MA 02139, USA.23*/24#include <linux/types.h>25#include <linux/pci.h>26#include <linux/kernel.h>2728#include <asm/pci.h>29#include <asm/io.h>30#include <asm/rm9k-ocd.h>3132/*33* PCI specific defines34*/35#define TITAN_PCI_0_CONFIG_ADDRESS 0x78036#define TITAN_PCI_0_CONFIG_DATA 0x7843738/*39* Titan PCI Config Read Byte40*/41static int titan_read_config(struct pci_bus *bus, unsigned int devfn, int reg,42int size, u32 * val)43{44uint32_t address, tmp;45int dev, busno, func;4647busno = bus->number;48dev = PCI_SLOT(devfn);49func = PCI_FUNC(devfn);5051address = (busno << 16) | (dev << 11) | (func << 8) |52(reg & 0xfc) | 0x80000000;535455/* start the configuration cycle */56ocd_writel(address, TITAN_PCI_0_CONFIG_ADDRESS);57tmp = ocd_readl(TITAN_PCI_0_CONFIG_DATA) >> ((reg & 3) << 3);5859switch (size) {60case 1:61tmp &= 0xff;62case 2:63tmp &= 0xffff;64}65*val = tmp;6667return PCIBIOS_SUCCESSFUL;68}6970static int titan_write_config(struct pci_bus *bus, unsigned int devfn, int reg,71int size, u32 val)72{73uint32_t address;74int dev, busno, func;7576busno = bus->number;77dev = PCI_SLOT(devfn);78func = PCI_FUNC(devfn);7980address = (busno << 16) | (dev << 11) | (func << 8) |81(reg & 0xfc) | 0x80000000;8283/* start the configuration cycle */84ocd_writel(address, TITAN_PCI_0_CONFIG_ADDRESS);8586/* write the data */87switch (size) {88case 1:89ocd_writeb(val, TITAN_PCI_0_CONFIG_DATA + (~reg & 0x3));90break;9192case 2:93ocd_writew(val, TITAN_PCI_0_CONFIG_DATA + (~reg & 0x2));94break;9596case 4:97ocd_writel(val, TITAN_PCI_0_CONFIG_DATA);98break;99}100101return PCIBIOS_SUCCESSFUL;102}103104/*105* Titan PCI structure106*/107struct pci_ops titan_pci_ops = {108titan_read_config,109titan_write_config,110};111112113