\hypertarget{dwmmc__altera_8c_source}{}\doxysection{dwmmc\+\_\+altera.\+c}
\label{dwmmc__altera_8c_source}\index{dev/mmc/host/dwmmc\_altera.c@{dev/mmc/host/dwmmc\_altera.c}}
\mbox{\hyperlink{dwmmc__altera_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00001}00001 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00002}00002 \textcolor{comment}{ * Copyright 2017 Emmanuel Vadot <manu@freebsd.org>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00004}00004 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00005}00005 \textcolor{comment}{ * modification, are permitted provided that the following conditions are}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00006}00006 \textcolor{comment}{ * met:}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00007}00007 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00008}00008 \textcolor{comment}{ *  1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00009}00009 \textcolor{comment}{ *     notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00010}00010 \textcolor{comment}{ *  2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00011}00011 \textcolor{comment}{ *     notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00012}00012 \textcolor{comment}{ *     documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00013}00013 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00014}00014 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00015}00015 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00016}00016 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00017}00017 \textcolor{comment}{ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00018}00018 \textcolor{comment}{ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00019}00019 \textcolor{comment}{ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00020}00020 \textcolor{comment}{ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00021}00021 \textcolor{comment}{ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00022}00022 \textcolor{comment}{ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00023}00023 \textcolor{comment}{ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00024}00024 \textcolor{comment}{ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00025}00025 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00026}00026 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00027}00027 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00028}\mbox{\hyperlink{dwmmc__altera_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00028}} \mbox{\hyperlink{dwmmc__altera_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00029}00029 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00030}00030 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00031}00031 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/bus.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/module.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/queue.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/taskqueue.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00036}00036 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <machine/bus.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00038}00038 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{bridge_8h}{dev/mmc/bridge.h}}>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{mmc__fdt__helpers_8h}{dev/mmc/mmc\_fdt\_helpers.h}}>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00041}00041 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <dev/ofw/ofw\_bus\_subr.h>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00043}00043 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{dwmmc__var_8h}{dev/mmc/host/dwmmc\_var.h}}>}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00045}00045 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00046}00046 \textcolor{preprocessor}{\#include "{}opt\_mmccam.h"{}}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00047}00047 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00048}\mbox{\hyperlink{dwmmc__altera_8c_ab1bb129b8c62d8033fbb3adf82f284a0}{00048}} \textcolor{keyword}{static} \textcolor{keyword}{struct }ofw\_compat\_data \mbox{\hyperlink{dwmmc__altera_8c_ab1bb129b8c62d8033fbb3adf82f284a0}{compat\_data}}[] = \{}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00049}00049         \{\textcolor{stringliteral}{"{}altr,socfpga-\/dw-\/mshc"{}},        1\},}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00050}00050         \{NULL,                          0\},}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00051}00051 \};}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00052}00052 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00053}00053 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00054}\mbox{\hyperlink{dwmmc__altera_8c_a393e3a7a0fc458b154fbc319168f9ddf}{00054}} \mbox{\hyperlink{dwmmc__altera_8c_a393e3a7a0fc458b154fbc319168f9ddf}{altera\_dwmmc\_probe}}(device\_t dev)}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00055}00055 \{}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00056}00056 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00057}00057         \textcolor{keywordflow}{if} (!ofw\_bus\_status\_okay(dev))}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00058}00058                 \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00059}00059 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00060}00060         \textcolor{keywordflow}{if} (ofw\_bus\_search\_compatible(dev, \mbox{\hyperlink{dwmmc__altera_8c_ab1bb129b8c62d8033fbb3adf82f284a0}{compat\_data}})-\/>ocd\_data == 0)}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00061}00061                 \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00062}00062 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00063}00063         device\_set\_desc(dev, \textcolor{stringliteral}{"{}Synopsys DesignWare Mobile "{}}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00064}00064             \textcolor{stringliteral}{"{}Storage Host Controller (Altera)"{}});}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00065}00065 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00066}00066         \textcolor{keywordflow}{return} (BUS\_PROBE\_VENDOR);}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00067}00067 \}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00068}00068 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00069}00069 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00070}\mbox{\hyperlink{dwmmc__altera_8c_af7213e4101fcc89ee1b3438baac39617}{00070}} \mbox{\hyperlink{dwmmc__altera_8c_af7213e4101fcc89ee1b3438baac39617}{altera\_dwmmc\_attach}}(device\_t dev)}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00071}00071 \{}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00072}00072         \textcolor{keyword}{struct }\mbox{\hyperlink{structdwmmc__softc}{dwmmc\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00073}00073         phandle\_t root;}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00074}00074 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00075}00075         sc = device\_get\_softc(\mbox{\hyperlink{structdwmmc__softc_a3d3c3daaf6846e3ca83573afe5c90dab}{dev}});}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00076}00076         sc-\/>\mbox{\hyperlink{structdwmmc__softc_ab257e576ddd8bc6fc0ff771dd8f53534}{hwtype}} = \mbox{\hyperlink{dwmmc__var_8h_a06fc87d81c62e9abb8790b6e5713c55ba11efdb80257ff5ceb83d53c6167c302f}{HWTYPE\_ALTERA}};}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00077}00077 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00078}00078         root = OF\_finddevice(\textcolor{stringliteral}{"{}/"{}});}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00079}00079 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00080}00080         \textcolor{keywordflow}{if} (ofw\_bus\_node\_is\_compatible(root, \textcolor{stringliteral}{"{}altr,socfpga-\/stratix10"{}})) \{}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00081}00081                 sc-\/>\mbox{\hyperlink{structdwmmc__softc_ad4e6e2524c467e812beb5d0122844441}{bus\_hz}} = 24000000;}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00082}00082                 sc-\/>\mbox{\hyperlink{structdwmmc__softc_aad8a2301ab039ca6563ead5ead782fc7}{use\_pio}} = 1;}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00083}00083         \}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00084}00084 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00085}00085         \textcolor{keywordflow}{return} (\mbox{\hyperlink{dwmmc_8c_a6825d13eaefa21a789a4b63262099d09}{dwmmc\_attach}}(\mbox{\hyperlink{structdwmmc__softc_a3d3c3daaf6846e3ca83573afe5c90dab}{dev}}));}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00086}00086 \}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00087}00087 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00088}\mbox{\hyperlink{dwmmc__altera_8c_a5314d1d928083bcf03cfc5b3338cda41}{00088}} \textcolor{keyword}{static} device\_method\_t \mbox{\hyperlink{dwmmc__altera_8c_a5314d1d928083bcf03cfc5b3338cda41}{altera\_dwmmc\_methods}}[] = \{}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00089}00089         \textcolor{comment}{/* bus interface */}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00090}00090         DEVMETHOD(device\_probe, \mbox{\hyperlink{dwmmc__altera_8c_a393e3a7a0fc458b154fbc319168f9ddf}{altera\_dwmmc\_probe}}),}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00091}00091         DEVMETHOD(device\_attach, \mbox{\hyperlink{dwmmc__altera_8c_af7213e4101fcc89ee1b3438baac39617}{altera\_dwmmc\_attach}}),}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00092}00092 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00093}00093         DEVMETHOD\_END}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00094}00094 \};}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00095}00095 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00096}\mbox{\hyperlink{dwmmc__altera_8c_a0b5bbf55f6f33e1e98bbfb8c6c3a2f52}{00096}} \textcolor{keyword}{static} devclass\_t \mbox{\hyperlink{dwmmc__altera_8c_a0b5bbf55f6f33e1e98bbfb8c6c3a2f52}{altera\_dwmmc\_devclass}};}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00097}00097 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00098}\mbox{\hyperlink{dwmmc__altera_8c_a8bb6b4b05ae3d65a3df141524ab5d2d1}{00098}} \mbox{\hyperlink{dwmmc__altera_8c_a8bb6b4b05ae3d65a3df141524ab5d2d1}{DEFINE\_CLASS\_1}}(altera\_dwmmc, altera\_dwmmc\_driver, \mbox{\hyperlink{dwmmc__altera_8c_a5314d1d928083bcf03cfc5b3338cda41}{altera\_dwmmc\_methods}},}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00099}00099     \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} \mbox{\hyperlink{structdwmmc__softc}{dwmmc\_softc}}), dwmmc\_driver);}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00100}00100 }
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00101}\mbox{\hyperlink{dwmmc__altera_8c_a56a47c22c779c534c6bd19bb9af28e9c}{00101}} \mbox{\hyperlink{dwmmc__altera_8c_a56a47c22c779c534c6bd19bb9af28e9c}{DRIVER\_MODULE}}(altera\_dwmmc, simplebus, altera\_dwmmc\_driver,}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00102}00102     \mbox{\hyperlink{dwmmc__altera_8c_a0b5bbf55f6f33e1e98bbfb8c6c3a2f52}{altera\_dwmmc\_devclass}}, 0, 0);}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00103}\mbox{\hyperlink{dwmmc__altera_8c_a9ae8bea5f9b420689b4d7dfee703797e}{00103}} \mbox{\hyperlink{dwmmc__altera_8c_a56a47c22c779c534c6bd19bb9af28e9c}{DRIVER\_MODULE}}(altera\_dwmmc, ofwbus, altera\_dwmmc\_driver, \mbox{\hyperlink{dwmmc__altera_8c_a0b5bbf55f6f33e1e98bbfb8c6c3a2f52}{altera\_dwmmc\_devclass}}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00104}00104     , NULL, NULL);}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00105}00105 \textcolor{preprocessor}{\#ifndef MMCCAM}}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00106}\mbox{\hyperlink{dwmmc__altera_8c_ac6a46171cde29453766da31c07575252}{00106}} \mbox{\hyperlink{dwmmc__altera_8c_ac6a46171cde29453766da31c07575252}{MMC\_DECLARE\_BRIDGE}}(altera\_dwmmc);}
\DoxyCodeLine{\Hypertarget{dwmmc__altera_8c_source_l00107}00107 \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
