Hi, On my board we use pins of uart0 for the spi interface ( all others pins are used ) .
To do so, we deactivate the max310x by default, but when the linux boot, it has to move a gpio to enable the device. I modified the spi driver to detect the parameter : enable-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>; also we used the max310x with an external clock, so we don't need a clock node. To do so, I modified the driver max310x to detect the parameter: clock-frequency = <1843200>; . And it works well ! the patch : >From 50358ac2b1daad3850e57caca85390dc39186da5 Mon Sep 17 00:00:00 2001 From: michael musset <[email protected]> Date: Wed, 9 Mar 2016 09:15:10 +0100 Subject: [PATCH] my patch Signed-off-by: michael musset <[email protected]> --- drivers/spi/spi.c | 26 +++++++++++- drivers/tty/serial/max310x.c | 58 ++++++++++++++------------ diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d35c1a1..91ebfc0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1520,7 +1520,9 @@ int spi_register_master(struct spi_master *master) struct boardinfo *bi; int status = -ENODEV; int dynamic = 0; - + int enable_gpio=0; + int ret=0; + enum of_gpio_flags flags; if (!dev) return -ENODEV; @@ -1576,6 +1578,28 @@ int spi_register_master(struct spi_master *master) } } + /* activate child device before talking to them*/ + enable_gpio = of_get_named_gpio_flags( master->dev.of_node, "enable-gpio", 0, &flags); + if (gpio_is_valid(enable_gpio)) { + printk("spi found reset gpio, request gpio %d\n", enable_gpio); + + ret = gpio_request( enable_gpio, "spi-gpio-reset"); + if (ret != 0){ + dev_warn(dev,"spi reset gpio : failed to request gpio\n"); + return ret; + } + ret = gpio_direction_output(enable_gpio, 0); + if (ret != 0){ + dev_warn(dev,"spi reset gpio : failed to put direction\n"); + return ret; + } + dev_warn(dev,"spi reset gpio : set gpio to 1"); + gpio_set_value(enable_gpio, 1); + mdelay(1000); + }else{ + dev_warn(dev,"no reset gpio\n"); + } + mutex_lock(&board_lock); list_add_tail(&master->list, &spi_master_list); list_for_each_entry(bi, &board_list, list) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 182549f..3542ca4 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1081,7 +1081,7 @@ static int max310x_gpio_direction_output(struct gpio_chip *chip, static int max310x_probe(struct device *dev, struct max310x_devtype *devtype, struct regmap *regmap, int irq, unsigned long flags) { - int i, ret, fmin, fmax, freq, uartclk; + int i, ret, fmin, fmax, freq=0, uartclk; struct clk *clk_osc, *clk_xtal; struct max310x_port *s; bool xtal = false; @@ -1096,31 +1096,39 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype, dev_err(dev, "Error allocating port structure\n"); return -ENOMEM; } - - clk_osc = devm_clk_get(dev, "osc"); - clk_xtal = devm_clk_get(dev, "xtal"); - if (!IS_ERR(clk_osc)) { - s->clk = clk_osc; - fmin = 500000; - fmax = 35000000; - } else if (!IS_ERR(clk_xtal)) { - s->clk = clk_xtal; - fmin = 1000000; - fmax = 4000000; - xtal = true; - } else if (PTR_ERR(clk_osc) == -EPROBE_DEFER || - PTR_ERR(clk_xtal) == -EPROBE_DEFER) { - return -EPROBE_DEFER; - } else { - dev_err(dev, "Cannot get clock\n"); - return -EINVAL; + if (of_find_property(dev->of_node, "clock-frequency", NULL)){ + of_property_read_u32(dev->of_node, "clock-frequency", &freq); + printk("clock frequency detected %d\n", freq); + } + if(freq!=0){ + fmin = 1000000; + fmax = 4000000; + xtal = 0; + }else{ + clk_osc = devm_clk_get(dev, "osc"); + clk_xtal = devm_clk_get(dev, "xtal"); + if (!IS_ERR(clk_osc)) { + s->clk = clk_osc; + fmin = 500000; + fmax = 35000000; + } else if (!IS_ERR(clk_xtal)) { + s->clk = clk_xtal; + fmin = 1000000; + fmax = 4000000; + xtal = true; + } else if (PTR_ERR(clk_osc) == -EPROBE_DEFER || + PTR_ERR(clk_xtal) == -EPROBE_DEFER) { + return -EPROBE_DEFER; + } else { + dev_err(dev, "Cannot get clock\n"); + return -EINVAL; + } + ret = clk_prepare_enable(s->clk); + if (ret) + return ret; + freq = clk_get_rate(s->clk); } - ret = clk_prepare_enable(s->clk); - if (ret) - return ret; - - freq = clk_get_rate(s->clk); /* Check frequency limits */ if (freq < fmin || freq > fmax) { ret = -ERANGE; @@ -1167,7 +1175,7 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype, s->uart.nr = devtype->nr; ret = uart_register_driver(&s->uart); if (ret) { - dev_err(dev, "Registering UART driver failed\n"); + dev_err(dev, "Registering UART driver failed %d\n", ret); goto out_clk; } -- 1.9.1 -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
