From: Paul Burton <paul.burton@imgtec.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 09/15] malta: support for coreFPGA6 boards
Date: Thu, 24 Oct 2013 10:47:04 +0100 [thread overview]
Message-ID: <5268EC98.7070305@imgtec.com> (raw)
In-Reply-To: <CACUy__WUTqns8qGMQS5DyVsEaFagLMi5uf1hQXkE9Dy+cUjn8A@mail.gmail.com>
>> diff --git a/drivers/pci/pci_msc01.c b/drivers/pci/pci_msc01.c
>> new file mode 100644
>> index 0000000..7904378
>> --- /dev/null
>> +++ b/drivers/pci/pci_msc01.c
>> @@ -0,0 +1,126 @@
>> +/*
>> + * Copyright (C) 2013 Imagination Technologies
>> + * Author: Paul Burton <paul.burton@imgtec.com>
>> + *
>> + * SPDX-License-Identifier: GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <msc01.h>
>> +#include <pci.h>
>> +#include <pci_msc01.h>
>> +#include <asm/io.h>
>> +
>> +#define PCI_ACCESS_READ 0
>> +#define PCI_ACCESS_WRITE 1
>> +
>> +struct msc01_pci_controller {
>> + struct pci_controller hose;
>> + void *base;
>> +};
>> +
>> +static inline struct msc01_pci_controller *
>> +hose_to_msc01(struct pci_controller *hose)
>> +{
>> + return container_of(hose, struct msc01_pci_controller, hose);
>> +}
>> +
>> +static int msc01_config_access(struct msc01_pci_controller *msc01,
>> + unsigned char access_type, pci_dev_t bdf,
>> + int where, u32 *data)
>> +{
>> + const u32 aborts = MSC01_PCI_INTSTAT_MA_MSK | MSC01_PCI_INTSTAT_TA_MSK;
>> + void *intstat = msc01->base + MSC01_PCI_INTSTAT_OFS;
>> + void *cfgdata = msc01->base + MSC01_PCI_CFGDATA_OFS;
>> + unsigned int bus = PCI_BUS(bdf);
>> + unsigned int dev = PCI_DEV(bdf);
>> + unsigned int devfn = PCI_DEV(bdf) << 3 | PCI_FUNC(bdf);
>> + u32 status;
>
> gcc-4.8 shows a warning:
>
> pci_msc01.c: In function 'msc01_config_access':
> pci_msc01.c:38:6: warning: unused variable 'status' [-Wunused-variable]
> u32 status;
> ^
Right you are.
>
>
>> +
>> + /* clear abort status */
>> + __raw_writel(aborts, intstat);
>> +
>> + /* setup address */
>> + __raw_writel((bus << MSC01_PCI_CFGADDR_BNUM_SHF) |
>> + (dev << MSC01_PCI_CFGADDR_DNUM_SHF) |
>> + (devfn << MSC01_PCI_CFGADDR_FNUM_SHF) |
>> + ((where / 4) << MSC01_PCI_CFGADDR_RNUM_SHF),
>> + msc01->base + MSC01_PCI_CFGADDR_OFS);
>
> Contrary to the kernel U-Boot code must not use base + offset in IO
> primitives. Registers should be implemented with a struct.
> For example:
>
> struct foobar_regs {
> u32 foo;
> u32 bar;
> };
>
> struct foobar_regs *regs = (struct foobar_regs *)CKSEG1ADDR(FOOBAR_BASE);
> u32 val = __raw_readl(®s->foo);
Could you point me to somewhere stating that? (and why?) I can't find
anything in README and I can see plenty of code using base+offset
already in U-boot. In this case the assembly in lowlevel_init.S has to
access various registers so using the offsets in C means I don't need to
duplicate the information in both struct & offset macro forms. I don't
mind too much if it's a rule but I'd like to see some
justification/reasoning before I change this.
Thanks for the review,
Paul
next prev parent reply other threads:[~2013-10-24 9:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-23 10:07 [U-Boot] [PATCH 00/15] MIPS Malta board support Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 01/15] mips32: detect L1 cache sizes if they're not defined Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 02/15] pcnet: code style cleanup Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 03/15] pcnet: s/le16_to_cpu/cpu_to_le16/ in pcnet_send Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 04/15] pcnet: add cache flushing & invalidation Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 05/15] pcnet: enable the NOUFLO feature Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 06/15] pci.h: allow inclusion in assembly source Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 07/15] qemu-malta: rename to just "malta" Paul Burton
2013-10-23 22:50 ` Daniel Schwierzeck
2013-10-24 9:31 ` [U-Boot] [PATCH v2 " Paul Burton
2013-10-24 10:04 ` Gabor Juhos
2013-10-24 10:10 ` Paul Burton
2013-10-24 10:43 ` Gabor Juhos
2013-10-24 10:54 ` Paul Burton
2013-10-24 11:51 ` Daniel Schwierzeck
2013-10-24 12:06 ` Gabor Juhos
2013-10-24 10:11 ` [U-Boot] [PATCH v3 " Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 08/15] malta: setup super I/O UARTs Paul Burton
2013-10-24 9:32 ` [U-Boot] [PATCH v2 " Paul Burton
2013-10-23 10:07 ` [U-Boot] [PATCH 09/15] malta: support for coreFPGA6 boards Paul Burton
2013-10-23 22:53 ` Daniel Schwierzeck
2013-10-24 9:33 ` [U-Boot] [PATCH v2 " Paul Burton
2013-10-24 12:14 ` Gabor Juhos
2013-10-24 9:47 ` Paul Burton [this message]
2013-10-23 10:08 ` [U-Boot] [PATCH 10/15] malta: display "U-boot" on the LCD screen Paul Burton
2013-10-24 9:34 ` [U-Boot] [PATCH v2 " Paul Burton
2013-10-23 10:08 ` [U-Boot] [PATCH 11/15] malta: enable CONFIG_PCNET_79C973, PCNET_HAS_PROM, CONFIG_CMD_DHCP Paul Burton
2013-10-23 10:08 ` [U-Boot] [PATCH 12/15] malta: remove cache size definitions Paul Burton
2013-10-23 10:08 ` [U-Boot] [PATCH 13/15] malta: disable L2 caches Paul Burton
2013-10-24 9:34 ` [U-Boot] [PATCH v2 " Paul Burton
2013-10-23 10:08 ` [U-Boot] [PATCH 14/15] malta: add script & instructions to flash U-boot Paul Burton
2013-10-23 22:54 ` Daniel Schwierzeck
2013-10-24 9:35 ` [U-Boot] [PATCH v2 " Paul Burton
2013-10-23 10:11 ` [U-Boot] [PATCH 15/15] malta: add myself to maintainers Paul Burton
2013-10-24 9:36 ` [U-Boot] [PATCH v2 " Paul Burton
-- strict thread matches above, loose matches on Subject: below --
2013-10-24 11:23 [U-Boot] [PATCH 09/15] malta: support for coreFPGA6 boards Daniel Schwierzeck
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=5268EC98.7070305@imgtec.com \
--to=paul.burton@imgtec.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.