All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver
@ 2013-07-10 20:06 Dan Murphy
  2013-07-10 20:06 ` [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander Dan Murphy
  2013-07-11 14:31 ` [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver Tom Rini
  0 siblings, 2 replies; 12+ messages in thread
From: Dan Murphy @ 2013-07-10 20:06 UTC (permalink / raw)
  To: u-boot

Add the tca642x gpio expander driver

Datasheet:
http://www.ti.com/product/tca6424a

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/gpio/Makefile  |    1 +
 drivers/gpio/tca642x.c |  322 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/tca642x.h      |   66 ++++++++++
 3 files changed, 389 insertions(+)
 create mode 100644 drivers/gpio/tca642x.c
 create mode 100644 include/tca642x.h

diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index f77c1ec..7e74dfe 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -49,6 +49,7 @@ COBJS-$(CONFIG_BCM2835_GPIO)	+= bcm2835_gpio.o
 COBJS-$(CONFIG_S3C2440_GPIO)	+= s3c2440_gpio.o
 COBJS-$(CONFIG_XILINX_GPIO)	+= xilinx_gpio.o
 COBJS-$(CONFIG_ADI_GPIO2)	+= adi_gpio2.o
+COBJS-$(CONFIG_TCA642X)		+= tca642x.o
 
 COBJS	:= $(COBJS-y)
 SRCS 	:= $(COBJS:.o=.c)
diff --git a/drivers/gpio/tca642x.c b/drivers/gpio/tca642x.c
new file mode 100644
index 0000000..a0c7a8b
--- /dev/null
+++ b/drivers/gpio/tca642x.c
@@ -0,0 +1,322 @@
+/*
+ * Copyright 2013 Texas Instruments, Inc.
+ * Author: Dan Murphy <dmurphy@ti.com>
+ *
+ * Derived work from the pca953x.c driver
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <tca642x.h>
+
+/* tca642x register address definitions */
+struct tca642x_bank_info tca642x_regs[] = {
+	{ .input_reg = 0x00,
+	  .output_reg = 0x04,
+	  .polarity_reg = 0x08,
+	  .configuration_reg = 0x0c },
+	{ .input_reg = 0x01,
+	  .output_reg = 0x05,
+	  .polarity_reg = 0x09,
+	  .configuration_reg = 0x0d },
+	{ .input_reg = 0x02,
+	  .output_reg = 0x06,
+	  .polarity_reg = 0x0a,
+	  .configuration_reg = 0x0e },
+};
+
+/*
+ * Modify masked bits in register
+ */
+static int tca642x_reg_write(uchar chip, uint8_t addr,
+		uint8_t reg_bit, uint8_t data)
+{
+	uint8_t valw;
+	int org_bus_num;
+	int ret;
+
+	org_bus_num = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_I2C_TCA642X_BUS_NUM);
+
+	if (i2c_read(chip, addr, 1, (uint8_t *)&valw, 1)) {
+		printf("Could not read before writing\n");
+		ret = -1;
+		goto error;
+	}
+	valw &= ~reg_bit;
+	valw |= data;
+
+	ret = i2c_write(chip, addr, 1, (u8 *)&valw, 1);
+
+error:
+	i2c_set_bus_num(org_bus_num);
+	return ret;
+}
+
+static int tca642x_reg_read(uchar chip, uint8_t addr, uint8_t *data)
+{
+	uint8_t valw;
+	int org_bus_num;
+	int ret = 0;
+
+	org_bus_num = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_I2C_TCA642X_BUS_NUM);
+	if (i2c_read(chip, addr, 1, (u8 *)&valw, 1)) {
+		ret = -1;
+		goto error;
+	}
+
+	*data = valw;
+
+error:
+	i2c_set_bus_num(org_bus_num);
+	return ret;
+}
+
+/*
+ * Set output value of IO pins in 'reg_bit' to corresponding value in 'data'
+ * 0 = low, 1 = high
+ */
+int tca642x_set_val(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data)
+{
+	uint8_t out_reg = tca642x_regs[gpio_bank].output_reg;
+
+	return tca642x_reg_write(chip, out_reg, reg_bit, data);
+}
+
+/*
+ * Set read polarity of IO pins in 'reg_bit' to corresponding value in 'data'
+ * 0 = read pin value, 1 = read inverted pin value
+ */
+int tca642x_set_pol(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data)
+{
+	uint8_t pol_reg = tca642x_regs[gpio_bank].polarity_reg;
+
+	return tca642x_reg_write(chip, pol_reg, reg_bit, data);
+}
+
+/*
+ * Set direction of IO pins in 'reg_bit' to corresponding value in 'data'
+ * 0 = output, 1 = input
+ */
+int tca642x_set_dir(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data)
+{
+	uint8_t config_reg = tca642x_regs[gpio_bank].configuration_reg;
+
+	return tca642x_reg_write(chip, config_reg, reg_bit, data);
+}
+
+/*
+ * Read current logic level of all IO pins
+ */
+int tca642x_get_val(uchar chip, uint8_t gpio_bank)
+{
+	uint8_t val;
+	uint8_t in_reg = tca642x_regs[gpio_bank].input_reg;
+
+	if (tca642x_reg_read(chip, in_reg, &val) < 0)
+		return -1;
+
+	return (int)val;
+}
+
+/*
+ * Set the inital register states for the tca642x gpio expander
+ */
+int tca642x_set_inital_state(uchar chip, struct tca642x_bank_info init_data[])
+{
+	int i, ret;
+	uint8_t config_reg;
+	uint8_t polarity_reg;
+	uint8_t output_reg;
+
+	for (i = 0; i < 3; i++) {
+		config_reg = tca642x_regs[i].configuration_reg;
+		ret = tca642x_reg_write(chip, config_reg, 0xff,
+				init_data[i].configuration_reg);
+		polarity_reg = tca642x_regs[i].polarity_reg;
+		ret = tca642x_reg_write(chip, polarity_reg, 0xff,
+				init_data[i].polarity_reg);
+		output_reg = tca642x_regs[i].output_reg;
+		ret = tca642x_reg_write(chip, output_reg, 0xff,
+				init_data[i].output_reg);
+	}
+
+	return ret;
+}
+
+#ifdef CONFIG_CMD_TCA642X
+/*
+ * Display tca642x information
+ */
+static int tca642x_info(uchar chip)
+{
+	int i, j;
+	uint8_t data;
+
+	printf("tca642x@ 0x%x (%d pins):\n", chip, 24);
+	for (i = 0; i < 3; i++) {
+		printf("Bank %i\n", i);
+		if (tca642x_reg_read(chip, tca642x_regs[i].configuration_reg, &data) < 0)
+			return -1;
+		printf("\tConfiguration: ");
+		for (j = 7; j >= 0; j--)
+			printf("%c", data & (1 << j) ? 'i' : 'o');
+		printf("\n");
+
+		if (tca642x_reg_read(chip, tca642x_regs[i].polarity_reg, &data) < 0)
+			return -1;
+		printf("\tPolarity: ");
+		for (j = 7; j >= 0; j--)
+			printf("%c", data & (1 << j) ? '1' : '0');
+		printf("\n");
+
+		if (tca642x_reg_read(chip, tca642x_regs[i].input_reg, &data) < 0)
+			return -1;
+		printf("\tInput value: ");
+		for (j = 7; j >= 0; j--)
+			printf("%c", data & (1 << j) ? '1' : '0');
+		printf("\n");
+
+		if (tca642x_reg_read(chip, tca642x_regs[i].output_reg, &data) < 0)
+			return -1;
+		printf("\tOutput value: ");
+		for (j = 7; j >= 0; j--)
+			printf("%c", data & (1 << j) ? '1' : '0');
+		printf("\n");
+	}
+
+	return 0;
+}
+
+cmd_tbl_t cmd_tca642x[] = {
+	U_BOOT_CMD_MKENT(device, 3, 0, (void *)TCA642X_CMD_DEVICE, "", ""),
+	U_BOOT_CMD_MKENT(output, 4, 0, (void *)TCA642X_CMD_OUTPUT, "", ""),
+	U_BOOT_CMD_MKENT(input, 3, 0, (void *)TCA642X_CMD_INPUT, "", ""),
+	U_BOOT_CMD_MKENT(invert, 4, 0, (void *)TCA642X_CMD_INVERT, "", ""),
+	U_BOOT_CMD_MKENT(info, 2, 0, (void *)TCA642X_CMD_INFO, "", ""),
+};
+
+int do_tca642x(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	static uchar chip = CONFIG_SYS_I2C_TCA642X_ADDR;
+	int ret = CMD_RET_USAGE, val;
+	uint8_t gpio_bank = 0;
+	uint8_t bank_shift;
+	ulong ul_arg2 = 0;
+	ulong ul_arg3 = 0;
+	cmd_tbl_t *c;
+
+	c = find_cmd_tbl(argv[1], cmd_tca642x, ARRAY_SIZE(cmd_tca642x));
+
+	/* All commands but "device" require 'maxargs' arguments */
+	if (!c || !((argc == (c->maxargs)) ||
+		(((int)c->cmd == TCA642X_CMD_DEVICE) &&
+		(argc == (c->maxargs - 1))))) {
+		return CMD_RET_USAGE;
+	}
+
+	/* arg2 used as chip number or pin number */
+	if (argc > 2)
+		ul_arg2 = simple_strtoul(argv[2], NULL, 10);
+
+	/* arg3 used as pin or invert value */
+	if (argc > 3) {
+		ul_arg3 = simple_strtoul(argv[3], NULL, 10) & 0x1;
+		if (ul_arg2 <= 7) {
+			gpio_bank = 0;
+		} else if ((ul_arg2 >= 10) && (ul_arg2 <= 17)) {
+			gpio_bank = 1;
+		} else if ((ul_arg2 >= 20) && (ul_arg2 <= 27)) {
+			gpio_bank = 2;
+		} else {
+			printf("Requested pin is not available\n");
+			ret = CMD_RET_FAILURE;
+			goto error;
+		}
+	}
+
+	switch ((int)c->cmd) {
+	case TCA642X_CMD_INFO:
+		ret = tca642x_info(chip);
+		if (ret)
+			ret = CMD_RET_FAILURE;
+		break;
+
+	case TCA642X_CMD_DEVICE:
+		if (argc == 3)
+			chip = (uint8_t)ul_arg2;
+		printf("Current device address: 0x%x\n", chip);
+		ret = CMD_RET_SUCCESS;
+		break;
+
+	case TCA642X_CMD_INPUT:
+		bank_shift = ul_arg2 - (gpio_bank * 10);
+		ret = tca642x_set_dir(chip, gpio_bank, (1 << bank_shift),
+				TCA642X_DIR_IN << bank_shift);
+		val = (tca642x_get_val(chip, gpio_bank) & (1 << bank_shift)) != 0;
+
+		if (ret)
+			ret = CMD_RET_FAILURE;
+		else
+			printf("chip 0x%02x, pin 0x%lx = %d\n", chip,
+				ul_arg2, val);
+		break;
+
+	case TCA642X_CMD_OUTPUT:
+		bank_shift = ul_arg2 - (gpio_bank * 10);
+		ret = tca642x_set_dir(chip, gpio_bank, (1 << bank_shift),
+				(TCA642X_DIR_OUT << bank_shift));
+		if (!ret)
+			ret = tca642x_set_val(chip, gpio_bank, (1 << bank_shift),
+						(ul_arg3 << bank_shift));
+		if (ret)
+			ret = CMD_RET_FAILURE;
+		break;
+
+	case TCA642X_CMD_INVERT:
+		bank_shift = ul_arg2 - (gpio_bank * 10);
+		ret = tca642x_set_pol(chip, gpio_bank, (1 << bank_shift),
+					(ul_arg3 << bank_shift));
+		if (ret)
+			ret = CMD_RET_FAILURE;
+		break;
+	}
+error:
+	if (ret == CMD_RET_FAILURE)
+		eprintf("Error talking to chip at 0x%x\n", chip);
+
+	return ret;
+}
+
+U_BOOT_CMD(
+	tca642x,	5,	1,	do_tca642x,
+	"tca642x gpio access",
+	"device [dev]\n"
+	"	- show or set current device address\n"
+	"tca642x info\n"
+	"	- display info for current chip\n"
+	"tca642x output pin 0|1\n"
+	"	- set pin as output and drive low or high\n"
+	"tca642x invert pin 0|1\n"
+	"	- disable/enable polarity inversion for reads\n"
+	"tca642x input pin\n"
+	"	- set pin as input and read value"
+);
+
+#endif /* CONFIG_CMD_TCA642X */
diff --git a/include/tca642x.h b/include/tca642x.h
new file mode 100644
index 0000000..64e4338
--- /dev/null
+++ b/include/tca642x.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2013 Texas Instruments, Inc.
+ * Author: Dan Murphy <dmurphy@ti.com>
+ *
+ * Derived work from the pca953x.c driver
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __TCA642X_H_
+#define __TCA642X_H_
+
+#ifdef CONFIG_CMD_TCA642X
+enum {
+	TCA642X_CMD_INFO,
+	TCA642X_CMD_DEVICE,
+	TCA642X_CMD_OUTPUT,
+	TCA642X_CMD_INPUT,
+	TCA642X_CMD_INVERT,
+};
+#endif
+
+#define TCA642X_OUT_LOW		0
+#define TCA642X_OUT_HIGH	1
+#define TCA642X_POL_NORMAL	0
+#define TCA642X_POL_INVERT	1
+#define TCA642X_DIR_OUT		0
+#define TCA642X_DIR_IN		1
+
+/* Default to an address that hopefully won't corrupt other i2c devices */
+#ifndef CONFIG_SYS_I2C_TCA642X_ADDR
+#define CONFIG_SYS_I2C_TCA642X_ADDR	(~0)
+#endif
+
+/* Default to an address that hopefully won't corrupt other i2c devices */
+#ifndef CONFIG_SYS_I2C_TCA642X_BUS_NUM
+#define CONFIG_SYS_I2C_TCA642X_BUS_NUM	(0)
+#endif
+
+struct tca642x_bank_info {
+	uint8_t input_reg;
+	uint8_t output_reg;
+	uint8_t polarity_reg;
+	uint8_t configuration_reg;
+};
+
+int tca642x_set_val(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data);
+int tca642x_set_pol(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data);
+int tca642x_set_dir(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data);
+int tca642x_get_val(uchar chip, uint8_t gpio_bank);
+int tca642x_set_inital_state(uchar chip, struct tca642x_bank_info init_data[]);
+
+#endif /* __TCA642X_H_ */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-10 20:06 [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver Dan Murphy
@ 2013-07-10 20:06 ` Dan Murphy
  2013-07-10 23:56   ` Nishanth Menon
  2013-07-11 14:31 ` [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver Tom Rini
  1 sibling, 1 reply; 12+ messages in thread
From: Dan Murphy @ 2013-07-10 20:06 UTC (permalink / raw)
  To: u-boot

Configure the tca6424 gpio expander
This allows use of the debug and tri color LEDs.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 board/ti/omap5_uevm/evm.c      |   21 +++++++++++++++++++++
 board/ti/omap5_uevm/mux_data.h |    2 ++
 include/configs/omap5_uevm.h   |    5 +++++
 3 files changed, 28 insertions(+)

diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
index 90046e8..0e9a559 100644
--- a/board/ti/omap5_uevm/evm.c
+++ b/board/ti/omap5_uevm/evm.c
@@ -26,6 +26,7 @@
 #include <palmas.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
+#include <tca642x.h>
 
 #include "mux_data.h"
 
@@ -35,6 +36,24 @@ const struct omap_sysinfo sysinfo = {
 	"Board: OMAP5430 EVM\n"
 };
 
+/* @brief tca642x_init - Initial states for the GPIO expander
+ * input reg, output reg, polarity reg, configuration reg
+ */
+struct tca642x_bank_info tca642x_init[] = {
+	{ .input_reg = 0x00,
+	  .output_reg = 0x04,
+	  .polarity_reg = 0x00,
+	  .configuration_reg = 0x80 },
+	{ .input_reg = 0x00,
+	  .output_reg = 0x00,
+	  .polarity_reg = 0x00,
+	  .configuration_reg = 0xff },
+	{ .input_reg = 0x00,
+	  .output_reg = 0x00,
+	  .polarity_reg = 0x00,
+	  .configuration_reg = 0x40 },
+};
+
 /**
  * @brief board_init
  *
@@ -46,6 +65,8 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM;
 	gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
 
+	tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init);
+
 	return 0;
 }
 
diff --git a/board/ti/omap5_uevm/mux_data.h b/board/ti/omap5_uevm/mux_data.h
index a82795d..7e6415e 100644
--- a/board/ti/omap5_uevm/mux_data.h
+++ b/board/ti/omap5_uevm/mux_data.h
@@ -56,6 +56,8 @@ const struct pad_conf_entry core_padconf_array_essential[] = {
 	{USBD0_HS_DP, (IEN | M0)},	/*  USBD0_HS_DP */
 	{USBD0_HS_DM, (IEN | M0)},	/*  USBD0_HS_DM */
 	{USBD0_SS_RX, (IEN | M0)},	/*  USBD0_SS_RX */
+	{I2C5_SCL, (IEN | M0)}, /* I2C5_SCL */
+	{I2C5_SDA, (IEN | M0)}, /* I2C5_SDA */
 
 };
 
diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
index 46dacc2..bee1278 100644
--- a/include/configs/omap5_uevm.h
+++ b/include/configs/omap5_uevm.h
@@ -53,6 +53,11 @@
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART
 
+#define CONFIG_TCA642X
+#define CONFIG_CMD_TCA642X
+#define CONFIG_SYS_I2C_TCA642X_BUS_NUM 4
+#define CONFIG_SYS_I2C_TCA642X_ADDR 0x22
+
 #define CONFIG_SYS_PROMPT		"OMAP5432 uEVM # "
 
 #define CONSOLEDEV		"ttyO2"
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-10 20:06 ` [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander Dan Murphy
@ 2013-07-10 23:56   ` Nishanth Menon
  2013-07-11 14:30     ` Tom Rini
  2013-07-11 15:55     ` Dan Murphy
  0 siblings, 2 replies; 12+ messages in thread
From: Nishanth Menon @ 2013-07-10 23:56 UTC (permalink / raw)
  To: u-boot

On 07/10/2013 03:06 PM, Dan Murphy wrote:
> Configure the tca6424 gpio expander
> This allows use of the debug and tri color LEDs.
>
> Signed-off-by: Dan Murphy <dmurphy@ti.com>
> ---
>   board/ti/omap5_uevm/evm.c      |   21 +++++++++++++++++++++
>   board/ti/omap5_uevm/mux_data.h |    2 ++
>   include/configs/omap5_uevm.h   |    5 +++++
>   3 files changed, 28 insertions(+)
>
> diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
> index 90046e8..0e9a559 100644
> --- a/board/ti/omap5_uevm/evm.c
> +++ b/board/ti/omap5_uevm/evm.c
> @@ -26,6 +26,7 @@
>   #include <palmas.h>
>   #include <asm/arch/sys_proto.h>
>   #include <asm/arch/mmc_host_def.h>
> +#include <tca642x.h>
>
>   #include "mux_data.h"
>
> @@ -35,6 +36,24 @@ const struct omap_sysinfo sysinfo = {
>   	"Board: OMAP5430 EVM\n"
>   };
>
> +/* @brief tca642x_init - Initial states for the GPIO expander
documentation style?
/*
  * @brief
?
> + * input reg, output reg, polarity reg, configuration reg
> + */
> +struct tca642x_bank_info tca642x_init[] = {
> +	{ .input_reg = 0x00,
> +	  .output_reg = 0x04,
> +	  .polarity_reg = 0x00,
> +	  .configuration_reg = 0x80 },
> +	{ .input_reg = 0x00,
> +	  .output_reg = 0x00,
> +	  .polarity_reg = 0x00,
> +	  .configuration_reg = 0xff },
> +	{ .input_reg = 0x00,
> +	  .output_reg = 0x00,
> +	  .polarity_reg = 0x00,
> +	  .configuration_reg = 0x40 },
> +};
> +
>   /**
>    * @brief board_init
>    *
> @@ -46,6 +65,8 @@ int board_init(void)
>   	gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM;
>   	gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
>
> +	tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init);
> +
>   	return 0;
>   }
>
> diff --git a/board/ti/omap5_uevm/mux_data.h b/board/ti/omap5_uevm/mux_data.h
> index a82795d..7e6415e 100644
> --- a/board/ti/omap5_uevm/mux_data.h
> +++ b/board/ti/omap5_uevm/mux_data.h
> @@ -56,6 +56,8 @@ const struct pad_conf_entry core_padconf_array_essential[] = {
>   	{USBD0_HS_DP, (IEN | M0)},	/*  USBD0_HS_DP */
>   	{USBD0_HS_DM, (IEN | M0)},	/*  USBD0_HS_DM */
>   	{USBD0_SS_RX, (IEN | M0)},	/*  USBD0_SS_RX */
> +	{I2C5_SCL, (IEN | M0)}, /* I2C5_SCL */
nit pick -> SCL (or i2c clk) is out put from master - always. IEN 
enables full duplex, but anyways.. just a nitpick :)

> +	{I2C5_SDA, (IEN | M0)}, /* I2C5_SDA */
>
>   };
>
> diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
> index 46dacc2..bee1278 100644
> --- a/include/configs/omap5_uevm.h
> +++ b/include/configs/omap5_uevm.h
> @@ -53,6 +53,11 @@
>   #define CONFIG_PARTITION_UUIDS
>   #define CONFIG_CMD_PART
>
> +#define CONFIG_TCA642X
> +#define CONFIG_CMD_TCA642X
> +#define CONFIG_SYS_I2C_TCA642X_BUS_NUM 4
> +#define CONFIG_SYS_I2C_TCA642X_ADDR 0x22
> +
>   #define CONFIG_SYS_PROMPT		"OMAP5432 uEVM # "
>
>   #define CONSOLEDEV		"ttyO2"
>

Else,
no further comments from me.
--
Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-10 23:56   ` Nishanth Menon
@ 2013-07-11 14:30     ` Tom Rini
  2013-07-11 15:10       ` Dan Murphy
  2013-07-11 15:55     ` Dan Murphy
  1 sibling, 1 reply; 12+ messages in thread
From: Tom Rini @ 2013-07-11 14:30 UTC (permalink / raw)
  To: u-boot

On Wed, Jul 10, 2013 at 06:56:15PM -0500, Nishanth Menon wrote:
> On 07/10/2013 03:06 PM, Dan Murphy wrote:
> >Configure the tca6424 gpio expander
> >This allows use of the debug and tri color LEDs.
> >
> >Signed-off-by: Dan Murphy <dmurphy@ti.com>
> >---
> >  board/ti/omap5_uevm/evm.c      |   21 +++++++++++++++++++++
> >  board/ti/omap5_uevm/mux_data.h |    2 ++
> >  include/configs/omap5_uevm.h   |    5 +++++
> >  3 files changed, 28 insertions(+)
> >
> >diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
> >index 90046e8..0e9a559 100644
> >--- a/board/ti/omap5_uevm/evm.c
> >+++ b/board/ti/omap5_uevm/evm.c
> >@@ -26,6 +26,7 @@
> >  #include <palmas.h>
> >  #include <asm/arch/sys_proto.h>
> >  #include <asm/arch/mmc_host_def.h>
> >+#include <tca642x.h>
> >
> >  #include "mux_data.h"
> >
> >@@ -35,6 +36,24 @@ const struct omap_sysinfo sysinfo = {
> >  	"Board: OMAP5430 EVM\n"
> >  };
> >
> >+/* @brief tca642x_init - Initial states for the GPIO expander
> documentation style?
> /*
>  * @brief
> ?

/**
 * @brief

even :)

And, no other comments.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130711/c95a021f/attachment.pgp>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver
  2013-07-10 20:06 [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver Dan Murphy
  2013-07-10 20:06 ` [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander Dan Murphy
@ 2013-07-11 14:31 ` Tom Rini
  2013-07-11 15:11   ` Dan Murphy
  1 sibling, 1 reply; 12+ messages in thread
From: Tom Rini @ 2013-07-11 14:31 UTC (permalink / raw)
  To: u-boot

On Wed, Jul 10, 2013 at 03:06:02PM -0500, Dan Murphy wrote:

> Add the tca642x gpio expander driver
> 
> Datasheet:
> http://www.ti.com/product/tca6424a
> 
> Signed-off-by: Dan Murphy <dmurphy@ti.com>
> ---
>  drivers/gpio/Makefile  |    1 +
>  drivers/gpio/tca642x.c |  322 ++++++++++++++++++++++++++++++++++++++++++++++++
>  include/tca642x.h      |   66 ++++++++++
>  3 files changed, 389 insertions(+)
>  create mode 100644 drivers/gpio/tca642x.c
>  create mode 100644 include/tca642x.h

Generally fine, but running checkpatch.pl:
total: 0 errors, 12 warnings, 2 checks, 395 lines checked

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX
MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE
USLEEP_RANGE

/tmp/gpio1.mbox has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

So, please address those.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130711/246e0831/attachment.pgp>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-11 14:30     ` Tom Rini
@ 2013-07-11 15:10       ` Dan Murphy
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Murphy @ 2013-07-11 15:10 UTC (permalink / raw)
  To: u-boot

On 07/11/2013 09:30 AM, Tom Rini wrote:
> On Wed, Jul 10, 2013 at 06:56:15PM -0500, Nishanth Menon wrote:
>> On 07/10/2013 03:06 PM, Dan Murphy wrote:
>>> Configure the tca6424 gpio expander
>>> This allows use of the debug and tri color LEDs.
>>>
>>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>>> ---
>>>  board/ti/omap5_uevm/evm.c      |   21 +++++++++++++++++++++
>>>  board/ti/omap5_uevm/mux_data.h |    2 ++
>>>  include/configs/omap5_uevm.h   |    5 +++++
>>>  3 files changed, 28 insertions(+)
>>>
>>> diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
>>> index 90046e8..0e9a559 100644
>>> --- a/board/ti/omap5_uevm/evm.c
>>> +++ b/board/ti/omap5_uevm/evm.c
>>> @@ -26,6 +26,7 @@
>>>  #include <palmas.h>
>>>  #include <asm/arch/sys_proto.h>
>>>  #include <asm/arch/mmc_host_def.h>
>>> +#include <tca642x.h>
>>>
>>>  #include "mux_data.h"
>>>
>>> @@ -35,6 +36,24 @@ const struct omap_sysinfo sysinfo = {
>>>  	"Board: OMAP5430 EVM\n"
>>>  };
>>>
>>> +/* @brief tca642x_init - Initial states for the GPIO expander
>> documentation style?
>> /*
>>  * @brief
>> ?
> /**
>  * @brief
>
> even :)
>
> And, no other comments.
>
Got it will fix it

-- 
------------------
Dan Murphy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver
  2013-07-11 14:31 ` [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver Tom Rini
@ 2013-07-11 15:11   ` Dan Murphy
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Murphy @ 2013-07-11 15:11 UTC (permalink / raw)
  To: u-boot

On 07/11/2013 09:31 AM, Tom Rini wrote:
> On Wed, Jul 10, 2013 at 03:06:02PM -0500, Dan Murphy wrote:
>
>> Add the tca642x gpio expander driver
>>
>> Datasheet:
>> http://www.ti.com/product/tca6424a
>>
>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>> ---
>>  drivers/gpio/Makefile  |    1 +
>>  drivers/gpio/tca642x.c |  322 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  include/tca642x.h      |   66 ++++++++++
>>  3 files changed, 389 insertions(+)
>>  create mode 100644 drivers/gpio/tca642x.c
>>  create mode 100644 include/tca642x.h
> Generally fine, but running checkpatch.pl:
> total: 0 errors, 12 warnings, 2 checks, 395 lines checked
>
> NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX
> MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE
> USLEEP_RANGE
>
> /tmp/gpio1.mbox has style problems, please review.
>
> If any of these errors are false positives, please report
> them to the maintainer, see CHECKPATCH in MAINTAINERS.
>
> So, please address those.
>
Yeah I ran cp on this file and when I looked @ it fixing the LTLs would have made the code look messy IMHO.

But I will fix it anyway and re-submit.

-- 
------------------
Dan Murphy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-10 23:56   ` Nishanth Menon
  2013-07-11 14:30     ` Tom Rini
@ 2013-07-11 15:55     ` Dan Murphy
  2013-07-11 18:02       ` Nishanth Menon
  1 sibling, 1 reply; 12+ messages in thread
From: Dan Murphy @ 2013-07-11 15:55 UTC (permalink / raw)
  To: u-boot

On 07/10/2013 06:56 PM, Nishanth Menon wrote:
> On 07/10/2013 03:06 PM, Dan Murphy wrote:
>> Configure the tca6424 gpio expander
>> This allows use of the debug and tri color LEDs.
>>
>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>> ---
>>   board/ti/omap5_uevm/evm.c      |   21 +++++++++++++++++++++
>>   board/ti/omap5_uevm/mux_data.h |    2 ++
>>   include/configs/omap5_uevm.h   |    5 +++++
>>   3 files changed, 28 insertions(+)
>>
>> diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
>> index 90046e8..0e9a559 100644
>> --- a/board/ti/omap5_uevm/evm.c
>> +++ b/board/ti/omap5_uevm/evm.c
>> @@ -26,6 +26,7 @@
>>   #include <palmas.h>
>>   #include <asm/arch/sys_proto.h>
>>   #include <asm/arch/mmc_host_def.h>
>> +#include <tca642x.h>
>>
>>   #include "mux_data.h"
>>
>> @@ -35,6 +36,24 @@ const struct omap_sysinfo sysinfo = {
>>       "Board: OMAP5430 EVM\n"
>>   };
>>
>> +/* @brief tca642x_init - Initial states for the GPIO expander
> documentation style?
> /*
>  * @brief
> ?
>> + * input reg, output reg, polarity reg, configuration reg
>> + */
>> +struct tca642x_bank_info tca642x_init[] = {
>> +    { .input_reg = 0x00,
>> +      .output_reg = 0x04,
>> +      .polarity_reg = 0x00,
>> +      .configuration_reg = 0x80 },
>> +    { .input_reg = 0x00,
>> +      .output_reg = 0x00,
>> +      .polarity_reg = 0x00,
>> +      .configuration_reg = 0xff },
>> +    { .input_reg = 0x00,
>> +      .output_reg = 0x00,
>> +      .polarity_reg = 0x00,
>> +      .configuration_reg = 0x40 },
>> +};
>> +
>>   /**
>>    * @brief board_init
>>    *
>> @@ -46,6 +65,8 @@ int board_init(void)
>>       gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM;
>>       gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
>>
>> +    tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init);
>> +
>>       return 0;
>>   }
>>
>> diff --git a/board/ti/omap5_uevm/mux_data.h b/board/ti/omap5_uevm/mux_data.h
>> index a82795d..7e6415e 100644
>> --- a/board/ti/omap5_uevm/mux_data.h
>> +++ b/board/ti/omap5_uevm/mux_data.h
>> @@ -56,6 +56,8 @@ const struct pad_conf_entry core_padconf_array_essential[] = {
>>       {USBD0_HS_DP, (IEN | M0)},    /*  USBD0_HS_DP */
>>       {USBD0_HS_DM, (IEN | M0)},    /*  USBD0_HS_DM */
>>       {USBD0_SS_RX, (IEN | M0)},    /*  USBD0_SS_RX */
>> +    {I2C5_SCL, (IEN | M0)}, /* I2C5_SCL */
> nit pick -> SCL (or i2c clk) is out put from master - always. IEN enables full duplex, but anyways.. just a nitpick :)
>
OK I changed this and did a test and reads fail without the IEN set.
This is to sync the client clocks.
>> +    {I2C5_SDA, (IEN | M0)}, /* I2C5_SDA */
>>
>>   };
>>
>> diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
>> index 46dacc2..bee1278 100644
>> --- a/include/configs/omap5_uevm.h
>> +++ b/include/configs/omap5_uevm.h
>> @@ -53,6 +53,11 @@
>>   #define CONFIG_PARTITION_UUIDS
>>   #define CONFIG_CMD_PART
>>
>> +#define CONFIG_TCA642X
>> +#define CONFIG_CMD_TCA642X
>> +#define CONFIG_SYS_I2C_TCA642X_BUS_NUM 4
>> +#define CONFIG_SYS_I2C_TCA642X_ADDR 0x22
>> +
>>   #define CONFIG_SYS_PROMPT        "OMAP5432 uEVM # "
>>
>>   #define CONSOLEDEV        "ttyO2"
>>
>
> Else,
> no further comments from me.
> -- 
> Regards,
> Nishanth Menon


