Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163569
b: refs/heads/master
c: 4907d57
h: refs/heads/master
i:
  163567: c30b5bb
v: v3
  • Loading branch information
Kuninori Morimoto authored and Paul Mundt committed Sep 11, 2009
1 parent f9c90e7 commit 945c002
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: be4ebf999a38dfe9d7d705c4913624ec816c48f2
refs/heads/master: 4907d57f76dc1d6c49c19c653fb705b9a2a8487c
81 changes: 79 additions & 2 deletions trunk/arch/sh/boards/mach-ecovec24/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/usb/r8a66597.h>
#include <linux/i2c.h>
#include <video/sh_mobile_lcdc.h>
#include <media/sh_mobile_ceu.h>
#include <asm/heartbeat.h>
Expand Down Expand Up @@ -342,9 +343,77 @@ static struct platform_device *ecovec_devices[] __initdata = {
&ceu1_device,
};

#define EEPROM_ADDR 0x50
static u8 mac_read(struct i2c_adapter *a, u8 command)
{
struct i2c_msg msg[2];
u8 buf;
int ret;

msg[0].addr = EEPROM_ADDR;
msg[0].flags = 0;
msg[0].len = 1;
msg[0].buf = &command;

msg[1].addr = EEPROM_ADDR;
msg[1].flags = I2C_M_RD;
msg[1].len = 1;
msg[1].buf = &buf;

ret = i2c_transfer(a, msg, 2);
if (ret < 0) {
printk(KERN_ERR "error %d\n", ret);
buf = 0xff;
}

return buf;
}

#define MAC_LEN 6
static void __init sh_eth_init(void)
{
struct i2c_adapter *a = i2c_get_adapter(1);
struct clk *eth_clk;
u8 mac[MAC_LEN];
int i;

if (!a) {
pr_err("can not get I2C 1\n");
return;
}

eth_clk = clk_get(NULL, "eth0");
if (!eth_clk) {
pr_err("can not get eth0 clk\n");
return;
}

/* read MAC address frome EEPROM */
for (i = 0; i < MAC_LEN; i++) {
mac[i] = mac_read(a, 0x10 + i);
msleep(10);
}

/* clock enable */
clk_enable(eth_clk);

/* reset sh-eth */
ctrl_outl(0x1, SH_ETH_ADDR + 0x0);

/* set MAC addr */
ctrl_outl((mac[0] << 24) |
(mac[1] << 16) |
(mac[2] << 8) |
(mac[3] << 0), SH_ETH_MAHR);
ctrl_outl((mac[4] << 8) |
(mac[5] << 0), SH_ETH_MALR);

clk_put(eth_clk);
}

#define PORT_HIZA 0xA4050158
#define IODRIVEA 0xA405018A
static int __init devices_setup(void)
static int __init arch_setup(void)
{
/* enable SCIFA0 */
gpio_request(GPIO_FN_SCIF0_TXD, NULL);
Expand Down Expand Up @@ -521,7 +590,15 @@ static int __init devices_setup(void)
return platform_add_devices(ecovec_devices,
ARRAY_SIZE(ecovec_devices));
}
arch_initcall(devices_setup);
arch_initcall(arch_setup);

static int __init devices_setup(void)
{
sh_eth_init();
return 0;
}
device_initcall(devices_setup);


static struct sh_machine_vector mv_ecovec __initmv = {
.mv_name = "R0P7724 (EcoVec)",
Expand Down

0 comments on commit 945c002

Please sign in to comment.