mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Various patches for imx35, fec, at24 driver and misc
@ 2012-07-16  1:04 Marc Reilly
  2012-07-16  1:04 ` [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address Marc Reilly
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Marc Reilly @ 2012-07-16  1:04 UTC (permalink / raw)
  To: barebox

Hi,

I've been meaning to submit these for quite a while.

Patch 1 allows setting eth MAC address from alternate source, eg, eeprom
Patch 2 & 3 correct clock divider for mmc
Patch 4 adds an at24 eeprom driver alongside existing at25 driver.
Patch 5 adds a misc driver for a digital potentiometer.

Patches were generated against next.

Cheers,
Marc


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

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

* [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address
  2012-07-16  1:04 Various patches for imx35, fec, at24 driver and misc Marc Reilly
@ 2012-07-16  1:04 ` Marc Reilly
  2012-07-16  7:43   ` Sascha Hauer
  2012-07-16  1:04 ` [PATCH 2/5] imx35: 6-bit divider helper Marc Reilly
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Marc Reilly @ 2012-07-16  1:04 UTC (permalink / raw)
  To: barebox

This patch adds a handler to the fec platform data to get MAC address.
If a handler is not specified the driver uses the existing one.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
---
 drivers/net/fec_imx.c |    6 +++++-
 include/fec.h         |    4 ++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 599a9b4..5084758 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -629,10 +629,14 @@ static int fec_probe(struct device_d *dev)
 	edev->send = fec_send;
 	edev->recv = fec_recv;
 	edev->halt = fec_halt;
-	edev->get_ethaddr = fec_get_hwaddr;
 	edev->set_ethaddr = fec_set_hwaddr;
 	edev->parent = dev;
 
+	if (pdata->get_hwaddr)
+		edev->get_ethaddr = pdata->get_hwaddr;
+	else
+		edev->get_ethaddr = fec_get_hwaddr;
+
 	fec->regs = dev_request_mem_region(dev, 0);
 
 	/* Reset chip. */
diff --git a/include/fec.h b/include/fec.h
index f56b023..5072bbf 100644
--- a/include/fec.h
+++ b/include/fec.h
@@ -36,6 +36,8 @@ typedef enum {
 	RGMII,
 } xceiver_type;
 
+struct eth_device;
+
 /*
  * Define the phy connected externally for FEC drivers
  * (like MPC52xx and i.MX27)
@@ -43,6 +45,8 @@ typedef enum {
 struct fec_platform_data {
         xceiver_type	xcv_type;
 	int		phy_addr;
+
+	int (*get_hwaddr)(struct eth_device *dev, unsigned char *mac);
 };
 
 #endif /* __INCLUDE_NETWORK_FEC_H */
-- 
1.7.7


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

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

* [PATCH 2/5] imx35: 6-bit divider helper
  2012-07-16  1:04 Various patches for imx35, fec, at24 driver and misc Marc Reilly
  2012-07-16  1:04 ` [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address Marc Reilly
@ 2012-07-16  1:04 ` Marc Reilly
  2012-07-16  1:04 ` [PATCH 3/5] imx35: mmc clock has 6 bit divider, not 3_3 Marc Reilly
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Marc Reilly @ 2012-07-16  1:04 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
---
 arch/arm/mach-imx/speed-imx35.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/speed-imx35.c b/arch/arm/mach-imx/speed-imx35.c
index 684dc14..905ab47 100644
--- a/arch/arm/mach-imx/speed-imx35.c
+++ b/arch/arm/mach-imx/speed-imx35.c
@@ -97,6 +97,11 @@ static unsigned long get_3_3_div(unsigned long in)
 	return (((in >> 3) & 0x7) + 1) * ((in & 0x7) + 1);
 }
 
+static unsigned long get_6_div(unsigned long in)
+{
+	return ((in & 0x3f) + 1);
+}
+
 static unsigned long imx_get_ipg_perclk(void)
 {
 	ulong pdr0 = readl(IMX_CCM_BASE + CCM_PDR0);
-- 
1.7.7


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

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

* [PATCH 3/5] imx35: mmc clock has 6 bit divider, not 3_3
  2012-07-16  1:04 Various patches for imx35, fec, at24 driver and misc Marc Reilly
  2012-07-16  1:04 ` [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address Marc Reilly
  2012-07-16  1:04 ` [PATCH 2/5] imx35: 6-bit divider helper Marc Reilly
@ 2012-07-16  1:04 ` Marc Reilly
  2012-07-16  1:04 ` [PATCH 4/5] at24: add I2C eeprom for 24cl02 Marc Reilly
  2012-07-16  1:04 ` [PATCH 5/5] misc: new driver: isl22316 digital potentiometer Marc Reilly
  4 siblings, 0 replies; 8+ messages in thread
From: Marc Reilly @ 2012-07-16  1:04 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
---
According to MCIMX35RM rev 3

 arch/arm/mach-imx/speed-imx35.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/speed-imx35.c b/arch/arm/mach-imx/speed-imx35.c
index 905ab47..6d4236a 100644
--- a/arch/arm/mach-imx/speed-imx35.c
+++ b/arch/arm/mach-imx/speed-imx35.c
@@ -170,10 +170,11 @@ unsigned long imx_get_uartclk(void)
 		return imx_get_ppllclk() / div;
 }
 
