public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 06/10] MIPS: qemu-malta: add PCI support
Date: Mon, 21 Jan 2013 13:56:13 +0100	[thread overview]
Message-ID: <20130121125613.944952005FF@gemini.denx.de> (raw)
In-Reply-To: <1358608777-7270-7-git-send-email-juhosg@openwrt.org>

Dear Gabor Juhos,

In message <1358608777-7270-7-git-send-email-juhosg@openwrt.org> you wrote:
> Qemu emulates the Galileo GT64120 System Controller
> which provides a CPU bus to PCI bus bridge.
> 
> The patch adds driver for this bridge and enables
> PCI support for the emulated Malta board.
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
> ---
>  board/qemu-malta/Makefile    |    5 +-
>  board/qemu-malta/pci.c       |  173 ++++++++++++++++++++++++++++++++++++++++++
>  include/configs/qemu-malta.h |    6 ++
>  3 files changed, 183 insertions(+), 1 deletion(-)
>  create mode 100644 board/qemu-malta/pci.c
> 
> diff --git a/board/qemu-malta/Makefile b/board/qemu-malta/Makefile
> index 6251bb8..59c1b1d 100644
> --- a/board/qemu-malta/Makefile
> +++ b/board/qemu-malta/Makefile
> @@ -25,7 +25,10 @@ include $(TOPDIR)/config.mk
>  
>  LIB	= $(obj)lib$(BOARD).o
>  
> -COBJS	= $(BOARD).o
> +COBJS-y			+= $(BOARD).o
> +COBJS-$(CONFIG_PCI)	+= pci.o
> +
> +COBJS   := $(COBJS-y)
>  SOBJS	= lowlevel_init.o
>  
>  SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
> diff --git a/board/qemu-malta/pci.c b/board/qemu-malta/pci.c
> new file mode 100644
> index 0000000..823ae9b
> --- /dev/null
> +++ b/board/qemu-malta/pci.c
> @@ -0,0 +1,173 @@
> +/*
> + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
> + *
> + * Based on the Linux implementation.
> + *   Copyright (C) 1999, 2000, 2004  MIPS Technologies, Inc.
> + *   Authors: Carsten Langgaard <carstenl@mips.com>
> + *            Maciej W. Rozycki <macro@mips.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
> + */
> +
> +#include <common.h>
> +#include <asm/addrspace.h>
> +#include <asm/gt64120.h>
> +#include <asm/malta.h>
> +#include <asm/io.h>
> +#include <pci.h>
> +
> +#define PCI_ACCESS_READ  0
> +#define PCI_ACCESS_WRITE 1
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/*
> + * PCI controller "hose" value
> + */
> +
> +static struct pci_controller hose;
> +static void __iomem *gt_base = (void __iomem *)CKSEG1ADDR(MALTA_GT_BASE);
> +
> +static inline u32 gt_read_host_reg(unsigned reg)
> +{
> +	return __raw_readl(gt_base + reg);
> +}
> +
> +static inline void gt_write_host_reg(unsigned reg, u32 val)
> +{
> +	__raw_writel(val, gt_base + reg);
> +}
> +
> +static inline u32 gt_read_reg(unsigned reg)
> +{
> +	return le32_to_cpu(gt_read_host_reg(reg));
> +}
> +
> +static inline gt_write_reg(unsigned reg, u32 val)
> +{
> +	gt_write_host_reg(reg, cpu_to_le32(val));
> +}

I dislike that you introduce new I/O accessors here, and additionally
in a way which is explicitly discouraged in U-Boot.

We don't allow to access device registers through a base address plus
offset notation; instead, we use C structs to describe the register
layout.

Also, on real hardware your accessors areprobably lacking sufficient
memory barriers etc.

Is there any specific reason for not using the usual standard
accessors as provided by <asm/io.h> ?

Best regards,

Wolfgang Denk

-- 
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
You can observe a lot just by watching.                  - Yogi Berra

  reply	other threads:[~2013-01-21 12:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-19 15:19 [U-Boot] [RFC 00/10] MIPS: initial support for emulated Malta board Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 01/10] MIPS: qemu-malta: add support for emulated MIPS " Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 02/10] MIPS: qemu-malta: add reset support Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 03/10] MIPS: qemu-malta: enable flash support Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 04/10] MIPS: import gt64120.h header from Linux 3.8-rc3 Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 05/10] MIPS: qemu-malta: setup GT64120 registers as done by YAMON Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 06/10] MIPS: qemu-malta: add PCI support Gabor Juhos
2013-01-21 12:56   ` Wolfgang Denk [this message]
2013-01-22  6:03     ` Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 07/10] net: pcnet: use pci_virt_to_mem to obtain buffer addresses Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 08/10] MIPS: qemu-malta: bring up ethernet Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 09/10] MIPS: bootm.c: add YAMON style Linux preparation/jump code Gabor Juhos
2013-01-19 15:19 ` [U-Boot] [RFC 10/10] MIPS: start.S: emulate REVISION register for qemu-malta Gabor Juhos

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=20130121125613.944952005FF@gemini.denx.de \
    --to=wd@denx.de \
    --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