Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: mxs: configure and register the second FEC device on TX28/STK5-V4
@ 2011-03-21 16:48 Lothar Waßmann
  2011-03-21 16:48 ` [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses Lothar Waßmann
  0 siblings, 1 reply; 4+ messages in thread
From: Lothar Waßmann @ 2011-03-21 16:48 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Lothar Wa?mann <LW@KARO-electronics.de>
---
 arch/arm/mach-mxs/module-tx28.c |   41 +++++++++++++++++++++++++++++++++-----
 arch/arm/mach-mxs/module-tx28.h |    1 +
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-mxs/module-tx28.c b/arch/arm/mach-mxs/module-tx28.c
index 7510057..7d44936 100644
--- a/arch/arm/mach-mxs/module-tx28.c
+++ b/arch/arm/mach-mxs/module-tx28.c
@@ -45,7 +45,7 @@ static const iomux_cfg_t tx28_fec_gpio_pads[] __initconst = {
 };
 
 #define FEC_MODE (MXS_PAD_8MA | MXS_PAD_PULLUP | MXS_PAD_3V3)
-static const iomux_cfg_t tx28_fec_pads[] __initconst = {
+static const iomux_cfg_t tx28_fec0_pads[] __initconst = {
 	MX28_PAD_ENET0_MDC__ENET0_MDC | FEC_MODE,
 	MX28_PAD_ENET0_MDIO__ENET0_MDIO | FEC_MODE,
 	MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | FEC_MODE,
@@ -57,7 +57,20 @@ static const iomux_cfg_t tx28_fec_pads[] __initconst = {
 	MX28_PAD_ENET_CLK__CLKCTRL_ENET | FEC_MODE,
 };
 
-static const struct fec_platform_data tx28_fec_data __initconst = {
+static const iomux_cfg_t tx28_fec1_pads[] __initconst = {
+	MX28_PAD_ENET0_RXD2__ENET1_RXD0,
+	MX28_PAD_ENET0_RXD3__ENET1_RXD1,
+	MX28_PAD_ENET0_TXD2__ENET1_TXD0,
+	MX28_PAD_ENET0_TXD3__ENET1_TXD1,
+	MX28_PAD_ENET0_COL__ENET1_TX_EN,
+	MX28_PAD_ENET0_CRS__ENET1_RX_EN,
+};
+
+static struct fec_platform_data tx28_fec0_data = {
+	.phy = PHY_INTERFACE_MODE_RMII,
+};
+
+static struct fec_platform_data tx28_fec1_data = {
 	.phy = PHY_INTERFACE_MODE_RMII,
 };
 
@@ -119,15 +132,15 @@ int __init tx28_add_fec0(void)
 	pr_debug("%s: Deasserting FEC PHY RESET\n", __func__);
 	gpio_set_value(TX28_FEC_PHY_RESET, 1);
 
-	ret = mxs_iomux_setup_multiple_pads(tx28_fec_pads,
-			ARRAY_SIZE(tx28_fec_pads));
+	ret = mxs_iomux_setup_multiple_pads(tx28_fec0_pads,
+			ARRAY_SIZE(tx28_fec0_pads));
 	if (ret) {
 		pr_debug("%s: mxs_iomux_setup_multiple_pads() failed with rc: %d\n",
 				__func__, ret);
 		goto free_gpios;
 	}
-	pr_debug("%s: Registering FEC device\n", __func__);
-	mx28_add_fec(0, &tx28_fec_data);
+	pr_debug("%s: Registering FEC0 device\n", __func__);
+	mx28_add_fec(0, &tx28_fec0_data);
 	return 0;
 
 free_gpios:
@@ -140,3 +153,19 @@ free_gpios:
 
 	return ret;
 }
+
+int __init tx28_add_fec1(void)
+{
+	int ret;
+
+	ret = mxs_iomux_setup_multiple_pads(tx28_fec1_pads,
+			ARRAY_SIZE(tx28_fec1_pads));
+	if (ret) {
+		pr_debug("%s: mxs_iomux_setup_multiple_pads() failed with rc: %d\n",
+				__func__, ret);
+		return ret;
+	}
+	pr_debug("%s: Registering FEC1 device\n", __func__);
+	mx28_add_fec(1, &tx28_fec1_data);
+	return 0;
+}
diff --git a/arch/arm/mach-mxs/module-tx28.h b/arch/arm/mach-mxs/module-tx28.h
index df9e1b6..8ed4254 100644
--- a/arch/arm/mach-mxs/module-tx28.h
+++ b/arch/arm/mach-mxs/module-tx28.h
@@ -7,3 +7,4 @@
  * Free Software Foundation.
  */
 int __init tx28_add_fec0(void);
+int __init tx28_add_fec1(void);
-- 
1.5.6.5

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

* [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses.
  2011-03-21 16:48 [PATCH 1/2] ARM: mxs: configure and register the second FEC device on TX28/STK5-V4 Lothar Waßmann
@ 2011-03-21 16:48 ` Lothar Waßmann
  2011-03-22 14:14   ` Shawn Guo
  0 siblings, 1 reply; 4+ messages in thread
From: Lothar Waßmann @ 2011-03-21 16:48 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Lothar Wa?mann <LW@KARO-electronics.de>
---
 arch/arm/mach-mxs/module-tx28.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mxs/module-tx28.c b/arch/arm/mach-mxs/module-tx28.c
index 7d44936..7a9e7b6 100644
--- a/arch/arm/mach-mxs/module-tx28.c
+++ b/arch/arm/mach-mxs/module-tx28.c
@@ -74,6 +74,43 @@ static struct fec_platform_data tx28_fec1_data = {
 	.phy = PHY_INTERFACE_MODE_RMII,
 };
 
+#define HW_OCOTP_CUST0			0x20
+#define HW_OCOTP_CUST(n)		(HW_OCOTP_CUST0 + (n) * 0x10)
+#define HW_OCOTP_CTRL			0x00
+#define HW_OCOTP_CTRL_SET		(HW_OCOTP_CTRL + 4)
+#define HW_OCOTP_CTRL_CLR		(HW_OCOTP_CTRL + 8)
+
+#define BM_OCOTP_CTRL_BUSY		(1 << 8)
+#define BM_OCOTP_CTRL_RD_BANK_OPEN	(1 << 12)
+
+static int __init tx28_set_mac(int id, unsigned char mac[])
+{
+	int i;
+	void __iomem *ocotp_base = ioremap(MX28_OCOTP_BASE_ADDR, SZ_4K);
+	u32 reg = 0;
+	long timeout = 1000;
+
+	if (ocotp_base == NULL)
+		return -ENOMEM;
+
+	/* set this bit to open the OTP banks for reading */
+	writel(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base + HW_OCOTP_CTRL_SET);
+
+	while (readl(ocotp_base + HW_OCOTP_CTRL) & BM_OCOTP_CTRL_BUSY) {
+		if (timeout-- < 0)
+			return -ETIMEDOUT;
+		udelay(100);
+	}
+
+	for (i = 0; i < ETH_ALEN; i++) {
+		if (i % 4 == 0)
+			reg = readl(ocotp_base + HW_OCOTP_CUST(id * 2 + i / 4));
+		mac[i] = reg >> (24 - ((i % 4) * 8));
+	}
+	iounmap(ocotp_base);
+	return 0;
+}
+
 int __init tx28_add_fec0(void)
 {
 	int i, ret;
@@ -139,6 +176,7 @@ int __init tx28_add_fec0(void)
 				__func__, ret);
 		goto free_gpios;
 	}
+	tx28_set_mac(0, tx28_fec0_data.mac);
 	pr_debug("%s: Registering FEC0 device\n", __func__);
 	mx28_add_fec(0, &tx28_fec0_data);
 	return 0;
@@ -165,6 +203,7 @@ int __init tx28_add_fec1(void)
 				__func__, ret);
 		return ret;
 	}
+	tx28_set_mac(1, tx28_fec1_data.mac);
 	pr_debug("%s: Registering FEC1 device\n", __func__);
 	mx28_add_fec(1, &tx28_fec1_data);
 	return 0;
-- 
1.5.6.5

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

* [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses.
  2011-03-21 16:48 ` [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses Lothar Waßmann
@ 2011-03-22 14:14   ` Shawn Guo
  2011-03-22 14:35     ` Lothar Waßmann
  0 siblings, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2011-03-22 14:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 21, 2011 at 05:48:06PM +0100, Lothar Wa?mann wrote:
> Signed-off-by: Lothar Wa?mann <LW@KARO-electronics.de>
> ---
>  arch/arm/mach-mxs/module-tx28.c |   39 +++++++++++++++++++++++++++++++++++++++
>  1 files changed, 39 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-mxs/module-tx28.c b/arch/arm/mach-mxs/module-tx28.c
> index 7d44936..7a9e7b6 100644
> --- a/arch/arm/mach-mxs/module-tx28.c
> +++ b/arch/arm/mach-mxs/module-tx28.c
> @@ -74,6 +74,43 @@ static struct fec_platform_data tx28_fec1_data = {
>  	.phy = PHY_INTERFACE_MODE_RMII,
>  };
>  
> +#define HW_OCOTP_CUST0			0x20
> +#define HW_OCOTP_CUST(n)		(HW_OCOTP_CUST0 + (n) * 0x10)
> +#define HW_OCOTP_CTRL			0x00
> +#define HW_OCOTP_CTRL_SET		(HW_OCOTP_CTRL + 4)
> +#define HW_OCOTP_CTRL_CLR		(HW_OCOTP_CTRL + 8)
> +
> +#define BM_OCOTP_CTRL_BUSY		(1 << 8)
> +#define BM_OCOTP_CTRL_RD_BANK_OPEN	(1 << 12)
> +
> +static int __init tx28_set_mac(int id, unsigned char mac[])
> +{
> +	int i;
> +	void __iomem *ocotp_base = ioremap(MX28_OCOTP_BASE_ADDR, SZ_4K);
> +	u32 reg = 0;
> +	long timeout = 1000;
> +
> +	if (ocotp_base == NULL)
> +		return -ENOMEM;
> +
> +	/* set this bit to open the OTP banks for reading */
> +	writel(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base + HW_OCOTP_CTRL_SET);
> +
> +	while (readl(ocotp_base + HW_OCOTP_CTRL) & BM_OCOTP_CTRL_BUSY) {
> +		if (timeout-- < 0)
> +			return -ETIMEDOUT;
> +		udelay(100);
> +	}
> +
> +	for (i = 0; i < ETH_ALEN; i++) {
> +		if (i % 4 == 0)
> +			reg = readl(ocotp_base + HW_OCOTP_CUST(id * 2 + i / 4));
> +		mac[i] = reg >> (24 - ((i % 4) * 8));
> +	}
> +	iounmap(ocotp_base);
> +	return 0;
> +}
> +

Why don't you use mxs_get_ocotp() to read otp?

-- 
Regards,
Shawn

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

* [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses.
  2011-03-22 14:14   ` Shawn Guo
@ 2011-03-22 14:35     ` Lothar Waßmann
  0 siblings, 0 replies; 4+ messages in thread
From: Lothar Waßmann @ 2011-03-22 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

Shawn Guo writes:
> On Mon, Mar 21, 2011 at 05:48:06PM +0100, Lothar Wa?mann wrote:
> > Signed-off-by: Lothar Wa?mann <LW@KARO-electronics.de>
> > ---
> >  arch/arm/mach-mxs/module-tx28.c |   39 +++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 39 insertions(+), 0 deletions(-)
> > 
> > diff --git a/arch/arm/mach-mxs/module-tx28.c b/arch/arm/mach-mxs/module-tx28.c
> > index 7d44936..7a9e7b6 100644
> > --- a/arch/arm/mach-mxs/module-tx28.c
> > +++ b/arch/arm/mach-mxs/module-tx28.c
> > @@ -74,6 +74,43 @@ static struct fec_platform_data tx28_fec1_data = {
> >  	.phy = PHY_INTERFACE_MODE_RMII,
> >  };
> >  
> > +#define HW_OCOTP_CUST0			0x20
> > +#define HW_OCOTP_CUST(n)		(HW_OCOTP_CUST0 + (n) * 0x10)
> > +#define HW_OCOTP_CTRL			0x00
> > +#define HW_OCOTP_CTRL_SET		(HW_OCOTP_CTRL + 4)
> > +#define HW_OCOTP_CTRL_CLR		(HW_OCOTP_CTRL + 8)
> > +
> > +#define BM_OCOTP_CTRL_BUSY		(1 << 8)
> > +#define BM_OCOTP_CTRL_RD_BANK_OPEN	(1 << 12)
> > +
> > +static int __init tx28_set_mac(int id, unsigned char mac[])
> > +{
> > +	int i;
> > +	void __iomem *ocotp_base = ioremap(MX28_OCOTP_BASE_ADDR, SZ_4K);
> > +	u32 reg = 0;
> > +	long timeout = 1000;
> > +
> > +	if (ocotp_base == NULL)
> > +		return -ENOMEM;
> > +
> > +	/* set this bit to open the OTP banks for reading */
> > +	writel(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base + HW_OCOTP_CTRL_SET);
> > +
> > +	while (readl(ocotp_base + HW_OCOTP_CTRL) & BM_OCOTP_CTRL_BUSY) {
> > +		if (timeout-- < 0)
> > +			return -ETIMEDOUT;
> > +		udelay(100);
> > +	}
> > +
> > +	for (i = 0; i < ETH_ALEN; i++) {
> > +		if (i % 4 == 0)
> > +			reg = readl(ocotp_base + HW_OCOTP_CUST(id * 2 + i / 4));
> > +		mac[i] = reg >> (24 - ((i % 4) * 8));
> > +	}
> > +	iounmap(ocotp_base);
> > +	return 0;
> > +}
> > +
> 
> Why don't you use mxs_get_ocotp() to read otp?
> 
Good question... I'll change it.


Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________

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

end of thread, other threads:[~2011-03-22 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-21 16:48 [PATCH 1/2] ARM: mxs: configure and register the second FEC device on TX28/STK5-V4 Lothar Waßmann
2011-03-21 16:48 ` [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses Lothar Waßmann
2011-03-22 14:14   ` Shawn Guo
2011-03-22 14:35     ` Lothar Waßmann

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