-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Add pinctrl driver for Quicklogic EOS S3 #60095
Add pinctrl driver for Quicklogic EOS S3 #60095
Conversation
2949b33
to
0032226
Compare
pinmux = <QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD_CFG | ||
QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX>; |
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.
why do we need 3 macros here? can't a single one be used to specify the UART RX functionality?
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.
In order to select an input function, one must first program IOMUX_PAD_x_CTRL
register,
and then route the signal to functional block using IOMUX_<function>_SEL
.
The second element in the DTS is used to set proper function to a physical pad.
The third element in the DTS is used for selecting proper IOMUX_<function_SEL
register, where the pad number must be written.
These values are independent and one cannot be deduced using the other.
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.
I mean, can't this all be encoded in 32-bit + dt props?
By looking at e.g. the RX case we have:
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD 45
#define QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX 77
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD_CFG \
(EOS_S3_UART_RXD_SEL_PAD45 | EOS_S3_PAD_OEN_DISABLE \
| EOS_S3_PAD_E_4MA | EOS_S3_PAD_REN_ENABLE)
PAD 45 is duplicated, for example. And what do all flags like OEN, REN, etc mean?
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.
The reason it's done this way is related to the code that uses the HAL and was used for IO MUX:
eos_s3_io_mux(UART_TX_PAD, UART_TX_PAD_CFG);
eos_s3_io_mux(UART_RX_PAD, UART_RX_PAD_CFG);
IO_MUX->UART_rxd_SEL = UART_RX_SEL;
In order to do the same thing in the driver as depicted in the third line, one must deduce that the input function for UART_rxd
is being set.
However, for different pads that can serve for the same function, the function values differ:
HAL/inc/eoss3_dev.h
1451:#define UART_RXD_SEL_PAD16 ((uint32_t) (0x00000002))
1452:#define UART_RXD_SEL_PAD45 ((uint32_t) (0x00000004))
Knowing that the function is 0x4 is not enough to conclude that the function of UART_RX is being set here.
Therefore, to ascertain this, we would need to map each (PAD, FUNCTION) pair to a register in IO_MUX
.
The value assigned would correspond to the shift to this field in the struct:
https://github.com/zephyrproject-rtos/hal_quicklogic/blob/ba7e35f175fcd28199de11f955cb995e1ef20c73/HAL/inc/eoss3_dev.h#L469
The flags used in the code here are utilized to configure active low output
, drive strength
and receive enable
respectively.
The second value provided in the DTS configures the pad as input using these parameters.
While it's a 32-bit value, based on the S3 TRM (pp. 204-205), it appears that only bits [12:0] are actually used. We could pass some information on the more siginifant bits to the driver.
I can see that passing 3 32-bit values seems a bit much as for an IO multiplexer, and I'm sure I can add a mapping of (PAD, FUNCTION) -> register
(Is this the preferred way?).
Considering the perspecive of both the TRM of EOS S3 and the HAL, it seemed logical to me that the configuration of inputs would require the pad number and two other values. Also, the current solution doesn't add any layer of mapping values between Zephyr and the HAL.
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.
Note: Devicetree can’t be influenced by HALs.
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.
All right, I've addressed this issue.
pinmux = <QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD_CFG | ||
QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX>; |
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.
I mean, can't this all be encoded in 32-bit + dt props?
By looking at e.g. the RX case we have:
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD 45
#define QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX 77
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD_CFG \
(EOS_S3_UART_RXD_SEL_PAD45 | EOS_S3_PAD_OEN_DISABLE \
| EOS_S3_PAD_E_4MA | EOS_S3_PAD_REN_ENABLE)
PAD 45 is duplicated, for example. And what do all flags like OEN, REN, etc mean?
f48b282
to
d3363f3
Compare
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD 45 | ||
|
||
#define UART_RX_SEL EOS_S3_UART_RXD_SEL_PAD45 | ||
|
||
#define QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_NONE 0 | ||
#define QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX (77 << 13) | ||
|
||
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD_CFG \ | ||
(QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX \ | ||
| EOS_S3_UART_RXD_SEL_PAD45 | EOS_S3_PAD_OEN_DISABLE \ | ||
| EOS_S3_PAD_E_4MA | EOS_S3_PAD_REN_ENABLE) |
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.
this continues to duplicate info, PAD45 is in both places.
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.
I've reworked the driver, this is done.
#define QUICKLOGIC_EOS_S3_PINMUX_USB_PAD_CFG (EOS_S3_PAD_E_4MA | EOS_S3_PAD_P_Z \ | ||
| EOS_S3_PAD_OEN_NORMAL | EOS_S3_PAD_SMT_DISABLE \ | ||
| EOS_S3_PAD_REN_DISABLE \ | ||
| EOS_S3_PAD_SR_SLOW | EOS_S3_PAD_CTRL_SEL_FPGA) |
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.
please use standard properties, 4MA looks like a drive strength...
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.
I've reworked the driver so that it utilizes properties from the DTS. Could you take a look at the current implementation? Thanks!
ede1061
to
b6a53a8
Compare
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD 45 | ||
|
||
#define QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX (77 << 13) | ||
|
||
#define QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD_CFG (QUICKLOGIC_EOS_S3_PINMUX_FUNC_SEL_UART_RX \ | ||
| QUICKLOGIC_EOS_S3_UART_RXD_SEL_PAD45) |
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.
is selection related to pad?
why not something like #define UART_TX_PAD44 QUICKLOGIC_EOS_S3_PINMUX(44, 0x3)
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.
*_FUNC_SEL*
is related to the function and the function is UART_rxd
in this case.
I've implemented the macro you suggested and reworked the driver. I think the DTS looks much simpler now. Thank you.
4dc348a
to
587d867
Compare
#include <zephyr/logging/log.h> | ||
#include <zephyr/dt-bindings/pinctrl/quicklogic-eos-s3-pinctrl.h> | ||
#include <soc.h> | ||
|
||
LOG_MODULE_REGISTER(pinctrl_eos_s3, CONFIG_PINCTRL_LOG_LEVEL); |
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.
logging not used
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.
drivers/pinctrl/pinctrl_eos_s3.c
Outdated
LOG_MODULE_REGISTER(pinctrl_eos_s3, CONFIG_PINCTRL_LOG_LEVEL); | ||
|
||
#define FUNCTION_REGISTER(func) (func >> 13) | ||
#define PAD_FUNC_SEL_MASK (BIT(0) | BIT(1) | BIT(2)) |
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.
maybe use GENMASK?
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.
I've modified this to use GENMASK
.
pinmux = <QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD QUICKLOGIC_EOS_S3_PINMUX_UART_RX_PAD_CFG>; | ||
input-enable; | ||
}; | ||
uart0_tx_default: uart0_tx_default { | ||
pinmux = <QUICKLOGIC_EOS_S3_PINMUX_UART_TX_PAD QUICKLOGIC_EOS_S3_PINMUX_UART_TX_PAD_CFG>; |
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.
needs update
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.
I've updated the bindings file.
enum: | ||
- "slow" | ||
- "fast" | ||
control-selection: |
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.
nit: quicklogic,control-selection
(vendor specific prop)
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.
Done.
- "slow" | ||
- "fast" | ||
control-selection: | ||
default: "a0registers" |
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.
default needs justification, per guidelines
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.
I've added proper descriptions.
description: | | ||
Quicklogic EOS S3 pin's configuration (pin, IO function). | ||
slew-rate: | ||
default: "slow" |
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.
ditto for default
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.
Done.
1fe4949
to
b103e74
Compare
This adds a new pinctrl driver for Quicklogic EOS S3 SoC Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Pinmuxing was previously done in the board.c file. Now it is done by the pinctrl driver. Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Pinmuxing was previously done in the board.c file. Now it is done by the pinctrl driver. Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Pinmuxing is now done by a pinctrl driver, not by board.c, so the code used previously for pinmuxing can be removed. Fixes zephyrproject-rtos#59186. Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
b103e74
to
6f775f6
Compare
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.
lgtm, thanks for the continued effort!
This PR adds a new driver for the Quicklogic EOS S3 SoC.
Currently, there are two boards that do pinmuxing in their
board.c
files:quick_feather
andqomu
.The legacy code is removed and now the driver does all the pinmuxing.
Fixes #59186.