-- 
------------------
Dan Murphy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-11 15:55     ` Dan Murphy
@ 2013-07-11 18:02       ` Nishanth Menon
  2013-07-12 17:30         ` Dan Murphy
  0 siblings, 1 reply; 12+ messages in thread
From: Nishanth Menon @ 2013-07-11 18:02 UTC (permalink / raw)
  To: u-boot

On Jul 11, 2013 10:55 AM, "Dan Murphy" <dmurphy@ti.com> wrote:
>
> On 07/10/2013 06:56 PM, Nishanth Menon wrote:
> > On 07/10/2013 03:06 PM, Dan Murphy wrote:
> >> Configure the tca6424 gpio expander
> >> This allows use of the debug and tri color LEDs.
> >>
> >> Signed-off-by: Dan Murphy <dmurphy@ti.com>
> >> ---
> >>   board/ti/omap5_uevm/evm.c      |   21 +++++++++++++++++++++
> >>   board/ti/omap5_uevm/mux_data.h |    2 ++
> >>   include/configs/omap5_uevm.h   |    5 +++++
> >>   3 files changed, 28 insertions(+)
> >>
> >> diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
> >> index 90046e8..0e9a559 100644
> >> --- a/board/ti/omap5_uevm/evm.c
> >> +++ b/board/ti/omap5_uevm/evm.c
> >> @@ -26,6 +26,7 @@
> >>   #include <palmas.h>
> >>   #include <asm/arch/sys_proto.h>
> >>   #include <asm/arch/mmc_host_def.h>
> >> +#include <tca642x.h>
> >>
> >>   #include "mux_data.h"
> >>
> >> @@ -35,6 +36,24 @@ const struct omap_sysinfo sysinfo = {
> >>       "Board: OMAP5430 EVM\n"
> >>   };
> >>
> >> +/* @brief tca642x_init - Initial states for the GPIO expander
> > documentation style?
> > /*
> >  * @brief
> > ?
> >> + * input reg, output reg, polarity reg, configuration reg
> >> + */
> >> +struct tca642x_bank_info tca642x_init[] = {
> >> +    { .input_reg = 0x00,
> >> +      .output_reg = 0x04,
> >> +      .polarity_reg = 0x00,
> >> +      .configuration_reg = 0x80 },
> >> +    { .input_reg = 0x00,
> >> +      .output_reg = 0x00,
> >> +      .polarity_reg = 0x00,
> >> +      .configuration_reg = 0xff },
> >> +    { .input_reg = 0x00,
> >> +      .output_reg = 0x00,
> >> +      .polarity_reg = 0x00,
> >> +      .configuration_reg = 0x40 },
> >> +};
> >> +
> >>   /**
> >>    * @brief board_init
> >>    *
> >> @@ -46,6 +65,8 @@ int board_init(void)
> >>       gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM;
> >>       gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param
addr */
> >>
> >> +    tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR,
tca642x_init);
> >> +
> >>       return 0;
> >>   }
> >>
> >> diff --git a/board/ti/omap5_uevm/mux_data.h
b/board/ti/omap5_uevm/mux_data.h
> >> index a82795d..7e6415e 100644
> >> --- a/board/ti/omap5_uevm/mux_data.h
> >> +++ b/board/ti/omap5_uevm/mux_data.h
> >> @@ -56,6 +56,8 @@ const struct pad_conf_entry
core_padconf_array_essential[] = {
> >>       {USBD0_HS_DP, (IEN | M0)},    /*  USBD0_HS_DP */
> >>       {USBD0_HS_DM, (IEN | M0)},    /*  USBD0_HS_DM */
> >>       {USBD0_SS_RX, (IEN | M0)},    /*  USBD0_SS_RX */
> >> +    {I2C5_SCL, (IEN | M0)}, /* I2C5_SCL */
> > nit pick -> SCL (or i2c clk) is out put from master - always. IEN
enables full duplex, but anyways.. just a nitpick :)
> >
> OK I changed this and did a test and reads fail without the IEN set.
> This is to sync the client clocks.

Scl? I2c clock? Does not work without input- something is fishy no?

> >> +    {I2C5_SDA, (IEN | M0)}, /* I2C5_SDA */
> >>
> >>   };
> >>
> >> diff --git a/include/configs/omap5_uevm.h
b/include/configs/omap5_uevm.h
> >> index 46dacc2..bee1278 100644
> >> --- a/include/configs/omap5_uevm.h
> >> +++ b/include/configs/omap5_uevm.h
> >> @@ -53,6 +53,11 @@
> >>   #define CONFIG_PARTITION_UUIDS
> >>   #define CONFIG_CMD_PART
> >>
> >> +#define CONFIG_TCA642X
> >> +#define CONFIG_CMD_TCA642X
> >> +#define CONFIG_SYS_I2C_TCA642X_BUS_NUM 4
> >> +#define CONFIG_SYS_I2C_TCA642X_ADDR 0x22
> >> +
> >>   #define CONFIG_SYS_PROMPT        "OMAP5432 uEVM # "
> >>
> >>   #define CONSOLEDEV        "ttyO2"
> >>
> >
> > Else,
> > no further comments from me.
> > --
> > Regards,
> > Nishanth Menon
>
>
> --
> ------------------
> Dan Murphy
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-11 18:02       ` Nishanth Menon
@ 2013-07-12 17:30         ` Dan Murphy
  2013-07-12 21:55           ` Nishanth Menon
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Murphy @ 2013-07-12 17:30 UTC (permalink / raw)
  To: u-boot

