mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/1] raspberry-pi: mac address detection support
@ 2015-01-19 12:29 Jean-Christophe PLAGNIOL-VILLARD
  2015-01-19 14:22 ` Antony Pavlov
  0 siblings, 1 reply; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-19 12:29 UTC (permalink / raw)
  To: barebox

increase the mbox timeout as it take more time to retreive the mac

fix led register too

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/raspberry-pi/rpi.c        | 44 ++++++++++++++++++++++++-------
 arch/arm/mach-bcm2835/include/mach/mbox.h | 14 ++++++++++
 arch/arm/mach-bcm2835/mbox.c              |  2 +-
 3 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c
index 108bd28..f9406d4 100644
--- a/arch/arm/boards/raspberry-pi/rpi.c
+++ b/arch/arm/boards/raspberry-pi/rpi.c
@@ -22,6 +22,7 @@
 #include <envfs.h>
 #include <malloc.h>
 #include <gpio.h>
+#include <net.h>
 #include <led.h>
 #include <asm/armlinux.h>
 #include <generated/mach-types.h>
@@ -47,6 +48,12 @@ struct msg_get_board_rev {
 	u32 end_tag;
 };
 
+struct msg_get_mac_address {
+	struct bcm2835_mbox_hdr hdr;
+	struct bcm2835_mbox_tag_get_mac_address get_mac_address;
+	u32 end_tag;
+};
+
 static int rpi_get_arm_mem(u32 *size)
 {
 	BCM2835_MBOX_STACK_ALIGN(struct msg_get_arm_mem, msg);
@@ -88,6 +95,23 @@ static int rpi_register_clkdev(u32 clock_id, const char *name)
 	return 0;
 }
 
+static void rpi_set_usbethaddr(void)
+{
+	BCM2835_MBOX_STACK_ALIGN(struct msg_get_mac_address, msg);
+	int ret;
+
+	BCM2835_MBOX_INIT_HDR(msg);
+	BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
+
+	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+	if (ret) {
+		printf("bcm2835: Could not query MAC address\n");
+		/* Ignore error; not critical */
+		return;
+	}
+
+	eth_register_ethaddr(0, msg->get_mac_address.body.resp.mac);
+}
 
 static struct gpio_led leds[] = {
 	{
@@ -124,12 +148,14 @@ static void rpi_b_plus_init(void)
 {
 	leds[0].gpio = 47;
 	leds[1].gpio = 35;
+	rpi_set_usbethaddr();
 }
 
 static void rpi_b_init(void)
 {
 	leds[0].gpio = 16;
 	leds[0].active_low = 1;
+	rpi_set_usbethaddr();
 }
 
 #define RPI_MODEL(_id, _name, _init)	\
@@ -143,18 +169,18 @@ static const struct {
 	void (*init)(void);
 } models[] = {
 	RPI_MODEL(0, "Unknown model", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL),
+	RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", rpi_b_init),
+	RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", rpi_b_init),
+	RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", rpi_b_init),
+	RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", rpi_b_init),
+	RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", rpi_b_init),
 	RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL),
 	RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL),
 	RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL),
-	RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL),
+	RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", rpi_b_init),
+	RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", rpi_b_init),
+	RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", rpi_b_init),
+	RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", rpi_b_plus_init),
 	RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL),
 	RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL),
 };
diff --git a/arch/arm/mach-bcm2835/include/mach/mbox.h b/arch/arm/mach-bcm2835/include/mach/mbox.h
index d991ba7..4c3fd77 100644
--- a/arch/arm/mach-bcm2835/include/mach/mbox.h
+++ b/arch/arm/mach-bcm2835/include/mach/mbox.h
@@ -158,6 +158,20 @@ struct bcm2835_mbox_tag_get_board_rev {
 	} body;
 };
 
+#define BCM2835_MBOX_TAG_GET_MAC_ADDRESS	0x00010003
+
+struct bcm2835_mbox_tag_get_mac_address {
+	struct bcm2835_mbox_tag_hdr tag_hdr;
+	union {
+		struct {
+		} req;
+		struct {
+			u8 mac[6];
+			u8 pad[2];
+		} resp;
+	} body;
+};
+
 #define BCM2835_MBOX_TAG_GET_ARM_MEMORY		0x00010005
 
 struct bcm2835_mbox_tag_get_arm_mem {
diff --git a/arch/arm/mach-bcm2835/mbox.c b/arch/arm/mach-bcm2835/mbox.c
index 2bca567..0e51f08 100644
--- a/arch/arm/mach-bcm2835/mbox.c
+++ b/arch/arm/mach-bcm2835/mbox.c
@@ -13,7 +13,7 @@
 
 #include <mach/mbox.h>
 
-#define TIMEOUT (MSECOND * 100) /* 100mS */
+#define TIMEOUT (MSECOND * 1000) /* 100mS */
 
 static int bcm2835_mbox_call_raw(u32 chan, struct bcm2835_mbox_hdr *buffer,
 					u32 *recv)
-- 
2.1.3


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

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

* Re: [PATCH 1/1] raspberry-pi: mac address detection support
  2015-01-19 12:29 [PATCH 1/1] raspberry-pi: mac address detection support Jean-Christophe PLAGNIOL-VILLARD
@ 2015-01-19 14:22 ` Antony Pavlov
  2015-01-20  6:54   ` Sascha Hauer
  2015-01-20  7:31   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 4+ messages in thread
From: Antony Pavlov @ 2015-01-19 14:22 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Mon, 19 Jan 2015 13:29:44 +0100
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:

> increase the mbox timeout as it take more time to retreive the mac
> 
> fix led register too
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
...
> diff --git a/arch/arm/mach-bcm2835/mbox.c b/arch/arm/mach-bcm2835/mbox.c
> index 2bca567..0e51f08 100644
> --- a/arch/arm/mach-bcm2835/mbox.c
> +++ b/arch/arm/mach-bcm2835/mbox.c
> @@ -13,7 +13,7 @@
>  
>  #include <mach/mbox.h>
>  
> -#define TIMEOUT (MSECOND * 100) /* 100mS */
> +#define TIMEOUT (MSECOND * 1000) /* 100mS */
>  

+#define TIMEOUT (MSECOND * 1000) /* 1000mS */

-- 
Best regards,
  Antony Pavlov

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

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

* Re: [PATCH 1/1] raspberry-pi: mac address detection support
  2015-01-19 14:22 ` Antony Pavlov
