@@ -22,6 +22,8 @@ struct tle9104_gpio_config {
2222 struct gpio_driver_config common ;
2323 /* parent MFD */
2424 const struct device * parent ;
25+ bool parallel_mode_out12 ;
26+ bool parallel_mode_out34 ;
2527};
2628
2729struct tle9104_gpio_data {
@@ -80,6 +82,16 @@ static int tle9104_gpio_pin_configure(const struct device *dev, gpio_pin_t pin,
8082 return - ENOTSUP ;
8183 }
8284
85+ if (config -> parallel_mode_out12 && pin == 1 ) {
86+ LOG_ERR ("cannot configure OUT2 if parallel mode is enabled for OUT1 and OUT2" );
87+ return - EINVAL ;
88+ }
89+
90+ if (config -> parallel_mode_out34 && pin == 3 ) {
91+ LOG_ERR ("cannot configure OUT4 if parallel mode is enabled for OUT3 and OUT4" );
92+ return - EINVAL ;
93+ }
94+
8395 k_mutex_lock (& data -> lock , K_FOREVER );
8496
8597 if ((flags & GPIO_OUTPUT_INIT_LOW ) != 0 ) {
@@ -110,6 +122,16 @@ static int tle9104_gpio_port_set_masked_raw(const struct device *dev, uint32_t m
110122 struct tle9104_gpio_data * data = dev -> data ;
111123 int result ;
112124
125+ if (config -> parallel_mode_out12 && (BIT (1 ) & mask ) != 0 ) {
126+ LOG_ERR ("cannot set OUT2 if parallel mode is enabled for OUT1 and OUT2" );
127+ return - EINVAL ;
128+ }
129+
130+ if (config -> parallel_mode_out34 && (BIT (3 ) & mask ) != 0 ) {
131+ LOG_ERR ("cannot set OUT4 if parallel mode is enabled for OUT3 and OUT4" );
132+ return - EINVAL ;
133+ }
134+
113135 /* cannot execute a bus operation in an ISR context */
114136 if (k_is_in_isr ()) {
115137 return - EWOULDBLOCK ;
@@ -139,6 +161,16 @@ static int tle9104_gpio_port_toggle_bits(const struct device *dev, uint32_t mask
139161 struct tle9104_gpio_data * data = dev -> data ;
140162 int result ;
141163
164+ if (config -> parallel_mode_out12 && (BIT (1 ) & mask ) != 0 ) {
165+ LOG_ERR ("cannot toggle OUT2 if parallel mode is enabled for OUT1 and OUT2" );
166+ return - EINVAL ;
167+ }
168+
169+ if (config -> parallel_mode_out34 && (BIT (3 ) & mask ) != 0 ) {
170+ LOG_ERR ("cannot toggle OUT4 if parallel mode is enabled for OUT3 and OUT4" );
171+ return - EINVAL ;
172+ }
173+
142174 /* cannot execute a bus operation in an ISR context */
143175 if (k_is_in_isr ()) {
144176 return - EWOULDBLOCK ;
@@ -176,6 +208,7 @@ static int tle9104_gpio_init(const struct device *dev)
176208{
177209 const struct tle9104_gpio_config * config = dev -> config ;
178210 struct tle9104_gpio_data * data = dev -> data ;
211+ int result ;
179212
180213 LOG_DBG ("initialize TLE9104 GPIO instance %s" , dev -> name );
181214
@@ -184,7 +217,7 @@ static int tle9104_gpio_init(const struct device *dev)
184217 return - EINVAL ;
185218 }
186219
187- int result = k_mutex_init (& data -> lock );
220+ result = k_mutex_init (& data -> lock );
188221 if (result != 0 ) {
189222 LOG_ERR ("unable to initialize mutex" );
190223 return result ;
@@ -199,6 +232,8 @@ static int tle9104_gpio_init(const struct device *dev)
199232 .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(inst), \
200233 }, \
201234 .parent = DEVICE_DT_GET(DT_PARENT(DT_DRV_INST(inst))), \
235+ .parallel_mode_out12 = DT_PROP(DT_PARENT(DT_DRV_INST(inst)), parallel_out12), \
236+ .parallel_mode_out34 = DT_PROP(DT_PARENT(DT_DRV_INST(inst)), parallel_out34), \
202237 }; \
203238 \
204239 static struct tle9104_gpio_data tle9104_gpio_##inst##_drvdata; \
0 commit comments