diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-09 08:30:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-09 08:30:24 +0100 |
commit | ac81a0d8768d75484212b208b6c42f6d11241c16 (patch) | |
tree | de3cf7aef1dd7892eb17c4a2e998a48b1be39df2 /drivers | |
parent | c3efa8470b3addb3cfbcfbf2a2be1ed799489623 (diff) | |
parent | 7033089ddf4c62fa2cfd4549d2bbfe0c101c65d1 (diff) | |
download | barebox-ac81a0d8768d75484212b208b6c42f6d11241c16.tar.gz barebox-ac81a0d8768d75484212b208b6c42f6d11241c16.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/clk/clk.c | 17 | ||||
-rw-r--r-- | drivers/firmware/altera_serial.c | 59 | ||||
-rw-r--r-- | drivers/led/led-gpio.c | 8 | ||||
-rw-r--r-- | drivers/net/designware.c | 3 |
4 files changed, 72 insertions, 15 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 584e2f3242..1f11bb3686 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -44,6 +44,9 @@ int clk_enable(struct clk *clk) { int ret; + if (!clk) + return 0; + if (IS_ERR(clk)) return PTR_ERR(clk); @@ -68,6 +71,9 @@ int clk_enable(struct clk *clk) void clk_disable(struct clk *clk) { + if (!clk) + return; + if (IS_ERR(clk)) return; @@ -89,10 +95,15 @@ unsigned long clk_get_rate(struct clk *clk) struct clk *parent; unsigned long parent_rate = 0; + if (!clk) + return 0; + if (IS_ERR(clk)) return 0; parent = clk_get_parent(clk); + + if (!IS_ERR_OR_NULL(parent)) parent_rate = clk_get_rate(parent); @@ -107,6 +118,9 @@ long clk_round_rate(struct clk *clk, unsigned long rate) unsigned long parent_rate = 0; struct clk *parent; + if (!clk) + return 0; + if (IS_ERR(clk)) return 0; @@ -125,6 +139,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate) struct clk *parent; unsigned long parent_rate = 0; + if (!clk) + return 0; + if (IS_ERR(clk)) return PTR_ERR(clk); diff --git a/drivers/firmware/altera_serial.c b/drivers/firmware/altera_serial.c index c5ffbb6393..4527d27c5c 100644 --- a/drivers/firmware/altera_serial.c +++ b/drivers/firmware/altera_serial.c @@ -25,6 +25,7 @@ #include <fcntl.h> #include <fs.h> + /* * Physical requirements: * - three free GPIOs for the signals nCONFIG, CONFIGURE_DONE, nSTATUS @@ -67,13 +68,19 @@ static int altera_spi_open(struct firmware_handler *fh) * after about 2 µs the FPGA must acknowledge with * STATUS and CONFIG DONE lines at low level */ - ret = wait_on_timeout(2 * USECOND, + if (gpio_is_valid(this->nstat_gpio)) { + ret = wait_on_timeout(2 * USECOND, (gpio_get_value(this->nstat_gpio) == 0) && (gpio_get_value(this->confd_gpio) == 0)); + } else { + ret = wait_on_timeout(2 * USECOND, + (gpio_get_value(this->confd_gpio) == 0)); + } + if (ret != 0) { dev_err(dev, "FPGA does not acknowledge the programming initiation\n"); - if (gpio_get_value(this->nstat_gpio)) + if (gpio_is_valid(this->nstat_gpio) && gpio_get_value(this->nstat_gpio)) dev_err(dev, "STATUS is still high!\n"); if (gpio_get_value(this->confd_gpio)) dev_err(dev, "CONFIG DONE is still high!\n"); @@ -90,11 +97,16 @@ static int altera_spi_open(struct firmware_handler *fh) * after about 1506 µs the FPGA must acknowledge this step * with the STATUS line at high level */ - ret = wait_on_timeout(1600 * USECOND, + + if (gpio_is_valid(this->nstat_gpio)) { + ret = wait_on_timeout(1600 * USECOND, gpio_get_value(this->nstat_gpio) == 1); - if (ret != 0) { - dev_err(dev, "FPGA does not acknowledge the programming start\n"); - return ret; + if (ret != 0) { + dev_err(dev, "FPGA does not acknowledge the programming start\n"); + return ret; + } + } else { + udelay(1600); } dev_dbg(dev, "Initiating passed\n"); @@ -177,16 +189,24 @@ static int altera_spi_close(struct firmware_handler *fh) * when programming was successful, * both status lines should be at high level */ - ret = wait_on_timeout(10 * USECOND, + if (gpio_is_valid(this->nstat_gpio)) { + ret = wait_on_timeout(10 * USECOND, (gpio_get_value(this->nstat_gpio) == 1) && (gpio_get_value(this->confd_gpio) == 1)); + } else { + ret = wait_on_timeout(10 * USECOND, + (gpio_get_value(this->confd_gpio) == 1)); + + } + if (ret == 0) { dev_dbg(dev, "Programming successful\n"); return ret; } dev_err(dev, "Programming failed due to time out\n"); - if (gpio_get_value(this->nstat_gpio) == 0) + if (gpio_is_valid(this->nstat_gpio) && + gpio_get_value(this->nstat_gpio) == 0) dev_err(dev, "STATUS is still low!\n"); if (gpio_get_value(this->confd_gpio) == 0) dev_err(dev, "CONFIG DONE is still low!\n"); @@ -201,10 +221,15 @@ static int altera_spi_of(struct device_d *dev, struct fpga_spi *this) int ret; name = "nstat-gpio"; - this->nstat_gpio = of_get_named_gpio(n, name, 0); - if (this->nstat_gpio < 0) { - ret = this->nstat_gpio; - goto out; + if (!of_get_property(n, name, NULL)) { + dev_info(dev, "nstat-gpio is not specified, assuming it is not connected\n"); + this->nstat_gpio = -1; + } else { + this->nstat_gpio = of_get_named_gpio(n, name, 0); + if (this->nstat_gpio < 0) { + ret = this->nstat_gpio; + goto out; + } } name = "confd-gpio"; @@ -225,9 +250,13 @@ static int altera_spi_of(struct device_d *dev, struct fpga_spi *this) ret = gpio_direction_output(this->nconfig_gpio, 1); if (ret) return ret; - ret = gpio_direction_input(this->nstat_gpio); - if (ret) - return ret; + + if (gpio_is_valid(this->nstat_gpio)) { + ret = gpio_direction_input(this->nstat_gpio); + if (ret) + return ret; + } + ret = gpio_direction_input(this->confd_gpio); if (ret) return ret; diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c index a1a661724d..ae3f13f45b 100644 --- a/drivers/led/led-gpio.c +++ b/drivers/led/led-gpio.c @@ -204,6 +204,7 @@ static int led_gpio_of_probe(struct device_d *dev) for_each_child_of_node(dev->device_node, child) { struct gpio_led *gled; + const char *default_state; enum of_gpio_flags flags; int gpio; const char *label; @@ -225,6 +226,13 @@ static int led_gpio_of_probe(struct device_d *dev) led_gpio_register(gled); led_of_parse_trigger(&gled->led, child); + + if (!of_property_read_string(child, "default-state", &default_state)) { + if (!strcmp(default_state, "on")) + led_gpio_set(&gled->led, 1); + else if (!strcmp(default_state, "off")) + led_gpio_set(&gled->led, 0); + } } return 0; diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 49ed0b1922..29a6047c7f 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -406,6 +406,9 @@ static void dwc_version(struct device_d *dev, u32 hwid) static int dwc_probe_dt(struct device_d *dev, struct dw_eth_dev *priv) { + if (!IS_ENABLED(CONFIG_OFTREE)) + return -ENODEV; + priv->phy_addr = -1; priv->interface = of_get_phy_mode(dev->device_node); |