|
| 1 | +/* |
| 2 | + * Copyright 2025 NXP |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +#include <zephyr/device.h> |
| 7 | +#include <zephyr/drivers/gpio.h> |
| 8 | + |
| 9 | +#include <zephyr/logging/log.h> |
| 10 | +LOG_MODULE_REGISTER(lcd_par_s035); |
| 11 | + |
| 12 | +#define INT_GPIO_DT_SPEC GPIO_DT_SPEC_GET(DT_NODELABEL(gt911_lcd_par_s035), irq_gpios) |
| 13 | + |
| 14 | +static int lcd_par_s035_init(void) |
| 15 | +{ |
| 16 | + int ret; |
| 17 | + |
| 18 | +#ifdef CONFIG_INPUT_GT911 |
| 19 | + static const struct gpio_dt_spec int_gpio = INT_GPIO_DT_SPEC; |
| 20 | + |
| 21 | + if (!gpio_is_ready_dt(&int_gpio)) { |
| 22 | + LOG_ERR("GT911 INT_GPIO controller device not ready"); |
| 23 | + return -ENODEV; |
| 24 | + } |
| 25 | + |
| 26 | + /* |
| 27 | + * We need to configure the int-pin to 0, in order to enter the |
| 28 | + * AddressMode0. Keeping the INT pin low during the reset sequence |
| 29 | + * should result in the device selecting an I2C address of 0x5D. |
| 30 | + */ |
| 31 | + ret = gpio_pin_configure_dt(&int_gpio, GPIO_OUTPUT_INACTIVE); |
| 32 | + if (ret != 0) { |
| 33 | + LOG_ERR("Failed to configure GT911 INT_GPIO: %d", ret); |
| 34 | + return ret; |
| 35 | + } |
| 36 | +#endif /* CONFIG_INPUT_GT911 */ |
| 37 | + |
| 38 | +#ifdef CONFIG_MIPI_DBI |
| 39 | + ret = device_init(DEVICE_DT_GET(DT_ALIAS(mipi_dbi))); |
| 40 | + if (ret != 0) { |
| 41 | + LOG_ERR("Failed to init mipi_dbi: %d", ret); |
| 42 | + return ret; |
| 43 | + } |
| 44 | +#endif /* CONFIG_MIPI_DBI */ |
| 45 | + |
| 46 | +#ifdef CONFIG_DISPLAY |
| 47 | + ret = device_init(DEVICE_DT_GET(DT_NODELABEL(st7796s))); |
| 48 | + if (ret != 0) { |
| 49 | + LOG_ERR("Failed to init st7796s display driver: %d", ret); |
| 50 | + return ret; |
| 51 | + } |
| 52 | +#endif /* CONFIG_DISPLAY */ |
| 53 | + |
| 54 | +#ifdef CONFIG_INPUT_GT911 |
| 55 | + ret = device_init(DEVICE_DT_GET(DT_NODELABEL(gt911_lcd_par_s035))); |
| 56 | + if (ret != 0) { |
| 57 | + LOG_ERR("Failed to init gt911_lcd_par_s035 input driver: %d", ret); |
| 58 | + return ret; |
| 59 | + } |
| 60 | +#endif /* CONFIG_DISPLAY */ |
| 61 | + |
| 62 | + return 0; |
| 63 | +} |
| 64 | + |
| 65 | +SYS_INIT(lcd_par_s035_init, POST_KERNEL, CONFIG_SHIELD_LCD_PAR_S035_INIT_PRIORITY); |
0 commit comments