From: Wolfgang Denk Date: Tue, 13 Nov 2012 09:29:27 +0100 Subject: [U-Boot] [PATCH 4/7] i2c: mxs: Abstract out the MXS I2C speed setup In-Reply-To: <1352766871-892-4-git-send-email-marex@denx.de> References: <1352766871-892-1-git-send-email-marex@denx.de> <1352766871-892-4-git-send-email-marex@denx.de> Message-ID: <20121113082927.5575C2002E1@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Marek, In message <1352766871-892-4-git-send-email-marex@denx.de> you wrote: > This patch pulls out the I2C speed setup from the i2c_init() call > and implements the bus configuration lookup table with register > values that needs to be programmed into the I2C IP to run at > particular speed. > > This patch is a first step towards implementing run-time I2C bus > speed configuration for the MXS I2C IP. Thanks. > +static struct mxs_i2c_speed_table { > + uint32_t speed; > + uint32_t timing0; > + uint32_t timing1; > +} mxs_i2c_tbl[] = { > + { > + 100000, > + (0x0078 << I2C_TIMING0_HIGH_COUNT_OFFSET) | > + (0x0030 << I2C_TIMING0_RCV_COUNT_OFFSET), > + (0x0080 << I2C_TIMING1_LOW_COUNT_OFFSET) | > + (0x0030 << I2C_TIMING1_XMIT_COUNT_OFFSET) > + }, > + { > + 400000, > + (0x000f << I2C_TIMING0_HIGH_COUNT_OFFSET) | > + (0x0007 << I2C_TIMING0_RCV_COUNT_OFFSET), > + (0x001f << I2C_TIMING1_LOW_COUNT_OFFSET) | > + (0x000f << I2C_TIMING1_XMIT_COUNT_OFFSET), > + } > +}; Do we really need such a compile-time initialized table which will have to include all possible I2C speeds anybody is ever going to use on any board? And if board XXX wants to use a funny I2C clock, we have to add yet another entry to this common file? Such a solution does not scale. Can we not rather calculate these register values for any arbitrary I2C clock given? 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 Microsoft Compatibility: your old Windows 3.11 application crash exactly as the new ones.