NM

On 07/11/2013 01:02 PM, Nishanth Menon wrote:
<snip>
>>> diff --git a/board/ti/omap5_uevm/mux_data.h
> b/board/ti/omap5_uevm/mux_data.h
>>>> index a82795d..7e6415e 100644
>>>> --- a/board/ti/omap5_uevm/mux_data.h
>>>> +++ b/board/ti/omap5_uevm/mux_data.h
>>>> @@ -56,6 +56,8 @@ const struct pad_conf_entry
> core_padconf_array_essential[] = {
>>>>       {USBD0_HS_DP, (IEN | M0)},    /*  USBD0_HS_DP */
>>>>       {USBD0_HS_DM, (IEN | M0)},    /*  USBD0_HS_DM */
>>>>       {USBD0_SS_RX, (IEN | M0)},    /*  USBD0_SS_RX */
>>>> +    {I2C5_SCL, (IEN | M0)}, /* I2C5_SCL */
>>> nit pick -> SCL (or i2c clk) is out put from master - always. IEN
> enables full duplex, but anyways.. just a nitpick :)
>> OK I changed this and did a test and reads fail without the IEN set.
>> This is to sync the client clocks.
> Scl? I2c clock? Does not work without input- something is fishy no?
Nope.  There is clock synchronization and clock arbitration that happens and the I2C master needs to see the SCL as an input.

