1 /* 2 * Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_SOC_ARM_RENESAS_RA_COMMON_RA_PINCTRL_SOC_H_ 8 #define ZEPHYR_SOC_ARM_RENESAS_RA_COMMON_RA_PINCTRL_SOC_H_ 9 10 enum { 11 PmnPFS_PODR_POS, 12 PmnPFS_PIDR_POS, 13 PmnPFS_PDR_POS, 14 PmnPFS_RSV3_POS, 15 PmnPFS_PCR_POS, 16 PmnPFS_RSV5_POS, 17 PmnPFS_NCODR_POS, 18 PmnPFS_RSV7_POS, 19 PmnPFS_RSV8_POS, 20 PmnPFS_RSV9_POS, 21 PmnPFS_DSCR_POS, 22 PmnPFS_DSCR1_POS, 23 PmnPFS_EOR_POS, 24 PmnPFS_EOF_POS, 25 PmnPFS_ISEL_POS, 26 PmnPFS_ASEL_POS, 27 PmnPFS_PMR_POS, 28 }; 29 30 struct pinctrl_ra_pin { 31 union { 32 uint32_t config; 33 struct { 34 uint8_t PODR: 1; 35 uint8_t PIDR: 1; 36 uint8_t PDR: 1; 37 uint8_t RESERVED3: 1; 38 uint8_t PCR: 1; 39 uint8_t RESERVED5: 1; 40 uint8_t NCODR: 1; 41 uint8_t RESERVED7: 1; 42 uint8_t RESERVED8: 1; 43 uint8_t RESERVED9: 1; 44 uint8_t DSCR: 2; 45 uint8_t EOFR: 2; 46 uint8_t ISEL: 1; 47 uint8_t ASEL: 1; 48 uint8_t PMR: 1; 49 uint8_t RESERVED17: 7; 50 uint8_t PSEL: 5; 51 uint8_t RESERVED29: 3; 52 }; 53 /* Using RESERVED fields for store pin and port info. */ 54 struct { 55 uint32_t UNUSED0: 17; 56 uint8_t pin: 4; 57 uint8_t port: 3; 58 uint32_t UNUSED24: 5; 59 uint8_t port4: 1; 60 uint32_t UNUSED30: 2; 61 }; 62 }; 63 }; 64 65 typedef struct pinctrl_ra_pin pinctrl_soc_pin_t; 66 67 extern int pinctrl_ra_query_config(uint32_t port, uint32_t pin, 68 struct pinctrl_ra_pin *const pincfg); 69 70 /** 71 * @brief Utility macro to initialize each pin. 72 * 73 * @param node_id Node identifier. 74 * @param prop Property name. 75 * @param idx Property entry index. 76 */ 77 #define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ 78 { \ 79 .config = DT_PROP_BY_IDX(node_id, prop, idx), \ 80 }, 81 82 /** 83 * @brief Utility macro to initialize state pins contained in a given property. 84 * 85 * @param node_id Node identifier. 86 * @param prop Property name describing state pins. 87 */ 88 #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ 89 { \ 90 DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), DT_FOREACH_PROP_ELEM, pinmux, \ 91 Z_PINCTRL_STATE_PIN_INIT) \ 92 } 93 94 #endif /* ZEPHYR_SOC_ARM_RENESAS_RA_COMMON_RA_PINCTRL_SOC_H_ */ 95