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

Migrate KSZ8863 driver to new I2C driver implementation #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bogdankolendovskyy
Copy link
Collaborator

Description

Migrate KSZ8863 driver to use i2c_master.h instead of legacy i2c.h. Examples updated accrodingly, and ioctl error

E (447) esp.emac: emac_esp_custom_ioctl(276): unknown io command: 4109

suppressed. It resulted from ETHERNET_EVENT_CONNECTED handler trying to use KSZ8863 custom ioctl command KSZ8863_ETH_CMD_G_PORT_NUM when host_eth_handle produced ETHERNET_EVENT_CONNECTED.

Related

Fixes #45

Testing

I2C bus probed to verify correct data transfer, examples are confirmed to be running without issues.


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@kostaond
Copy link
Collaborator

ksz8863/CMakeLists.txt Outdated Show resolved Hide resolved
ksz8863/src/ksz8863_ctrl.c Outdated Show resolved Hide resolved
ksz8863/src/ksz8863_ctrl.c Outdated Show resolved Hide resolved
ksz8863/src/ksz8863_ctrl.c Show resolved Hide resolved
@bogdankolendovskyy bogdankolendovskyy force-pushed the ksz8863_new_i2c_dev branch 2 times, most recently from 54d4049 to 947cfb7 Compare December 6, 2024 12:22
memcpy(reg_addr_and_data + 1, data, len);
// When performing a soft reset, the KSZ8863 doesn't produce an ACK. Print a warning that the error is expected and ignore it.
if unlikely(reg_addr == KSZ8863_RESET_ADDR) {
ESP_LOGW(TAG, "Ignore the error below. KSZ8863 does not produce ACK when performing soft reset.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

It needs to be specifically said it's I2C error to ignore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rephrased. Also added clarification of why we won't support SMI access to the README.

@kostaond
Copy link
Collaborator

kostaond commented Dec 9, 2024

@bogdankolendovskyy don't forget to update idf_component.yml. Please also check the new I2C driver is available in IDFv5.3 which stated as dependency for KS8863.

@bogdankolendovskyy bogdankolendovskyy force-pushed the ksz8863_new_i2c_dev branch 2 times, most recently from 7056470 to dd0d710 Compare December 10, 2024 13:02
.master.clk_speed = CONFIG_EXAMPLE_I2C_CLOCK_KHZ * 1000,
.sda_io_num = CONFIG_EXAMPLE_I2C_SDA_GPIO,
.glitch_ignore_cnt = 7,
.flags.enable_internal_pullup = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to be set to true in my opinion. It's common practice the I2C bus to be always designed with external pullups.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fix in all applicable examples.

memcpy(reg_addr_and_data + 1, data, len);
// When performing a soft reset, the KSZ8863 doesn't produce an ACK. Print a warning that the error is expected and ignore it.
if unlikely(reg_addr == KSZ8863_RESET_ADDR) {
ESP_LOGW(TAG, "Ignore the error below. It is produced by the I2C driver because KSZ8863 does not produce ACK when performing soft reset. It is epxected behaviour and requires no actions on your side.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please reformulate in something like "The following I2C error can be ignored ..." or something similar. Problematic part is "Ignore the error below" because logs and printfs in general are not deterministic. There might be context switch and different error could be printed before printing the I2C error.

break;
case KSZ8863_SPI_MODE:
spi_bus_remove_device(s_ksz8863_ctrl_intf->spi_bus_spec.spi_handle);
vSemaphoreDelete(s_ksz8863_ctrl_intf->bus_lock);
spi_bus_remove_device(s_ksz8863_ctrl_intf->spi_handle);
case KSZ8863_SMI_MODE:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove all the case KSZ8863_SMI_MODE: cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KSZ8863 - I2C Migration, ioctl error suppression (IDFGH-13977)
2 participants