summaryrefslogtreecommitdiff
path: root/arch/arm/imx-common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-10-02 17:17:23 +0300
committerSimon Glass <sjg@chromium.org>2014-10-22 10:36:55 -0600
commitc6f3f32356b21f3220cfb4a17c37645249ba6d30 (patch)
tree0cb694e96f8db4b3dfa92a6d08a9e2f5c5aa8bdf /arch/arm/imx-common
parentedbf8b4f8c7ef61d3dea5f629e0d756990b8277d (diff)
downloadu-boot-imx-c6f3f32356b21f3220cfb4a17c37645249ba6d30.zip
u-boot-imx-c6f3f32356b21f3220cfb4a17c37645249ba6d30.tar.gz
u-boot-imx-c6f3f32356b21f3220cfb4a17c37645249ba6d30.tar.bz2
dm: imx: i2c: Use gpio_request() to request GPIOs
GPIOs should be requested before use. Without this, driver model will not permit the GPIO to be used. Cc: Igor Grinberg <grinberg@compulab.co.il> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il> Acked-by: Igor Grinberg <grinberg@compulab.co.il>
Diffstat (limited to 'arch/arm/imx-common')
-rw-r--r--arch/arm/imx-common/i2c-mxv7.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/arm/imx-common/i2c-mxv7.c b/arch/arm/imx-common/i2c-mxv7.c
index 70cff5c..34f5387 100644
--- a/arch/arm/imx-common/i2c-mxv7.c
+++ b/arch/arm/imx-common/i2c-mxv7.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
+#include <malloc.h>
#include <asm/arch/clock.h>
#include <asm/arch/imx-regs.h>
#include <asm/errno.h>
@@ -72,10 +73,27 @@ static void * const i2c_bases[] = {
int setup_i2c(unsigned i2c_index, int speed, int slave_addr,
struct i2c_pads_info *p)
{
+ char *name1, *name2;
int ret;
if (i2c_index >= ARRAY_SIZE(i2c_bases))
return -EINVAL;
+
+ name1 = malloc(9);
+ name2 = malloc(9);
+ if (!name1 || !name2)
+ return -ENOMEM;
+
+ sprintf(name1, "i2c_sda%d", i2c_index);
+ sprintf(name2, "i2c_scl%d", i2c_index);
+ ret = gpio_request(p->sda.gp, name1);
+ if (ret)
+ goto err_req1;
+
+ ret = gpio_request(p->scl.gp, name2);
+ if (ret)
+ goto err_req2;
+
/* Enable i2c clock */
ret = enable_i2c_clk(1, i2c_index);
if (ret)
@@ -93,5 +111,12 @@ int setup_i2c(unsigned i2c_index, int speed, int slave_addr,
err_idle:
err_clk:
+ gpio_free(p->scl.gp);
+err_req2:
+ gpio_free(p->sda.gp);
+err_req1:
+ free(name1);
+ free(name2);
+
return ret;
}