Kernel configures the I2C mux for 1 and 5 the same way.
<snip>

-- 
------------------
Dan Murphy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-12 17:30         ` Dan Murphy
@ 2013-07-12 21:55           ` Nishanth Menon
  0 siblings, 0 replies; 12+ messages in thread
From: Nishanth Menon @ 2013-07-12 21:55 UTC (permalink / raw)
  To: u-boot

On Fri, Jul 12, 2013 at 12:30 PM, Dan Murphy <dmurphy@ti.com> wrote:
> On 07/11/2013 01:02 PM, Nishanth Menon wrote:
>>>> diff --git a/board/ti/omap5_uevm/mux_data.h
>> b/board/ti/omap5_uevm/mux_data.h
>>>>> index a82795d..7e6415e 100644
>>>>> --- a/board/ti/omap5_uevm/mux_data.h
>>>>> +++ b/board/ti/omap5_uevm/mux_data.h
>>>>> @@ -56,6 +56,8 @@ const struct pad_conf_entry
>> core_padconf_array_essential[] = {
>>>>>       {USBD0_HS_DP, (IEN | M0)},    /*  USBD0_HS_DP */
>>>>>       {USBD0_HS_DM, (IEN | M0)},    /*  USBD0_HS_DM */
>>>>>       {USBD0_SS_RX, (IEN | M0)},    /*  USBD0_SS_RX */
>>>>> +    {I2C5_SCL, (IEN | M0)}, /* I2C5_SCL */
>>>> nit pick -> SCL (or i2c clk) is out put from master - always. IEN
>> enables full duplex, but anyways.. just a nitpick :)
>>> OK I changed this and did a test and reads fail without the IEN set.
>>> This is to sync the client clocks.
>> Scl? I2c clock? Does not work without input- something is fishy no?
> Nope.  There is clock synchronization and clock arbitration that happens and the I2C master needs to see the SCL as an input.

