Lines Matching refs:the
9 to a MAC layer, which communicates with the physical connection through a
10 PHY. The PHY concerns itself with negotiating link parameters with the link
11 partner on the other side of the network connection (typically, an ethernet
15 While these devices are distinct from the network devices, and conform to a
16 standard layout for the registers, it has been common practice to integrate
17 the PHY management code with the network driver. This has resulted in large
19 sometimes quite different) ethernet controllers connected to the same
20 management bus, it is difficult to ensure safe use of the bus.
22 Since the PHYs are devices, and the management busses through which they are
23 accessed are, in fact, busses, the PHY Abstraction Layer treats them as such.
38 In order to take advantage of the PAL, each bus interface needs to be
46 mii_id is the address on the bus for the PHY, and regnum is the register
49 the operation is complete
51 2) A reset function is optional. This is used to return the bus to an
54 3) A probe function is needed. This function should set up anything the bus
55 driver needs, setup the mii_bus structure, and register with the PAL using
59 4) Like any driver, the device_driver structure must be configured, and init
60 exit functions are used to register the driver.
66 for one of the users. (e.g. "git grep fsl,.*-mdio arch/powerpc/boot/dts/")
70 Sometime during startup, the network driver needs to establish a connection
71 between the PHY device, and the network device. At this time, the PHY's bus
72 and drivers need to all have been loaded, so it is ready for the connection.
73 At this point, there are several ways to connect to the PHY:
75 1) The PAL handles everything, and only calls the network driver when
76 the link state changes, so it can react.
78 2) The PAL handles everything except interrupts (usually because the
79 controller has the interrupt registers).
81 3) The PAL handles everything, but checks in with the driver every second,
82 allowing the network driver to react first to any changes before the PAL
85 4) The PAL serves only as a library of functions, with the network device
86 manually calling functions to update status, and configure the PHY
89 Letting the PHY Abstraction Layer do Everything
92 useful to drivers that can't), connecting to the PHY is simple:
94 First, you need a function to react to changes in the link state. This
99 Next, you need to know the device name of the PHY connected to this device.
100 The name will look something like, "0:00", where the first number is the
101 bus id, and the second is the PHY's address on that bus. Typically,
102 the bus is responsible for making its ID unique.
108 phydev is a pointer to the phy_device structure which represents the PHY. If
109 phy_connect is successful, it will return the pointer. dev, here, is the
110 pointer to your net_device. Once done, this function will have started the
111 PHY's software state machine, and registered for the PHY's interrupt, if it
112 has one. The phydev structure will be populated with information about the
113 current state, though the PHY will not yet be truly operational at this
116 PHY-specific flags should be set in phydev->dev_flags prior to the call
117 to phy_connect() such that the underlying PHY driver can check for flags
119 This is useful if the system has put hardware restrictions on
120 the PHY/controller, of which the PHY needs to be aware.
122 interface is a u32 which specifies the connection type used
123 between the controller and the PHY. Examples are GMII, MII,
130 for these bitfields. Note that you should not SET any bits, or the PHY may
133 Lastly, once the controller is ready to handle network traffic, you call
134 phy_start(phydev). This tells the PAL that you are ready, and configures the
135 PHY to connect to the network. If you want to handle your own interrupts,
139 When you want to disconnect from the network (even if just briefly), you call
142 Keeping Close Tabs on the PAL
144 It is possible that the PAL's built-in state machine needs a little help to
145 keep your network device and the PHY properly in sync. If so, you can
146 register a helper function when connecting to the PHY, which will be called
147 every second before the state machine reacts to any changes. To do this, you
149 phy_start_machine() with the second argument set to point to your special
153 on it has been limited because the author does not have any drivers which use
158 There's a remote chance that the PAL's built-in state machine cannot track
159 the complex interactions between the PHY and your network device. If this is
162 handle (phy_start and phy_stop toggle between some of the states, so you
166 accessed without the state-machine running, and most of these functions are
168 However, again, no effort has been made so far to test running without the
171 Here is a brief rundown of the functions:
176 Simple read/write primitives. They invoke the bus's read/write function
181 A convenience function to print out the PHY status neatly.
186 Requests the IRQ for the PHY interrupts, then enables them for
192 Attaches a network device to a particular PHY, binding the PHY to a generic
197 Using variables inside the phydev structure, either configures advertising
203 Fills the phydev structure with up-to-date information about the current
204 settings in the PHY.
214 The MII ioctl. Note that this function will completely screw up the state
222 With the PHY Abstraction Layer, adding support for new PHYs is
228 If the desired PHY doesn't have any errata, quirks, or special
230 support, and let the PHY Abstraction Layer's Generic PHY Driver
231 do all of the work.
235 If you do need to write a PHY driver, the first thing to do is
237 This is done during bus initialization by reading the device's
262 config_aneg: Changes the speed/duplex/negotiation settings
263 aneg_done: Determines the auto-negotiation result
264 read_status: Reads the current speed/duplex/negotiation settings
266 did_interrupt: Checks if the PHY generated an interrupt
269 ts_info: Queries about the HW timestamping status
270 hwtstamp: Set the PHY HW timestamping configuration
271 rxtstamp: Requests a receive timestamp at the PHY level for a 'skb'
272 txtsamp: Requests a transmit timestamp at the PHY level for a 'skb'
273 set_wol: Enable Wake-on-LAN at the PHY level
274 get_wol: Get the Wake-on-LAN status at the PHY level
279 assigned by the driver code. The rest are optional. Also, it is
280 preferred to use the generic phy driver's versions of these two
284 these functions, and so your functions will wrap the generic
287 Feel free to look at the Marvell, Cicada, and Davicom drivers in
288 drivers/net/phy/ for examples (the lxt and qsemi drivers have
291 The PHY's MMD register accesses are handled by the PAL framework
293 required. This could be the case if a PHY was released for
294 manufacturing before the MMD PHY register definitions were
295 standardized by the IEEE. Most modern PHYs will be able to use
296 the generic PAL framework for accessing the PHY's MMD registers.
298 implemented in the PAL. This support uses the PAL to access MMD
299 registers for EEE query and configuration if the PHY supports
300 the IEEE standard access mechanisms, or can use the PHY's specific
301 access interfaces if overridden by the specific PHY driver. See
302 the Micrel driver in drivers/net/phy/ for an example of how this
307 Sometimes the specific interaction between the platform and the PHY requires
308 special handling. For instance, to change where the PHY's clock input is,
309 or to add a delay to account for latency issues in the data path. In order
310 to support such contingencies, the PHY Layer allows platform code to register
311 fixups to be run when the PHY is brought up (or subsequently reset).
313 When the PHY Layer brings up a PHY it checks to see if there are any fixups
314 registered for it, matching based on UID (contained in the PHY device's phy_id
315 field) and the bus identifier (contained in phydev->dev.bus_id). Both must
317 wildcards for the bus ID and UID, respectively.
319 When a match is found, the PHY layer will invoke the run function associated
320 with the fixup. This function is passed a pointer to the phy_device of
323 The platform code can either register the fixup using phy_register_fixup():
329 Or using one of the two stubs, phy_register_fixup_for_uid() and
337 The stubs set one of the two matching criteria, and set the other one to