From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dirk Eibach Date: Mon, 06 May 2013 17:55:22 +0200 Subject: [U-Boot] [PATCH v2 06/10] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards In-Reply-To: <20130506152259.E8260380E6C@gemini.denx.de> References: <1367847325-21463-1-git-send-email-dirk.eibach@gdsys.cc> <1367847325-21463-7-git-send-email-dirk.eibach@gdsys.cc> <20130506141000.81015380E1C@gemini.denx.de> <20130506152259.E8260380E6C@gemini.denx.de> Message-ID: <449c45a6a9978c55e84d3fe7efe6f0ac@gdsys.cc> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Wolfgang, Am 06.05.2013 17:22, schrieb Wolfgang Denk: > Dear Dirk Eibach, > > In message you wrote: >> >>> You had the this, and now attempt to throw it away. This makes no >>> sense. >> >> In fact it does. >> We have FPGAs that are memory mapped and others that are not. They >> must >> be accessed by the same drivers. So the alternative would be to >> create >> FPGA instances at address NULL and getting the register offesets by >> casting pointers to u16. Not very nice either. > > Your new code still boils down to using the same standard I/O > accessors. > > So your FPGA registers must be mapped somehow to I/O memory. > > When you can do something like > > +u16 fpga_get_reg(unsigned int fpga, u16 reg) > +{ > + return in_le16((u16 *)CONFIG_SYS_FPGA_BASE(fpga) + reg / > sizeof(u16)); > +} > > why would you not be able to continue using in_le16() directly? > > Sorry, I don't get it. Read the source, Luke :) On our iocon platform you find: +void fpga_set_reg(unsigned int fpga, u16 reg, u16 data) +{ + int res; + struct ihs_fpga *fpga_0 = (struct ihs_fpga *)CONFIG_SYS_FPGA_BASE(0); + + switch (fpga) { + case 0: + out_le16((u16 *)fpga_0 + reg / sizeof(u16), data); + break; + default: + res = mclink_send(fpga - 1, reg, data); + if (res < 0) + printf("mclink_send reg %02x data %04x returned %d\n", + reg, data, res); + break; + } +} So no memory mapping here. That's the reason for all this fuzz. And sorry for the messed up series. Sometimes rebase can make things worse :) Cheers Dirk