* [PATCH 2/8] w1: introduce helper to generate mac address from 1-wire id
2012-10-30 21:00 ` [PATCH 1/8] arm: at91: add gpio_is_valid support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-30 21:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 3/8] pm9g45: add 1-wire support Jean-Christophe PLAGNIOL-VILLARD
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-30 21:00 UTC (permalink / raw)
To: barebox
use the first 3 byte of the id of a 1-wire
or 6 if no OUI provided device to provide an Ethernet address
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
include/w1_mac_address.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
create mode 100644 include/w1_mac_address.h
diff --git a/include/w1_mac_address.h b/include/w1_mac_address.h
new file mode 100644
index 0000000..89dd914
--- /dev/null
+++ b/include/w1_mac_address.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __W1_MAC_ADDRESS_H__
+#define __W1_MAC_ADDRESS_H__
+
+/**
+ * w1_local_mac_address_register - use the first 3 byte of the id of a 1-wire
+ * or 6 if no OUI provided device to provide an Ethernet address
+ * @ethid: ethernet device id
+ * @oui: Ethernet OUI (3 bytes)
+ * @w1_dev: 1-wire device name
+ *
+ * Generate a local Ethernet address (MAC) that is not multicast using a 1-wire id.
+ */
+static inline int w1_local_mac_address_register(int ethid, char * oui, char *w1_dev)
+{
+ char addr[6];
+ const char *val;
+ u64 id;
+ int nb_oui = 0;
+ int i, shift;
+ char *tmp = NULL;
+ int ret = 0;
+
+ if (oui) {
+ nb_oui = 3;
+
+ for (i = 0; i < nb_oui; i++)
+ addr[i] = oui[i];
+ }
+
+ tmp = asprintf("%s.id", w1_dev);
+ if (!tmp)
+ return -ENOMEM;
+
+ val = getenv(tmp);
+ if (!val) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ id = simple_strtoull(val, NULL, 16);
+ if (!id) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ for (i = nb_oui, shift = 40; i < 6; i++, shift -= 8)
+ addr[i] = (id >> shift) & 0xff;
+
+ addr[0] &= 0xfe; /* clear multicast bit */
+ addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
+
+ eth_register_ethaddr(ethid, addr);
+
+err:
+ free(tmp);
+ return ret;
+}
+
+#endif /* __W1_MAC_ADDRESS_H__ */
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/8] pm9g45: add 1-wire support
2012-10-30 21:00 ` [PATCH 1/8] arm: at91: add gpio_is_valid support Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 2/8] w1: introduce helper to generate mac address from 1-wire id Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-30 21:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 4/8] pm9g45: use w1 serial number to generate local mac address Jean-Christophe PLAGNIOL-VILLARD
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-30 21:00 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/pm9g45/init.c | 11 ++++++++++-
arch/arm/configs/pm9g45_defconfig | 2 ++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boards/pm9g45/init.c b/arch/arm/boards/pm9g45/init.c
index a12896b..907c6bb 100644
--- a/arch/arm/boards/pm9g45/init.c
+++ b/arch/arm/boards/pm9g45/init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ * Copyright (C) 2009-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
*
* Copyright (C) 2007 Sascha Hauer, Pengutronix
*
@@ -35,6 +35,12 @@
#include <mach/io.h>
#include <mach/at91sam9_smc.h>
#include <mach/sam9_smc.h>
+#include <linux/w1-gpio.h>
+
+struct w1_gpio_platform_data w1_pdata = {
+ .pin = AT91_PIN_PA31,
+ .is_open_drain = 0,
+};
static struct atmel_nand_data nand_pdata = {
.ale = 21,
@@ -132,6 +138,9 @@ mem_initcall(pm9g45_mem_init);
static int pm9g45_devices_init(void)
{
+ at91_set_gpio_input(w1_pdata.pin, 0);
+ add_generic_device_res("w1-gpio", DEVICE_ID_SINGLE, NULL, 0, &w1_pdata);
+
pm_add_device_nand();
pm9g45_add_device_mci();
pm9g45_phy_init();
diff --git a/arch/arm/configs/pm9g45_defconfig b/arch/arm/configs/pm9g45_defconfig
index 958301d..d242bdc 100644
--- a/arch/arm/configs/pm9g45_defconfig
+++ b/arch/arm/configs/pm9g45_defconfig
@@ -56,6 +56,8 @@ CONFIG_USB_OHCI_AT91=y
CONFIG_USB_STORAGE=y
CONFIG_MCI=y
CONFIG_MCI_ATMEL=y
+CONFIG_W1=y
+CONFIG_W1_MASTER_GPIO=y
CONFIG_FS_TFTP=y
CONFIG_FS_FAT=y
CONFIG_FS_FAT_WRITE=y
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/8] pm9g45: use w1 serial number to generate local mac address
2012-10-30 21:00 ` [PATCH 1/8] arm: at91: add gpio_is_valid support Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 2/8] w1: introduce helper to generate mac address from 1-wire id Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 3/8] pm9g45: add 1-wire support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-30 21:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 5/8] pm9263: add 1-wire support Jean-Christophe PLAGNIOL-VILLARD
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-30 21:00 UTC (permalink / raw)
To: barebox
The OUI will be 'ron' => 72:6F:6E
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/pm9g45/init.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boards/pm9g45/init.c b/arch/arm/boards/pm9g45/init.c
index 907c6bb..675ebe8 100644
--- a/arch/arm/boards/pm9g45/init.c
+++ b/arch/arm/boards/pm9g45/init.c
@@ -36,6 +36,7 @@
#include <mach/at91sam9_smc.h>
#include <mach/sam9_smc.h>
#include <linux/w1-gpio.h>
+#include <w1_mac_address.h>
struct w1_gpio_platform_data w1_pdata = {
.pin = AT91_PIN_PA31,
@@ -128,6 +129,13 @@ static void pm9g45_phy_init(void)
at91_set_gpio_value(AT91_PIN_PD2, 1);
}
+static void pm9g45_add_device_eth(void)
+{
+ w1_local_mac_address_register(0, "ron", "w1-1-0");
+ pm9g45_phy_init();
+ at91_add_device_eth(0, &macb_pdata);
+}
+
static int pm9g45_mem_init(void)
{
at91_add_device_sdram(128 * 1024 * 1024);
@@ -143,8 +151,7 @@ static int pm9g45_devices_init(void)
pm_add_device_nand();
pm9g45_add_device_mci();
- pm9g45_phy_init();
- at91_add_device_eth(0, &macb_pdata);
+ pm9g45_add_device_eth();
pm9g45_add_device_usbh();
devfs_add_partition("nand0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5/8] pm9263: add 1-wire support
2012-10-30 21:00 ` [PATCH 1/8] arm: at91: add gpio_is_valid support Jean-Christophe PLAGNIOL-VILLARD
` (2 preceding siblings ...)
2012-10-30 21:00 ` [PATCH 4/8] pm9g45: use w1 serial number to generate local mac address Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-30 21:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 6/8] pm9263: use w1 serial number to generate local mac address Jean-Christophe PLAGNIOL-VILLARD
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-30 21:00 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/pm9263/init.c | 11 +++++++++++
arch/arm/configs/pm9263_defconfig | 2 ++
2 files changed, 13 insertions(+)
diff --git a/arch/arm/boards/pm9263/init.c b/arch/arm/boards/pm9263/init.c
index b17a90a..1d13e03 100644
--- a/arch/arm/boards/pm9263/init.c
+++ b/arch/arm/boards/pm9263/init.c
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) 2009-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
* Copyright (C) 2007 Sascha Hauer, Pengutronix
*
* This program is free software; you can redistribute it and/or
@@ -34,6 +36,12 @@
#include <mach/io.h>
#include <mach/at91sam9_smc.h>
#include <mach/sam9_smc.h>
+#include <linux/w1-gpio.h>
+
+struct w1_gpio_platform_data w1_pdata = {
+ .pin = AT91_PIN_PB31,
+ .is_open_drain = 0,
+};
static struct atmel_nand_data nand_pdata = {
.ale = 21,
@@ -95,6 +103,9 @@ mem_initcall(pm9263_mem_init);
static int pm9263_devices_init(void)
{
+ at91_set_gpio_input(w1_pdata.pin, 0);
+ add_generic_device_res("w1-gpio", DEVICE_ID_SINGLE, NULL, 0, &w1_pdata);
+
/*
* PB27 enables the 50MHz oscillator for Ethernet PHY
* 1 - enable
diff --git a/arch/arm/configs/pm9263_defconfig b/arch/arm/configs/pm9263_defconfig
index 8c92894..e223e77 100644
--- a/arch/arm/configs/pm9263_defconfig
+++ b/arch/arm/configs/pm9263_defconfig
@@ -35,3 +35,5 @@ CONFIG_DRIVER_NET_MACB=y
# CONFIG_SPI is not set
CONFIG_DRIVER_CFI=y
CONFIG_CFI_BUFFER_WRITE=y
+CONFIG_W1=y
+CONFIG_W1_MASTER_GPIO=y
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 6/8] pm9263: use w1 serial number to generate local mac address
2012-10-30 21:00 ` [PATCH 1/8] arm: at91: add gpio_is_valid support Jean-Christophe PLAGNIOL-VILLARD
` (3 preceding siblings ...)
2012-10-30 21:00 ` [PATCH 5/8] pm9263: add 1-wire support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-30 21:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 7/8] pm9261: add 1-wire support Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 8/8] pm9261: use w1 serial number to generate local mac address Jean-Christophe PLAGNIOL-VILLARD
6 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-30 21:00 UTC (permalink / raw)
To: barebox
The OUI will be 'ron' => 72:6F:6E
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/pm9263/init.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/arch/arm/boards/pm9263/init.c b/arch/arm/boards/pm9263/init.c
index 1d13e03..14e821f 100644
--- a/arch/arm/boards/pm9263/init.c
+++ b/arch/arm/boards/pm9263/init.c
@@ -37,6 +37,7 @@
#include <mach/at91sam9_smc.h>
#include <mach/sam9_smc.h>
#include <linux/w1-gpio.h>
+#include <w1_mac_address.h>
struct w1_gpio_platform_data w1_pdata = {
.pin = AT91_PIN_PB31,
@@ -93,6 +94,24 @@ static struct at91_ether_platform_data macb_pdata = {
.phy_addr = 0,
};
+static void pm9263_phy_init(void)
+{
+ /*
+ * PB27 enables the 50MHz oscillator for Ethernet PHY
+ * 1 - enable
+ * 0 - disable
+ */
+ at91_set_gpio_output(AT91_PIN_PB27, 1);
+ at91_set_gpio_value(AT91_PIN_PB27, 1); /* 1- enable, 0 - disable */
+}
+
+static void pm9263_add_device_eth(void)
+{
+ w1_local_mac_address_register(0, "ron", "w1-1-0");
+ pm9263_phy_init();
+ at91_add_device_eth(0, &macb_pdata);
+}
+
static int pm9263_mem_init(void)
{
at91_add_device_sdram(64 * 1024 * 1024);
@@ -106,16 +125,8 @@ static int pm9263_devices_init(void)
at91_set_gpio_input(w1_pdata.pin, 0);
add_generic_device_res("w1-gpio", DEVICE_ID_SINGLE, NULL, 0, &w1_pdata);
- /*
- * PB27 enables the 50MHz oscillator for Ethernet PHY
- * 1 - enable
- * 0 - disable
- */
- at91_set_gpio_output(AT91_PIN_PB27, 1);
- at91_set_gpio_value(AT91_PIN_PB27, 1); /* 1- enable, 0 - disable */
-
pm_add_device_nand();
- at91_add_device_eth(0, &macb_pdata);
+ pm9263_add_device_eth();
add_cfi_flash_device(0, AT91_CHIPSELECT_0, 4 * 1024 * 1024, 0);
devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 7/8] pm9261: add 1-wire support
2012-10-30 21:00 ` [PATCH 1/8] arm: at91: add gpio_is_valid support Jean-Christophe PLAGNIOL-VILLARD
` (4 preceding siblings ...)
2012-10-30 21:00 ` [PATCH 6/8] pm9263: use w1 serial number to generate local mac address Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-30 21:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-30 21:00 ` [PATCH 8/8] pm9261: use w1 serial number to generate local mac address Jean-Christophe PLAGNIOL-VILLARD
6 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-30 21:00 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/pm9261/init.c | 8 ++++++++
arch/arm/configs/pm9261_defconfig | 2 ++
2 files changed, 10 insertions(+)
diff --git a/arch/arm/boards/pm9261/init.c b/arch/arm/boards/pm9261/init.c
index 5214394..2c3615f 100644
--- a/arch/arm/boards/pm9261/init.c
+++ b/arch/arm/boards/pm9261/init.c
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) 2009-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
* Copyright (C) 2007 Sascha Hauer, Pengutronix
*
* This program is free software; you can redistribute it and/or
@@ -34,6 +36,12 @@
#include <mach/at91sam9_smc.h>
#include <mach/sam9_smc.h>
#include <dm9000.h>
+#include <linux/w1-gpio.h>
+
+struct w1_gpio_platform_data w1_pdata = {
+ .pin = AT91_PIN_PA7,
+ .is_open_drain = 0,
+};
static struct atmel_nand_data nand_pdata = {
.ale = 22,
diff --git a/arch/arm/configs/pm9261_defconfig b/arch/arm/configs/pm9261_defconfig
index 1db16d5..0aea2c9 100644
--- a/arch/arm/configs/pm9261_defconfig
+++ b/arch/arm/configs/pm9261_defconfig
@@ -50,3 +50,5 @@ CONFIG_MTD=y
CONFIG_NAND=y
CONFIG_NAND_ATMEL=y
CONFIG_UBI=y
+CONFIG_W1=y
+CONFIG_W1_MASTER_GPIO=y
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 8/8] pm9261: use w1 serial number to generate local mac address
2012-10-30 21:00 ` [PATCH 1/8] arm: at91: add gpio_is_valid support Jean-Christophe PLAGNIOL-VILLARD
` (5 preceding siblings ...)
2012-10-30 21:00 ` [PATCH 7/8] pm9261: add 1-wire support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-30 21:00 ` Jean-Christophe PLAGNIOL-VILLARD
6 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-30 21:00 UTC (permalink / raw)
To: barebox
The OUI will be 'ron' => 72:6F:6E
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/pm9261/init.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/boards/pm9261/init.c b/arch/arm/boards/pm9261/init.c
index 2c3615f..6d2ac98 100644
--- a/arch/arm/boards/pm9261/init.c
+++ b/arch/arm/boards/pm9261/init.c
@@ -37,6 +37,7 @@
#include <mach/sam9_smc.h>
#include <dm9000.h>
#include <linux/w1-gpio.h>
+#include <w1_mac_address.h>
struct w1_gpio_platform_data w1_pdata = {
.pin = AT91_PIN_PA7,
@@ -120,6 +121,7 @@ static struct sam9_smc_config __initdata dm9000_smc_config = {
static void __init pm_add_device_dm9000(void)
{
+ w1_local_mac_address_register(0, "ron", "w1-1-0");
/* Configure chip-select 2 (DM9000) */
sam9_smc_configure(2, &dm9000_smc_config);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread