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

I2C: Add real clock control #175

Open
omeh-a opened this issue Jul 25, 2024 · 7 comments
Open

I2C: Add real clock control #175

omeh-a opened this issue Jul 25, 2024 · 7 comments
Labels
drivers Issues pertaining to driver code for a device class meson Devices on a Meson platform - e.g. ODROID C4

Comments

@omeh-a
Copy link
Member

omeh-a commented Jul 25, 2024

Currently the I2C driver has absolutely no idea how to set its timing. It depends on hard-coded constants to set clock dividers, and this means that the functionality of the I2C is now dependent on the system clocks being exactly what those hard-coded values are tuned for AND is fully insensitive to variations in device clocking.

This principally refers to the Meson I2C driver (as the only extant one), but this will be needed in general.

To solve this issue, a clock driver must be connected to I2C to allow it to detect the clock rate and tune itself OR the I2C must be given access to the relevant clocking hardware to set the divider values appropriately.

@omeh-a omeh-a added drivers Issues pertaining to driver code for a device class meson Devices on a Meson platform - e.g. ODROID C4 labels Jul 25, 2024
@terryzbai
Copy link

Now the clock driver #278 is ready to be used for dynamically configuring clock rates. As we don't have a complete clock management policy (e.g., which parent clock is better for the requested rate, what rate is compatible with multiple different requests, or what configurations would be beneficial for power saving) yet, the clients have to know which clock it wants to configure and the modification won't break other devices.

I saw the I2C clock is configured by setting QTR_CLK_DLY (i2c_regs->ctl) now. This should still be part of I2C driver, as the register is on I2C memory region and should not be touched by clock driver at all, but the rate ofclk81 (clock source of I2C clock) and the gate clock can be dynamically configured via clock driver.

@omeh-a
Copy link
Member Author

omeh-a commented Nov 21, 2024

Now the clock driver #278 is ready to be used for dynamically configuring clock rates. As we don't have a complete clock management policy (e.g., which parent clock is better for the requested rate, what rate is compatible with multiple different requests, or what configurations would be beneficial for power saving) yet, the clients have to know which clock it wants to configure and the modification won't break other devices.

I saw the I2C clock is configured by setting QTR_CLK_DLY (i2c_regs->ctl) now. This should still be part of I2C driver, as the register is on I2C memory region and should not be touched by clock driver at all, but the rate ofclk81 (clock source of I2C clock) and the gate clock can be dynamically configured via clock driver.

That's good news. Right now all that's needed is to have a known value of clk81 because all the clock divider values are completely arbitrary now based on the usual value set by U-boot. If we can read the rate, we can appropriately do the math to calculate the dividers properly

@terryzbai
Copy link

That's good news. Right now all that's needed is to have a known value of clk81 because all the clock divider values are completely arbitrary now based on the usual value set by U-boot. If we can read the rate, we can appropriately do the math to calculate the dividers properly

yea, the client interfaces (https://github.com/au-ts/sddf/blob/clk_driver/include/sddf/clk/client.h) are already provided to get/set rate. You can also check https://github.com/au-ts/sddf/blob/clk_driver/examples/clk/client.c to see how to use them.

@omeh-a
Copy link
Member Author

omeh-a commented Nov 21, 2024

Great. I can get onto solving this issue sometime next month unless somebody else gets it first

@terryzbai
Copy link

Great. I can get onto solving this issue sometime next month unless somebody else gets it first

I can replace clk81-related configurations with requests to clock driver now, so you will just need to do some math for I2C features.

@omeh-a
Copy link
Member Author

omeh-a commented Nov 21, 2024

Sure, just do so on a branch for this issue if you do please

@omeh-a
Copy link
Member Author

omeh-a commented Nov 21, 2024

Created 175-i2c-add-real-clock-control

terryzbai added a commit that referenced this issue Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drivers Issues pertaining to driver code for a device class meson Devices on a Meson platform - e.g. ODROID C4
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants