Commit a949b81b authored by Wesley W. Terpstra's avatar Wesley W. Terpstra

eb-w1: initialize onewire in case wrpc did not

This is useful for example when using a secondary onewire controller.
parent 592db092
......@@ -41,6 +41,7 @@ static int write_w1(int w1base, int w1len)
uint8_t buf[w1len];
int i;
wrpc_w1_init();
w1_scan_bus(&wrpc_w1_bus);
if (verbose) { /* code borrowed from dev/w1.c -- "w1" shell command */
......
......@@ -66,6 +66,17 @@ static void w1_write_bit(struct w1_bus *bus, int bit)
__wait_cycle(device);
}
#define WB_CLOCK 62500000
#define CLK_DIV_NOR (WB_CLOCK / 200000 - 1) /* normal mode */
#define CLK_DIV_OVD (WB_CLOCK / 1000000 - 1) /* overdrive mode (not used) */
void wrpc_w1_init(void)
{
eb_data_t data = ((CLK_DIV_NOR & SOCKIT_OWM_CDR_N_MSK) |
((CLK_DIV_OVD << SOCKIT_OWM_CDR_O_OFST) &
SOCKIT_OWM_CDR_O_MSK));
eb_device_write(device, BASE_ONEWIRE+4, EB_DATA32|EB_BIG_ENDIAN, data, 0, 0);
}
struct w1_ops wrpc_w1_ops = {
.reset = w1_reset,
.read_bit = w1_read_bit,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment