How to write to a PCIe config space during kernel boot up
Hi,My CPU is Intel x86 (Broadwell DE). I want to write to the command register of the management ethernet PHY's PCIeconfig space during Linux boot up. And I want to do that before kernel start loading the igb (ethernet) driver for this PHY.Can I do that inside the start_kernel() routine in init.main.c, or is the driver is already installed once code reaches this point (I am assuming probably not) ?If this is the correct routine to do this job, is there any kernel code that I can use to write to this config space? I have bus/device/function info for this management PHY which is already set by the BIOS. thanks,Khalid.
On Tue, Apr 12, 2022 at 11:00 PM Khalid F. Sabzwari <kfsabzwari@yahoo.com> wrote:
Hi,
Hello,
My CPU is Intel x86 (Broadwell DE). I want to write to the command register of the management ethernet PHY's PCIe config space during Linux boot up. And I want to do that before kernel start loading the igb (ethernet) driver for this PHY. Can I do that inside the start_kernel() routine in init.main.c, or is the driver is already installed once code reaches this point (I am assuming probably not) ? If this is the correct routine to do this job, is there any kernel code that I can use to write to this config space?
I dont think this right way, there should be a phy.h header file in kernel and i think should use PHY Abstraction Layer. https://docs.kernel.org/networking/phy.html
I have bus/device/function info for this management PHY which is already set by the BIOS.
thanks, Khalid.
Thanks Ozgur for quick reply.The link you shared below seems to work with MDIO interface.The PHY used on my board is Intel's i211 PHY which is controlled by PCIe interface.I found this link:https://docs.kernel.org/PCI/pci.html#how-to-access-pci-config-space I never wrote a kernel code before, and am trying to just hack for an experiment to write to config space of this PHY. so I will give it a try to see if i can read/write to i211's config space, during early kernel boot time, using pci_(read|write)_config_(byte|word|dword) thanks,Khalid. On Tuesday, April 12, 2022, 12:11:21 PM PDT, Ozgur Karatas <ozgurk@ieee.org> wrote: On Tue, Apr 12, 2022 at 11:00 PM Khalid F. Sabzwari <kfsabzwari@yahoo.com> wrote: Hi, Hello, My CPU is Intel x86 (Broadwell DE). I want to write to the command register of the management ethernet PHY's PCIeconfig space during Linux boot up. And I want to do that before kernel start loading the igb (ethernet) driver for this PHY.Can I do that inside the start_kernel() routine in init.main.c, or is the driver is already installed once code reaches this point (I am assuming probably not) ?If this is the correct routine to do this job, is there any kernel code that I can use to write to this config space? I dont think this right way, there should be a phy.h header file in kernel and i think should use PHY Abstraction Layer. https://docs.kernel.org/networking/phy.html I have bus/device/function info for this management PHY which is already set by the BIOS. thanks,Khalid. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Wed, Apr 13, 2022 at 07:01:01AM +0000, Khalid F. Sabzwari wrote:
Thanks Ozgur for quick reply.The link you shared below seems to work with MDIO interface.The PHY used on my board is Intel's i211 PHY which is controlled by PCIe interface.I found this link:https://docs.kernel.org/PCI/pci.html#how-to-access-pci-config-space
I never wrote a kernel code before, and am trying to just hack for an experiment to write to config space of this PHY. so I will give it a try to see if i can read/write to i211's config space, during early kernel boot time, using pci_(read|write)_config_(byte|word|dword)
Do so in the driver that binds to the device, before it initializes it. Not in the kernel core, otherwise in the kernel core you do not have access to the needed pci structures. thanks, greg k-h
On Wed, Apr 13, 2022 at 11:34 AM Greg KH <greg@kroah.com> wrote:
On Wed, Apr 13, 2022 at 07:01:01AM +0000, Khalid F. Sabzwari wrote:
Thanks Ozgur for quick reply.The link you shared below seems to work with MDIO interface.The PHY used on my board is Intel's i211 PHY which is controlled by PCIe interface.I found this link: https://docs.kernel.org/PCI/pci.html#how-to-access-pci-config-space
I never wrote a kernel code before, and am trying to just hack for an experiment to write to config space of this PHY. so I will give it a try to see if i can read/write to i211's config space, during early kernel boot time, using pci_(read|write)_config_(byte|word|dword)
Hello, as Greg-KH said below, you dont need to do anything about kernel or PCI structure. So I have question, this card already driven and initialized by Linux kernel? Can you run this card inserting into slot as PCIE? if it probably has a driver that uses phy.h I think and in this case, will get a PHY id and use it to shift it after initing to PCIE address (for example PCIE0). You just need to process module file before inital process and you dont need to work with an additional processing or PCIE structure on kernel side. if you want to see an example please check these out: Documentation/devicetree/bindings/pci/qcom,pcie.txt Documentation/devicetree/bindings/phy/qcom-pcie-phy.txt drivers/pci/host/pcie-qcom.c drivers/phy/phy-qcom-pcie.c These examples will show you PCIE addressing shift and PHY communication of a Qualcom PCIE etherner card. Sorry for my bad English and wrong information. Regards Ozgur
Do so in the driver that binds to the device, before it initializes it. Not in the kernel core, otherwise in the kernel core you do not have access to the needed pci structures.
thanks,
greg k-h
HI Ozgur, Please see my inline response below as [Khalid] On Wednesday, April 13, 2022, 02:09:49 AM PDT, Ozgur Karatas <ozgurk@ieee.org> wrote: On Wed, Apr 13, 2022 at 11:34 AM Greg KH <greg@kroah.com> wrote: On Wed, Apr 13, 2022 at 07:01:01AM +0000, Khalid F. Sabzwari wrote:
Thanks Ozgur for quick reply.The link you shared below seems to work with MDIO interface.The PHY used on my board is Intel's i211 PHY which is controlled by PCIe interface.I found this link:https://docs.kernel.org/PCI/pci.html#how-to-access-pci-config-space
I never wrote a kernel code before, and am trying to just hack for an experiment to write to config space of this PHY. so I will give it a try to see if i can read/write to i211's config space, during early kernel boot time, using pci_(read|write)_config_(byte|word|dword)
Hello, as Greg-KH said below, you dont need to do anything about kernel or PCI structure.So I have question, this card already driven and initialized by Linux kernel? Can you run this card inserting into slot as PCIE? [Khalid]: its not a card. the PHY is just a chip soldered on the board connected directly to Intel CPU via PCIe. if it probably has a driver that uses phy.h I think and in this case, will get a PHY id and use it to shift it after initing to PCIE address (for example PCIE0). You just need to process module file before inital process and you dont need to work with an additional processing or PCIE structure on kernel side. if you want to see an example please check these out: Documentation/devicetree/bindings/pci/qcom,pcie.txt Documentation/devicetree/bindings/phy/qcom-pcie-phy.txt drivers/pci/host/pcie-qcom.c drivers/phy/phy-qcom-pcie.c [Khalid]: Thanks for he pointers. I will check those out. As Greg-K-H mentioned I will try to write some code in the driver, not the kernel coreas I was originally intending, and will see if I can read/modify the config space of this i211 PHY. These examples will show you PCIE addressing shift and PHY communication of a Qualcom PCIE etherner card. Sorry for my bad English and wrong information. Regards Ozgur Do so in the driver that binds to the device, before it initializes it. Not in the kernel core, otherwise in the kernel core you do not have access to the needed pci structures. thanks, greg k-h
participants (3)
-
Greg KH -
Khalid F. Sabzwari -
Ozgur Karatas