+/* mmc0 clk only */
 unsigned long imx_get_mmcclk(void)
 {
 	unsigned long pdr3 = readl(IMX_CCM_BASE + CCM_PDR3);
-	unsigned long div = get_3_3_div(pdr3);
+	unsigned long div = get_6_div(pdr3);
 
 	if (pdr3 & (1 << 6))
 		return imx_get_armclk() / div;
-- 
1.7.7


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

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

* [PATCH 4/5] at24: add I2C eeprom for 24cl02
  2012-07-16  1:04 Various patches for imx35, fec, at24 driver and misc Marc Reilly
                   ` (2 preceding siblings ...)
  2012-07-16  1:04 ` [PATCH 3/5] imx35: mmc clock has 6 bit divider, not 3_3 Marc Reilly
@ 2012-07-16  1:04 ` Marc Reilly
  2012-07-16  7:49   ` Sascha Hauer
  2012-07-16  1:04 ` [PATCH 5/5] misc: new driver: isl22316 digital potentiometer Marc Reilly
  4 siblings, 1 reply; 8+ messages in thread
From: Marc Reilly @ 2012-07-16  1:04 UTC (permalink / raw)
  To: barebox

This series adds a driver for at24 eeproms. Much of the guts of the code
is taken from the at24 driver in the linux kernel.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
---
 drivers/eeprom/Kconfig  |    7 +++
 drivers/eeprom/Makefile |    1 +
 drivers/eeprom/at24.c   |  134 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 142 insertions(+), 0 deletions(-)
 create mode 100644 drivers/eeprom/at24.c

diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig
index a0b5489..56dfd1a 100644
--- a/drivers/eeprom/Kconfig
+++ b/drivers/eeprom/Kconfig
@@ -8,4 +8,11 @@ config EEPROM_AT25
 	  after you configure the board init code to know about each eeprom
 	  on your target board.
 
+config EEPROM_AT24
+	bool "at24 based eeprom"
+	depends on I2C
+	help
+	  Provides read/write for the at24 family of I2C EEPROMS.
+	  Currently only the 2K bit versions are supported.
+	  
 endmenu
diff --git a/drivers/eeprom/Makefile b/drivers/eeprom/Makefile
index e323bd0..e287eb0 100644
--- a/drivers/eeprom/Makefile
+++ b/drivers/eeprom/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_EEPROM_AT25)	+= at25.o
+obj-$(CONFIG_EEPROM_AT24)	+= at24.o
diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
new file mode 100644
index 0000000..fd578b1
--- /dev/null
+++ b/drivers/eeprom/at24.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2007 Sascha Hauer, Pengutronix
+ *               2009 Marc Kleine-Budde <mkl@pengutronix.de>
+ *               2010 Marc Reilly, Creative Product Design
+ *
+ * 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 <init.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+
+#include <i2c/i2c.h>
+
+#define DRIVERNAME		"eeprom"
+
+struct at24 {
+	struct cdev		cdev;
+	struct i2c_client	*client;
+	/* size in bytes */
+	unsigned int		size;
+};
+
+#define to_at24(a)		container_of(a, struct at24, cdev)
+
+static ssize_t at24_read(struct cdev *cdev, void *_buf, size_t count,
+		ulong offset, ulong flags)
+{
+	struct at24 *priv = to_at24(cdev);
+	u8 *buf = _buf;
+	size_t i = count;
+	ssize_t numwritten = 0;
+	int retries = 5;
+	int ret;
+
+	while (i && retries) {
+		ret = i2c_read_reg(priv->client, offset, buf, i);
+		if (ret < 0)
+			return (ssize_t)ret;
+		else if (ret == 0)
+			--retries;
+
+		numwritten += ret;
+		i -= ret;
+		offset += ret;
+		buf += ret;
+	}
+
+	return numwritten;
+}
+
+static ssize_t at24_write(struct cdev *cdev, const void *_buf, size_t count,
+		ulong offset, ulong flags)
+{
+	struct at24 *priv = to_at24(cdev);
+	const u8 *buf = _buf;
+	const int maxwrite = 8;
+	int numtowrite;
+	ssize_t numwritten = 0;
+
+	while (count) {
+		int ret;
+
+		numtowrite = count;
+		if (numtowrite > maxwrite)
+			numtowrite = maxwrite;
+
+		ret = i2c_write_reg(priv->client, offset, buf, numtowrite);
+		if (ret < 0)
+			return (ssize_t)ret;
+
+		mdelay(10);
+
+		numwritten += ret;
+		buf += ret;
+		count -= ret;
+		offset += ret;
+	}
+
+	return numwritten;
+}
+
+static struct file_operations at24_fops = {
+	.lseek	= dev_lseek_default,
+	.read	= at24_read,
+	.write	= at24_write,
+};
+
+static int at24_probe(struct device_d *dev)
+{
+	struct at24 *at24;
+	at24 = xzalloc(sizeof(*at24));
+
+	dev->priv = at24;
+
+	at24->cdev.name = DRIVERNAME;
+	at24->client = to_i2c_client(dev);
+	at24->cdev.size = 256;
+	at24->cdev.dev = dev;
+	at24->cdev.ops = &at24_fops;
+
+	devfs_create(&at24->cdev);
+
+	return 0;
+}
+
+static struct driver_d at24_driver = {
+	.name  = DRIVERNAME,
+	.probe = at24_probe,
+};
+
+static int at24_init(void)
+{
+	register_driver(&at24_driver);
+	return 0;
+}
+
+device_initcall(at24_init);
-- 
1.7.7


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

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

* [PATCH 5/5] misc: new driver: isl22316 digital potentiometer
  2012-07-16  1:04 Various patches for imx35, fec, at24 driver and misc Marc Reilly
                   ` (3 preceding siblings ...)
  2012-07-16  1:04 ` [PATCH 4/5] at24: add I2C eeprom for 24cl02 Marc Reilly
@ 2012-07-16  1:04 ` Marc Reilly
  4 siblings, 0 replies; 8+ messages in thread
From: Marc Reilly @ 2012-07-16  1:04 UTC (permalink / raw)
  To: barebox

This series adds a driver for the isl22316 digital pot.
A new misc config option and folder is added.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
---
 drivers/Kconfig         |    1 +
 drivers/Makefile        |    1 +
 drivers/misc/Kconfig    |   10 +++
 drivers/misc/Makefile   |    1 +
 drivers/misc/isl22316.c |  180 +++++++++++++++++++++++++++++++++++++++++++++++
 include/misc/isl22316.h |   26 +++++++
 6 files changed, 219 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/Kconfig
 create mode 100644 drivers/misc/Makefile
 create mode 100644 drivers/misc/isl22316.c
 create mode 100644 include/misc/isl22316.h

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 883b0e7..8710432 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -18,5 +18,6 @@ source "drivers/input/Kconfig"
 source "drivers/watchdog/Kconfig"
 source "drivers/pwm/Kconfig"
 source "drivers/dma/Kconfig"
+source "drivers/misc/Kconfig"
 
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index ea3263f..5c93274 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_PWM) += pwm/
 obj-y	+= input/
 obj-y	+= dma/
 obj-y  += watchdog/
+obj-$(CONFIG_MISC) += misc/
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
new file mode 100644
index 0000000..859035f
--- /dev/null
+++ b/drivers/misc/Kconfig
@@ -0,0 +1,10 @@
+menuconfig MISC
+	bool "Misc devices support"
+
+if MISC
+
+config ISL22316
+	bool "isl22316 digital controlled potentiometer"
+	depends on I2C
+
+endif
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
new file mode 100644
index 0000000..1ab3a6c
--- /dev/null
+++ b/drivers/misc/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ISL22316) += isl22316.o
diff --git a/drivers/misc/isl22316.c b/drivers/misc/isl22316.c
new file mode 100644
index 0000000..aeb9f89
--- /dev/null
+++ b/drivers/misc/isl22316.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2007 Sascha Hauer, Pengutronix
+ *               2009 Marc Kleine-Budde <mkl@pengutronix.de>
+ * Copyright (C) 2010 Baruch Siach <baruch@tkos.co.il>
+ *               2011 Marc Reilly, Creative Product Design
+ *
+ * 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 <init.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+
+#include <i2c/i2c.h>
+#include <misc/isl22316.h>
+
+#define DRIVERNAME		"isl22316"
+
+#define to_isl22316(a)		container_of(a, struct isl22316, cdev)
+
+#define ISL22316_WR		0
+#define ISL22316_ACR		2
+#define ISL22316_ACR_VOL	0x80
+#define ISL22316_ACR_SHDN	0x40
+#define ISL22316_ACR_WIP	0x20
+
+static struct isl22316 *isl22316_dev;
+
+struct isl22316 *isl22316_get(void)
+{
+	return isl22316_dev;
+}
+EXPORT_SYMBOL(isl22316_get);
+
+int isl22316_reg_read(struct isl22316 *isl22316, u8 reg, u8 *val)
+{
+	int ret;
+
+	ret = i2c_read_reg(isl22316->client, reg, val, 1);
+
+	return ret == 1 ? 0 : ret;
+}
+EXPORT_SYMBOL(isl22316_reg_read);
+
+int isl22316_reg_write(struct isl22316 *isl22316, u8 reg, u8 val)
+{
+	int ret;
+
+	ret = i2c_write_reg(isl22316->client, reg, &val, 1);
+
+	return ret == 1 ? 0 : ret;
+}
+EXPORT_SYMBOL(isl22316_reg_write);
+
+int isl22316_get_value(struct isl22316 *isl22316, u8 *val, int save)
+{
+	int ret;
+	u8 acr = ISL22316_ACR_SHDN;
+
+	if (!save)
+		acr |= ISL22316_ACR_VOL;
+
+	ret = isl22316_reg_write(isl22316, ISL22316_ACR, acr);
+	if (ret)
+		return ret;
+
+	ret = isl22316_reg_read(isl22316, ISL22316_WR, val);
+
+	return ret;
+}
+EXPORT_SYMBOL(isl22316_get_value);
+
+int isl22316_set_value(struct isl22316 *isl22316, u8 val, int save)
+{
+	int ret;
+	u8 acr = ISL22316_ACR_SHDN;
+
+	if (!save)
+		acr |= ISL22316_ACR_VOL;
+
+	ret = isl22316_reg_write(isl22316, ISL22316_ACR, acr);
+	if (ret)
+		return ret;
+
+	ret = isl22316_reg_write(isl22316, ISL22316_WR, val);
+
+	return ret;
+}
+EXPORT_SYMBOL(isl22316_set_value);
+
+static ssize_t isl22316_read(struct cdev *cdev, void *_buf, size_t count,
+		ulong offset, ulong flags)
+{
+	struct isl22316 *priv = to_isl22316(cdev);
+	u8 *buf = _buf;
+	size_t i = count;
+	int err;
+
+	while (i) {
+		err = isl22316_reg_read(priv, offset, buf);
+		if (err)
+			return (ssize_t)err;
+		buf++;
+		i--;
+		offset++;
+	}
+
+	return count;
+}
+
+static ssize_t isl22316_write(struct cdev *cdev, const void *_buf, size_t count,
+		ulong offset, ulong flags)
+{
+	struct isl22316 *isl22316 = to_isl22316(cdev);
+	const u8 *buf = _buf;
+	size_t i = count;
+	int err;
+
+	while (i) {
+		err = isl22316_reg_write(isl22316, offset, *buf);
+		if (err)
+			return (ssize_t)err;
+		buf++;
+		i--;
+		offset++;
+	}
+
+	return count;
+}
+
+static struct file_operations isl22316_fops = {
+	.lseek	= dev_lseek_default,
+	.read	= isl22316_read,
+	.write	= isl22316_write,
+};
+
+static int isl22316_probe(struct device_d *dev)
+{
+	if (isl22316_dev)
+		return -EBUSY;
+
+	isl22316_dev = xzalloc(sizeof(*isl22316_dev));
+	isl22316_dev->cdev.name = DRIVERNAME;
+	isl22316_dev->client = to_i2c_client(dev);
+	isl22316_dev->cdev.dev = dev;
+	isl22316_dev->cdev.size = 3;
+	isl22316_dev->cdev.ops = &isl22316_fops;
+
+	devfs_create(&isl22316_dev->cdev);
+
+	return 0;
+}
+
+static struct driver_d isl22316_driver = {
+	.name  = DRIVERNAME,
+	.probe = isl22316_probe,
+};
+
+static int isl22316_init(void)
+{
+	register_driver(&isl22316_driver);
+	return 0;
+}
+
+device_initcall(isl22316_init);
diff --git a/include/misc/isl22316.h b/include/misc/isl22316.h
new file mode 100644
index 0000000..3563dc3
--- /dev/null
+++ b/include/misc/isl22316.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011 Creative Product Design
+ *
+ * This file is released under the GPLv2
+ */
+#ifndef __ISL22316_H
+#define __ISL22316_H
+
+struct isl22316 {
+	struct cdev		cdev;
+	struct i2c_client	*client;
+};
+
+struct isl22316 *isl22316_get(void);
+
+int isl22316_reg_read(struct isl22316 *isl22316, u8 reg, u8 *val);
+int isl22316_reg_write(struct isl22316 *isl22316, u8 reg, u8 val);
+
+/*
+ * Uses non volatile storage if save is non zero.
+ * (remember that saving to non-vol also sets the working value)
+ */
+int isl22316_get_value(struct isl22316 *isl22316, u8 *val, int save);
+int isl22316_set_value(struct isl22316 *isl22316, u8 val, int save);
+
+#endif
-- 
1.7.7


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

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

