aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh
diff options
context:
space:
mode:
authorKuninori Morimoto <morimoto.kuninori@renesas.com>2009-09-09 21:39:58 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-09-11 00:19:18 -0400
commit4907d57f76dc1d6c49c19c653fb705b9a2a8487c (patch)
treeff81abc32feb86dfd1c2fd4e392aebba23af66c7 /arch/sh
parentbe4ebf999a38dfe9d7d705c4913624ec816c48f2 (diff)
sh: EcoVec24: write MAC address in boot
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c81
1 files changed, 79 insertions, 2 deletions
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index b44c06058e34..6cd1b782845f 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -17,6 +17,7 @@
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/usb/r8a66597.h> 19#include <linux/usb/r8a66597.h>
20#include <linux/i2c.h>
20#include <video/sh_mobile_lcdc.h> 21#include <video/sh_mobile_lcdc.h>
21#include <media/sh_mobile_ceu.h> 22#include <media/sh_mobile_ceu.h>
22#include <asm/heartbeat.h> 23#include <asm/heartbeat.h>
@@ -342,9 +343,77 @@ static struct platform_device *ecovec_devices[] __initdata = {
342 &ceu1_device, 343 &ceu1_device,
343}; 344};
344 345
346#define EEPROM_ADDR 0x50
347static u8 mac_read(struct i2c_adapter *a, u8 command)
348{
349 struct i2c_msg msg[2];
350 u8 buf;
351 int ret;
352
353 msg[0].addr = EEPROM_ADDR;
354 msg[0].flags = 0;
355 msg[0].len = 1;
356 msg[0].buf = &command;
357
358 msg[1].addr = EEPROM_ADDR;
359 msg[1].flags = I2C_M_RD;
360 msg[1].len = 1;
361 msg[1].buf = &buf;
362
363 ret = i2c_transfer(a, msg, 2);
364 if (ret < 0) {
365 printk(KERN_ERR "error %d\n", ret);
366 buf = 0xff;
367 }
368
369 return buf;
370}
371
372#define MAC_LEN 6
373static void __init sh_eth_init(void)
374{
375 struct i2c_adapter *a = i2c_get_adapter(1);
376 struct clk *eth_clk;
377 u8 mac[MAC_LEN];
378 int i;
379
380 if (!a) {
381 pr_err("can not get I2C 1\n");
382 return;
383 }
384
385 eth_clk = clk_get(NULL, "eth0");
386 if (!eth_clk) {
387 pr_err("can not get eth0 clk\n");
388 return;
389 }
390
391 /* read MAC address frome EEPROM */
392 for (i = 0; i < MAC_LEN; i++) {
393 mac[i] = mac_read(a, 0x10 + i);
394 msleep(10);
395 }
396
397 /* clock enable */
398 clk_enable(eth_clk);
399
400 /* reset sh-eth */
401 ctrl_outl(0x1, SH_ETH_ADDR + 0x0);
402
403 /* set MAC addr */
404 ctrl_outl((mac[0] << 24) |
405 (mac[1] << 16) |
406 (mac[2] << 8) |
407 (mac[3] << 0), SH_ETH_MAHR);
408 ctrl_outl((mac[4] << 8) |
409 (mac[5] << 0), SH_ETH_MALR);
410
411 clk_put(eth_clk);
412}
413
345#define PORT_HIZA 0xA4050158 414#define PORT_HIZA 0xA4050158
346#define IODRIVEA 0xA405018A 415#define IODRIVEA 0xA405018A
347static int __init devices_setup(void) 416static int __init arch_setup(void)
348{ 417{
349 /* enable SCIFA0 */ 418 /* enable SCIFA0 */
350 gpio_request(GPIO_FN_SCIF0_TXD, NULL); 419 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
@@ -521,7 +590,15 @@ static int __init devices_setup(void)
521 return platform_add_devices(ecovec_devices, 590 return platform_add_devices(ecovec_devices,
522 ARRAY_SIZE(ecovec_devices)); 591 ARRAY_SIZE(ecovec_devices));
523} 592}
524arch_initcall(devices_setup); 593arch_initcall(arch_setup);
594
595static int __init devices_setup(void)
596{
597 sh_eth_init();
598 return 0;
599}
600device_initcall(devices_setup);
601
525 602
526static struct sh_machine_vector mv_ecovec __initmv = { 603static struct sh_machine_vector mv_ecovec __initmv = {
527 .mv_name = "R0P7724 (EcoVec)", 604 .mv_name = "R0P7724 (EcoVec)",