From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 06/10] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards
Date: Tue, 28 May 2013 13:47:23 +0200 [thread overview]
Message-ID: <20130528114723.6A64A3831A2@gemini.denx.de> (raw)
In-Reply-To: <0e4604dcfff89a1bd2b7f144a5b3ceae@gdsys.cc>
Dear Dirk,
In message <0e4604dcfff89a1bd2b7f144a5b3ceae@gdsys.cc> you wrote:
>
> sorry for the delay, I had to clean some other things on my ToDoList.
Ditto :-(
> > void fpga_set_reg(u32 fpga, u16 *reg, off_t regoff, u16 data)
> > {
> > if (fpga)
> > return mclink_send(fpga - 1, regoff, data);
> >
> > return out_le16(reg, data);
> > }
...
> > #define FPGA_SET_REG(ix,fld,val) \
> > fpga_set_reg((ix), \
> > &fpga_ptr->fld, \
> > offsetof(struct ihs_fpga, fld), \
> > val)
...
> > FPGA_SET_REG(0, mc_tx_address, addr);
> > FPGA_SET_REG(0, mc_tx_data, data);
> > FPGA_SET_REG(0, mc_tx_cmd, (slave & 0x03) << 14);
>
> This works nicely for our memory mapped FPGA. But how about the other
> FPGAs? I don't have a fpga_ptr for them. Setting it NULL would make
> FPGA_SET_REG dereference a NULL pointer.
No, it does not.
In your setup you have a single memory mapped FPGA, addressed by the
globally visible pointer fpga_ptr.
When accessing this memory mapped FPGA (index is zero), then this
pointer gets used, which is OK.
For the other devices (index is not zero), then the pointer is
ignored, and only the offset is used.
In case you had more memory mapped devices (not only index 0; say,
something like index < N) you can still use this, and pass any
(properly aligned) pointer for the non-memory mapped case. Note that
the pointer will NOT be dereferenced - only the address of field "fld"
will be calculated (and even this only in theory, because this code
will not be executed for the non-memory mapped case).
> Certainly I might call
> fpga_set_reg(1,
> NULL,
> offsetof(struct ihs_fpga, mc_tx_address),
> addr);
> but that would not be generic any more.
You don't call fpga_set_reg() any more, you just use the
FPGA_SET_REG() macro described above.
> Do you have any idea how to solve this?
I think this needs no new solution, because it shoul just work :-)
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
Alan Turing thought about criteria to settle the question of whether
machines can think, a question of which we now know that it is about
as relevant as the question of whether submarines can swim.
-- Edsger Dijkstra
next prev parent reply other threads:[~2013-05-28 11:47 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 13:35 [U-Boot] [PATCH v2 0/10] Update gdsys ppc4xx-based boards dirk.eibach at gdsys.cc
2013-05-06 13:35 ` [U-Boot] [PATCH v2 01/10] powerpc/ppc4xx: Add generic accessor functions for gdsys FPGA dirk.eibach at gdsys.cc
2013-05-06 14:01 ` Wolfgang Denk
2013-05-06 14:02 ` Wolfgang Denk
2013-05-06 13:35 ` [U-Boot] [PATCH v2 02/10] powerpc/ppc4xx: Add gdsys mclink interface dirk.eibach at gdsys.cc
2013-05-06 13:35 ` [U-Boot] [PATCH v2 03/10] powerpc/ppc4xx: Add fpgad command for dumping gdsys fpga registers dirk.eibach at gdsys.cc
2013-05-06 13:35 ` [U-Boot] [PATCH v2 04/10] powerpc/ppc4xx: Use generic FPGA accessors in gdsys common code dirk.eibach at gdsys.cc
2013-05-06 14:07 ` Wolfgang Denk
2013-05-06 14:57 ` Tom Rini
2013-05-06 15:02 ` Dirk Eibach
2013-05-06 15:09 ` Tom Rini
2013-05-06 15:51 ` Dirk Eibach
2013-05-06 13:35 ` [U-Boot] [PATCH v2 05/10] powerpc/ppc4xx: Support gdsys multichannel iocon hardware dirk.eibach at gdsys.cc
2013-05-06 14:12 ` Wolfgang Denk
2013-05-06 14:16 ` Dirk Eibach
2013-05-06 15:18 ` Wolfgang Denk
2013-05-06 15:49 ` Dirk Eibach
2013-05-06 19:15 ` Wolfgang Denk
2013-05-06 19:31 ` Joe Hershberger
2013-05-06 13:35 ` [U-Boot] [PATCH v2 06/10] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards dirk.eibach at gdsys.cc
2013-05-06 14:10 ` Wolfgang Denk
2013-05-06 14:50 ` Dirk Eibach
2013-05-06 15:22 ` Wolfgang Denk
2013-05-06 15:55 ` Dirk Eibach
2013-05-06 19:23 ` Wolfgang Denk
2013-05-07 8:32 ` Dirk Eibach
2013-05-07 11:36 ` Wolfgang Denk
2013-05-07 12:08 ` Dirk Eibach
2013-05-07 19:18 ` Wolfgang Denk
2013-05-07 20:45 ` Dirk Eibach
2013-05-08 10:13 ` Wolfgang Denk
2013-05-08 11:17 ` Dirk Eibach
2013-05-08 15:37 ` Wolfgang Denk
2013-05-15 9:23 ` Dirk Eibach
2013-05-28 7:39 ` Dirk Eibach
2013-05-28 7:47 ` Dirk Eibach
2013-05-28 11:47 ` Wolfgang Denk [this message]
2013-05-06 13:35 ` [U-Boot] [PATCH v2 07/10] powerpc/ppc4xx: Fixup phy erratum on gdsys iocon hardware dirk.eibach at gdsys.cc
2013-05-06 13:35 ` [U-Boot] [PATCH v2 08/10] powerpc/ppc4xx: Increase timeout for gdsys mclink bus startup dirk.eibach at gdsys.cc
2013-05-06 13:35 ` [U-Boot] [PATCH v2 09/10] powerpc/ppc4xx: Consider gdsys FPGA OSD size dirk.eibach at gdsys.cc
2013-05-06 13:35 ` [U-Boot] [PATCH v2 10/10] powerpc/ppc4xx: Remove CONFIG_SYS_FLASH_PROTECTION from gdsys boards dirk.eibach at gdsys.cc
2013-05-06 14:03 ` [U-Boot] [PATCH v2 0/10] Update gdsys ppc4xx-based boards Wolfgang Denk
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=20130528114723.6A64A3831A2@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