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

boards: stm: arduino_portenta_h7: support onboard ethernet + pf1550 driver #76542

Merged
merged 4 commits into from
Feb 14, 2025

Conversation

facchinm
Copy link
Collaborator

@facchinm facchinm commented Jul 31, 2024

This PR adds support for the onboard ethernet phy on Arduino Portenta H7.
To properly provide the 1V2 rail for the PHY, I also implemented a driver for the PF1550 PMIC (nice side effect 🙂 ).

The driver is feature complete for our factory OTP programming on the A0 variant. Other variants are untested (the only difference would be BUCK1/2 voltage ranges)

On the charger side, I'd need some guidance on how to expose the led configuration via device tree (at the moment it's hardcoded in the init function

Copy link

Hello @facchinm, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@facchinm facchinm changed the title [Arduino Portenta H7] Support onboard ethernet + pf1550 driver boards: stm: arduino_portenta_h7: support onboard ethernet + pf1550 driver Jul 31, 2024
Copy link
Member

@fabiobaltieri fabiobaltieri left a comment

Choose a reason for hiding this comment

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

Good stuff, check your compliance error as well (you can also run them locally ./scripts/ci/check_compliance.py -c ..., also the commits need al la description and signed-off-by

drivers/charger/charger_pf1550.c Outdated Show resolved Hide resolved
drivers/charger/charger_pf1550.c Outdated Show resolved Hide resolved
Comment on lines 164 to 172
enum {
PF1550_CHARGER_OFF_LINEAR_OFF,
PF1550_CHARGER_OFF_LINEAR_ON,
PF1550_CHARGER_ON_LINEAR_ON,
};
Copy link
Member

Choose a reason for hiding this comment

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

just use a define for PF1550_CHARGER_ON_LINEAR_ON outside of here?

drivers/charger/charger_pf1550.c Outdated Show resolved Hide resolved
drivers/charger/charger_pf1550.c Outdated Show resolved Hide resolved
drivers/charger/charger_pf1550.c Outdated Show resolved Hide resolved
drivers/charger/charger_pf1550.c Outdated Show resolved Hide resolved
drivers/mfd/mfd_pf1550.c Outdated Show resolved Hide resolved
Comment on lines 22 to 27
config REGULATOR_NXP_PF1550_INIT_PRIORITY
int "PF1550 regulator driver init priority"
default 87
help
Init priority for the NXP PF1550 regulator driver. It must be
greater than REGULATOR_NXP_PF1550_COMMON_INIT_PRIORITY
Copy link
Member

Choose a reason for hiding this comment

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

if you use the same priority value on all devices they should all get sequence correctly thanks to the subpriority value, want to try that? may get rid of few symbols, I would keep the MFD one for all of them

drivers/regulator/regulator_pf1550.c Outdated Show resolved Hide resolved
@rriveramcrus
Copy link
Contributor

@facchinm, just a helpful tip, quite a few of the indentation and line wrapping issues can be fixed with a git clang-format :)

@facchinm facchinm force-pushed the portenta_h7_eth_f branch from 63caebe to 35f5779 Compare August 1, 2024 12:03
@decsny decsny removed their request for review August 1, 2024 13:55
@facchinm facchinm force-pushed the portenta_h7_eth_f branch from 35f5779 to af73bba Compare August 1, 2024 14:29
drivers/mfd/mfd_pf1550.c Show resolved Hide resolved
drivers/regulator/regulator_pf1550.c Outdated Show resolved Hide resolved
drivers/regulator/regulator_pf1550.c Outdated Show resolved Hide resolved
drivers/regulator/regulator_pf1550.c Outdated Show resolved Hide resolved
Comment on lines 11 to 48
constant-charge-current-max-microamp:
required: true
type: int

vbus-current-limit-microamp:
type: int
required: true

constant-charge-voltage-max-microvolt:
type: int
required: true

system-voltage-min-threshold-microvolt:
type: int
required: true
enum:
- 3500000
- 3700000
- 4300000
description: |
System voltage minimum threshold.

thermistor-monitoring-mode:
type: string
required: true
enum:
- "disabled"
- "thermistor"
- "JEITA-1"
- "JEITA-2"
description: |
Thermistor monitoring mode.
Refer to ThrmCfg register description and Table 2 for details.

int-gpios:
type: phandle-array
required: true
description: Interrupt pin
Copy link
Member

Choose a reason for hiding this comment

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