@ 2015-01-20  6:54   ` Sascha Hauer
  2015-01-20  7:31   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2015-01-20  6:54 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Mon, Jan 19, 2015 at 06:22:46PM +0400, Antony Pavlov wrote:
> On Mon, 19 Jan 2015 13:29:44 +0100
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> 
> > increase the mbox timeout as it take more time to retreive the mac
> > 
> > fix led register too
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ...
> > diff --git a/arch/arm/mach-bcm2835/mbox.c b/arch/arm/mach-bcm2835/mbox.c
> > index 2bca567..0e51f08 100644
> > --- a/arch/arm/mach-bcm2835/mbox.c
> > +++ b/arch/arm/mach-bcm2835/mbox.c
> > @@ -13,7 +13,7 @@
> >  
> >  #include <mach/mbox.h>
> >  
> > -#define TIMEOUT (MSECOND * 100) /* 100mS */
> > +#define TIMEOUT (MSECOND * 1000) /* 100mS */
> >  
> 
> +#define TIMEOUT (MSECOND * 1000) /* 1000mS */

I removed the comment while applying. No need to state the obvious.

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] 4+ messages in thread

* Re: [PATCH 1/1] raspberry-pi: mac address detection support
  2015-01-19 14:22 ` Antony Pavlov
  2015-01-20  6:54   ` Sascha Hauer
@ 2015-01-20  7:31   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-20  7:31 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On 18:22 Mon 19 Jan     , Antony Pavlov wrote:
> On Mon, 19 Jan 2015 13:29:44 +0100
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> 
> > increase the mbox timeout as it take more time to retreive the mac
> > 
> > fix led register too
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ...
> > diff --git a/arch/arm/mach-bcm2835/mbox.c b/arch/arm/mach-bcm2835/mbox.c
> > index 2bca567..0e51f08 100644
> > --- a/arch/arm/mach-bcm2835/mbox.c
> > +++ b/arch/arm/mach-bcm2835/mbox.c
> > @@ -13,7 +13,7 @@
> >  
> >  #include <mach/mbox.h>
> >  
> > -#define TIMEOUT (MSECOND * 100) /* 100mS */
> > +#define TIMEOUT (MSECOND * 1000) /* 100mS */
> >  
> 
> +#define TIMEOUT (MSECOND * 1000) /* 1000mS */
should simply drop the comment useless

Best Regards,
J.
> 
> -- 
> Best regards,
>   Antony Pavlov

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

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

end of thread, other threads:[~2015-01-20  7:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19 12:29 [PATCH 1/1] raspberry-pi: mac address detection support Jean-Christophe PLAGNIOL-VILLARD
2015-01-19 14:22 ` Antony Pavlov
2015-01-20  6:54   ` Sascha Hauer
2015-01-20  7:31   ` Jean-Christophe PLAGNIOL-VILLARD

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