From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dirk Eibach Date: Tue, 07 May 2013 22:45:22 +0200 Subject: [U-Boot] [PATCH v2 06/10] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards In-Reply-To: <20130507191803.7F57C380E1B@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> <449c45a6a9978c55e84d3fe7efe6f0ac@gdsys.cc> <20130506192356.7929A380E1C@gemini.denx.de> <20130507113609.7D3F038119A@gemini.denx.de> <20130507191803.7F57C380E1B@gemini.denx.de> Message-ID: <58ff5023adcbf08481bc2707b0a70f50@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, in my example we have four FPGAs. One is memory mapped while the other three are not. They all have the same register interface which is mapped by struct ihs_fpga { u16 reflection_low; u16 versions; ... u16 mc_tx_address; u16 mc_tx_data; u16 mc_tx_cmd; ... }; To have instances of those FPGA structs, we might create an array like this: struct ihs_fpga system_fpgas[] = { (struct ihs_fpga *)CONFIG_SYS_FPGA_BASE, (struct ihs_fpga *)NULL, (struct ihs_fpga *)NULL, (struct ihs_fpga *)NULL, }; The first element ist our memory mapped FPGA with base address CONFIG_SYS_FPGA_BASE. For the other three I use NULL as base address because I don't have any better idea what else to choose. To probe those FPGAs we might have to do something like: for (k=0; k < 4; ++k) fpga_set_reg(k, &system_fpgas[k].reflection_low, REFLECTION_TESTPATTERN); The implementation of fpga_set_reg() might look like: void fpga_set_reg(unsigned int fpga, u16 *reg, u16 data) { switch (fpga) { case 0: out_le16(reg, data); break; default: mclink_send(fpga - 1, (u16)reg, data); break; } } where mclink_send() is the routine to access the non memory mapped FPGAs through the memory mapped FPGA: int mclink_send(u8 slave, u16 addr, u16 data) { ... fpga_set_reg(0, &system_fpgas[0].mc_tx_address, addr); fpga_set_reg(0, &system_fpgas[0].mc_tx_data, data); fpga_set_reg(0, &system_fpgas[0].mc_tx_cmd, (slave & 0x03) << 14); } The cast to u16 I am talking about happens, when mclink_send() is called. Cheers Dirk