diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d58b664..f460a7a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -108,9 +108,20 @@ struct property *reg; device_node_for_nach_child(node, n) { - chip.name = n->name; + memset(&chip, 0, sizeof(chip)); + chip.name = xstrdup(n->name); chip.bus_num = master->bus_num; - chip.max_speed_hz = 300000; /* FIXME */ + /* Mode (clock phase/polarity/etc.) */ + if (of_find_property(n, "spi-cpha")) + chip.mode |= SPI_CPHA; + if (of_find_property(n, "spi-cpol")) + chip.mode |= SPI_CPOL; + if (of_find_property(n, "spi-cs-high")) + chip.mode |= SPI_CS_HIGH; + if (of_find_property(n, "spi-3wire")) + chip.mode |= SPI_3WIRE; + of_property_read_u32(n, "spi-max-frequency", + &chip.max_speed_hz); reg = of_find_property(n, "reg"); if (!reg) continue;