Skip to contentSkip to conversation

pci_ftpci100: Implementation FTPCI100 PCI driver

PATCH Superseded Macpaul Lin 3 participants 7 messages Oct 5, 2011 – Dec 5, 2011 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci_ftpci100: Implementation FTPCI100 PCI driver

From: Gavin Guo <[email protected]>

FTPCI100 is a SoC PCI componenet of Faraday company. Which is usually built into SoC chips for providing embedded PCI functions.

---
 drivers/pci/Makefile       |    1 +
 drivers/pci/pci_ftpci100.c |  312 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci_ftpci100.h |   94 +++++++++++++
 3 files changed, 407 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci_ftpci100.c
 create mode 100644 drivers/pci/pci_ftpci100.h
drivers/pci/Makefile +1 -0
index ee0c64d..1ae35d3 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libpci.o
 
 COBJS-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o
 COBJS-$(CONFIG_PCI) += pci.o pci_auto.o pci_indirect.o
+COBJS-$(CONFIG_FTPCI100) += pci_ftpci100.o
 COBJS-$(CONFIG_IXP_PCI) += pci_ixp.o
 COBJS-$(CONFIG_SH4_PCI) += pci_sh4.o
 COBJS-$(CONFIG_SH7751_PCI) +=pci_sh7751.o
drivers/pci/pci_ftpci100.c new file +312 -0

312 lines not on this page · raw message

drivers/pci/pci_ftpci100.h new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#1 lore raw

PATCH 1/1 pci_ftpci100: Implementation FTPCI100 PCI driver

Dear Macpaul Lin,

Quoted 9 lines · In message <[email protected]> you wrote:

From: Gavin Guo <[email protected]>

FTPCI100 is a SoC PCI componenet of Faraday company. Which is usually built into SoC chips for providing embedded PCI functions.

Quoted 7 lines
---
 drivers/pci/Makefile       |    1 +
 drivers/pci/pci_ftpci100.c |  312 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci_ftpci100.h |   94 +++++++++++++
 3 files changed, 407 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci_ftpci100.c
 create mode 100644 drivers/pci/pci_ftpci100.h

Checkpatch says:

total: 0 errors, 5 warnings, 413 lines checked

Please clean up and resubmit. Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If I can have honesty, it's easier to overlook mistakes.
	-- Kirk, "Space Seed", stardate 3141.9
#2 lore raw

PATCH v2 1/1 pci_ftpci100: Implementation FTPCI100 PCI driver

From: Gavin Guo <[email protected]>

FTPCI100 is a SoC PCI componenet of Faraday company. Which is usually built into SoC chips for providing embedded PCI functions.

---
Changes for v2:
- clean up lines over 80 charaters.

 drivers/pci/Makefile       |    1 +
 drivers/pci/pci_ftpci100.c |  316 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci_ftpci100.h |   94 +++++++++++++
 3 files changed, 411 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci_ftpci100.c
 create mode 100644 drivers/pci/pci_ftpci100.h
drivers/pci/Makefile +1 -0
index ee0c64d..1ae35d3 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libpci.o
 
 COBJS-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o
 COBJS-$(CONFIG_PCI) += pci.o pci_auto.o pci_indirect.o
+COBJS-$(CONFIG_FTPCI100) += pci_ftpci100.o
 COBJS-$(CONFIG_IXP_PCI) += pci_ixp.o
 COBJS-$(CONFIG_SH4_PCI) += pci_sh4.o
 COBJS-$(CONFIG_SH7751_PCI) +=pci_sh7751.o
drivers/pci/pci_ftpci100.c new file +316 -0

316 lines not on this page · raw message

drivers/pci/pci_ftpci100.h new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#3 lore raw

PATCH v2 1/1 pci_ftpci100: Implementation FTPCI100 PCI driver

drivers/pci/pci_ftpci100.c line 24

Quoted 6 lines · On Thursday 20 October 2011 04:16:25 Macpaul Lin wrote:
drivers/pci/pci_ftpci100.c new file +3 -0
 
+#ifndef __io
+#define __io
+#endif

this is most likely wrong. drop it.

drivers/pci/pci_ftpci100.c line 30

Quoted 5 lines
drivers/pci/pci_ftpci100.c new file +5 -0
+#include <asm/io.h>
+#include <asm/types.h> /* u32, u16.... used by pci.h */
+#include <common.h>
+#include <malloc.h>
+#include <pci.h>

the asm/ includes should come after the non-asm includes

drivers/pci/pci_ftpci100.c line 42

Quoted 2 lines
drivers/pci/pci_ftpci100.c new file +2 -0
+struct pci_config devs[FTPCI100_MAX_FUNCTIONS];
+struct pci_controller hose;

need to be static

drivers/pci/pci_ftpci100.c line 45

Quoted 2 lines
drivers/pci/pci_ftpci100.c new file +2 -0
+void setup_pci_bar(unsigned int bus, unsigned int dev, unsigned func,
+		unsigned char header, struct ftpci100_data *priv)

should be static

drivers/pci/pci_ftpci100.c line 93

Quoted 6 lines
drivers/pci/pci_ftpci100.c new file +6 -0
+#ifdef CONFIG_FTPCI100_DEBUG
+			printf("Allocated IO address 0x%X-" \
+				"0x%X for Bus %d, Device %d, Function %d\n",
+				priv->io_base,
+				priv->io_base + size_mask, bus, dev, func);
+#endif

use debug() and drop the CONFIG_FTPCI100_DEBUG, and fix globally in this file

drivers/pci/pci_ftpci100.c line 97

Quoted 3 lines
drivers/pci/pci_ftpci100.c new file +3 -0
+		} else {
+		/* Memory space */
+			unsigned int is_64bit = ((tmp32 & 0x6) == 0x4);

indent that comment

Quoted 1 line

+void pci_bus_scan(struct ftpci100_data *priv)

should be static

Quoted 5 lines
drivers/pci/pci_ftpci100.c new file +5 -0
+#ifdef CONFIG_PCI_SCAN_SHOW
+				printf("%06d  %03d  %03d  " \
+					"%04d  %08x  %08x  " \
+					"%03d  %08x  %06d  %08x\n",
+					priv->ndevs, devs[priv->ndevs].bus,

drivers/pci/pci_ftpci100.c line 232

Quoted 10 lines
drivers/pci/pci_ftpci100.c new file +10 -0
+					devs[priv->ndevs].dev,
+					devs[priv->ndevs].func,
+					devs[priv->ndevs].d_id,
+					devs[priv->ndevs].v_id,
+					devs[priv->ndevs].pin,
+					devs[priv->ndevs].bar[0].addr,
+					devs[priv->ndevs].bar[0].size,
+					data32 >> 8);
+				priv->ndevs++;
+#endif

should that ndevs inc really be inside this ifdef ? and would this be better as debug() ?

Quoted 7 lines
drivers/pci/pci_ftpci100.c new file +7 -0
+static int ftpci_probe(unsigned int addr_p)
+{
+	int ftpci_probed;
+	unsigned int *addr = (unsigned int *) addr_p;
+
+	*(unsigned int *) addr = 0x80000000;
+

drivers/pci/pci_ftpci100.c line 253

Quoted 10 lines
drivers/pci/pci_ftpci100.c new file +10 -0
+	if (*(unsigned int *) addr == 0x80000000) {
+		printf("Faraday ftpci100 PCI bridge probed ok\n");
+		ftpci_probed = 1;
+	} else {
+		ftpci_probed = 0;
+	}
+
+	*(unsigned int *) addr = 0x0;
+	return ftpci_probed;
+}

the LHS casts on addr make no sense. drop them.

Quoted 1 line

+void ftpci_preinit(struct ftpci100_data *priv)

static

Quoted 1 line

+void pci_ftpci_init(void)

static

drivers/pci/pci_ftpci100.c line 300

Quoted 4 lines
drivers/pci/pci_ftpci100.c new file +4 -0
+#ifdef CONFIG_PCI_SCAN_SHOW
+	printf("Device  bus  dev  func  deviceID  vendorID  pin  address" \
+		"   size    class\n");
+#endif

debug()

drivers/pci/pci_ftpci100.c line 316

Quoted 4 lines
drivers/pci/pci_ftpci100.c new file +4 -0
+	pci_hose_write_config_dword(&hose, bridge_num, PCI_MEM_BASE_SIZE1,
+					FTPCI100_BASE_ADR_SIZE(1024));
+	return;
+}

drop the useless "return;"

Quoted 25 lines
drivers/pci/pci_ftpci100.h new file +19 -0
 
+#define PCI_INT_MASK			0x4c
+#define PCI_MEM_BASE_SIZE1		0x50
+#define PCI_MEM_BASE_SIZE2		0x54
+#define PCI_MEM_BASE_SIZE3		0x58
...
+#define PCI_INTA_ENABLE			(1 << 22)
+#define PCI_INTB_ENABLE			(1 << 23)
+#define PCI_INTC_ENABLE			(1 << 24)
+#define PCI_INTD_ENABLE			(1 << 25)
...
+#define PCI_IRQ_LINES			4
+
+#define MAX_BUS_NUM			256
+#define MAX_DEV_NUM			32
+#define MAX_FUN_NUM			8
+
+#define PCI_MAX_BAR_PER_FUNC		6
...
+struct pcibar {
+	unsigned int size;
+	unsigned int addr;
+};

drivers/pci/pci_ftpci100.h line 92

Quoted 10 lines
drivers/pci/pci_ftpci100.h new file +10 -0
+
+struct pci_config {
+	unsigned int bus;
+	unsigned int dev;				/* device */
+	unsigned int func;
+	unsigned int pin;
+	unsigned short v_id;				/* vendor id */
+	unsigned short d_id;				/* device id */
+	struct pcibar bar[PCI_MAX_BAR_PER_FUNC + 1];
+};