Also, Table 24-1. HS I2C Input/Output in OMAP5 ES2.0 TRM Rev U
supports the requirement of SCL being input as well.

I think you mean bus busy condition here[1] rather than multi-master
arbitration? in the case of arbitration, the SDA will be monitored
than SCL - See "Figure 24-9. HS I2C Arbitration Between Master
Transmitters" in TRM.

Bus busy on the other hand needs stop condition  detection for
transmission which involves SCL and SDA. yet another need is the
requirement to support clock stretching[2] (where the i2c slave holds
the SCL low while it does "something").


Either way, it explains why SCL needs to be in IEN.

[1] http://www.i2c-bus.org/MultiMaster/
[2] http://www.i2c-bus.org/clock-stretching/
Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander
  2013-07-11 18:10 [U-Boot] [PATCH " Dan Murphy
@ 2013-07-11 18:10 ` Dan Murphy
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Murphy @ 2013-07-11 18:10 UTC (permalink / raw)
  To: u-boot

Configure the tca6424 gpio expander
This allows use of the debug and tri color LEDs.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---

v2 - Updated per comments - http://patchwork.ozlabs.org/patch/257603/
v3 - Updated documentation. No change to mux data the code is the
patch is required or I2C reads fail - http://patchwork.ozlabs.org/patch/257840/

 board/ti/omap5_uevm/evm.c      |   22 ++++++++++++++++++++++
 board/ti/omap5_uevm/mux_data.h |    2 ++
 include/configs/omap5_uevm.h   |    5 +++++
 3 files changed, 29 insertions(+)

diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
index 90046e8..c3581ee 100644
--- a/board/ti/omap5_uevm/evm.c
+++ b/board/ti/omap5_uevm/evm.c
@@ -26,6 +26,7 @@
 #include <palmas.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
+#include <tca642x.h>
 
 #include "mux_data.h"
 
@@ -36,6 +37,25 @@ const struct omap_sysinfo sysinfo = {
 };
 
 /**
+ * @brief tca642x_init - uEVM default values for the GPIO expander
+ * input reg, output reg, polarity reg, configuration reg
+ */
+struct tca642x_bank_info tca642x_init[] = {
+	{ .input_reg = 0x00,
+	  .output_reg = 0x04,
+	  .polarity_reg = 0x00,
+	  .configuration_reg = 0x80 },
+	{ .input_reg = 0x00,
+	  .output_reg = 0x00,
+	  .polarity_reg = 0x00,
+	  .configuration_reg = 0xff },
+	{ .input_reg = 0x00,
+	  .output_reg = 0x00,
+	  .polarity_reg = 0x00,
+	  .configuration_reg = 0x40 },
+};
+
+/**
  * @brief board_init
  *
  * @return 0
@@ -46,6 +66,8 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM;
 	gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
 
+	tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init);
+
 	return 0;
 }
 
diff --git a/board/ti/omap5_uevm/mux_data.h b/board/ti/omap5_uevm/mux_data.h
index a82795d..7e6415e 100644
--- a/board/ti/omap5_uevm/mux_data.h
+++ b/board/ti/omap5_uevm/mux_data.h
@@ -56,6 +56,8 @@ const struct pad_conf_entry core_padconf_array_essential[] = {
 	{USBD0_HS_DP, (IEN | M0)},	/*  USBD0_HS_DP */
 	{USBD0_HS_DM, (IEN | M0)},	/*  USBD0_HS_DM */
 	{USBD0_SS_RX, (IEN | M0)},	/*  USBD0_SS_RX */
+	{I2C5_SCL, (IEN | M0)}, /* I2C5_SCL */
+	{I2C5_SDA, (IEN | M0)}, /* I2C5_SDA */
 
 };
 
diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
index 46dacc2..bee1278 100644
--- a/include/configs/omap5_uevm.h
+++ b/include/configs/omap5_uevm.h
@@ -53,6 +53,11 @@
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART
 
+#define CONFIG_TCA642X
+#define CONFIG_CMD_TCA642X
+#define CONFIG_SYS_I2C_TCA642X_BUS_NUM 4
+#define CONFIG_SYS_I2C_TCA642X_ADDR 0x22
+
 #define CONFIG_SYS_PROMPT		"OMAP5432 uEVM # "
 
 #define CONSOLEDEV		"ttyO2"
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-07-12 21:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-10 20:06 [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver Dan Murphy
2013-07-10 20:06 ` [U-Boot] [[PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander Dan Murphy
2013-07-10 23:56   ` Nishanth Menon
2013-07-11 14:30     ` Tom Rini
2013-07-11 15:10       ` Dan Murphy
2013-07-11 15:55     ` Dan Murphy
2013-07-11 18:02       ` Nishanth Menon
2013-07-12 17:30         ` Dan Murphy
2013-07-12 21:55           ` Nishanth Menon
2013-07-11 14:31 ` [U-Boot] [[PATCH v3 1/2] gpio: tca642x: Add the tca642x gpio expander driver Tom Rini
2013-07-11 15:11   ` Dan Murphy
2013-07-11 18:10 [U-Boot] [PATCH " Dan Murphy
2013-07-11 18:10 ` [U-Boot] [PATCH v3 2/2] gpio: omap5-uevm: Configure the tca6424 gpio expander Dan Murphy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.