[PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses.

Shawn Guo shawn.guo at freescale.com
Tue Mar 22 10:14:47 EDT 2011


On Mon, Mar 21, 2011 at 05:48:06PM +0100, Lothar Waßmann wrote:
> Signed-off-by: Lothar Waßmann <LW at 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




More information about the linux-arm-kernel mailing list