these should be namespaced to your driver, or moved to a common pci include -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111020/417a7bd3/attachment.pgp

#4 lore raw

PATCH 1/1 pci_ftpci100: Implementation FTPCI100 PCI driver

In reply to Wolfgang Denk

From: Gavin Guo <[email protected]>

FTPCI100 is a SoC PCI componenet of Faraday company. Which is usually built into SoC chips for providing embedded PCI functions.

---
Changes for v2:
- clean up lines over 80 charaters.
- fix static functions.
- fix the oder of include headers.

Changes for v3:
- fix incorrect malloc assignment to priv strcuture.
- fix pci_set_region related configurations.
- remove useless probe function.
- remove useless __io.
- indent comment to correct format.
- add static to internal functions.
- drop the CONFIG_FTPCI100_DEBUG
- fix priv->ndevs++ in bus_scan function by dropping define CONFIG_FTPCI100_DEBUG

 drivers/pci/Makefile       |    1 +
 drivers/pci/pci_ftpci100.c |  330 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci_ftpci100.h |   94 +++++++++++++
 3 files changed, 425 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci_ftpci100.c
 create mode 100644 drivers/pci/pci_ftpci100.h
drivers/pci/Makefile +1 -0
index ee0c64d..1ae35d3 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libpci.o
 
 COBJS-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o
 COBJS-$(CONFIG_PCI) += pci.o pci_auto.o pci_indirect.o
+COBJS-$(CONFIG_FTPCI100) += pci_ftpci100.o
 COBJS-$(CONFIG_IXP_PCI) += pci_ixp.o
 COBJS-$(CONFIG_SH4_PCI) += pci_sh4.o
 COBJS-$(CONFIG_SH7751_PCI) +=pci_sh7751.o
drivers/pci/pci_ftpci100.c new file +330 -0

330 lines not on this page · raw message

drivers/pci/pci_ftpci100.h new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#5 lore raw

PATCH v4 1/1 pci_ftpci100: Implementation FTPCI100 PCI driver

In reply to Wolfgang Denk

From: Gavin Guo <[email protected]>

FTPCI100 is a SoC PCI componenet of Faraday company. Which is usually built into SoC chips for providing embedded PCI functions.

---
Changes for v2:
- clean up lines over 80 charaters.
- fix static functions.
- fix the oder of include headers.
Changes for v3:
- fix incorrect malloc assignment to priv strcuture.
- fix pci_set_region related configurations.
- remove useless probe function.
- remove useless __io.
- indent comment to correct format.
- add static to internal functions.
- drop the CONFIG_FTPCI100_DEBUG
- fix priv->ndevs++ in bus_scan function by dropping define CONFIG_FTPCI100_DEBUG
Changes for v4:
- Update version number only since the e-mail server seems didn't send out mail correctly.

 drivers/pci/Makefile       |    1 +
 drivers/pci/pci_ftpci100.c |  330 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci_ftpci100.h |   94 +++++++++++++
 3 files changed, 425 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci_ftpci100.c
 create mode 100644 drivers/pci/pci_ftpci100.h
drivers/pci/Makefile +1 -0
index ee0c64d..1ae35d3 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libpci.o
 
 COBJS-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o
 COBJS-$(CONFIG_PCI) += pci.o pci_auto.o pci_indirect.o
+COBJS-$(CONFIG_FTPCI100) += pci_ftpci100.o
 COBJS-$(CONFIG_IXP_PCI) += pci_ixp.o
 COBJS-$(CONFIG_SH4_PCI) += pci_sh4.o
 COBJS-$(CONFIG_SH7751_PCI) +=pci_sh7751.o
drivers/pci/pci_ftpci100.c new file +330 -0

330 lines not on this page · raw message

drivers/pci/pci_ftpci100.h new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#6 lore raw

PATCH v4 1/1 pci_ftpci100: Implementation FTPCI100 PCI driver

Dear Macpaul Lin,

Quoted 27 lines · In message <[email protected]> you wrote:

From: Gavin Guo <[email protected]>

FTPCI100 is a SoC PCI componenet of Faraday company. Which is usually built into SoC chips for providing embedded PCI functions.

---
Changes for v2:
- clean up lines over 80 charaters.
- fix static functions.
- fix the oder of include headers.
Changes for v3:
- fix incorrect malloc assignment to priv strcuture.
- fix pci_set_region related configurations.
- remove useless probe function.
- remove useless __io.
- indent comment to correct format.
- add static to internal functions.
- drop the CONFIG_FTPCI100_DEBUG
- fix priv->ndevs++ in bus_scan function by dropping define CONFIG_FTPCI100_DEBUG
Changes for v4:
- Update version number only since the e-mail server seems didn't send out mail correctly.

Quoted 6 lines
 drivers/pci/Makefile       |    1 +
 drivers/pci/pci_ftpci100.c |  330 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci_ftpci100.h |   94 +++++++++++++
 3 files changed, 425 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci_ftpci100.c
 create mode 100644 drivers/pci/pci_ftpci100.h

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Brain fried - Core dumped