drivers: fpga: add checks for optional properties of iCE40
Add checks in the GPIO bitbang mode to avoid a fault for missing configuration in the devicetree. Fixes #80850 Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
This commit is contained in:
parent
c6cc7a17e5
commit
035b139f64
1 changed files with 30 additions and 0 deletions
|
@ -207,6 +207,26 @@ static int fpga_ice40_load_gpio(const struct device *dev, uint32_t *image_ptr, u
|
||||||
struct fpga_ice40_data *data = dev->data;
|
struct fpga_ice40_data *data = dev->data;
|
||||||
const struct fpga_ice40_config *config = dev->config;
|
const struct fpga_ice40_config *config = dev->config;
|
||||||
|
|
||||||
|
if (!device_is_ready(config->clk.port)) {
|
||||||
|
LOG_ERR("%s: GPIO for clk is not ready", dev->name);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device_is_ready(config->pico.port)) {
|
||||||
|
LOG_ERR("%s: GPIO for pico is not ready", dev->name);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config->set == NULL) {
|
||||||
|
LOG_ERR("%s: set register was not specified", dev->name);
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config->clear == NULL) {
|
||||||
|
LOG_ERR("%s: clear register was not specified", dev->name);
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
/* prepare masks */
|
/* prepare masks */
|
||||||
cs = BIT(config->bus.config.cs.gpio.pin);
|
cs = BIT(config->bus.config.cs.gpio.pin);
|
||||||
clk = BIT(config->clk.pin);
|
clk = BIT(config->clk.pin);
|
||||||
|
@ -502,6 +522,16 @@ static int fpga_ice40_init(const struct device *dev)
|
||||||
int ret;
|
int ret;
|
||||||
const struct fpga_ice40_config *config = dev->config;
|
const struct fpga_ice40_config *config = dev->config;
|
||||||
|
|
||||||
|
if (!device_is_ready(config->creset.port)) {
|
||||||
|
LOG_ERR("%s: GPIO for creset is not ready", dev->name);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device_is_ready(config->cdone.port)) {
|
||||||
|
LOG_ERR("%s: GPIO for cdone is not ready", dev->name);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
ret = gpio_pin_configure_dt(&config->creset, GPIO_OUTPUT_HIGH);
|
ret = gpio_pin_configure_dt(&config->creset, GPIO_OUTPUT_HIGH);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LOG_ERR("failed to configure CRESET: %d", ret);
|
LOG_ERR("failed to configure CRESET: %d", ret);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue