Skip to contentSkip to conversation

alpha: pci_ops update

PATCH New Ivan Kokshaysky 1 participant 1 message Sep 7, 2002 Alpha port

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alpha: pci_ops update

Tested on CIA (sparse config space) and Irongate (dense config space); other platforms should work as they are similar to these two.

Access config space directly on rx164.

Ivan.

arch/alpha/kernel/sys_rx164.c +9 -10
@@ -35,16 +35,15 @@
 /* Note mask bit is true for ENABLED irqs.  */
 static unsigned long cached_irq_mask;
 
-/* Bus 0, Device 0.  Nothing else matters, since we invoke the
-   POLARIS routines directly.  */
-static struct pci_dev rx164_system;
-
 static inline void
 rx164_update_irq_hw(unsigned long mask)
 {
-	unsigned int temp;
-	polaris_write_config_dword(&rx164_system, 0x74, mask);
-	polaris_read_config_dword(&rx164_system, 0x74, &temp);
+	volatile unsigned int *irq_mask;
+
+	irq_mask = (void *)(POLARIS_DENSE_CONFIG_BASE + 0x74);
+	*irq_mask = mask;
+	mb();
+	*irq_mask;
 }
 
 static inline void
@@ -86,14 +85,14 @@ static struct hw_interrupt_type rx164_ir
 static void 
 rx164_device_interrupt(unsigned long vector, struct pt_regs *regs)
 {
-	unsigned int temp;
 	unsigned long pld;
+	volatile unsigned int *dirr;
 	long i;
 
 	/* Read the interrupt summary register.  On Polaris, this is
 	   the DIRR register in PCI config space (offset 0x84).  */
-	polaris_read_config_dword(&rx164_system, 0x84, &temp);
-	pld = temp;
+	dirr = (void *)(POLARIS_DENSE_CONFIG_BASE + 0x84);
+	pld = *dirr;
 
 	/*
 	 * Now for every possible bit set, work through them and call
arch/alpha/kernel/core_t2.c +6 -28
@@ -89,11 +89,11 @@
  */
 
 static int
-mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
+mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
 	     unsigned long *pci_addr, unsigned char *type1)
 {
 	unsigned long addr;
-	u8 bus = bus_dev->number;
+	u8 bus = pbus->number;
 
 	DBG(("mk_conf_addr(bus=%d, dfn=0x%x, where=0x%x,"
 	     " addr=0x%lx, type1=0x%x)\n",
@@ -248,20 +248,8 @@ t2_read_config(struct pci_bus *bus, unsi
 	if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	switch (size) {
-	case 1:
-		mask = 0x00;
-		shift = (where & 3) * 8;
-		break;
-	case 2:
-		mask = 0x08;
-		shift = (where & 3) * 8;
-		break;
-	case 4:
-		mask = 0x18;
-		shift = 0;
-		break;
-	}
+	mask = (size - 1) * 8;
+	shift = (where & 3) * 8;
 	addr = (pci_addr << 5) + mask + T2_CONF;
 	*value = conf_read(addr, type1) >> (shift);
 	return PCIBIOS_SUCCESSFUL;
@@ -275,20 +263,10 @@ t2_write_config(struct pci_bus *bus, uns
 	unsigned char type1;
 	long mask;
 
-	if (mk_conf_addr(dev, where, &pci_addr, &type1))
+	if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	switch (size) {
-	case 1:
-		mask = 0x00;
-		break;
-	case 2:
-		mask = 0x08;
-		break;
-	case 4:
-		mask = 0x18;
-		break;
-	}
+	mask = (size - 1) * 8;
 	addr = (pci_addr << 5) + mask + T2_CONF;
 	conf_write(addr, value << ((where & 3) * 8), type1);
 	return PCIBIOS_SUCCESSFUL;
arch/alpha/kernel/core_polaris.c +36 -10

74 lines not on this page · raw message

arch/alpha/kernel/core_lca.c +8 -30
@@ -99,11 +99,11 @@
  */
 
 static int
-mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
+mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
 	     unsigned long *pci_addr)
 {
 	unsigned long addr;
-	u8 bus = bus_dev->number;
+	u8 bus = pbus->number;
 
 	if (bus == 0) {
 		int device = device_fn >> 3;
@@ -204,32 +204,20 @@ lca_read_config(struct pci_bus *bus, uns
 {
 	unsigned long addr, pci_addr;
 	long mask;
-	int shift
+	int shift;
 
-	if (mk_conf_addr(bus, devfn, dev, where, &pci_addr))
+	if (mk_conf_addr(bus, devfn, where, &pci_addr))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	switch (size) {
-	case 1:
-		shift = (where & 3) * 8;
-		mask = 0x00;
-		break;
-	case 2:
-		shift = (where & 3) * 8;
-		mask = 0x08
-		break;
-	case 4:
-		shift = 0;
-		mask = 0x18
-		break;
-	}
+	shift = (where & 3) * 8;
+	mask = (size - 1) * 8;
 	addr = (pci_addr << 5) + mask + LCA_CONF;
 	*value = conf_read(addr) >> (shift);
 	return PCIBIOS_SUCCESSFUL;
 }
 
 static int 
-lca_write_config(struct pci_bus *dev, unsigned int devfn, int where, int size,
+lca_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
 		 u32 value)
 {
 	unsigned long addr, pci_addr;
@@ -238,17 +226,7 @@ lca_write_config(struct pci_bus *dev, un
 	if (mk_conf_addr(bus, devfn, where, &pci_addr))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-		switch (size) {
-	case 1:
-		mask = 0x00;
-		break;
-	case 2:
-		mask = 0x08
-		break;
-	case 4:
-		mask = 0x18
-		break;
-	}
+	mask = (size - 1) * 8;
 	addr = (pci_addr << 5) + mask + LCA_CONF;
 	conf_write(addr, value << ((where & 3) * 8));
 	return PCIBIOS_SUCCESSFUL;
arch/alpha/kernel/core_irongate.c +32 -7
@@ -83,11 +83,11 @@
  */
 
 static int
-mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
+mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
 	     unsigned long *pci_addr, unsigned char *type1)
 {
 	unsigned long addr;
-	u8 bus = bus_dev->number;
+	u8 bus = pbus->number;
 
 	DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, "
 		 "pci_addr=0x%p, type1=0x%p)\n",
@@ -113,7 +113,18 @@ irongate_read_config(struct pci_bus *bus
 	if (mk_conf_addr(bus, devfn, where, &addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	*value = __kernel_ldbu(*(vucp)addr);
+	switch (size) {
+	case 1:
+		*value = __kernel_ldbu(*(vucp)addr);
+		break;
+	case 2:
+		*value = __kernel_ldwu(*(vusp)addr);
+		break;
+	case 4:
+		*value = *(vuip)addr;
+		break;
+	}
+
 	return PCIBIOS_SUCCESSFUL;
 }
 
@@ -127,12 +138,26 @@ irongate_write_config(struct pci_bus *bu
 	if (mk_conf_addr(bus, devfn, where, &addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	__kernel_stb(value, *(vucp)addr);
-	mb();
-	__kernel_ldbu(*(vucp)addr);
+	switch (size) {
+	case 1:
+		__kernel_stb(value, *(vucp)addr);
+		mb();
+		__kernel_ldbu(*(vucp)addr);
+		break;
+	case 2:
+		__kernel_stw(value, *(vusp)addr);
+		mb();
+		__kernel_ldwu(*(vusp)addr);
+		break;
+	case 4:
+		*(vuip)addr = value;
+		mb();
+		*(vuip)addr;
+		break;
+	}
+
 	return PCIBIOS_SUCCESSFUL;
 }
-
 
 struct pci_ops irongate_pci_ops =
 {
arch/alpha/kernel/core_cia.c +4 -28
@@ -219,22 +219,9 @@ cia_read_config(struct pci_bus *bus, uns
 	if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	switch (size) {
-	case 1:
-		mask = 0x00;
-		shift = (where & 3) * 8;
-		break;
-	case 2:
-		mask = 0x08;
-		shift = (where & 3) * 8;
-		break;
-	case 4:
-		mase = 0x18;
-		shift = 0;
-		break;
-	}
-
-	addr = (pci_addr << 5) + 0x18 + CIA_CONF;
+	mask = (size - 1) * 8;
+	shift = (where & 3) * 8;
+	addr = (pci_addr << 5) + mask + CIA_CONF;
 	*value = conf_read(addr, type1) >> (shift);
 	return PCIBIOS_SUCCESSFUL;
 }
@@ -250,18 +237,7 @@ cia_write_config(struct pci_bus *bus, un
 	if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	switch (size) {
-	case 1:
-		mask = 0x00;
-		break;
-	case 2:
-		mask = 0x08;
-		break;
-	case 4:
-		mase = 0x18;
-		break;
-	}
-
+	mask = (size - 1) * 8;
 	addr = (pci_addr << 5) + mask + CIA_CONF;
 	conf_write(addr, value << ((where & 3) * 8), type1);
 	return PCIBIOS_SUCCESSFUL;
arch/alpha/kernel/core_apecs.c +9 -30
@@ -90,11 +90,11 @@
  */
 
 static int
-mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
+mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
 	     unsigned long *pci_addr, unsigned char *type1)
 {
 	unsigned long addr;
-	u8 bus = bus_dev->number;
+	u8 bus = pbus->number;
 
 	DBGC(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x,"
 	      " pci_addr=0x%p, type1=0x%p)\n",
@@ -272,8 +272,8 @@ conf_write(unsigned long addr, unsigned 
 }
 
 static int
-apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
-		  u8 *value)
+apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where,
+		  int size, u32 *value)
 {
 	unsigned long addr, pci_addr;
 	unsigned char type1;
@@ -283,27 +283,16 @@ apecs_read_config(struct pci_bus *bus, u
 	if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-		switch (size) {
-	case 1:
-		mask = 0x00;
-		shift = (where & 3) * 8;
-		break;
-	case 2:
-		mask = 0x08;
-		shift = (where & 3) * 8;
-		break;
-	case 4:
-		mask = 0x18;
-		shift = 0;
-		break;
-	}
+	mask = (size - 1) * 8;
+	shift = (where & 3) * 8;
 	addr = (pci_addr << 5) + mask + APECS_CONF;
 	*value = conf_read(addr, type1) >> (shift);
 	return PCIBIOS_SUCCESSFUL;
 }
 
 static int
-apecs_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
+apecs_write_config(struct pci_bus *bus, unsigned int devfn, int where,
+		   int size, u32 value)
 {
 	unsigned long addr, pci_addr;
 	unsigned char type1;
@@ -312,17 +301,7 @@ apecs_write_config(struct pci_bus *bus, 
 	if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	switch (size) {
-	case 1:
-		mask = 0x00;
-		break;
-	case 2:
-		mask = 0x08;
-		break;
-	case 4:
-		mask = 0x18;
-		break;
-	}
+	mask = (size - 1) * 8;
 	addr = (pci_addr << 5) + mask + APECS_CONF;
 	conf_write(addr, value << ((where & 3) * 8), type1);
 	return PCIBIOS_SUCCESSFUL;
arch/alpha/kernel/core_wildfire.c +41 -74

157 lines not on this page · raw message

arch/alpha/kernel/core_tsunami.c +41 -74

157 lines not on this page · raw message

arch/alpha/kernel/core_titan.c +41 -74

158 lines not on this page · raw message

arch/alpha/kernel/core_mcpcia.c +28 -69

140 lines not on this page · raw message