-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add initial pinctrl support for NXP kinetis #39743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Copyright (c) 2021 Linaro Limited. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <drivers/pinctrl.h> | ||
|
|
||
| int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, | ||
| uintptr_t reg) | ||
| { | ||
| for (uint8_t i = 0U; i < pin_cnt; i++) { | ||
| pins[i].port_reg->PCR[pins[i].pin] = pins[i].mux; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some more valid bits in the PCR register, shouldn't this be read, clear lowest 16 bits, and '|' mux value operation? Maybe in some scenario, this can create problems?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which bits would you preserve here? The idea is that all these bits are controlled by the pinctrl driver based on the devicetree properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IRQC bits, which are currently configured by gpio_mcux.c driver for interrupt configuration
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah. Right. |
||
| } | ||
|
|
||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| config SOC_FAMILY_KINETIS | ||
| bool | ||
| select HAS_SEGGER_RTT | ||
| select PINCTRL | ||
|
|
||
| if SOC_FAMILY_KINETIS | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Copyright (c) 2021 Linaro Limited. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /** | ||
| * @file | ||
| * Public APIs for pin control drivers | ||
| */ | ||
|
Comment on lines
+6
to
+9
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be removed |
||
|
|
||
| #ifndef ZEPHYR_SOC_ARM_NXP_KINETIS_COMMON_PINCTRL_SOC_H_ | ||
| #define ZEPHYR_SOC_ARM_NXP_KINETIS_COMMON_PINCTRL_SOC_H_ | ||
|
|
||
| /** | ||
| * @brief Pin Controller Interface (NXP Kinetis) | ||
| * @defgroup pinctrl_interface_nxp_kinetis Pin Controller Interface | ||
| * @ingroup pinctrl_interface | ||
| * @{ | ||
| */ | ||
|
Comment on lines
+14
to
+19
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this file doesn't expose any public API this can likely be removed |
||
|
|
||
| #include <devicetree.h> | ||
| #include <zephyr/types.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** @cond INTERNAL_HIDDEN */ | ||
|
|
||
| /** Type for NXP Kinetis pin. */ | ||
| typedef struct pinctrl_soc_pin { | ||
| PORT_Type *port_reg; | ||
| uint8_t pin; | ||
| uint16_t mux; | ||
| } pinctrl_soc_pin_t; | ||
|
|
||
| #define PINCTRL_SOC_PINS_ELEM_INIT(node_id) \ | ||
| { \ | ||
| .port_reg = (PORT_Type *)DT_REG_ADDR(DT_PARENT(node_id)), \ | ||
| .pin = DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 0), \ | ||
| .mux = PORT_PCR_MUX(DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 1)) | \ | ||
| (DT_PROP(node_id, bias_pull_up) & (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)) | \ | ||
| (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PS_MASK) | \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't PORT_PCR_PE_MASK be used for pull-down?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. This should be |
||
| (DT_PROP(node_id, drive_open_drain) & PORT_PCR_ODE_MASK), \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PORT_PCR_ODE_MASK is 0x20, If DT_PROP(node_id, drive_open_drain) return true(1) then '&' of them (1 & 0x20) will be 0. Instead we want 5th bit to be set here. Isn't it? Should we write here (DT_PROP(node_id, drive_open_drain) << PORT_PCR_ODE_SHIFT)? If this is true, then same can be applied to other '&' operations as well. |
||
| }, | ||
|
|
||
| /** | ||
| * @brief Utility macro to initialize each pin. | ||
| * | ||
| * @param node_id Node identifier. | ||
| * @param state_prop State property name. | ||
| * @param idx State property entry index. | ||
| */ | ||
| #define Z_PINCTRL_STATE_PIN_INIT(node_id, state_prop, idx) \ | ||
| PINCTRL_SOC_PINS_ELEM_INIT(DT_PROP_BY_IDX(node_id, state_prop, idx)) | ||
|
|
||
| /** | ||
| * @brief Utility macro to initialize state pins contained in a given property. | ||
| * | ||
| * @param node_id Node identifier. | ||
| * @param prop Property name describing state pins. | ||
| */ | ||
| #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ | ||
| {DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT)} | ||
|
|
||
| /** @endcond */ | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| #endif /* ZEPHYR_SOC_ARM_NXP_KINETIS_COMMON_PINCTRL_SOC_H_ */ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.