* Re: [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address
  2012-07-16  1:04 ` [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address Marc Reilly
@ 2012-07-16  7:43   ` Sascha Hauer
  0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2012-07-16  7:43 UTC (permalink / raw)
  To: Marc Reilly; +Cc: barebox

On Mon, Jul 16, 2012 at 11:04:55AM +1000, Marc Reilly wrote:
> This patch adds a handler to the fec platform data to get MAC address.
> If a handler is not specified the driver uses the existing one.

We already have a generic mechanism for that. See eth_register_ethaddr.
If you pass a MAC address to this function this one will be used instead
of the default one from the driver.

Sascha

> 
> Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
> ---
>  drivers/net/fec_imx.c |    6 +++++-
>  include/fec.h         |    4 ++++
>  2 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> index 599a9b4..5084758 100644
> --- a/drivers/net/fec_imx.c
> +++ b/drivers/net/fec_imx.c
> @@ -629,10 +629,14 @@ static int fec_probe(struct device_d *dev)
>  	edev->send = fec_send;
>  	edev->recv = fec_recv;
>  	edev->halt = fec_halt;
> -	edev->get_ethaddr = fec_get_hwaddr;
>  	edev->set_ethaddr = fec_set_hwaddr;
>  	edev->parent = dev;
>  
> +	if (pdata->get_hwaddr)
> +		edev->get_ethaddr = pdata->get_hwaddr;
> +	else
> +		edev->get_ethaddr = fec_get_hwaddr;
> +
>  	fec->regs = dev_request_mem_region(dev, 0);
>  
>  	/* Reset chip. */
> diff --git a/include/fec.h b/include/fec.h
> index f56b023..5072bbf 100644
> --- a/include/fec.h
> +++ b/include/fec.h
> @@ -36,6 +36,8 @@ typedef enum {
>  	RGMII,
>  } xceiver_type;
>  
> +struct eth_device;
> +
>  /*
>   * Define the phy connected externally for FEC drivers
>   * (like MPC52xx and i.MX27)
> @@ -43,6 +45,8 @@ typedef enum {
>  struct fec_platform_data {
>          xceiver_type	xcv_type;
>  	int		phy_addr;
> +
> +	int (*get_hwaddr)(struct eth_device *dev, unsigned char *mac);
>  };
>  
>  #endif /* __INCLUDE_NETWORK_FEC_H */
> -- 
> 1.7.7
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 4/5] at24: add I2C eeprom for 24cl02
  2012-07-16  1:04 ` [PATCH 4/5] at24: add I2C eeprom for 24cl02 Marc Reilly
@ 2012-07-16  7:49   ` Sascha Hauer
  0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2012-07-16  7:49 UTC (permalink / raw)
  To: Marc Reilly; +Cc: barebox

On Mon, Jul 16, 2012 at 11:04:58AM +1000, Marc Reilly wrote:
> This series adds a driver for at24 eeproms. Much of the guts of the code
> is taken from the at24 driver in the linux kernel.
> 
> Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
> ---
>  drivers/eeprom/Kconfig  |    7 +++
>  drivers/eeprom/Makefile |    1 +
>  drivers/eeprom/at24.c   |  134 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 142 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/eeprom/at24.c
> 
> diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig
> index a0b5489..56dfd1a 100644
> --- a/drivers/eeprom/Kconfig
> +++ b/drivers/eeprom/Kconfig
> @@ -8,4 +8,11 @@ config EEPROM_AT25
>  	  after you configure the board init code to know about each eeprom
>  	  on your target board.
>  
> +config EEPROM_AT24
> +	bool "at24 based eeprom"
> +	depends on I2C
> +	help
> +	  Provides read/write for the at24 family of I2C EEPROMS.
> +	  Currently only the 2K bit versions are supported.
> +	  

Trailing whitespace here.

> +{
> +	struct at24 *priv = to_at24(cdev);
> +	const u8 *buf = _buf;
> +	const int maxwrite = 8;
> +	int numtowrite;
> +	ssize_t numwritten = 0;
> +
> +	while (count) {
> +		int ret;
> +
> +		numtowrite = count;
> +		if (numtowrite > maxwrite)
> +			numtowrite = maxwrite;
> +
> +		ret = i2c_write_reg(priv->client, offset, buf, numtowrite);
> +		if (ret < 0)
> +			return (ssize_t)ret;
> +
> +		mdelay(10);

Do we need this? This makes the driver veeery slow. If we could poll
this somehow it would be much better.

> +
> +static int at24_init(void)
> +{
> +	register_driver(&at24_driver);
> +	return 0;

We can safely return the result of register_driver here. There was a
time when barebox paniced on a failed initcall, but this is not the case
anymore. Instead we have some debug output for failed initcalls which
seems more useful

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

end of thread, other threads:[~2012-07-16  7:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-16  1:04 Various patches for imx35, fec, at24 driver and misc Marc Reilly
2012-07-16  1:04 ` [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address Marc Reilly
2012-07-16  7:43   ` Sascha Hauer
2012-07-16  1:04 ` [PATCH 2/5] imx35: 6-bit divider helper Marc Reilly
2012-07-16  1:04 ` [PATCH 3/5] imx35: mmc clock has 6 bit divider, not 3_3 Marc Reilly
2012-07-16  1:04 ` [PATCH 4/5] at24: add I2C eeprom for 24cl02 Marc Reilly
2012-07-16  7:49   ` Sascha Hauer
2012-07-16  1:04 ` [PATCH 5/5] misc: new driver: isl22316 digital potentiometer Marc Reilly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox