|
| 1 | +/* |
| 2 | + * Copyright 2024-2025 NXP |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#ifndef ZEPHYR_SOC_ARM_NXP_IMX_RT7XX_PINCTRL_SOC_H_ |
| 8 | +#define ZEPHYR_SOC_ARM_NXP_IMX_RT7XX_PINCTRL_SOC_H_ |
| 9 | + |
| 10 | +#include <zephyr/devicetree.h> |
| 11 | +#include <zephyr/types.h> |
| 12 | + |
| 13 | +#ifdef __cplusplus |
| 14 | +extern "C" { |
| 15 | +#endif |
| 16 | + |
| 17 | +/** @cond INTERNAL_HIDDEN */ |
| 18 | + |
| 19 | +typedef uint32_t pinctrl_soc_pin_t; |
| 20 | + |
| 21 | +#define IOPCTL_PIO_PUPDENA_MASK (0x10U) |
| 22 | +#define IOPCTL_PIO_PUPDSEL_MASK (0x20U) |
| 23 | + |
| 24 | +#define IOPCTL_PIO_ODENA_MASK (0x400U) |
| 25 | +#define IOPCTL_PIO_ODENA_SHIFT (10U) |
| 26 | +#define IOPCTL_PIO_ODENA(x) \ |
| 27 | + (((uint32_t)(((uint32_t)(x)) << IOPCTL_PIO_ODENA_SHIFT)) & IOPCTL_PIO_ODENA_MASK) |
| 28 | + |
| 29 | +#define IOPCTL_PIO_IBENA_MASK (0x40U) |
| 30 | +#define IOPCTL_PIO_IBENA_SHIFT (6U) |
| 31 | +#define IOPCTL_PIO_IBENA(x) \ |
| 32 | + (((uint32_t)(((uint32_t)(x)) << IOPCTL_PIO_IBENA_SHIFT)) & IOPCTL_PIO_IBENA_MASK) |
| 33 | + |
| 34 | +/* Please note there is no SLEWRATE attribution on IOPCTL2 */ |
| 35 | +#define IOPCTL_PIO_SLEWRATE_MASK (0x80U) |
| 36 | +#define IOPCTL_PIO_SLEWRATE_SHIFT (7U) |
| 37 | +#define IOPCTL_PIO_SLEWRATE(x) \ |
| 38 | + (((uint32_t)(((uint32_t)(x)) << IOPCTL_PIO_SLEWRATE_SHIFT)) & IOPCTL_PIO_SLEWRATE_MASK) |
| 39 | + |
| 40 | +/* Please note there is no FULLDRIVE attribution on IOPCTL2 */ |
| 41 | +#define IOPCTL_PIO_FULLDRIVE_MASK (0x100U) |
| 42 | +#define IOPCTL_PIO_FULLDRIVE_SHIFT (8U) |
| 43 | +#define IOPCTL_PIO_FULLDRIVE(x) \ |
| 44 | + (((uint32_t)(((uint32_t)(x)) << IOPCTL_PIO_FULLDRIVE_SHIFT)) & IOPCTL_PIO_FULLDRIVE_MASK) |
| 45 | + |
| 46 | +#define IOPCTL_PIO_IIENA_MASK (0x800U) |
| 47 | +#define IOPCTL_PIO_IIENA_SHIFT (11U) |
| 48 | +#define IOPCTL_PIO_IIENA(x) \ |
| 49 | + (((uint32_t)(((uint32_t)(x)) << IOPCTL_PIO_IIENA_SHIFT)) & IOPCTL1_PIO_IIENA_MASK) |
| 50 | + |
| 51 | +/* Please note there is no AMENA attribution on IOPCTL2 */ |
| 52 | +#define IOPCTL_PIO_AMENA_MASK (0x200U) |
| 53 | +#define IOPCTL_PIO_AMENA_SHIFT (9U) |
| 54 | +#define IOPCTL_PIO_AMENA(x) \ |
| 55 | + (((uint32_t)(((uint32_t)(x)) << IOPCTL_PIO_AMENA_SHIFT)) & IOPCTL_PIO_AMENA_MASK) |
| 56 | + |
| 57 | +#define Z_PINCTRL_IOPCTL_PINCFG(node_id) \ |
| 58 | + (IF_ENABLED(DT_PROP(node_id, bias_pull_down), \ |
| 59 | + (IOPCTL_PIO_PUPDENA_MASK |)) /* pull down */ \ |
| 60 | + IF_ENABLED(DT_PROP(node_id, bias_pull_up), \ |
| 61 | + (IOPCTL_PIO_PUPDENA_MASK | IOPCTL_PIO_PUPDSEL_MASK |)) /* pull up */ \ |
| 62 | + IOPCTL_PIO_ODENA(DT_PROP(node_id, drive_open_drain)) | /* open drain */ \ |
| 63 | + IOPCTL_PIO_IBENA(DT_PROP(node_id, input_enable)) | /* input buffer */ \ |
| 64 | + IOPCTL_PIO_SLEWRATE(DT_ENUM_IDX(node_id, slew_rate)) | /* slew rate */ \ |
| 65 | + IOPCTL_PIO_FULLDRIVE( \ |
| 66 | + DT_ENUM_IDX(node_id, drive_strength)) | /* drive strength */ \ |
| 67 | + IOPCTL_PIO_IIENA(DT_PROP(node_id, nxp_invert)) | /* invert input */ \ |
| 68 | + IOPCTL_PIO_AMENA( \ |
| 69 | + DT_PROP(node_id, nxp_analog_mode))) /* analog multiplexor */ |
| 70 | + |
| 71 | +/* MCUX RT parts only have one pin type */ |
| 72 | +#define Z_PINCTRL_IOCON_D_PIN_MASK (0xFFF) |
| 73 | +#define Z_PINCTRL_IOCON_A_PIN_MASK (0) |
| 74 | +#define Z_PINCTRL_IOCON_I_PIN_MASK (0) |
| 75 | + |
| 76 | +#define Z_PINCTRL_STATE_PIN_INIT(group, pin_prop, idx) \ |
| 77 | + DT_PROP_BY_IDX(group, pin_prop, idx) | Z_PINCTRL_IOPCTL_PINCFG(group), |
| 78 | + |
| 79 | +#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ |
| 80 | + {DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), DT_FOREACH_PROP_ELEM, pinmux, \ |
| 81 | + Z_PINCTRL_STATE_PIN_INIT)} |
| 82 | + |
| 83 | +#ifdef __cplusplus |
| 84 | +} |
| 85 | +#endif |
| 86 | + |
| 87 | +#endif /* ZEPHYR_SOC_ARM_NXP_IMX_RT7XX_PINCTRL_SOC_H_ */ |
0 commit comments