From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olliver Schinagl Date: Mon, 15 May 2017 10:02:37 +0200 Subject: [U-Boot] [PATCHv6 21/28] net: sunxi: Have sunxi common functions together In-Reply-To: <20170515080244.21345-1-oliver@schinagl.nl> References: <20170515080244.21345-1-oliver@schinagl.nl> Message-ID: <20170515080244.21345-22-oliver@schinagl.nl> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The sun[8x]i network drivers have some common functions. Let's introduce a common file with the reading of the MAC address as a start. In the future, we can move more sunxi shared/common code into this file. Signed-off-by: Olliver Schinagl --- drivers/net/sunxi_common.c | 33 +++++++++++++++++++++++++++++++++ drivers/net/sunxi_common.h | 13 +++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 drivers/net/sunxi_common.c create mode 100644 drivers/net/sunxi_common.h diff --git a/drivers/net/sunxi_common.c b/drivers/net/sunxi_common.c new file mode 100644 index 0000000000..a22fd2bfe7 --- /dev/null +++ b/drivers/net/sunxi_common.c @@ -0,0 +1,33 @@ +/* + * (c) Copyright 2017 + * Author: Olliver Schinagl + * + * SPX-License-Identifier: GPL-3.0+ + * + * Common code for the sunxi series of the ethernet sunxi mac driver + * + */ + +#include +#include +#include +#include +#include + +/* + * Set ethernet MAC address based on serial number. + * FIXME: For now we call sunxi_gen_hwaddr to generate the MAC address there. + * This is done because we have some devices, which expect their MAC address to + * to be passed via the environment and obtained from the FDT. Once that code + * has been refactored (it is quircky to say the least), the mac generating code + * should live here. + */ +int sunxi_mac_read_rom_hwaddr(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + + if (!pdata || (dev->seq < 0)) + return -ENOSYS; + + return sunxi_gen_hwaddr(dev->seq, pdata->enetaddr); +} diff --git a/drivers/net/sunxi_common.h b/drivers/net/sunxi_common.h new file mode 100644 index 0000000000..99ef5e6f25 --- /dev/null +++ b/drivers/net/sunxi_common.h @@ -0,0 +1,13 @@ +/* + * (c) Copyright 2017 + * Author: Olliver Schinagl + * + * SPX-License-Identifier: GPL-3.0+ + * + * Common code for the sunxi series of the ethernet sunxi mac drivers + * + */ + +#include + +int sunxi_mac_read_rom_hwaddr(struct udevice *dev); -- 2.11.0