-
Notifications
You must be signed in to change notification settings - Fork 8.3k
boards: beagle_bcf: Move gpio-i2c-switch to i2c bus #65031
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
Conversation
|
Looks good. Thanks @Ayush1325 |
|
Just pinging some people who might already be familiar with this |
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.
This node is missing a @N peripheral address.
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.
Hi, is the peripheral address supposed to signify something or is it supposed to just be unique for the same types of nodes?
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.
It signifies the i2c address of the peripheral. In most cases, each peripheral address on an i2c bus should be unique. If the peripheral is being multiplexed (may be the case here?) then it might be possible to use duplicate addresses.
Some i2c peripherals are capable of supporting one of several possible i2c peripheral addresses (configured via wiring specific pins to ground). That way, a particular board could have more than 1 of the same type of i2c peripheral even on the same i2c bus.
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.
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.
It looks to not be an i2c device. Probably more of a platform device, because it looks to be connected via gpio.
In any case, if it's not on the i2c bus, then it should probably not be a child of i2c0.
I would suggest undoing this part.
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.
Well, the reason I moved it to i2c was because #64881 commit moved the sensors to i2c.
I think the sensors need to be children of gpio switch (unless I am getting that part wrong). So should I move the sensors back to their original place as well?
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.
Well, the reason I moved it to i2c was because #64881 commit moved the sensors to i2c. I think the sensors need to be children of gpio switch (unless I am getting that part wrong). So should I move the sensors back to their original place as well?
I would definitely say leave i2c sensors as children of the i2c controller.
Devicetree is a bus-centric abstraction. By bus, I mean basically a group of tightly related copper traces on a board, or interconnects in an IC.
The main bus of the Devicetree is memory - namely the addressable range(s) of memory that have meaning to a particular CPU inside of a particular SoC.
PCIe is a bus as well, and so is SPI, and so is I2C. PCIe's address space has a 1:1 mapping to main memory, whereas I2C addresses are either the 7 or 10-bit numbers we use regularly. e.g. 0x44 or @44 or something for i2c. SPI "addresses" are just indexes into an array of GPIO that are used as chip-enables.
Sensors that are connected over the I2C bus would naturally be children of a i2c node (like i2c0).
Technically speaking, GPIO is also a bus, so the gpio-i2c-switch node could potentially be a child of the GPIO device that it is connected to.
Does that make sense?
There isn't really a way to specify an address for a device that is connected via GPIO though (although multiple devices could technically drive the same wire with proper arbitration). Actually, that's kind of the point of this analog switch, I would imagine. To prevent multiple devices from driving voltages on the same wire.
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.
@cfriedt I think I somewhat understand, i2c senors should be defined as children of i2c controller, and the analog switch should be either child of gpio node or be in its original position.
However, I am still not sure how to show that the gpio switch drives the i2c sensors without making sensors as child nodes to the switch. Is there some primitive in device tree or maybe a new property needs to be added to gpio i2c switch bindings.
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.
However, I am still not sure how to show that the gpio switch drives the i2c sensors
Unless there is some dedicated binding for a chip-enable pin (which isn't part of the i2c spec, but may be present on certain sensor bindings), and unless that pin is wired in to the same GPIO in this case, I'm not sure if it's possible to have software (e.g. i2c controller driver, hypothetically) automatically enable it.
It's really easy to have application code set or clear the gpio though - and there is minimal Devicetree involved. In the case that you still want a binding for the gpio i2c switch, you could give it a phandle to the gpio controller and an index representing the offset of the particular driver for the pin.
It's kind of weird that this node is an i2c controller though.
I would just have application code get a phandle to the gpio device and flip it as necessary.
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 that is prone to error and potential race conditions. By defining a bus, we avoid mistakes and enable even shell tools to see the sensor i2c bus properly. Originally, I was looking at this as a bridge, but I can see that by not having an I2C address, it does not look like a peripheral to the primary I2C bus controller. To that end, I think we could use a different property to define the sensor I2C bus controller, rather than make it look like a peripheral. Does that make sense?
zephyrproject-rtos#64881 breaks zephyrproject-rtos#64693 Instead of reverting, I thought it might be better to move the whole switch to i2c. Signed-off-by: Ayush Singh <[email protected]>
ee5939a to
b07e5cb
Compare
| }; | ||
| }; | ||
|
|
||
| sens_i2c: sensor-switch { |
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.
OK, it looks like the way I had it before made more sense. I just listed a controller to define this new bus. I think @Ayush1325 might have had a different perspective on it, but I think the previous instance method was fine.
| reg = <0x4>; | ||
| }; | ||
|
|
||
| light: opt3001-light@44 { |
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.
It looks like this was in the wrong place. It should go under the sens_i2c or i2c0s I think it was called on other versions.
…m board" This reverts commit 3769938. Now that gpio_i2c_switch is upstream, this hack should be removed. This had the unintended effect of disabling the on-board sensors. The issue was that the board was merged before this driver was upstream, resulting in the issue this commit "fixed". This revert also does not move the bus driver under the controller used by the driver as the sensor bus I2C driver is not an I2C peripheral. See: * zephyrproject-rtos#64881 * zephyrproject-rtos#64693 * zephyrproject-rtos#65031 Signed-off-by: Jason Kridner <[email protected]>
|
Better to just revert: #66400 |
Agreed - that actually makes things much clearer. Thanks! @Ayush1325 - OK to close this PR? |
|
Closing this in favor of #66400 |
…m board" This reverts commit 3769938. Now that gpio_i2c_switch is upstream, this hack should be removed. This had the unintended effect of disabling the on-board sensors. The issue was that the board was merged before this driver was upstream, resulting in the issue this commit "fixed". This revert also does not move the bus driver under the controller used by the driver as the sensor bus I2C driver is not an I2C peripheral. See: * #64881 * #64693 * #65031 Signed-off-by: Jason Kridner <[email protected]>
…m board" This reverts commit 3769938. Now that gpio_i2c_switch is upstream, this hack should be removed. This had the unintended effect of disabling the on-board sensors. The issue was that the board was merged before this driver was upstream, resulting in the issue this commit "fixed". This revert also does not move the bus driver under the controller used by the driver as the sensor bus I2C driver is not an I2C peripheral. See: * zephyrproject-rtos/zephyr#64881 * zephyrproject-rtos/zephyr#64693 * zephyrproject-rtos/zephyr#65031 (cherry picked from commit 547a75d) Original-Signed-off-by: Jason Kridner <[email protected]> GitOrigin-RevId: 547a75d Change-Id: Ib6a6a0f71d249bc19a312d469f6e41224b70524b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5119865 Reviewed-by: Yuval Peress <[email protected]> Tested-by: Yuval Peress <[email protected]> Commit-Queue: Yuval Peress <[email protected]> Tested-by: ChromeOS Prod (Robot) <[email protected]>
#64881 breaks #64693
Instead of reverting, I thought it might be better to move the whole switch to i2c.