please, prefix vendor specific properties, eg nxp,prop-name.

Comment on lines 6 to 7
config REGULATOR
default y if NETWORKING
Copy link
Member

Choose a reason for hiding this comment

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

this looks wrong: device driver relying on regulator to be used should select this option

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you expand on this? If I understand correctly, the proposal would be to move the explicit configuration to a regulator field for the ethernet phy in the board dts, right?

Copy link
Member

Choose a reason for hiding this comment

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

Networking does not directly depend on regulators, but some device driver. This driver should be the one selecting regulator enablement. The reality though is that regulator usage is nowadays not great, we have no infrastructure for automatically turning them on/off on a device level. So maybe the defconfig should be linked to the device itself, at least future refactors will be easier to spot what's going on.

Copy link

github-actions bot commented Oct 5, 2024

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@pillo79
Copy link
Collaborator

pillo79 commented Feb 12, 2025

@gmarull concerns have been addressed, please revisit your -1. Thanks!

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.

a few minor nits, otherwise lgtm

Comment on lines 29 to 30
# Enable charger
CONFIG_CHARGER=y

# Enable USB Stack
CONFIG_USB_DEVICE_STACK=y
Copy link
Member

Choose a reason for hiding this comment

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

boards need to enable the minimum, e.g. to run hello world, is charger/usb stack needed there? If not, drop

@@ -9,6 +9,7 @@
#include <st/h7/stm32h747xihx-pinctrl.dtsi>
#include "arduino_portenta_h7-common.dtsi"
#include <../boards/common/usb/cdc_acm_serial.dtsi>
#include <dt-bindings/charger/pf1550.h>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#include <dt-bindings/charger/pf1550.h>
#include <zephyr/dt-bindings/charger/pf1550.h>

# The following macros are available:
# - LED_ON_IN_CHARGING_FLASH_IN_FAULT
# - LED_FLASH_IN_CHARGING_ON_IN_FAULT
# - LED_MANUAL_OFF
pf1550,led-behaviour:
Copy link
Member

Choose a reason for hiding this comment

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

should likely be a string property, see e.g. how nPM1300 LED behavior is specified. You can later use DT_ENUM_IDX helpers to get a number.

fabiobaltieri
fabiobaltieri previously approved these changes Feb 12, 2025
Copy link
Contributor

@rriveramcrus rriveramcrus left a comment

Choose a reason for hiding this comment

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

Just needs the compliance fix to get my +1 again :)

Comment on lines 53 to 55
- on_in_charging_flash_in_fault
- flash_in_charging_on_in_fault
- manual_off
Copy link
Contributor

@rriveramcrus rriveramcrus Feb 12, 2025

Choose a reason for hiding this comment

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

These need to be indented another level to satisfy the compliance checks and have a valid dt-binding.

Additionally these strings should be in quotes as is done for the pf1550,thermistor-monitoring-mode string enum.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the heads-up, updated (with quotes for good measure 🙂)

fabiobaltieri
fabiobaltieri previously approved these changes Feb 13, 2025
rriveramcrus
rriveramcrus previously approved these changes Feb 13, 2025
Copy link
Contributor

@rriveramcrus rriveramcrus left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@pillo79
Copy link
Collaborator

pillo79 commented Feb 13, 2025

@gmarull please revisit your -1, thanks!
(only pushing to get this in 4.1)

Comment on lines 54 to 56
- "on_in_charging_flash_in_fault"
- "flash_in_charging_on_in_fault"
- "manual_off"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- "on_in_charging_flash_in_fault"
- "flash_in_charging_on_in_fault"
- "manual_off"
- "on-in-charging-flash-in-fault"
- "flash-in-charging-on-in-fault"
- "manual-off"

Add driver for nxp pf1550 PMIC

Signed-off-by: Martino Facchin <[email protected]>
Enable PF1550 PMIC for Arduino Portenta H7

Signed-off-by: Martino Facchin <[email protected]>
On older Portenta H7, 1V2 power rail must be enabled
to get a functional ethernet phy.

Signed-off-by: Martino Facchin <[email protected]>
Selecting the wrong power scheme could potentially destroy the board.
Luckily, the bit can only be set once and the default build still
uses the Arduino bootloader (which has the correct setting).

Signed-off-by: Martino Facchin <[email protected]>
@kartben kartben merged commit d720fd7 into zephyrproject-rtos:main Feb 14, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants