Skip to content
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

DRAFT: ARM: Introduce Infineon PSoC 6 SoC #42725

Conversation

npal-cy
Copy link
Contributor

@npal-cy npal-cy commented Feb 11, 2022

This introduce an Infineon PSoC 6 SoC. This is a first MR which include following part:

The next PR: will include GPIO driver, ADC driver, CYW42XXX BT HCI extension driver, CYW42XXX wifi driver, etc.

PSoC 6 Integration structure:
image

This is a draft PR. We are still working on integration, but we would appreciate to get feedback as soon as possible.

Add Ian Fyall (@ifyall) as codeowner for Infineon/Cypress sources

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Add initial version of Devicetree for Infineon PSoC 6 SOC .

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Add initial version of Infineon CAT1/PSoC 6 SOC integration.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Add initial version of Infineon CAT1 UART driver.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Add initial version of binding file for Infineon CAT1 UART driver.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Add initial version of cy8cproto_062_4343w board.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Enable 'submodules' feature in hal_infineon module.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
@npal-cy npal-cy changed the title ARM: Introduce Infineon PSoC 6 SoC DRAFT: ARM: Introduce Infineon PSoC 6 SoC Feb 11, 2022
@npal-cy npal-cy marked this pull request as draft February 11, 2022 08:15
@carlescufi
Copy link
Member

Thanks for this contribution!

I see that you have added the cy8cproto_062_4343w board and the SoC family SOC_FAMILY_CAT1A as well as SOC_DIE_PSOC6 in soc/arm/infineon_cat1/psoc6. But in the tree we already have cy8ckit_062_ble and cy8ckit_062_wifi_bt and also SOC_FAMILY_PSOC6 in soc/arm/cypress/, so this seems to be duplicating a SoC and a board that is already in-tree, and that was submitted by Cypress, see the commit.

We can't have two implementations of the same board and SoC on the tree, so you need to remove the previous one if you want to rework the whole SoC and board support.

@nandojve
Copy link
Member

Hi @carlescufi,

We can't have two implementations of the same board and SoC on the tree, so you need to remove the previous one if you want to rework the whole SoC and board support.

I don 't think it is prudent remove current implementation. I would say it should be renamed to, instead. I remember that a very complex part was treat interrupt for both Cortex-M0+/M4 and that is already working. That was deeply discussed with @galak and @mbolivar-nordic and took months. I mean, I imagine that still have parts in this architecture that should be well discussed.

My view is simple, Infineon should propose a RFC and tell to everyone how this migration will be made. That should present a clear path about how things will be organized and if they want introduce WIFI/BLE I imagine they want to use blobs.

So, instead try reintroduce something ignoring completely what already is working seems not to be right path. I would say, maybe, better way is rework what already works based on a clear path step by step. This is how things are recommended to be made with Zephyr and will involve less people on each review.

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. I see numerous issues in the approach taken here, please check my comments. I agree with others that existing Infineon PSoC support can't be ignored, so there should be an integration plan.

@@ -0,0 +1,160 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please split 87a40b2 into smaller chunks, to ease review process. I can spot a few issues, but I can't hardly review thousands of line in one go.

Comment on lines +19 to +21
/* Add include for DTS generated information */
#include <devicetree.h>
#include <cy_device_headers.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be removed, nothing in this header needs them.

Comment on lines +5 to +6
bool "Infineon CAT1 UART driver"
default y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please default based on dt compat status (see some other drivers)

Comment on lines +33 to +38
#if CONFIG_UART_INTERRUPT_DRIVEN
uart_irq_callback_user_data_t irq_cb; /* Interrupt Callback */
void *irq_cb_data; /* Interrupt Callback Arg */
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */

#if CONFIG_UART_ASYNC_API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR has dozens of formatting issues (mixing tabs/spaces one of them), can you please review/fix all of them?

Comment on lines +50 to +52
///////////////////////////////////////////////////////////////////////////////
// INTERNAL API //
///////////////////////////////////////////////////////////////////////////////
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no // comments, please check styleguide.

Comment on lines +445 to +450
result = cyhal_uart_init(&DEV_DATA(dev)->obj, \
(cyhal_gpio_t) DT_INST_PROP(n, tx_pin), \
(cyhal_gpio_t) DT_INST_PROP(n, rx_pin), \
(cyhal_gpio_t) DT_INST_PROP(n, cts_pin), \
(cyhal_gpio_t) DT_INST_PROP(n, rts_pin), \
NULL, NULL); \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to implement a pinctrl driver, this is no longer allowed. please check #39740

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will rework to use pinctrl data instead tx_pin, rx_pin, cts_pin, rts_pin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: pinctrl data is opaque, so drivers are not allowed to use such information. cyhal_uart_init will likely need to be reworked to not initialize pins.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean, that i can not retrieve information about port and pin from pinctrl data ? or i can but it is not allowed...
I expected to create objects of cyhat_gpio_t from pinctrl data, which can be used for cyhal_uart_init().

Copy link
Member

@gmarull gmarull Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opaque types such as pinctrl_soc_pin_t are meant to be opaque, so using their fields is not allowed. With the pinctrl model, drivers need to call the pinctrl_apply_state API to configure pins. There are now a few drivers doing this. You can read this guide for more details https://docs.zephyrproject.org/latest/guides/pinctrl/index.html

#define INFINEON_CAT1_UART_INIT(n) \
static struct uart_cat1_data INFINEON_CAT1_uart##n##_data = { 0 }; \
\
static int INFINEON_CAT1_uart##n##_init(const struct device *dev) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why define a custom init function for each instance? please store DT config to driver's config and create a single one.

Comment on lines +11 to +20
zephyr_library_sources(bsp/cybsp.c)
zephyr_library_sources(bsp/system_psoc6_cm4.c)

zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_clocks.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_peripherals.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_pins.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_qspi_memslot.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_routing.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_system.c)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's going on with all these autogenerated files? I guess this, at best, should be part of a HAL. Some look suspicious, though, like custom clock/pin control

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agreed! I'll add that everything that is autogenerated should stay at vendors hal and not ay Zephyr main tree.
This is why a plan is important!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed as well, please move this to the HAL repo.

Comment on lines +17 to +18
/* Initializes the board support package */
result = cybsp_init();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is "board support package" needed in Zephyr?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, in Zephyr we do not have "BSP"s, we just have "boards".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmarull and @carlescufi,

The cybsp_* APIs are APIs from our SOC SDK. They are used to act on a board (represented by a BSP) to initialize or control peripherals. Rather than reimplement how we initialize our board in different environments, we just reuse the SDK.

Does this make sense and address your concerns?

Copy link
Member

@gmarull gmarull Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is missing some fundamental Zephyr concepts. There's no "BSP" in Zephyr. Boards define instead the enabled SoC peripherals or other hardware devices in Devicetree. Then, drivers pick this information to setup the system accordingly. We still have some boards doing manual pinmux, something that could be seen as "BSP code", but still this will soon be deprecated because there's now a pinctrl API. So the approach taken here has to be reworked to follow this model. Note that you can still plug some init code into the SoC init function, if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The board uses GPIO, UART from Devicetree configuration. Another peripherals support (ADC, SPI, I2C, etc) will be done in future PRs.

"bsp" was reused from existing Asset (https://github.com/Infineon/TARGET_CY8CPROTO-062-4343W) to do board configuration of system resources (PLL, FLL, WCO, CM4/CM0p clock configuration, SWD configuration, power, etc).

so we can do following:

  1. move 'bsp' from board zephyr\boards\arm\cy8cproto_062_4343w\ to hal_infenion\bsp\TARGET_CY8CPROTO-062-4343W
  2. call cybsp_init() from zephyr\soc\arm\infineon_cat1\psoc6\soc.c.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you don't need any BSP code. You need drivers that configure your peripherals based on DT configuration. Sometimes, you'll need some init code part of soc.c, but not a BSP hidden within soc.c.

Comment on lines +4 to +7
* Description:
* Wrapper function to initialize all generated code.
* This file was automatically generated and should not be modified.
* Tools Package 2.4.0.5721
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please no autogenerated files of this kind in-tree

@carlescufi
Copy link
Member

So, instead try reintroduce something ignoring completely what already is working seems not to be right path. I would say, maybe, better way is rework what already works based on a clear path step by step. This is how things are recommended to be made with Zephyr and will involve less people on each review.

@nandojve I agree, although ultimately it is the contributor's call how to present the change. As it exists today it certainly cannot go in, so I leave it to the contributors to pick a direction. I do agree that starting from scratch when there is an existing implementation in the tree seems counter-productive, but I do not know enough about the port or the SoC to argue against it. I would personally be much happier with smaller steps instead of a wholesale replace like this too.

Comment on lines +11 to +20
zephyr_library_sources(bsp/cybsp.c)
zephyr_library_sources(bsp/system_psoc6_cm4.c)

zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_clocks.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_peripherals.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_pins.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_qspi_memslot.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_routing.c)
zephyr_library_sources(bsp/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg_system.c)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agreed! I'll add that everything that is autogenerated should stay at vendors hal and not ay Zephyr main tree.
This is why a plan is important!

@nandojve
Copy link
Member

So, instead try reintroduce something ignoring completely what already is working seems not to be right path. I would say, maybe, better way is rework what already works based on a clear path step by step. This is how things are recommended to be made with Zephyr and will involve less people on each review.

@nandojve I agree, although ultimately it is the contributor's call how to present the change. As it exists today it certainly cannot go in, so I leave it to the contributors to pick a direction. I do agree that starting from scratch when there is an existing implementation in the tree seems counter-productive, but I do not know enough about the port or the SoC to argue against it. I would personally be much happier with smaller steps instead of a wholesale replace like this too.

I know a little about PSoC-6 and it is a complex device. Sometimes it could be controversial in some aspects. Because of that I believe it will be better a plan about how to do it and make it easy to acceptance. I'm suggesting an RFC because experts can do suggestions and it keep records about decisions. The other thing which is good about RFC is that anyone can track all changes at one place, for instance #38657. This way anyone can have a big picture about what is happen and that makes life easy for everyone, mostly to reviewers and users.

@carlocaione carlocaione added the dev-review To be discussed in dev-review meeting label Feb 17, 2022
@carlocaione carlocaione self-requested a review February 17, 2022 08:12
@ifyall
Copy link
Collaborator

ifyall commented Feb 17, 2022

We have filed an RFC to discuss this planning. The RFC is here: #42883

@npal-cy
Copy link
Contributor Author

npal-cy commented Feb 18, 2022

per discussion, closing this PR.
will open new PRs (smaller portion) in scope of #42883 tasks.

NOTE: i will save/move all current comments, which requires code change to the new PRs.

Thanks you All for review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Boards dev-review To be discussed in dev-review meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants