-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[DNM] soc: arm: cypress: psoc6: Introduce pinctrl #28645
Changes from 1 commit
28f2161
49e3067
ed6b79f
fd7ca00
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,100 @@ | ||
/* | ||
* Copyright (c) 2020 Linaro Limited | ||
* Copyright (c) 2020 ATL Electronics | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef PINCTRL_CYPRESS_PSOC6_H_ | ||
#define PINCTRL_CYPRESS_PSOC6_H_ | ||
|
||
#include <sys/util_macro.h> | ||
|
||
/** | ||
* Functions are defined using HSIOM SEL | ||
*/ | ||
|
||
#define HSIOM_SEL_gpio 0 | ||
#define HSIOM_SEL_gpio_dsi 1 | ||
#define HSIOM_SEL_dsi_dsi 2 | ||
#define HSIOM_SEL_dsi_gpio 3 | ||
#define HSIOM_SEL_amuxa 4 | ||
#define HSIOM_SEL_amuxb 5 | ||
#define HSIOM_SEL_amuxa_dsi 6 | ||
#define HSIOM_SEL_amuxb_dsi 7 | ||
#define HSIOM_SEL_act_0 8 | ||
#define HSIOM_SEL_act_1 9 | ||
#define HSIOM_SEL_act_2 10 | ||
#define HSIOM_SEL_act_3 11 | ||
#define HSIOM_SEL_ds_0 12 | ||
#define HSIOM_SEL_ds_1 13 | ||
#define HSIOM_SEL_ds_2 14 | ||
#define HSIOM_SEL_ds_3 15 | ||
#define HSIOM_SEL_act_4 16 | ||
#define HSIOM_SEL_act_5 17 | ||
#define HSIOM_SEL_act_6 18 | ||
#define HSIOM_SEL_act_7 19 | ||
#define HSIOM_SEL_act_8 20 | ||
#define HSIOM_SEL_act_9 21 | ||
#define HSIOM_SEL_act_10 22 | ||
#define HSIOM_SEL_act_11 23 | ||
#define HSIOM_SEL_act_12 24 | ||
#define HSIOM_SEL_act_13 25 | ||
#define HSIOM_SEL_act_14 26 | ||
#define HSIOM_SEL_act_15 27 | ||
#define HSIOM_SEL_ds_4 28 | ||
#define HSIOM_SEL_ds_5 29 | ||
#define HSIOM_SEL_ds_6 30 | ||
#define HSIOM_SEL_ds_7 31 | ||
|
||
|
||
/* Create a pincfg device tree node: | ||
* | ||
* The node name and nodelabel will be of the form: | ||
* | ||
* NODE = p<port>_<pin>_<inst>_<signal> | ||
* | ||
* NODE: NODE { | ||
* cypress,pins = < &p<port> <port> <pin> HSIOM_SEL_<hsiom> >; | ||
* flags_1; | ||
* ... | ||
* flags_N; | ||
* } | ||
* | ||
* So for example: | ||
* | ||
* DT_CYPRESS_PIN(uart5, rx, 5, 0, act_6); | ||
* | ||
* Will become: | ||
* | ||
* p5_0_uart5_rx: p5_0_uart5_rx { | ||
* cypress,pins = <&p5 0x5 0x0 0x12 >; | ||
* } | ||
* | ||
* Flags are optional and should be pass one by one as arguments: | ||
* | ||
* DT_CYPRESS_PIN(uart5, rx, 5, 0, act_6, bias-pull-up, input-enable); | ||
* | ||
* Will become: | ||
* | ||
* p5_0_uart5_rx: p5_0_uart5_rx { | ||
* cypress,pins = <&p5 0x5 0x0 0x12 >; | ||
* bias-pull-up; | ||
* input-enable; | ||
* } | ||
* | ||
* For the complete list of flags see cypress,psoc6-pinctrl.yaml | ||
* | ||
*/ | ||
|
||
#define DT_CYPRESS_HSIOM_FLAG(flag) flag; | ||
#define DT_CYPRESS_HSIOM_FLAGS(...) \ | ||
MACRO_MAP_CAT(DT_CYPRESS_HSIOM_FLAG __VA_OPT__(,) __VA_ARGS__) | ||
|
||
#define DT_CYPRESS_HSIOM(inst, signal, port, pin, hsiom, ...) \ | ||
p##port##_##pin##_##inst##_##signal: \ | ||
p##port##_##pin##_##inst##_##signal { \ | ||
cypress,pins = < &p##port port pin HSIOM_SEL_##hsiom > ; \ | ||
DT_CYPRESS_HSIOM_FLAGS(__VA_ARGS__) \ | ||
} | ||
|
||
#endif /* PINCTRL_CYPRESS_PSOC6_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2020 ATL Electronics | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "pinctrl_cypress_psoc6.h" | ||
|
||
/ { | ||
soc { | ||
pinctrl@40310000 { | ||
/* instance, signal, port, pin, hsiom [, flag1, ... ] */ | ||
DT_CYPRESS_HSIOM(uart5, rx, 5, 0, act_6, input-enable); | ||
DT_CYPRESS_HSIOM(uart5, tx, 5, 1, act_6, drive-push-pull); | ||
DT_CYPRESS_HSIOM(uart6, rx, 13, 0, act_6, input-enable); | ||
DT_CYPRESS_HSIOM(uart6, tx, 13, 1, act_6, drive-push-pull); | ||
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. I'm not familiar with this SoC, but if the number of pinctrl options is large, you may consider making pinctrl part of the SoC HAL as we've done for ST. 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. I don't have intention to move this to HAL and mix Zephyr with Cypress. 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. It doesn't have to be in PDL directly. It could be inside a dts/ at cypress module root. |
||
}; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2020 ATL Electronics | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: Cypress GPIO PORT node | ||
|
||
compatible: "cypress,psoc6-gpio" | ||
|
||
include: [gpio-controller.yaml, base.yaml] | ||
|
||
properties: | ||
reg: | ||
required: true | ||
|
||
interrupts: | ||
required: true | ||
|
||
label: | ||
required: true | ||
|
||
"#gpio-cells": | ||
const: 2 | ||
|
||
"#cypress,pin-cells": | ||
type: int | ||
required: true | ||
const: 3 | ||
description: Number of items to expect in a cypress,pins specifier | ||
|
||
gpio-cells: | ||
- pin | ||
- flags | ||
|
||
cypress,pin-cells: | ||
- port | ||
- pin | ||
- hsiom | ||
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. Why does this commit introduce gpio bindings? Shouldn't it be pinctrl stuff only? I think it's better to split gpio and pinctrl stuff, they are in principle orthogonal things. 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) 2020 ATL Electronics | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: Cypress High Speed I/O Matrix | ||
|
||
compatible: "cypress,psoc6-hsiom" | ||
|
||
include: base.yaml | ||
|
||
properties: | ||
reg: | ||
required: true | ||
|
||
interrupts: | ||
required: true | ||
|
||
label: | ||
required: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) 2020, Linaro Limited | ||
# Copyright (c) 2020, ATL Electronics | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: Cypress PSoC-6 Pinctrl container node | ||
|
||
compatible: "cypress,psoc6-pinctrl" | ||
|
||
include: [base.yaml, pincfg-node.yaml] | ||
|
||
properties: | ||
"#address-cells": | ||
required: true | ||
const: 1 | ||
"#size-cells": | ||
required: true | ||
const: 1 | ||
|
||
child-binding: | ||
description: cypress pins | ||
properties: | ||
"cypress,pins": | ||
type: phandle-array | ||
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 you provide a usage example of the pinctrl bindings (board)? 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. Yes, to have something that works need solve dependencies first: dt-util.h, IRQ and GPIO. |
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 wonder if pin information can be encoded into an uint32, similar to what we do on STM32: https:/zephyrproject-rtos/zephyr/blob/master/include/dt-bindings/pinctrl/stm32-pinctrl.h#L42
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 think it already is at end:
This is the structure that will handle:
The soc/arm/cypress/common/cypress_psoc6_dt.h have a macro CY_PSOC6_DT_PIN that will collect from DT and create above structure at driver level at build time.
The DT_CYPRESS_HSIOM is a variable length argument list that accept flags:
First 5 parameters are mandatory, than flags are added one by one with commas.
DT_CYPRESS_HSIOM(uart5, rx, 5, 0, act_6);
DT_CYPRESS_HSIOM(uart5, rx, 5, 0, act_6, bias-pull-up);
DT_CYPRESS_HSIOM(uart5, rx, 5, 0, act_6, bias-pull-up, input-enable [, etc]);
Above all entries are valid and create a node like:
The CY_PSOC6_DT_PIN will combine 0x12 (function) + bias-pull-up + input-enable as flags. From &p5 we get reg addr and 0x0 is the pin itself at p5. The remaining 0x5 is the uart instance number and doesn't have nothing to do with pinctrl and probably will be dropped. It was necessary to solve the chicken and egg problem when platform doesn't have nothing.