Lines Matching refs:pin

34 void mt_set_gpio_dir_chip(uint32_t pin, int dir)  in mt_set_gpio_dir_chip()  argument
38 assert(pin < MAX_GPIO_PIN); in mt_set_gpio_dir_chip()
41 pos = pin / MAX_GPIO_REG_BITS; in mt_set_gpio_dir_chip()
42 bit = pin % MAX_GPIO_REG_BITS; in mt_set_gpio_dir_chip()
50 int mt_get_gpio_dir_chip(uint32_t pin) in mt_get_gpio_dir_chip() argument
55 assert(pin < MAX_GPIO_PIN); in mt_get_gpio_dir_chip()
57 pos = pin / MAX_GPIO_REG_BITS; in mt_get_gpio_dir_chip()
58 bit = pin % MAX_GPIO_REG_BITS; in mt_get_gpio_dir_chip()
64 void mt_set_gpio_out_chip(uint32_t pin, int output) in mt_set_gpio_out_chip() argument
68 assert(pin < MAX_GPIO_PIN); in mt_set_gpio_out_chip()
71 pos = pin / MAX_GPIO_REG_BITS; in mt_set_gpio_out_chip()
72 bit = pin % MAX_GPIO_REG_BITS; in mt_set_gpio_out_chip()
80 int mt_get_gpio_out_chip(uint32_t pin) in mt_get_gpio_out_chip() argument
85 assert(pin < MAX_GPIO_PIN); in mt_get_gpio_out_chip()
87 pos = pin / MAX_GPIO_REG_BITS; in mt_get_gpio_out_chip()
88 bit = pin % MAX_GPIO_REG_BITS; in mt_get_gpio_out_chip()
94 int mt_get_gpio_in_chip(uint32_t pin) in mt_get_gpio_in_chip() argument
99 assert(pin < MAX_GPIO_PIN); in mt_get_gpio_in_chip()
101 pos = pin / MAX_GPIO_REG_BITS; in mt_get_gpio_in_chip()
102 bit = pin % MAX_GPIO_REG_BITS; in mt_get_gpio_in_chip()
108 void mt_set_gpio_mode_chip(uint32_t pin, int mode) in mt_set_gpio_mode_chip() argument
114 assert(pin < MAX_GPIO_PIN); in mt_set_gpio_mode_chip()
120 pos = pin / MAX_GPIO_MODE_PER_REG; in mt_set_gpio_mode_chip()
121 bit = (pin % MAX_GPIO_MODE_PER_REG) * GPIO_MODE_BITS; in mt_set_gpio_mode_chip()
129 int mt_get_gpio_mode_chip(uint32_t pin) in mt_get_gpio_mode_chip() argument
135 assert(pin < MAX_GPIO_PIN); in mt_get_gpio_mode_chip()
139 pos = pin / MAX_GPIO_MODE_PER_REG; in mt_get_gpio_mode_chip()
140 bit = (pin % MAX_GPIO_MODE_PER_REG) * GPIO_MODE_BITS; in mt_get_gpio_mode_chip()
146 int32_t gpio_get_pull_iocfg(uint32_t pin) in gpio_get_pull_iocfg() argument
148 switch (pin) { in gpio_get_pull_iocfg()
180 int32_t gpio_get_pupd_iocfg(uint32_t pin) in gpio_get_pupd_iocfg() argument
184 switch (pin) { in gpio_get_pupd_iocfg()
198 int gpio_get_pupd_offset(uint32_t pin) in gpio_get_pupd_offset() argument
200 switch (pin) { in gpio_get_pupd_offset()
202 return (pin - 29) * 4 % 32; in gpio_get_pupd_offset()
204 return (pin - 35) * 4 % 32; in gpio_get_pupd_offset()
206 return (pin - 91) * 4 % 32; in gpio_get_pupd_offset()
208 return (pin - 122) * 4 % 32; in gpio_get_pupd_offset()
210 return (pin - 130) * 4 % 32; in gpio_get_pupd_offset()
216 void mt_set_gpio_pull_enable_chip(uint32_t pin, int en) in mt_set_gpio_pull_enable_chip() argument
218 int pullen_addr = gpio_get_pull_iocfg(pin) + PULLEN_ADDR_OFFSET; in mt_set_gpio_pull_enable_chip()
219 int pupd_addr = gpio_get_pupd_iocfg(pin); in mt_set_gpio_pull_enable_chip()
220 int pupd_offset = gpio_get_pupd_offset(pin); in mt_set_gpio_pull_enable_chip()
222 assert(pin < MAX_GPIO_PIN); in mt_set_gpio_pull_enable_chip()
224 assert(!((PULL_offset[pin].offset == (int8_t)-1) && in mt_set_gpio_pull_enable_chip()
228 if (PULL_offset[pin].offset == (int8_t)-1) in mt_set_gpio_pull_enable_chip()
232 1U << PULL_offset[pin].offset); in mt_set_gpio_pull_enable_chip()
234 if (PULL_offset[pin].offset == (int8_t)-1) { in mt_set_gpio_pull_enable_chip()
246 1U << PULL_offset[pin].offset); in mt_set_gpio_pull_enable_chip()
263 int mt_get_gpio_pull_enable_chip(uint32_t pin) in mt_get_gpio_pull_enable_chip() argument
267 int pullen_addr = gpio_get_pull_iocfg(pin) + PULLEN_ADDR_OFFSET; in mt_get_gpio_pull_enable_chip()
268 int pupd_addr = gpio_get_pupd_iocfg(pin); in mt_get_gpio_pull_enable_chip()
269 int pupd_offset = gpio_get_pupd_offset(pin); in mt_get_gpio_pull_enable_chip()
271 assert(pin < MAX_GPIO_PIN); in mt_get_gpio_pull_enable_chip()
273 assert(!((PULL_offset[pin].offset == (int8_t)-1) && in mt_get_gpio_pull_enable_chip()
276 if (PULL_offset[pin].offset == (int8_t)-1) { in mt_get_gpio_pull_enable_chip()
281 return ((reg & (1U << PULL_offset[pin].offset)) ? 1 : 0); in mt_get_gpio_pull_enable_chip()
287 void mt_set_gpio_pull_select_chip(uint32_t pin, int sel) in mt_set_gpio_pull_select_chip() argument
289 int pullsel_addr = gpio_get_pull_iocfg(pin) + PULLSEL_ADDR_OFFSET; in mt_set_gpio_pull_select_chip()
290 int pupd_addr = gpio_get_pupd_iocfg(pin); in mt_set_gpio_pull_select_chip()
291 int pupd_offset = gpio_get_pupd_offset(pin); in mt_set_gpio_pull_select_chip()
293 assert(pin < MAX_GPIO_PIN); in mt_set_gpio_pull_select_chip()
295 assert(!((PULL_offset[pin].offset == (int8_t) -1) && in mt_set_gpio_pull_select_chip()
300 mt_set_gpio_pull_enable_chip(pin, GPIO_PULL_DISABLE); in mt_set_gpio_pull_select_chip()
301 if (PULL_offset[pin].offset == (int8_t)-1) in mt_set_gpio_pull_select_chip()
305 1U << PULL_offset[pin].offset); in mt_set_gpio_pull_select_chip()
307 mt_set_gpio_pull_enable_chip(pin, GPIO_PULL_ENABLE); in mt_set_gpio_pull_select_chip()
308 if (PULL_offset[pin].offset == (int8_t)-1) in mt_set_gpio_pull_select_chip()
312 1U << PULL_offset[pin].offset); in mt_set_gpio_pull_select_chip()
314 mt_set_gpio_pull_enable_chip(pin, GPIO_PULL_ENABLE); in mt_set_gpio_pull_select_chip()
315 if (PULL_offset[pin].offset == -1) in mt_set_gpio_pull_select_chip()
319 1U << PULL_offset[pin].offset); in mt_set_gpio_pull_select_chip()
324 int mt_get_gpio_pull_select_chip(uint32_t pin) in mt_get_gpio_pull_select_chip() argument
328 int pullen_addr = gpio_get_pull_iocfg(pin) + PULLEN_ADDR_OFFSET; in mt_get_gpio_pull_select_chip()
329 int pullsel_addr = gpio_get_pull_iocfg(pin) + PULLSEL_ADDR_OFFSET; in mt_get_gpio_pull_select_chip()
330 int pupd_addr = gpio_get_pupd_iocfg(pin); in mt_get_gpio_pull_select_chip()
331 int pupd_offset = gpio_get_pupd_offset(pin); in mt_get_gpio_pull_select_chip()
333 assert(pin < MAX_GPIO_PIN); in mt_get_gpio_pull_select_chip()
335 assert(!((PULL_offset[pin].offset == (int8_t)-1) && in mt_get_gpio_pull_select_chip()
338 if (PULL_offset[pin].offset == (int8_t)-1) { in mt_get_gpio_pull_select_chip()
351 if ((reg & (1U << PULL_offset[pin].offset))) { in mt_get_gpio_pull_select_chip()
353 return ((reg & (1U << PULL_offset[pin].offset)) ? in mt_get_gpio_pull_select_chip()
370 uint32_t pin; in mt_get_gpio_dir() local
372 pin = (uint32_t)gpio; in mt_get_gpio_dir()
373 return mt_get_gpio_dir_chip(pin); in mt_get_gpio_dir()
378 uint32_t pin; in mt_set_gpio_pull() local
380 pin = (uint32_t)gpio; in mt_set_gpio_pull()
381 mt_set_gpio_pull_select_chip(pin, pull); in mt_set_gpio_pull()
386 uint32_t pin; in mt_get_gpio_pull() local
388 pin = (uint32_t)gpio; in mt_get_gpio_pull()
389 return mt_get_gpio_pull_select_chip(pin); in mt_get_gpio_pull()
394 uint32_t pin; in mt_set_gpio_out() local
396 pin = (uint32_t)gpio; in mt_set_gpio_out()
397 mt_set_gpio_out_chip(pin, value); in mt_set_gpio_out()
402 uint32_t pin; in mt_get_gpio_out() local
404 pin = (uint32_t)gpio; in mt_get_gpio_out()
405 return mt_get_gpio_out_chip(pin); in mt_get_gpio_out()
410 uint32_t pin; in mt_get_gpio_in() local
412 pin = (uint32_t)gpio; in mt_get_gpio_in()
413 return mt_get_gpio_in_chip(pin); in mt_get_gpio_in()
418 uint32_t pin; in mt_set_gpio_mode() local
420 pin = (uint32_t)gpio; in mt_set_gpio_mode()
421 mt_set_gpio_mode_chip(pin, mode); in mt_set_gpio_mode()
426 uint32_t pin; in mt_get_gpio_mode() local
428 pin = (uint32_t)gpio; in mt_get_gpio_mode()
429 return mt_get_gpio_mode_chip(pin); in mt_get_gpio_mode()