kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Re: How to write to a PCIe config space during kernel boot up
       [not found] ` <1342951442.155989.1649789971947@mail.yahoo.com>
@ 2022-04-12 19:10   ` Ozgur Karatas
       [not found]     ` <1021050155.256602.1649833261242@mail.yahoo.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Ozgur Karatas @ 2022-04-12 19:10 UTC (permalink / raw)
  To: Khalid F. Sabzwari; +Cc: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 928 bytes --]

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.
>

[-- Attachment #1.2: Type: text/html, Size: 2301 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to write to a PCIe config space during kernel boot up
       [not found]     ` <1021050155.256602.1649833261242@mail.yahoo.com>
@ 2022-04-13  7:34       ` Greg KH
  2022-04-13  9:09         ` Ozgur Karatas
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2022-04-13  7:34 UTC (permalink / raw)
  To: Khalid F. Sabzwari; +Cc: Ozgur Karatas, 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

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to write to a PCIe config space during kernel boot up
  2022-04-13  7:34       ` Greg KH
@ 2022-04-13  9:09         ` Ozgur Karatas
  0 siblings, 0 replies; 3+ messages in thread
From: Ozgur Karatas @ 2022-04-13  9:09 UTC (permalink / raw)
  To: Greg KH; +Cc: Khalid F. Sabzwari, kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 1863 bytes --]

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
>

[-- Attachment #1.2: Type: text/html, Size: 2697 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-13  9:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1342951442.155989.1649789971947.ref@mail.yahoo.com>
     [not found] ` <1342951442.155989.1649789971947@mail.yahoo.com>
2022-04-12 19:10   ` How to write to a PCIe config space during kernel boot up Ozgur Karatas
     [not found]     ` <1021050155.256602.1649833261242@mail.yahoo.com>
2022-04-13  7:34       ` Greg KH
2022-04-13  9:09         ` Ozgur Karatas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).