public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] pci_ftpci100: Implementation FTPCI100 PCI driver
Date: Thu, 20 Oct 2011 08:35:31 -0400	[thread overview]
Message-ID: <201110200835.33201.vapier@gentoo.org> (raw)
In-Reply-To: <1319098585-25134-1-git-send-email-macpaul@andestech.com>

On Thursday 20 October 2011 04:16:25 Macpaul Lin wrote:
> --- /dev/null
> +++ b/drivers/pci/pci_ftpci100.c
>
> +#ifndef __io
> +#define __io
> +#endif

this is most likely wrong.  drop it.

> +#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

> +struct pci_config devs[FTPCI100_MAX_FUNCTIONS];
> +struct pci_controller hose;

need to be static

> +void setup_pci_bar(unsigned int bus, unsigned int dev, unsigned func,
> +		unsigned char header, struct ftpci100_data *priv)

should be static

> +#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

> +		} else {
> +		/* Memory space */
> +			unsigned int is_64bit = ((tmp32 & 0x6) == 0x4);

indent that comment

> +void pci_bus_scan(struct ftpci100_data *priv)

should be static

> +#ifdef CONFIG_PCI_SCAN_SHOW
> +				printf("%06d  %03d  %03d  " \
> +					"%04d  %08x  %08x  " \
> +					"%03d  %08x  %06d  %08x\n",
> +					priv->ndevs, devs[priv->ndevs].bus,
> +					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() ?

> +static int ftpci_probe(unsigned int addr_p)
> +{
> +	int ftpci_probed;
> +	unsigned int *addr = (unsigned int *) addr_p;
> +
> +	*(unsigned int *) addr = 0x80000000;
> +
> +	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.

> +void ftpci_preinit(struct ftpci100_data *priv)

static

> +void pci_ftpci_init(void)

static

> +#ifdef CONFIG_PCI_SCAN_SHOW
> +	printf("Device  bus  dev  func  deviceID  vendorID  pin  address" \
> +		"   size    class\n");
> +#endif

debug()

> +	pci_hose_write_config_dword(&hose, bridge_num, PCI_MEM_BASE_SIZE1,
> +					FTPCI100_BASE_ADR_SIZE(1024));
> +	return;
> +}

drop the useless "return;"

> --- /dev/null
> +++ b/drivers/pci/pci_ftpci100.h
>
> +#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;
> +};
> +
> +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 

  reply	other threads:[~2011-10-20 12:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-05  7:56 [U-Boot] [PATCH] pci_ftpci100: Implementation FTPCI100 PCI driver Macpaul Lin
2011-10-06 21:08 ` Wolfgang Denk
2011-10-20  8:16   ` [U-Boot] [PATCH v2] " Macpaul Lin
2011-10-20 12:35     ` Mike Frysinger [this message]
2011-11-29  6:48   ` [U-Boot] [PATCH] " Macpaul Lin
2011-11-29  6:59   ` [U-Boot] [PATCH v4] " Macpaul Lin
2011-12-05 22:13     ` Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2010-12-29 13:16 [U-Boot] [PATCH v2] " Gavin Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201110200835.33201.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox