\hypertarget{dp83822phy_8c_source}{}\doxysection{dp83822phy.\+c}
\label{dp83822phy_8c_source}\index{dev/mii/dp83822phy.c@{dev/mii/dp83822phy.c}}
\mbox{\hyperlink{dp83822phy_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2021 Alstom Group.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00005}00005 \textcolor{comment}{ * Copyright (c) 2021 Semihalf.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00006}00006 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00007}00007 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00008}00008 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00009}00009 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00010}00010 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00011}00011 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00012}00012 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00013}00013 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00014}00014 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00015}00015 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00016}00016 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00017}00017 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00018}00018 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00019}00019 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00020}00020 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00021}00021 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00022}00022 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00023}00023 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00024}00024 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00025}00025 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00026}00026 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00027}00027 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00028}00028 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00029}00029 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00030}00030 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00031}00031 \textcolor{comment}{ * Driver for TI DP83822 Ethernet PHY}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00032}00032 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00033}00033 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00035}\mbox{\hyperlink{dp83822phy_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00035}} \mbox{\hyperlink{dp83822phy_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00036}00036 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/bus.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/module.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/resource.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/rman.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/socket.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00044}00044 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00045}00045 \textcolor{preprocessor}{\#include <machine/resource.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00046}00046 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <net/if.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00048}00048 \textcolor{preprocessor}{\#include <net/if\_media.h>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00049}00049 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00050}00050 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{mii_8h}{dev/mii/mii.h}}>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00051}00051 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{miivar_8h}{dev/mii/miivar.h}}>}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00052}00052 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00053}00053 \textcolor{preprocessor}{\#include "{}miidevs.h"{}}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00054}00054 \textcolor{preprocessor}{\#include "{}miibus\_if.h"{}}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00055}00055 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00056}\mbox{\hyperlink{dp83822phy_8c_ad27cc17b25bb93134368d5eb21126eae}{00056}} \textcolor{preprocessor}{\#define BIT(x)                  (1 << (x))}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00057}00057 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00058}\mbox{\hyperlink{dp83822phy_8c_abaa42bae094e22d868210a174da55ea0}{00058}} \textcolor{preprocessor}{\#define DP83822\_PHYSTS                  0x10}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00059}\mbox{\hyperlink{dp83822phy_8c_a7b306984df76298820bb2cfcdfa74d79}{00059}} \textcolor{preprocessor}{\#define DP83822\_PHYSTS\_LINK\_UP          BIT(0)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00060}\mbox{\hyperlink{dp83822phy_8c_abed8299c66d40ed679a3a263f6891760}{00060}} \textcolor{preprocessor}{\#define DP83822\_PHYSTS\_SPEED\_100        BIT(1)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00061}\mbox{\hyperlink{dp83822phy_8c_ab132fc902c6a920a3288fd8b1de34b55}{00061}} \textcolor{preprocessor}{\#define DP83822\_PHYSTS\_FD               BIT(2)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00062}00062 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00063}\mbox{\hyperlink{dp83822phy_8c_a89dc4d6cf02bb111e3460e58148ec582}{00063}} \textcolor{preprocessor}{\#define DP83822\_PHYSCR          0x11}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00064}\mbox{\hyperlink{dp83822phy_8c_a245cafe3ecc853c5d42bd07e7711532e}{00064}} \textcolor{preprocessor}{\#define DP83822\_PHYSCR\_INT\_OE   BIT(0)  }\textcolor{comment}{/* Behaviour of INT pin. */}\textcolor{preprocessor}{}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00065}\mbox{\hyperlink{dp83822phy_8c_a0e952db0166d288e7208e1043fa44560}{00065}} \textcolor{preprocessor}{\#define DP83822\_PHYSCR\_INT\_EN   BIT(1)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00066}00066 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00067}\mbox{\hyperlink{dp83822phy_8c_a3898a1ddfc1910aeb41328476ccfb9f9}{00067}} \textcolor{preprocessor}{\#define DP83822\_MISR1                   0x12}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00068}\mbox{\hyperlink{dp83822phy_8c_a0d735b3cba73997ee5e7f2e0d2a3ea3a}{00068}} \textcolor{preprocessor}{\#define DP83822\_MISR1\_AN\_CMPL\_EN        BIT(2)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00069}\mbox{\hyperlink{dp83822phy_8c_a037a1802e2cc22df02a040a4dfe943f9}{00069}} \textcolor{preprocessor}{\#define DP83822\_MISR1\_DP\_CHG\_EN         BIT(3)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00070}\mbox{\hyperlink{dp83822phy_8c_a2cbb70eb742eed75744a3a916f69bf74}{00070}} \textcolor{preprocessor}{\#define DP83822\_MISR1\_SPD\_CHG\_EN        BIT(4)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00071}\mbox{\hyperlink{dp83822phy_8c_ac3012750139eecce8dc3556350776859}{00071}} \textcolor{preprocessor}{\#define DP83822\_MISR1\_LINK\_CHG\_EN       BIT(5)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00072}\mbox{\hyperlink{dp83822phy_8c_a5c3730b72228310024fe9da56dd9f6a0}{00072}} \textcolor{preprocessor}{\#define DP83822\_MISR1\_INT\_MASK          0xFF}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00073}\mbox{\hyperlink{dp83822phy_8c_a5b6c76c48d68eeadeababa83259feb93}{00073}} \textcolor{preprocessor}{\#define DP83822\_MISR1\_INT\_STS\_SHIFT     8}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00074}00074 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00075}\mbox{\hyperlink{dp83822phy_8c_a37921d34476ea62cf996ad8e9d2c393f}{00075}} \textcolor{preprocessor}{\#define DP83822\_MISR2                   0x13}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00076}\mbox{\hyperlink{dp83822phy_8c_aaaac9bab34bab38ccb1a0f1b4c3dcc7a}{00076}} \textcolor{preprocessor}{\#define DP83822\_MISR2\_AN\_ERR\_EN         BIT(6)}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00077}\mbox{\hyperlink{dp83822phy_8c_a1e441f7fa639899412266cb828d1814c}{00077}} \textcolor{preprocessor}{\#define DP83822\_MISR2\_INT\_MASK          0xFF}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00078}\mbox{\hyperlink{dp83822phy_8c_a0da062d09b83912994c741176928a7ec}{00078}} \textcolor{preprocessor}{\#define DP83822\_MISR2\_INT\_STS\_SHIFT     8}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00079}00079 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00080}00080 \textcolor{keyword}{static} \textcolor{keywordtype}{int} \mbox{\hyperlink{dp83822phy_8c_adc6feb9702534d51bb7e1e6f3f10b5af}{dp\_service}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structmii__softc}{mii\_softc}}*, \textcolor{keyword}{struct} \mbox{\hyperlink{structmii__data}{mii\_data}}*, \textcolor{keywordtype}{int});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00081}00081 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00082}\mbox{\hyperlink{structdp83822__softc}{00082}} \textcolor{keyword}{struct }\mbox{\hyperlink{structdp83822__softc}{dp83822\_softc}} \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00083}\mbox{\hyperlink{structdp83822__softc_a6df47fd42ac26f144328f86ef1895d0b}{00083}}         \textcolor{keyword}{struct }\mbox{\hyperlink{structmii__softc}{mii\_softc}} \mbox{\hyperlink{structdp83822__softc_a6df47fd42ac26f144328f86ef1895d0b}{mii\_sc}};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00084}\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{00084}}         \textcolor{keyword}{struct }resource *\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00085}\mbox{\hyperlink{structdp83822__softc_af250e8fc7b9d18285c542ecf76ebcf8a}{00085}}         \textcolor{keywordtype}{void}            *\mbox{\hyperlink{structdp83822__softc_af250e8fc7b9d18285c542ecf76ebcf8a}{irq\_cookie}};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00086}00086 \};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00087}00087 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00088}\mbox{\hyperlink{dp83822phy_8c_ad4e9c7143d120d933b8d8fa6a9f6fd4f}{00088}} \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keyword}{struct }\mbox{\hyperlink{structmii__phydesc}{mii\_phydesc}} \mbox{\hyperlink{dp83822phy_8c_ad4e9c7143d120d933b8d8fa6a9f6fd4f}{dpphys}}[] = \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00089}00089         \mbox{\hyperlink{miivar_8h_ae87ddbe9ffefd4caca54be68c7b281fc}{MII\_PHY\_DESC}}(xxTI, DP83822),}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00090}00090         \mbox{\hyperlink{miivar_8h_a4cc657798701d214afbeff2b27c5083d}{MII\_PHY\_END}}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00091}00091 \};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00092}00092 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00093}\mbox{\hyperlink{dp83822phy_8c_a24e55fa2dd452dec0c13fde390f89c65}{00093}} \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keyword}{struct }\mbox{\hyperlink{structmii__phy__funcs}{mii\_phy\_funcs}} \mbox{\hyperlink{dp83822phy_8c_a24e55fa2dd452dec0c13fde390f89c65}{dpphy\_funcs}} = \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00094}00094         \mbox{\hyperlink{dp83822phy_8c_adc6feb9702534d51bb7e1e6f3f10b5af}{dp\_service}},}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00095}00095         \mbox{\hyperlink{miivar_8h_af0fe8ba84ff2d8de4b480836f1cd7bbc}{ukphy\_status}},}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00096}00096         \mbox{\hyperlink{mii__physubr_8c_ac21db38f2acb040663be6eac5468eaa2}{mii\_phy\_reset}}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00097}00097 \};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00099}00099 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00100}\mbox{\hyperlink{dp83822phy_8c_ad2adc69aa49a191bfd0561465ba2b132}{00100}} \mbox{\hyperlink{dp83822phy_8c_ad2adc69aa49a191bfd0561465ba2b132}{dp\_intr}}(\textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00101}00101 \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00102}00102         \textcolor{keyword}{struct }\mbox{\hyperlink{structmii__softc}{mii\_softc}} *sc = (\textcolor{keyword}{struct }\mbox{\hyperlink{structmii__softc}{mii\_softc}} *)arg;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00103}00103         uint32\_t status;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00104}00104 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00105}00105         status = \mbox{\hyperlink{miivar_8h_a4f9acdc044cd8d94bd80432e4f01bcd2}{PHY\_READ}}(sc, \mbox{\hyperlink{dp83822phy_8c_a3898a1ddfc1910aeb41328476ccfb9f9}{DP83822\_MISR1}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00106}00106 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00107}00107         \textcolor{keywordflow}{if} (!((status >> \mbox{\hyperlink{dp83822phy_8c_a5b6c76c48d68eeadeababa83259feb93}{DP83822\_MISR1\_INT\_STS\_SHIFT}}) \&}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00108}00108             (status \& \mbox{\hyperlink{dp83822phy_8c_a5c3730b72228310024fe9da56dd9f6a0}{DP83822\_MISR1\_INT\_MASK}})))}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00109}00109                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00110}00110 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00111}00111         \mbox{\hyperlink{miivar_8h_a1c1cdb714bf40ba701256727dd6a73c5}{PHY\_STATUS}}(sc);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00112}00112         \mbox{\hyperlink{mii__physubr_8c_ac5a93e41e086c93143a04d9d4548b251}{mii\_phy\_update}}(sc, \mbox{\hyperlink{miivar_8h_a6c5cb4a5233e6b1e8a8542636e8ba4c8}{MII\_MEDIACHG}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00113}00113 \}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00114}00114 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00115}00115 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00116}\mbox{\hyperlink{dp83822phy_8c_aed36deaddd3bae53c4fd85648b045cb1}{00116}} \mbox{\hyperlink{dp83822phy_8c_aed36deaddd3bae53c4fd85648b045cb1}{dp\_probe}}(device\_t dev)}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00117}00117 \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00118}00118 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00119}00119         \textcolor{keywordflow}{return} (\mbox{\hyperlink{mii__physubr_8c_a6eae4dd21de85ca536b06467bf0a5f88}{mii\_phy\_dev\_probe}}(dev, \mbox{\hyperlink{dp83822phy_8c_ad4e9c7143d120d933b8d8fa6a9f6fd4f}{dpphys}}, BUS\_PROBE\_DEFAULT));}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00120}00120 \}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00121}00121 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00122}00122 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00123}\mbox{\hyperlink{dp83822phy_8c_a7177af199833a2de4dd768976d0be47d}{00123}} \mbox{\hyperlink{dp83822phy_8c_a7177af199833a2de4dd768976d0be47d}{dp\_attach}}(device\_t dev)}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00124}00124 \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00125}00125         \textcolor{keyword}{struct }\mbox{\hyperlink{structdp83822__softc}{dp83822\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00126}00126         \textcolor{keyword}{struct }\mbox{\hyperlink{structmii__softc}{mii\_softc}} *mii\_sc;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00127}00127         uint32\_t value;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00128}00128         \textcolor{keywordtype}{int} error, rid;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00129}00129 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00130}00130         sc = device\_get\_softc(dev);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00131}00131         mii\_sc = \&sc-\/>\mbox{\hyperlink{structdp83822__softc_a6df47fd42ac26f144328f86ef1895d0b}{mii\_sc}};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00132}00132         \mbox{\hyperlink{mii__physubr_8c_a50acf7ba3fab73b23c13fe7da8c93f1d}{mii\_phy\_dev\_attach}}(dev, \mbox{\hyperlink{miivar_8h_a8d2d38c2ee2b3eb2ccd1f0a3da5fed03}{MIIF\_NOMANPAUSE}}, \&\mbox{\hyperlink{dp83822phy_8c_a24e55fa2dd452dec0c13fde390f89c65}{dpphy\_funcs}}, 1);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00133}00133 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00134}00134         \mbox{\hyperlink{miivar_8h_aa355e0359542ffc84e9060ab4556f4d8}{PHY\_RESET}}(mii\_sc);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00135}00135 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00136}00136         rid = 0;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00137}00137         sc-\/>\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}} = bus\_alloc\_resource\_any(dev, SYS\_RES\_IRQ, \&rid, RF\_ACTIVE);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00138}00138         \textcolor{keywordflow}{if} (sc-\/>\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}} == NULL)}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00139}00139                 \textcolor{keywordflow}{goto} no\_irq;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00140}00140 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00141}00141         error = bus\_setup\_intr(dev, sc-\/>\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}}, INTR\_TYPE\_NET | INTR\_MPSAFE,}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00142}00142             NULL, \mbox{\hyperlink{dp83822phy_8c_ad2adc69aa49a191bfd0561465ba2b132}{dp\_intr}}, sc, \&sc-\/>\mbox{\hyperlink{structdp83822__softc_af250e8fc7b9d18285c542ecf76ebcf8a}{irq\_cookie}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00143}00143         \textcolor{keywordflow}{if} (error != 0) \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00144}00144                 bus\_release\_resource(dev, SYS\_RES\_IRQ, 0, sc-\/>\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00145}00145                 sc-\/>\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}} = NULL;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00146}00146                 \textcolor{keywordflow}{goto} no\_irq;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00147}00147         \}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00148}00148 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00149}00149         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00150}00150 \textcolor{comment}{         * ACK and unmask all relevant interrupts.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00151}00151 \textcolor{comment}{         * We have a single register that serves the purpose}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00152}00152 \textcolor{comment}{         * of both interrupt status and mask.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00153}00153 \textcolor{comment}{         * Interrupts are cleared on read.}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00154}00154 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00155}00155         (void)\mbox{\hyperlink{miivar_8h_a4f9acdc044cd8d94bd80432e4f01bcd2}{PHY\_READ}}(mii\_sc, \mbox{\hyperlink{dp83822phy_8c_a3898a1ddfc1910aeb41328476ccfb9f9}{DP83822\_MISR1}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00156}00156         value = \mbox{\hyperlink{dp83822phy_8c_a0d735b3cba73997ee5e7f2e0d2a3ea3a}{DP83822\_MISR1\_AN\_CMPL\_EN}} |}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00157}00157                 \mbox{\hyperlink{dp83822phy_8c_a037a1802e2cc22df02a040a4dfe943f9}{DP83822\_MISR1\_DP\_CHG\_EN}}  |}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00158}00158                 \mbox{\hyperlink{dp83822phy_8c_a2cbb70eb742eed75744a3a916f69bf74}{DP83822\_MISR1\_SPD\_CHG\_EN}} |}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00159}00159                 \mbox{\hyperlink{dp83822phy_8c_ac3012750139eecce8dc3556350776859}{DP83822\_MISR1\_LINK\_CHG\_EN}};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00160}00160         \mbox{\hyperlink{miivar_8h_af302bd91f8177e3ca317b822f00680b5}{PHY\_WRITE}}(mii\_sc, \mbox{\hyperlink{dp83822phy_8c_a3898a1ddfc1910aeb41328476ccfb9f9}{DP83822\_MISR1}}, value);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00161}00161         value = \mbox{\hyperlink{miivar_8h_a4f9acdc044cd8d94bd80432e4f01bcd2}{PHY\_READ}}(mii\_sc, \mbox{\hyperlink{dp83822phy_8c_a89dc4d6cf02bb111e3460e58148ec582}{DP83822\_PHYSCR}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00162}00162         value |= \mbox{\hyperlink{dp83822phy_8c_a245cafe3ecc853c5d42bd07e7711532e}{DP83822\_PHYSCR\_INT\_OE}} |}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00163}00163                  \mbox{\hyperlink{dp83822phy_8c_a0e952db0166d288e7208e1043fa44560}{DP83822\_PHYSCR\_INT\_EN}};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00164}00164         \mbox{\hyperlink{miivar_8h_af302bd91f8177e3ca317b822f00680b5}{PHY\_WRITE}}(mii\_sc, \mbox{\hyperlink{dp83822phy_8c_a89dc4d6cf02bb111e3460e58148ec582}{DP83822\_PHYSCR}}, value);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00165}00165 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00166}00166 no\_irq:}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00167}00167         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00168}00168 \}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00169}00169 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00170}00170 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00171}\mbox{\hyperlink{dp83822phy_8c_a274be2b2ba6c8ee7020eb7a84b08ad74}{00171}} \mbox{\hyperlink{dp83822phy_8c_a274be2b2ba6c8ee7020eb7a84b08ad74}{dp\_detach}}(device\_t dev)}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00172}00172 \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00173}00173         \textcolor{keyword}{struct }\mbox{\hyperlink{structdp83822__softc}{dp83822\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00174}00174 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00175}00175         sc = device\_get\_softc(dev);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00176}00176 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00177}00177         bus\_teardown\_intr(dev, sc-\/>\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}}, sc-\/>\mbox{\hyperlink{structdp83822__softc_af250e8fc7b9d18285c542ecf76ebcf8a}{irq\_cookie}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00178}00178         bus\_release\_resource(dev, SYS\_RES\_IRQ, 0, sc-\/>\mbox{\hyperlink{structdp83822__softc_acb5e18ad9550a01839e104851d6350a4}{irq\_res}});}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00179}00179 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00180}00180         \textcolor{keywordflow}{return} (\mbox{\hyperlink{mii__physubr_8c_af08a34e3932c19824be61fc41ee1083f}{mii\_phy\_detach}}(dev));}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00181}00181 \}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00182}00182 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00183}00183 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00184}\mbox{\hyperlink{dp83822phy_8c_adc6feb9702534d51bb7e1e6f3f10b5af}{00184}} \mbox{\hyperlink{dp83822phy_8c_adc6feb9702534d51bb7e1e6f3f10b5af}{dp\_service}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structmii__softc}{mii\_softc}} *sc, \textcolor{keyword}{struct} \mbox{\hyperlink{structmii__data}{mii\_data}} *mii, \textcolor{keywordtype}{int} cmd)}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00185}00185 \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00186}00186 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00187}00187         \textcolor{keywordflow}{switch} (cmd) \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00188}00188         \textcolor{keywordflow}{case} \mbox{\hyperlink{miivar_8h_a5ee687df11441661206e4d2922ab5a52}{MII\_POLLSTAT}}:}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00189}00189                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00190}00190         \textcolor{keywordflow}{case} \mbox{\hyperlink{miivar_8h_a6c5cb4a5233e6b1e8a8542636e8ba4c8}{MII\_MEDIACHG}}:}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00191}00191                 \mbox{\hyperlink{mii__physubr_8c_afac2ea5f0d036a16125e01fc48a41457}{mii\_phy\_setmedia}}(sc);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00192}00192                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00193}00193         \textcolor{keywordflow}{case} \mbox{\hyperlink{miivar_8h_a7aba758235b2d688fc41842a167187e5}{MII\_TICK}}:}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00194}00194                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{mii__physubr_8c_aee0c2c158db70e66816d5c1269e83290}{mii\_phy\_tick}}(sc) == EJUSTRETURN)}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00195}00195                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00196}00196 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00197}00197                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00198}00198         \}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00199}00199 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00200}00200         \mbox{\hyperlink{miivar_8h_a1c1cdb714bf40ba701256727dd6a73c5}{PHY\_STATUS}}(sc);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00201}00201         \mbox{\hyperlink{mii__physubr_8c_ac5a93e41e086c93143a04d9d4548b251}{mii\_phy\_update}}(sc, cmd);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00202}00202         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00203}00203 \}}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00204}00204 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00205}\mbox{\hyperlink{dp83822phy_8c_a52ecfaeef36bd19ec3df05ecd4270f92}{00205}} \textcolor{keyword}{static} device\_method\_t \mbox{\hyperlink{dp83822phy_8c_a52ecfaeef36bd19ec3df05ecd4270f92}{dp\_methods}}[] = \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00206}00206         DEVMETHOD(device\_probe,         \mbox{\hyperlink{dp83822phy_8c_aed36deaddd3bae53c4fd85648b045cb1}{dp\_probe}}),}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00207}00207         DEVMETHOD(device\_attach,        \mbox{\hyperlink{dp83822phy_8c_a7177af199833a2de4dd768976d0be47d}{dp\_attach}}),}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00208}00208         DEVMETHOD(device\_detach,        \mbox{\hyperlink{dp83822phy_8c_a274be2b2ba6c8ee7020eb7a84b08ad74}{dp\_detach}}),}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00209}00209         DEVMETHOD\_END}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00210}00210 \};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00211}00211 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00212}\mbox{\hyperlink{dp83822phy_8c_a489bf6f91e1d78ba96639d9d924865de}{00212}} \textcolor{keyword}{static} devclass\_t \mbox{\hyperlink{dp83822phy_8c_a489bf6f91e1d78ba96639d9d924865de}{dp\_devclass}};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00213}00213 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00214}\mbox{\hyperlink{dp83822phy_8c_ab2d2438912846be67cdf9cd7a55b4437}{00214}} \textcolor{keyword}{static} driver\_t \mbox{\hyperlink{dp83822phy_8c_ab2d2438912846be67cdf9cd7a55b4437}{dp\_driver}} = \{}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00215}00215         \textcolor{stringliteral}{"{}dp83822phy"{}},}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00216}00216         \mbox{\hyperlink{dp83822phy_8c_a52ecfaeef36bd19ec3df05ecd4270f92}{dp\_methods}},}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00217}00217         \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct }\mbox{\hyperlink{structdp83822__softc}{dp83822\_softc}})}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00218}00218 \};}
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00219}00219 }
\DoxyCodeLine{\Hypertarget{dp83822phy_8c_source_l00220}\mbox{\hyperlink{dp83822phy_8c_a50282371ff4baab41ff32188b5cde2fd}{00220}} \mbox{\hyperlink{dp83822phy_8c_a50282371ff4baab41ff32188b5cde2fd}{DRIVER\_MODULE}}(dp83822phy, \mbox{\hyperlink{miibus__if_8m_a4cbc1805319b363b9b338406a4b2a683}{miibus}}, \mbox{\hyperlink{dp83822phy_8c_ab2d2438912846be67cdf9cd7a55b4437}{dp\_driver}}, \mbox{\hyperlink{dp83822phy_8c_a489bf6f91e1d78ba96639d9d924865de}{dp\_devclass}}, 0, 0);}

\end{DoxyCode}
