From: Wolfgang Denk Date: Fri, 30 Nov 2012 16:07:54 +0100 Subject: [U-Boot] [PATCH] mxs: i2c: Implement algorithm to set up arbitrary i2c speed In-Reply-To: <1354280910-17539-1-git-send-email-marex@denx.de> References: <1354280910-17539-1-git-send-email-marex@denx.de> Message-ID: <20121130150754.3313D201015@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 Vasut, In message <1354280910-17539-1-git-send-email-marex@denx.de> you wrote: > This algorithm computes the values of TIMING{0,1,2} registers for the > MX28 I2C block. This algorithm was derived by using a scope, but the > result seems correct. Thanks! I like that! ... > + uint32_t base = ((24000000 / speed) - 38) / 2; ... > + return 24000000 / ((((timing0 >> 16) - 3) * 2) + 38); But we should get rid of this magic constant. On other i.MX systems that would probably be MXC_HCLK ? For iMX28, we have CONFIG_PL011_CLOCK in the board config files instead. Hm... grepping the source tree for 24000000 I get the feeling that this really needs some cleanup.... 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 Vulcans worship peace above all. -- McCoy, "Return to Tomorrow", stardate 4768.3