public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/2] warp: Add MAX77696 support
Date: Tue, 21 Jul 2015 21:47:22 -0300	[thread overview]
Message-ID: <1437526042-15118-2-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1437526042-15118-1-git-send-email-festevam@gmail.com>

From: Fabio Estevam <fabio.estevam@freescale.com>

Warp has a MAX77696 PMIC connected via I2C1 bus.

Add support for it.                                                                

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- None

 board/warp/warp.c      | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/configs/warp.h | 11 +++++++++++
 2 files changed, 61 insertions(+)

diff --git a/board/warp/warp.c b/board/warp/warp.c
index 21ac5e7..49dfdb6 100644
--- a/board/warp/warp.c
+++ b/board/warp/warp.c
@@ -15,13 +15,17 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/gpio.h>
 #include <asm/imx-common/iomux-v3.h>
+#include <asm/imx-common/mxc_i2c.h>
 #include <asm/io.h>
 #include <linux/sizes.h>
 #include <common.h>
 #include <watchdog.h>
 #include <fsl_esdhc.h>
+#include <i2c.h>
 #include <mmc.h>
 #include <usb.h>
+#include <power/pmic.h>
+#include <power/max77696_pmic.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -35,6 +39,11 @@ DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_SRE_FAST  | PAD_CTL_HYS | \
 	PAD_CTL_LVE)
 
+#define I2C_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE |		\
+		      PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |	\
+		      PAD_CTL_DSE_40ohm | PAD_CTL_HYS |		\
+		      PAD_CTL_ODE | PAD_CTL_SRE_FAST)
+
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
@@ -88,6 +97,45 @@ int board_usb_phy_mode(int port)
 	return USB_INIT_DEVICE;
 }
 
+/* I2C1 for PMIC */
+#define I2C_PMIC	0
+#define PC	MUX_PAD_CTRL(I2C_PAD_CTRL)
+struct i2c_pads_info i2c_pad_info1 = {
+	.sda = {
+		.i2c_mode = MX6_PAD_I2C1_SDA__I2C1_SDA | PC,
+		.gpio_mode = MX6_PAD_I2C1_SDA__GPIO_3_13 | PC,
+		.gp = IMX_GPIO_NR(3, 13),
+	},
+	.scl = {
+		.i2c_mode = MX6_PAD_I2C1_SCL__I2C1_SCL | PC,
+		.gpio_mode = MX6_PAD_I2C1_SCL__GPIO_3_12 | PC,
+		.gp = IMX_GPIO_NR(3, 12),
+	},
+};
+
+int power_init_board(void)
+{
+	struct pmic *p;
+	int ret;
+	unsigned int reg;
+
+	ret = power_max77696_init(I2C_PMIC);
+	if (ret)
+		return ret;
+
+	p = pmic_get("MAX77696");
+	if (!p)
+		return -EINVAL;
+
+	ret = pmic_reg_read(p, CID, &reg);
+	if (ret)
+		return ret;
+
+	printf("PMIC:  MAX77696 detected, rev=0x%x\n", reg);
+
+	return pmic_probe(p);
+}
+
 int board_early_init_f(void)
 {
 	setup_iomux_uart();
@@ -99,6 +147,8 @@ int board_init(void)
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
+	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
+
 	return 0;
 }
 
diff --git a/include/configs/warp.h b/include/configs/warp.h
index 48e2058..f38f781 100644
--- a/include/configs/warp.h
+++ b/include/configs/warp.h
@@ -98,6 +98,17 @@
 #define CONFIG_CMD_FUSE
 #define CONFIG_MXC_OCOTP
 
+/* I2C Configs */
+#define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MXC
+#define CONFIG_SYS_I2C_SPEED		  100000
+
+/* PMIC */
+#define CONFIG_POWER
+#define CONFIG_POWER_I2C
+#define CONFIG_POWER_MAX77696
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
-- 
1.9.1

  reply	other threads:[~2015-07-22  0:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22  0:47 [U-Boot] [PATCH v2 1/2] power: pmic: Add support for MAX77696 PMIC Fabio Estevam
2015-07-22  0:47 ` Fabio Estevam [this message]
2015-07-26 10:14   ` [U-Boot] [PATCH v2 2/2] warp: Add MAX77696 support Stefano Babic
2015-07-26 10:13 ` [U-Boot] [PATCH v2 1/2] power: pmic: Add support for MAX77696 PMIC Stefano Babic

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=1437526042-15118-2-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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