Esempio n. 1
0
static int
prep_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
		  int len, u32 val)
{
	struct pci_controller *hose = bus->sysdata;
	volatile void __iomem *cfg_data;

	if (bus->number != 0 || DEVNO(devfn) < MIN_DEVNR
	    || DEVNO(devfn) > MAX_DEVNR)
		return PCIBIOS_DEVICE_NOT_FOUND;

	/*
	 * Note: the caller has already checked that offset is
	 * suitably aligned and that len is 1, 2 or 4.
	 */
	cfg_data = hose->cfg_data + CFGADDR(devfn) + offset;
	switch (len) {
	case 1:
		out_8(cfg_data, val);
		break;
	case 2:
		out_le16(cfg_data, val);
		break;
	default:
		out_le32(cfg_data, val);
		break;
	}
	return PCIBIOS_SUCCESSFUL;
}
Esempio n. 2
0
static int bcm1480_pcibios_read(struct pci_bus *bus, unsigned int devfn,
                int where, int size, u32 * val)
{
    u32 data = 0;

    if ((size == 2) && (where & 1))
        return PCIBIOS_BAD_REGISTER_NUMBER;
    else if ((size == 4) && (where & 3))
        return PCIBIOS_BAD_REGISTER_NUMBER;

    if (bcm1480_pci_can_access(bus, devfn))
        data = READCFG32(CFGADDR(bus, devfn, where));
    else
        data = 0xFFFFFFFF;

    if (size == 1)
        *val = (data >> ((where & 3) << 3)) & 0xff;
    else if (size == 2)