mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 08/10] i2c: i.MX: Read clock-frequency from device tree
Date: Mon,  4 Mar 2019 10:18:41 +0100	[thread overview]
Message-ID: <20190304091843.17839-9-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20190304091843.17839-1-s.hauer@pengutronix.de>

We speed up the clock frequency only if probed via platform_data.
Additionally honour the "clock-frequency" property.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/i2c/busses/i2c-imx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 9ce6bb7533..409c178e6a 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -49,9 +49,6 @@
 #include <i2c/i2c.h>
 #include <mach/clock.h>
 
-/* Default value */
-#define FSL_I2C_BIT_RATE	100000	/* 100kHz */
-
 /* IMX I2C registers:
  * the I2C register offset is different between SoCs,
  * to provid support for all these chips, split the
@@ -611,6 +608,7 @@ static int __init i2c_fsl_probe(struct device_d *pdev)
 	struct fsl_i2c_struct *i2c_fsl;
 	struct i2c_platform_data *pdata;
 	int ret;
+	int bitrate;
 
 	pdata = pdev->platform_data;
 
@@ -652,10 +650,12 @@ static int __init i2c_fsl_probe(struct device_d *pdev)
 	i2c_fsl->dfsrr = -1;
 
 	/* Set up clock divider */
+	bitrate = 100000;
+	of_property_read_u32(pdev->device_node, "clock-frequency", &bitrate);
 	if (pdata && pdata->bitrate)
-		i2c_fsl_set_clk(i2c_fsl, pdata->bitrate);
-	else
-		i2c_fsl_set_clk(i2c_fsl, FSL_I2C_BIT_RATE);
+		bitrate = pdata->bitrate;
+
+	i2c_fsl_set_clk(i2c_fsl, bitrate);
 
 	/* Set up chip registers to defaults */
 	fsl_i2c_write_reg(i2c_fsl->hwdata->i2cr_ien_opcode ^ I2CR_IEN,
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-03-04  9:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04  9:18 [PATCH 00/10] i2c: i.MX more cleanup, early driver Sascha Hauer
2019-03-04  9:18 ` [PATCH 01/10] i2c: i.MX: remove unnecesary define Sascha Hauer
2019-03-04  9:18 ` [PATCH 02/10] i2c: i.MX: remove unnecessary ifdef Sascha Hauer
2019-03-04  9:18 ` [PATCH 03/10] i2c: i.MX: Fix FSL_I2C_DFSRR register offset Sascha Hauer
2019-03-04  9:18 ` [PATCH 04/10] i2c: i.MX: remove unnecessary ifdef Sascha Hauer
2019-03-04  9:18 ` [PATCH 05/10] i2c: i.MX: Consolidate status polling loops Sascha Hauer
2019-03-04  9:18 ` [PATCH 06/10] i2c: i.MX: stop after read only in last transfer of a message Sascha Hauer
2019-03-04  9:18 ` [PATCH 07/10] i2c: i.MX: remove unused define Sascha Hauer
2019-03-04  9:18 ` Sascha Hauer [this message]
2019-03-04  9:18 ` [PATCH 09/10] i2c: i.MX: Create header file for register defines Sascha Hauer
2019-03-04  9:18 ` [PATCH 10/10] i2c: i.MX: Add early driver for use in PBL Sascha Hauer

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=20190304091843.17839-9-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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