Path: blob/master/arch/sh/drivers/pci/fixups-sdk7786.c
10819 views
/*1* SDK7786 FPGA PCIe mux handling2*3* Copyright (C) 2010 Paul Mundt4*5* This file is subject to the terms and conditions of the GNU General Public6* License. See the file "COPYING" in the main directory of this archive7* for more details.8*/9#define pr_fmt(fmt) "PCI: " fmt1011#include <linux/init.h>12#include <linux/kernel.h>13#include <linux/pci.h>14#include <mach/fpga.h>1516/*17* The SDK7786 FPGA supports mangling of most of the slots in some way or18* another. Slots 3/4 are special in that only one can be supported at a19* time, and both appear on port 3 to the PCI bus scan. Enabling slot 420* (the horizontal edge connector) will disable slot 3 entirely.21*22* Misconfigurations can be detected through the FPGA via the slot23* resistors to determine card presence. Hotplug remains unsupported.24*/25static unsigned int slot4en __devinitdata;2627char *__devinit pcibios_setup(char *str)28{29if (strcmp(str, "slot4en") == 0) {30slot4en = 1;31return NULL;32}3334return str;35}3637static int __init sdk7786_pci_init(void)38{39u16 data = fpga_read_reg(PCIECR);4041/*42* Enable slot #4 if it's been specified on the command line.43*44* Optionally reroute if slot #4 has a card present while slot #345* does not, regardless of command line value.46*47* Card presence is logically inverted.48*/49slot4en ?: (!(data & PCIECR_PRST4) && (data & PCIECR_PRST3));50if (slot4en) {51pr_info("Activating PCIe slot#4 (disabling slot#3)\n");5253data &= ~PCIECR_PCIEMUX1;54fpga_write_reg(data, PCIECR);5556/* Warn about forced rerouting if slot#3 is occupied */57if ((data & PCIECR_PRST3) == 0) {58pr_warning("Unreachable card detected in slot#3\n");59return -EBUSY;60}61} else62pr_info("PCIe slot#4 disabled\n");6364return 0;65}66postcore_initcall(sdk7786_pci_init);676869