Skip to contentSkip to conversation

Marvell Feroceon-FR131/Sheeva-88SV131 cpu core support

PATCH New Prafulla Wadaskar 9 participants 68 messages Apr 3, 2009 – May 21, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Marvell Feroceon-FR131/Sheeva-88SV131 cpu core support

This is ARM v5TE-compliant processor core with
MMU and L1/L2 Cache

Reviewed by: Ronen Shitrit <[email protected]>

---
 cpu/arm926ejs/start.S |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
cpu/arm926ejs/start.S +5 -0
index ed4932a..08ec955 100644
@@ -214,10 +214,15 @@ cpu_init_crit:
 	 * disable MMU stuff and caches
 	 */
 	mrc	p15, 0, r0, c1, c0, 0
+#if defined (CONFIG_FEROCEON_88FR131) || defined (CONFIG_SHEEVA_88SV131)
+	bic	r0, r0, #0x00000007	/* clear bits 2:0 (CAM) */
+	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
+#else
 	bic	r0, r0, #0x00002300	/* clear bits 13, 9:8 (--V- --RS) */
 	bic	r0, r0, #0x00000087	/* clear bits 7, 2:0 (B--- -CAM) */
 	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
 	orr	r0, r0, #0x00001000	/* set bit 12 (I) I-Cache */
+#endif
 	mcr	p15, 0, r0, c1, c0, 0
 
 	/*
Signature · 1 line
1.5.3.3
#1 lore raw

PATCH 1/1 Marvell Kirkwood family SOC support

From: prafulla_wadaskar <[email protected]>

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0

Other supported features:-
1) Doimage utility needed to create binaries with
bootROM header
2) get_random_hex() fucntion
3) SPI port controller driver
4) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

Reviewed by: Ronen Shitrit <[email protected]>

---
 board/Marvell/common/kw_lowlevel_init.S        |   45 +
 board/Marvell/include/core.h                   |    4 +
 cpu/arm926ejs/kirkwood/Makefile                |   52 +
 cpu/arm926ejs/kirkwood/bin_dep.sh              |   50 +
 cpu/arm926ejs/kirkwood/config.mk               |   25 +
 cpu/arm926ejs/kirkwood/doimage/Makefile        |  112 ++
 cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h |   88 ++
 cpu/arm926ejs/kirkwood/doimage/doimage         |  Bin 0 -> 17712 bytes
 cpu/arm926ejs/kirkwood/doimage/doimage.c       | 1341 ++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/dram.c                  |   49 +
 cpu/arm926ejs/kirkwood/kw88f6192.h             |   34 +
 cpu/arm926ejs/kirkwood/kw88f6281.h             |   34 +
 cpu/arm926ejs/kirkwood/kwcore.c                |  262 +++++
 cpu/arm926ejs/kirkwood/kwcore.h                |  141 +++
 cpu/arm926ejs/kirkwood/serial.c                |  187 ++++
 cpu/arm926ejs/kirkwood/soc_init.S              |  156 +++
 cpu/arm926ejs/kirkwood/spi.c                   |  213 ++++
 cpu/arm926ejs/kirkwood/timer.c                 |  165 +++
 include/configs/kirkwood.h                     |   46 +
 19 files changed, 3004 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/common/kw_lowlevel_init.S
 create mode 100644 cpu/arm926ejs/kirkwood/Makefile
 create mode 100755 cpu/arm926ejs/kirkwood/bin_dep.sh
 create mode 100644 cpu/arm926ejs/kirkwood/config.mk
 create mode 100644 cpu/arm926ejs/kirkwood/doimage/Makefile
 create mode 100644 cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h
 create mode 100755 cpu/arm926ejs/kirkwood/doimage/doimage
 create mode 100644 cpu/arm926ejs/kirkwood/doimage/doimage.c
 create mode 100644 cpu/arm926ejs/kirkwood/dram.c
 create mode 100644 cpu/arm926ejs/kirkwood/kw88f6192.h
 create mode 100644 cpu/arm926ejs/kirkwood/kw88f6281.h
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.h
 create mode 100644 cpu/arm926ejs/kirkwood/serial.c
 create mode 100644 cpu/arm926ejs/kirkwood/soc_init.S
 create mode 100644 cpu/arm926ejs/kirkwood/spi.c
 create mode 100644 cpu/arm926ejs/kirkwood/timer.c
 create mode 100644 include/configs/kirkwood.h
board/Marvell/common/kw_lowlevel_init.S new file +45 -0
new file mode 100644
index 0000000..61453a7
@@ -0,0 +1,45 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#define KW_ASMLANGUAGE
+#include <config.h>
+
+.globl lowlevel_init
+lowlevel_init:
+    /* Linux expects` the internal registers to be at 0xf1000000 */
+    ldr r1, = KW_OFFSET_REG
+    ldr r3, = KW_REGS_PHY_BASE
+    str r3,[r1]
+
+    /* save Link Registers */
+    mov r2, lr
+
+    /* Enable L2 cache in write through mode */
+    bl kw_enable_invalidate_l2_cache
+
+    /* Initialize BUS-L to DDR configuration parameters     */
+    /* Must be done prior to DDR operation                  */
+    bl kw_cpu_if_pre_init
+    mov lr, r2
+    mov pc, lr
board/Marvell/include/core.h +4 -0
index c413439..ecc4682 100644
@@ -12,9 +12,11 @@ space). The macros take care of Big/Little endian conversions.
 #ifndef __INCcoreh
 #define __INCcoreh
 
+#ifndef CONFIG_KIRKWOOD
 #include "mv_gen_reg.h"
 
 extern unsigned int INTERNAL_REG_BASE_ADDR;
+#endif /* CONFIG_KIRKWOOD */
 
 /****************************************/
 /*	    GENERAL Definitions			*/
@@ -91,10 +93,12 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;
 #define _1G		0x40000000
 #define _2G		0x80000000
 
+#ifndef __ASSEMBLY__
 #ifndef	BOOL_WAS_DEFINED
 #define BOOL_WAS_DEFINED
 typedef enum _bool{false,true} bool;
 #endif
+#endif
 
 /* Little to Big endian conversion macros */
 
cpu/arm926ejs/kirkwood/Makefile new file +52 -0

52 lines not on this page · raw message

cpu/arm926ejs/kirkwood/bin_dep.sh new file +50 -0

50 lines not on this page · raw message

cpu/arm926ejs/kirkwood/config.mk new file +25 -0
new file mode 100644
index 0000000..000eeb4
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+PLATFORM_CPPFLAGS += -march=armv5te
cpu/arm926ejs/kirkwood/doimage/Makefile new file +112 -0

112 lines not on this page · raw message

cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h new file +88 -0

88 lines not on this page · raw message

cpu/arm926ejs/kirkwood/doimage/doimage new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..9fee11740454ff880c081a64be0d692b1da4c19a
GIT binary patch

z4%DARxz at sc7EZbLr2&{}A)J2l at 3e5c{}KydfSU9tEWFL)|EYz)Y0;mx at KY9jgM}w8 ze4T|~jhgc6EWFIZ3oLw^g+FZJ)RX)H3lCZN0~TIk$$!Yg^DO%97QWG<f6Kx@wCIds zUf;9m_bOEU2sOtuE!>vZV&MoqN&l6F=UezB3;&CSuOR+kZV%FVsV+A+xz$0xL0gJ z^o>b at yo<K;HMn8sHoUb8>*a>%IoPqCz0-Dj9AwM8)Fk(OMO(tB8dCRl?sG)J1iu z-duBYK#BDg(X-Az4Iit*>6xfI~}oh_jVc*()G%KA;By0Rt|_Jh=*haxqi)>l&# zswAhsp+VF}>e#(HT<NQ;hC<bi&;|lFHUxD)<TM29bhJaC4StA(kjmP6@KIMw@mgQ7 zPE<Ge{o>jsi{~$>m{w4fh6-Ua)-zWM|JwhuC8Yk^ZJD)8a&WC=F(t at CSr-R`7jl&y zx7u<fo+Vx)5!Vv<cQ_Ur{XPtfp8g*84<KNkhFvbi8sH-k59?S%tt!^w53t5W*09Fn ztY?kIt+O5>L?dgD5Sv+J!8frUg&f8D0wK1t9xcQ+*3fV}>x+cg!P+at{j6cgPSzI- zv5Pf=a1U!F&qr7zfjr9k^Fr)pJywXvSzju|0oLP$IK=ugA<B){qo+N|<1i(;3U(wb zza+%dM at 0WuZUjev{wn;XKl<}&v0PcHll{2zX?cLORJX+GfdE~cYL_ at Y5x__ywO8Ww zNI)aLOXBoQU?TDD5~qg(oaa=N#ObL(3GsS~(_?|T#Meojo(n7@zD(luU|<>Xxe})* z1FMJ^N}LItRt>ToSqHPpj3{;>ES><aUpSfI?zbG_fs_F)8m0A;wL3e&j+>=@0Kc zAh4ZyyTmyYf%}Q?l{jZ4u#5OEiF0NGj}YH3an4X+FYzXcbEX0Zh}TP;GZttkz7BZN z+qW36L{IfDyK#A-<I}c#Ge~h2L8Cs?MeO;4DWB>j=5bCJ?&1Sk67J&WIOVwd0!uF zi9M$eOMU}Pt5!dKWV^g9-ljPo1h|M?b6_(z%qfld({Uy%zN&w>8|^cX+&(3_!lWJ z+U|OoP5onHWU|NlgEZpfGc{y?X7Dxc)^EKg2X{#o6vA at W$Hp&(SUcU}UE|k8S<k zP=q>|OGlgK9&g*)9B*5e>qzvlE1Gge-t)E{fjlsnOFd@!XtOjY+ZF9_N8fVCp1bpX zNx5m|3c2w-NzqS@$Ddy#sD-!fuG84NjlWFlFnWJ?a-<ab@kNn050cO5l6@X=>BEmF zi%#@p9Zzz|k3EsoP{VNlQ?$d?{1@)Dk>^+6QXvOgxuW^B8%x|=JKBuo#A9dv+TU-u z^OBA5tXb+YIzBoc{d9!)Zb~*UDSD>))qXirN76IBrIp;~3U|?A)$DBa4AnS#sK%V3 z8pjOPIBuxMTt}nPF at 2j<DtbhVzT=_h_mnY4KGesX*+pIXQu${(-trj7r*D(SMvu6o z@3<nb7+oKAHy@=dR^K8$gG_??L^c!2KA73LFweaUxx44{vBbt6|o2S$7o8vtl$LU zZUw(U_^5*aO!$C;J&yr?RKXJn?^3WFX9ve|=gnffC4W1|+N^j^5Uy8n&aVJhDR>d# zRSIq)yhOo|5}vEzlZ1;EJmzu06BWFMaIS)P5YAEX3Bqm#=k5c{sfKO=!lxDdIN_5D zP7;1z!6j{gyDWafhZMY*@LmPKPk4l3-<%QU%_h#Z&UDA!c7XEPoL-(58;4<50Gb# zf=?1&reN&=;DrjVCtRZ7M+r|>@J7nf6r5!H7zK|x2-u_G*@XK(mbUAJdlmdB;Zq7u z5<a2eaZdn#*3sUs;Du~|+|mAsg151Kr=xwlf~A}mM|-1!50Jmc(Y{W>|4dtM1pM at o z_>w#~l4<{KeMm7#BsVml-ipoKbQv)Qm3gzfv-C8=T6C7mY}y&)9wQrKvn?oIdfJE; z1BsU=jaUhREl2xgqC4mT>w7<oZt#h=e?gr6O%lw(wlq8QTd&N!pW!9!W!tdqw4H zP|%??^lTd98dB8f)6jD^fDkO!_L^rblaIU)R%_DCrV1{w>YvSzl3(gFFPhT{{?Qy z_O^*=a>4Ae-g_PZgSV}{KQC5;>>B;KG)Y+|?z}kpXB7&v>pXNt$}p!J)KQjF>3A7 zFHSz=V9F&^TvAfkK=vSs4?39td<M=fKSiP0NHU%rXlUG+=Vlhp2F*BZmY!-V5g4P| z(d__8YV<5nmN+Os1VxRWWwde{QcvRSHb{rd99_PB9v$xdC_{%=RlG at O6sL7?Lx(O0 z<?^%+Zljd}koxLSI<z{vyoqtn<%hq1n4!Zhj&6I=?ISr0yxoKv^BlzcsCz2|p;=A zSvq437V4jR80a9sxE%dgoJXe(nL0g#Ik)30cR(jB7U=YI2eF_1oH~J}Gsdu$I(ey+ zTvQA_-O=$FI$D+ at Mj-Vj2l3xPv}^=1^)wdzAj__H at NWYDxx5|!Aj8|emmHTRJyi z&I1Kra8M?KqN2Yv~r=RN{7<nVMmt_Fpg6P?tymXkIdAe#?kH9ASoT@LWkuJ${tXZ z4s(rGCXrMJ?g9q+VZ5WuZRgP;_I#Rl9*N753|xbXwcz59TY9CgJ!fceWm6MrNaY zE^lL;bNRuQsY8{cTN_ALJZLf=u5}Q90HPHSAR4Vqm8oAL!UlQcVn?sa^Jud1y$o;s zH|E>+#^eD_FajKsa1gx%nt*7uGLfey4W-FFj$SWfv~&67?RPUYS?1{W5V~1Df!CqQ zbO$j8qU941jaF_XsUIQe2KnR at OrmYv_2|Xq{52zS03B51<v{ca2h*3xBvVXI&$2<{ ze&OI0mbh#qb_n8{5^~$ybaB#fFueo|m8MNl&%7i)-(_Ss-Qg16*gDg%mKbLO70y^ zB~$d@o6;zwbsSQj8E4%;<@-6{WvRfjkRziGj^ZE?U%7IZ#4HCgooha7BeDX^BEp6 ze)GTm{mC<!INJ%|fI^mEIm2IxCOC~AeX;^_^e-qt(=S&5m*#$lfRPZO#>ZLVR=D4k zXN9MB;M{T$TZ8Bj=lF2 at 4p=O-rL?8<DnRB;vgOph?2wJmc;-esInn$eiNfwN{Ty z*(1R{+DL4}UvJx-nL;sMCX}@BiDG_ZgK(rkwOcBW&z!$&<Q|sIvBPasM3WBRv&b^ zW<nL-h?y}Z68Ck(9#Wmk%(!a1fr1}ajYZzJ8z^{>Lazc!!9Pw5#^FFfE*?ula+Q=! zm7n+tIBd5Vf5>zUxWqveUXkS9O&~i_Mt$y^6Wlv#z3DwAj<tuJjOme&<)WC=^MJ? z4=12Y_8GAHAUeX4^E0e|LN!jYtbS6VS6Wsd0;=3e<)sBP59<x)J|%T59FtHzW_#OK z(u==N%Uek=K9!cYl3r|2%cB7Y@4+9)yDB*sp=QVJy?;g^Pjxgjqam8$@^DA8qp$2X z<<Vh6*UT;i>~II;DlmHYCzv;@jV*sPV?0S2rO%u4IAfHb=!}hq6by>(n(^xK-t!hG zBTl40FW!Zt<N!}+jM;_}n))rcj+Gv5j3ypMlh7|P_Yp86-8~~ZOS?H$11T&rO7&! zB@LiO$4>8UiAZrTy9TJK^=gEmGA?>DCwj(pS%34Jd=}H(iHC>6NKkoWOLuC9;{8?z zZ+pH5)?t!UnrZ7gc4myaHe6)NJ>DqqPJIB)%(xV{v^(CFc at cMi2Jbl4a#diCI#*z zuPyMBnbP=%3ry(^Xw);(ltUV&-QN9j7q2$Tk9phT+)TGF{f|_O8e(V05Dtw8L at Qk# z{>_F^Xty+ at D;y)Wb2w%|gwzV!Nm1wx?OLU+<=xQ)r!<QhPtL73b{l-Df?>Ef#?`D2 za&B+z*L2baMtm=Nm|?epCo=!&F}5Vl)uW9EA4j91<HSEYFM0elo>sK$>x|8LZZk%9 z-UmFXTEAheL8}x(-XE*hV)7crdC69V=aGweOyOfBK07ZNk+?Uu0GefN0Y%Wxu?6Hl zi7lY3XJ8dAK}TgucI3{p%vkL))+TN3FHs|YN$Q!9+GE^LAPP1qJ)qay68FX)!?2&J z$6SXVM*$~&?+hsRD>Nv at vLfXswp8ig1#SbkuhPeR;j|6yyP8n$jJQ99PapA1JcVm z+DfNG%Q3zXN=PY&D9gRcw!+|ySZ~8pUaxrv376EeU>-L!^!(@s=xo?F6_9GyVE) zY+1uWhOr5q&<nbH=>KJKywVU%H-TyQDQ?t2o8(m*Xi!rb&+w%Z5>E$!eu4heg_ z$s7lB=feGcm}b!f!TXu;Mf8{}`f0W|#s|zQVza$1OTfdC$uJODFDDUphaWzwbdG%4 z+$a60D=q(k!P8nk#<ARa?4Qhs67kp)$frR($%DdOB>5X~8AlKUvv*S{En3B<HF={= z6(*aN?9EOOlq=aZBl$F7v$YYjn?DwXLVRb2T4>pkDN=tlVX$3{+;^aTdYJzO0)mtg zqr8QA{6$hIhJ|@KXc$c at Y7c8mZSo{fy$Ky-?U?Uad!)cxj at Deg?exOWFiProNXMO$ zo1LRFFht}k3g(Z8sNM6CdQHS8>~Dl at 85KR_NMU}rD7V;@=o}d$kz5k2VTa)vVA}b z7}m-{kz1pQMexp$1134(2#S3c-ggctDQ~}FQKEB5 at 5hAWsn1XY9)XOW3+;T at G7A=) zF;0q6+GVyr3r9s?%sZH1JK>aN?&!UNy^gm6yVmcP=L at sr+^XqNCkKz?r3S3JDT8e zRp|L<t30>9nypK#w6J8p44rc&1e+Ti4Pqv%IS__P(_qKRleR7hCE;d21q1FeF}r zg=T4&(Gh(m`w0g7q-Ts)_H%VZbH;BkruzeM8L=)jbI#brnc-Te|1Jg9I<0$+QJBzZ z;t)snwtNB(a$bqKG54{N+4m+&J7zvec~5}@zYxH&vJVorT<;kxX#@D}NTt459Fj?c zRLc7ov at wHx6$zM6u$x~MP|fJ-NRAtM7}ZHnK7QE}BM*1HGH&EE#wF2CS98CZjnn!t z+#mGprHuPt#|q6&@VwOgn&6gvL~h9#%9Ms<*4?`qb+q{N;GTIxpWq0;JZJdr13mRW z_+8K15|L;B9Zg2;C``7F1WS|=w4WlMJ7qZ+I9;Zpj+Y)K={K-%Yw2qy4iEb%z!=UM zD|4Hr&l+VOv$WeN!%rp88)Z3W=?SB3j9L1!Q8vyjJ!zEXMiUG<OvPn#UU;7dWS2FF zoELfXW?(mZ3Mv at KFd6wnPQyuRXeEprVU3)+_=Ckfvvj)7o|G(bzK|i{DJ at nPeX50 z+8=G78y}N^BK3=J0l!D2A<5))Lf2Hx@Ru*Gh1nE^sr@?lI%i?s<S8G3LYYM~(R~ ze6KMdhCgo1hv5f|7r#DF&~Dv8}oBzpi+!Fr6n~^pn-|l0>zXcO?lMYy724iR1vTa zSO{8JeSIDE2ID{<Z%8uSs#7E(x0nE5BclX@1v@H!Y~Gc@>%GKKsr7<z6RhyiO# zamYzW*Zx<X<D?T@#yBfDP8G&UZ&);ghy;_Wpd%U^ZM(NU{X1oK|m3G4)bei54c9 zzwIN^Ll{(TBL~=PQn%|}JJG?5f}WcSmQLB79CR>io^aBt_q_s%N0c0+yWCGj^vdt z)LE28PG%Hb$p;u~^6@$;X{AW_;PxQ70AoevSZ)r)%oMlT2ZoDdxOnb3#@AthN=#}L z9+#=qIShwQZY&Qn6LVE9Wg=4B%yFt38-oC(Yc7+0c<Y{{2d!K8jTb1u6UpsCnkG^6 zw)_VvF_x(Ej%#Fb&%pu>*hXs)Y~@P_T2RxPL9E;{}D#yS)&IxqMC8&+k<SDM0xw zl?G5MPjG9GUbxBR4O(nM!uzuGLC;^c_X*IcZxf-PbB-60yo<d;&D@{^8MMS>FBa zwkGA&Bu;C2KK?v4>B;i8Tmh|np36mTb~!lInh$!uMh?W&Kf>Hb9iaCJn3Tin at N) zCUkJy3arj>#SSn<d)(fZe}zFkFJve%f(m$S1@0J9fjxgZkNu=s3fQCjGRz-K70cYw zV|>&jw~|clK7 at p5k0<h!3Y=KK?xABVD7aPn5UatLRw4BR+_tNL!;nvJQ6YY4H0nb z(7}kELWD5j9zmahh?J*|Ya~OVz@^Nl}BoQcA7KJ22SDUB=c#DCDLqVr6-GxzYR4 zTSjlknemej8?7EpchB6FFS+yLReA0c7Y4AhUQ86A)w@5&>haOlMr<;G7k|#bFFnW} zFaDgQ&KPAg-mKN&Z8<Z5Z1h@7!yEem=h&X{>E-cnh$wq#9jm~^;7&YRfM+YL9!X= zUvJxGa at J?=<Ct5 at j1&1ykl%4;ggqzKGGgd2M*R9e;!N@qHkxR^C-R)xD%%n9NEm!N zF6liB&mkpFr_yV=nNkw69XE-#6w>jdx3}d%{x}t*qOR08=PWvz8bM!2<nWv(T+i3 z7U!9Z_J(*_mT_#-3rt0w|HFwUkK)J5kU_>CH08~gDNh~_nfu~$@nQos6S5B??emae z%CWrr$4NKAFwsQ!cr)Ci+<<6YfF726a^Rl0bPr_OhLIk92P=LV@?lhp&g$7Y*ph7h zoAENYZOJFl)UxC(8@ZfLwYMQmEExN269-_o&#T)aZa@BX(PU)4_HFBA#P-Zdt2Us zbH28Zr0*=YEbd5-&oEZ59XfC&L|evckv|NM1=3SjArPGrhS)e;U^*;@WeOY=7Nn>6 z4%uKCa+y%6j+Zi(;_|Uh+A=^%PsJg_snoo|0 at c(ZR_ikbCghYlVwLosYX%F5$)JWt zQ!@p$%67++AwBwzTb~<^aWdSg4WHuv(D?+MuS7ESz?Hm-EacAo^nb&S?_f<kf=BMJ zQ5n8MzsQWsIED#Rz-#W4iep_&C8m6f7@t5)u7cFfjLC%jRodGcdjO7$CeGlm(C=tU z5Ec4uro6wQqXXzDZ<*Jc^2b7+AE_iCMU%euMF>_;_;JR@)-ZmSPPQTY1#(~+>^*3 z0&p(jX4?XPSZ9)Vdq&A=lCKRZEnP^c8soTiF4jB;{j$8lLWtsdlw89Yd~RAsH1R$) zS5H0S56+fJgo|Ev!vhhJO?j_HVH86pE~oZs1!))0KBT-(yCr3)<dHstZ8zAW2UWJ zrUTZ1=<1CZmmpPITc0{wQ9U}ZX{bTeDn{g_2N?r7kYdkHeKgTWWAzP|<1zOg)Pqkp zR+w^XT?u;6zO&$x;CL_nLA7N}QyUsxFhM#RYRWSzJn$N)PqxA@=Q<N^Lg#pHp&8?F z(RTODBl?x+x=*_hI&L3<@+3_usxD-UVjVXqKTu@x{K5e4E0tX6X&yc*=wQZnp4N zA>Hyl*_G2Q^l|Aq!?QOTEJ)h#u#5F9NuNovYtYg&wNu_F!9!SMGKcBH2h|y&LgRf zAEm(LbnUr1>acWx1Jeuf=_R*6V(J*KX}u at 8{vYm*g!F*nGr)C6?Xk+~l8r506DP zMnGw=0w$IAc5La*GRu4M65*GN5K!?p>Vr4(c(2E8t8_F&mT$tj^ZLi)q&IU*Z{$zW zqq*0Ix{zqICb;C;8GoUQpaEYq)DPPJaE}W;X8)-;c^y2+8Mohw)jwf}30hU)+p0 z7h#rsub1N&6%-bV6_NV-P=oHT(pH2PXjT5(gO&d9EKO**miiiQ_t(^DB_(Au3QMMG zQ?z+Sg9t?>g(MUXCdyQh9aD!$F!0nBOm3ZSX^hDXX;l27g7puL|#DZ>R_d at 9=9A z1OCQIV#>{0eJHFCMH*EZ!fV-eRb&VU*9U8YdXOfK61bNM*feE164qbSdX-BX|K^ zRM+^z0kJ+5(i=jxq8_B+vYEzcR_(x7t#Y5UaJb#3p2r7Oe4WSLcVXCPAwXMKIJT zQQFWDYS8dLcRgA2!&)j>~_9CUYAK|5c!QZnQwe&QXycYFRWEI_<fw4QDURWFPye& z6#f>=zadRkzd8Rw5O^n6s(2sv>QXA8try}LpT_!gEq_%!luoxjlgrEdL6Xz*R|C! z&);C<Yc(mLB3Neuc&A-k9q{|%6bLhwL*+KOTZKjFR*Lt{TlqE(Fvgj)YTfq!aaE7 zeIsm}HA+mm(Gsa|s>keV8Yg27{l7-~e~sn;HJqO{n4dMA2q6Ot+yhsz+95~_hNYm% zay+Fxb>0}PsTrzoU1d$A%C9MlpmNP7ej71mp(V1)AJ(axawD-|osXW<;E}2ZU#&I~ zfQrFVtB=3YU&%hKBa#;Z+u#p}2lp8;!h#0ba<%lu)fyvMSwkggWnp8rbq!$oLx7B z0?=DdgN$$5xxx|}4n-O&F$;sn=cKTY>L|aDU}%Q at l{)4&R6X?Anv!R^%^I~T82&aE zG#8@}oiyG8suCJA!CppDkK;RLueDKuEr-9Qkx-U(c%n!eENVFppXiEUyamfU>vwd zOu313Td^@%r3W<5>7vqAYAMU6$#$rhOfH%+dHS@;Gm4R=mTLOOaIk_ao?SFwxH1 at 2 zz3P0mevAzTDnoTTzSam!O%_jEfY=D?T7!QB!WX8j-=qbmZj_(tSdlSMA^jkf!WutF zVMrl2X<REZdbu7mR`A!I7Serx+v<ev%VmIDc6_!GH9^EB*1232G=%<Jrg6%UmpAyW zd|l<QL>$*>Un!b4S({c^TrycJD3~-$yKdff3$<lTR?O?{yFm5zS5{WkhOkB_7R_1Y ztF1-&q2rw8D<*5x=Uj&*gO7oxEWut?<J&}c)FQ<*K0|d?VWc4hnO|GDeBM&&Vai<$ z=huT(W=3>aw)lD^DGqSEuO?U}!(hd{8|O)XVsBYwWe2InENziYezJ!>|Fa-gV1mF} zq|IWgu~N0nfim?^RErm>Xp$VjN;sSlNwND+%j~aj49Um|Pe!7l!c4kKg3=%D1KHRq z+R|rwrab24^XbCsM)#{|BZc>CRW$<zJmOYwWDDPspX^8XS~{W4D3PRwX(fM&17@R zlnDuW%gR6*nOd9T%)x3-)Vlc_cCUFj&hDC6M}Z0VYJoI#>(*64(WGwefF3c!IZf z4eq=nIrWmM at NZR1!$M52LFj1j{TP!Q?)e6F at -ow$Z%8}!F_+1_fuYn<XqE;isYJv zRU5=vtZu_7UJjncb@*CNZgq%qf-+Qa?(x-Kjhx8TiS&RR%1&kJgO{%c=c1}j*zb^n zCTJlXbQ*$O&zq*!O}d8itNAINR_#L<wZ2tymd7?Q&&jXC*=zao>z5<RGZ67{ov*$C z=Rui_sPX#Xh7JA(=58FIs*s;e;DU5T!E^Fg7x^0@7pVQ9-VIIlob>4)c>dy#OaG zc}!K!l7F$xI|~B7%5R4wI6qkQ{HjT+b72V%g1F=na+ZcIWj=NWsKE1OIDJ0n<_QIT z+(%(nIPFVxz2=>N#nD6b$i}NQ;8(?!M3M*|mKDZ at Aa(sjz6|xfOj_=b*d+zAGJl z@q}yJ-25x+V8sG?Ky>#^8>dhhPe62_FXh35sxKxrdGLjJjZS&e%&Y$34as*<Tw6 z#rT8s^LXEh4?j+!UWQu!GLG7H$8zD?>~UQ&+U?$ory}IXXM^H?@bUSBn0JvUmNoxE z!fY==*#=q=b(*#yI_z%uJ-n?ExaaD3)a=61wS7Pd>$xH#M~bIj3^rMq09%L_J_9N z(?`B8O3*ts1E_>M7)lIA9rLwd=4lt4zLXOqqK)FsnG^}N+|GopvZw-!o4kS55H~I zQ1DqHzUdbH at iWwpcBmGjF1@Jl0uJ!+zFKhWXLlNYx7#xo<%=jYP|8qNqEw^Yj&e83 z_fdX=(uQ&j<pq>CP(DN%j&IP%qI?l$21*&qN|b7p+fnXD;aK#keTi!qESRND#3$C1 zwBmxIf@#>z3%^=8bJ|z5iOaFf7GcH7_9 at e+VT=C%;-3C@$^QT3rj-TZ0Ke|_trrFO zT-V=FFAA`1{RQ*pFP at _NHdxq(x=6wLNDv>k2dhK at u>fy43#vBNg*VlzT5nJk>#i*W zsQ|6PUqgNc)Ys at 75Z@*j=>A6htp);82q$fyDDVd=s&TL4uRyLEz(fJh at L>$6s#_~T zgh*d)uoA<CAO?R5q--T;eHh%lpZ3@3cIbU(&9%c==US2fPXQ3F2m2z87u)bti{z94 zp8yCNaQouJG+q->Yy^2XaIb9lA|De9SR;4?Dzhxwf}~uMnzC8){A@^uvINItIl zL*P4!!W at 7~@-SzVp>W-kk2zu|5atH^A}_D&P_RbixLn(JVGz6!ksg=*SyrPk9}s3v zXa^tlbB+sC+=?<1g?!8 at z2MUTJMG}&<ayiXV-CszLzl(JdDZ!w;6 at HavbKs6X0Xs zvM=)S+K6KF^@6V#e7kHTK_ef_T at F6}Ul!XjImwA=v@ZIN*H#o;9&>IZjAb6TFMHhY zqJez0cL(@(fUlYcSeMQBec(2q{Qo83<e}v4aqx{xxIN?M2(ii*hT4|*3yY6)%*Sc ze=+DU?C4=p at HL)k00(fodg@gO4BRHi6HU0a6<70L;0dJmz%%e;Zv^8!E|1J)S|a z$6bQGX9)uLY<a}_Bf8DUJ!%>F>d|Ij<Y761V)M0wuN{2$T#?t7{YStYpZf6!jBfBv i25euN1-you^6ZOzV;lOXpd?0ox%z2w2h#)`Th^~{+Sp6

literal 0
HcmV?d00001

cpu/arm926ejs/kirkwood/doimage/doimage.c new file +1341 -0

1,341 lines not on this page · raw message

cpu/arm926ejs/kirkwood/dram.c new file +49 -0

49 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kw88f6192.h new file +34 -0
new file mode 100644
index 0000000..566c471
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6192 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_KW88F6192_H
+#define _CONFIG_KW88F6192_H
+
+/* SOC specific definations */
+#define KW88F6192_REGS_PHYS_BASE	0xf1000000
+#define KW_REGS_PHY_BASE		KW88F6192_REGS_PHYS_BASE
+
+#endif /* _CONFIG_KW88F6192_H */
cpu/arm926ejs/kirkwood/kw88f6281.h new file +34 -0
new file mode 100644
index 0000000..3c0795a
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6281 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_KW88F6281_H
+#define _CONFIG_KW88F6281_H
+
+/* SOC specific definations */
+#define KW88F6281_REGS_PHYS_BASE	0xf1000000
+#define KW_REGS_PHY_BASE		KW88F6281_REGS_PHYS_BASE
+
+#endif /* _CONFIG_KW88F6281_H */
cpu/arm926ejs/kirkwood/kwcore.c new file +262 -0

262 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.h new file +141 -0

141 lines not on this page · raw message

cpu/arm926ejs/kirkwood/serial.c new file +187 -0

187 lines not on this page · raw message

cpu/arm926ejs/kirkwood/soc_init.S new file +156 -0

156 lines not on this page · raw message

cpu/arm926ejs/kirkwood/spi.c new file +213 -0

213 lines not on this page · raw message

cpu/arm926ejs/kirkwood/timer.c new file +165 -0

165 lines not on this page · raw message

include/configs/kirkwood.h new file +46 -0

23 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.3.3

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 1/1 Gbe Controller driver support for kirkwood SOCs

From: prafulla_wadaskar <[email protected]>

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

Reviewed by: Ronen Shitrit <[email protected]>

---
 cpu/arm926ejs/kirkwood/Makefile     |    1 +
 cpu/arm926ejs/kirkwood/egiga.c      | 2169 +++++++++++++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/egiga.h      |  707 ++++++++++++
 cpu/arm926ejs/kirkwood/egiga_regs.h |  161 +++
 cpu/arm926ejs/kirkwood/kwcore.h     |    2 +
 net/eth.c                           |    4 +
 6 files changed, 3044 insertions(+), 0 deletions(-)
 create mode 100644 cpu/arm926ejs/kirkwood/egiga.c
 create mode 100644 cpu/arm926ejs/kirkwood/egiga.h
 create mode 100644 cpu/arm926ejs/kirkwood/egiga_regs.h
cpu/arm926ejs/kirkwood/Makefile +1 -0
index 41ac8d7..3e20898 100644
@@ -30,6 +30,7 @@ COBJS-y	= timer.o
 COBJS-y	+= serial.o
 COBJS-y	+= kwcore.o
 COBJS-y	+= dram.o
+COBJS-y	+= egiga.o
 COBJS-$(CONFIG_KIRKWOOD_SPI)		+= spi.o
 
 SOBJS	= soc_init.o
cpu/arm926ejs/kirkwood/egiga.c new file +2169 -0

2,169 lines not on this page · raw message

cpu/arm926ejs/kirkwood/egiga.h new file +707 -0

707 lines not on this page · raw message

cpu/arm926ejs/kirkwood/egiga_regs.h new file +161 -0

117 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.h +2 -0
index 0ddc6a8..50043d8 100644

Lines of this file are not shown. View the raw message.

net/eth.c +4 -0
index 4bbf84b..77fa8a5 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.3.3

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH 1/1 Marvell 88EXXXX Switch/PHY init support

From: prafulla_wadaskar <[email protected]>

Chips supprted:-
1. 88E61XX 6 port gbe swtich with 5 integrated PHYs
2. 88E6061 6 port fe swtich with 5 integrated PHYs
3. 88E1116 gbe transceiver

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

Reviewed by: Ronen Shitrit <[email protected]>

---
 board/Marvell/common/mv88e1116.c |   72 +++++++
 board/Marvell/common/mv88e60xx.c |  409 +++++++++++++++++++++++++++++++++++++
 board/Marvell/common/mv88e61xx.c |  414 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 895 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/common/mv88e1116.c
 create mode 100644 board/Marvell/common/mv88e60xx.c
 create mode 100644 board/Marvell/common/mv88e61xx.c
board/Marvell/common/mv88e1116.c new file +72 -0
new file mode 100644
index 0000000..87ec550
@@ -0,0 +1,72 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Contributors
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef MV88E1116_DEBUG
+#define MV88E1116_DEBUG 0
+#endif
+#define DEBUG_PRINT	MV88E1116_DEBUG
+
+#include <common.h>
+#include <debug_prints.h>
+#include "../common/ppc_error_no.h"
+
+#if defined (CONFIG_PHY_88E1116)
+
+/*
+ * Marvell 88E1116 PHY initialization
+ */
+void mv_phy_88e1116_init(u32 eth_port_num)
+{
+	u16 reg;
+	u32 smi_dev_addr;
+
+	debug_print_ftrace();
+	smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(eth_port_num));
+
+	/* Leds link and activity */
+	eth_smi_reg_write(eth_port_num, smi_dev_addr, 22, 0x3);
+	eth_smi_reg_read(eth_port_num, smi_dev_addr, 16, &reg);
+	reg &= ~0xf;
+	reg |= 0x1;
+	eth_smi_reg_write(eth_port_num, smi_dev_addr, 16, reg);
+	eth_smi_reg_write(eth_port_num, smi_dev_addr, 22, 0x0);
+
+	/* Set RGMII delay */
+	eth_smi_reg_write(eth_port_num, smi_dev_addr, 22, 2);
+	eth_smi_reg_read(eth_port_num, smi_dev_addr, 21, &reg);
+	reg |= (BIT5 | BIT4);
+	eth_smi_reg_write(eth_port_num, smi_dev_addr, 21, reg);
+	eth_smi_reg_write(eth_port_num, smi_dev_addr, 22, 0);
+
+	/* reset the phy */
+	eth_smi_reg_read(eth_port_num, smi_dev_addr, 0, &reg);
+	reg |= BIT15;
+	eth_smi_reg_write(eth_port_num, smi_dev_addr, 0, reg);
+
+	info_print("88E1116 Initialized");
+}
+
+#endif /* CONFIG_PHY_88E61XX */
board/Marvell/common/mv88e60xx.c new file +409 -0

409 lines not on this page · raw message

board/Marvell/common/mv88e61xx.c new file +414 -0

414 lines not on this page · raw message

Signature · 1 line
1.5.3.3
#4 lore raw

PATCH 1/1 Marvell 88EXXXX Switch/PHY init support

Hi Prafulla,

Quoted 7 lines · Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

Chips supprted:-
1. 88E61XX 6 port gbe swtich with 5 integrated PHYs
2. 88E6061 6 port fe swtich with 5 integrated PHYs
3. 88E1116 gbe transceiver

Quoted 7 lines

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

I'll review these changes, but as-is placing chip support in 'board/Marvell' is inappropriate. If they are pure ethernet devices they need to go in 'drivers/net'. We also need to move the Marvell system controller chips that are already in 'board/Marvell', but I'm not sure where they should go. As you see, there's a tremendous amount of redundancy there.

regards,
Ben

#5 lore raw

PATCH 1/1 Marvell MV88F6281GTW_GE Board support

In reply to Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash

Reviewed by: Ronen Shitrit <[email protected]>
Tested by: Piyush Shah <[email protected]>

---
 MAKEALL                                         |    1 +
 Makefile                                        |    3 +
 board/Marvell/mv88f6281gtw_ge/Makefile          |   54 +++++++
 board/Marvell/mv88f6281gtw_ge/bin_dep.sh        |   74 +++++++++
 board/Marvell/mv88f6281gtw_ge/config.mk         |   25 +++
 board/Marvell/mv88f6281gtw_ge/dramregs_333h.txt |   27 ++++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  135 ++++++++++++++++
 board/Marvell/mv88f6281gtw_ge/u-boot.lds        |   53 +++++++
 include/configs/mv88f6281gtw_ge.h               |  187 +++++++++++++++++++++++
 9 files changed, 559 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/mv88f6281gtw_ge/Makefile
 create mode 100755 board/Marvell/mv88f6281gtw_ge/bin_dep.sh
 create mode 100644 board/Marvell/mv88f6281gtw_ge/config.mk
 create mode 100644 board/Marvell/mv88f6281gtw_ge/dramregs_333h.txt
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
 create mode 100644 board/Marvell/mv88f6281gtw_ge/u-boot.lds
 create mode 100644 include/configs/mv88f6281gtw_ge.h
MAKEALL +1 -0
index 854f303..de25165 100755
@@ -506,6 +506,7 @@ LIST_ARM9="			\
 	lpd7a400		\
 	mx1ads			\
 	mx1fs2			\
+	mv88f6281gtw_ge		\
 	netstar			\
 	nmdk8815		\
 	omap1510inn		\
Makefile +3 -0
index 8bf36ce..eb2fdfb 100644
@@ -2564,6 +2564,9 @@ DB64360_config:	unconfig
 DB64460_config:	unconfig
 	@$(MKCONFIG) DB64460 ppc 74xx_7xx db64460 Marvell
 
+mv88f6281gtw_ge_config: unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 ELPPC_config: unconfig
 	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx elppc eltec
 
board/Marvell/mv88f6281gtw_ge/Makefile new file +54 -0

54 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/bin_dep.sh new file +74 -0

74 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/config.mk new file +25 -0
new file mode 100644
index 0000000..fb29a1b
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+TEXT_BASE = 0x00600000
board/Marvell/mv88f6281gtw_ge/dramregs_333h.txt new file +27 -0
new file mode 100644
index 0000000..d40a9c7
@@ -0,0 +1,27 @@
+0xFFD01400 0x43000a00
+0xFFD01404 0x38543000
+0xFFD01408 0x2202433D
+0xFFD0140C 0x0000002A
+0xFFD01410 0x0000000D
+0xFFD01414 0x00000000
+0xFFD01418 0x00000000
+0xFFD0141C 0x00000c52
+0xFFD01420 0x00000046
+0xFFD01424 0x0000F1FF
+0xFFD01428 0x00085520
+0xFFD0147c 0x00008552
+0xFFD01508 0x00000000
+0xFFD01504 0x07FFFFF1
+0xFFD0150C 0x00000000
+0xFFD01514 0x00000000
+0xFFD0151C 0x00000000
+0xFFD01494 0x00010001
+0xFFD01498 0x00000000
+0xFFD0149C 0x0000E811
+0xFFD01480 0x00000001
+0xFFD20204 0x00000000
+0xFFD100E0 0x1B1B1B9B
+0xFFD100D8 0x00000060
+0xFFD1007C 0x00000068
+0xFFD50430 0x00000008
+0x0 0x0
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +135 -0

135 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +53 -0

53 lines not on this page · raw message

include/configs/mv88f6281gtw_ge.h new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
1.5.3.3
#6 lore raw

PATCH 1/1 Marvell MV88F6281GTW_GE Board support

Dear Prafulla Wadaskar,

Quoted 14 lines · In message <[email protected]> you wrote:

From: prafulla_wadaskar <[email protected]>

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash

Reviewed by: Ronen Shitrit <[email protected]>
Tested by: Piyush Shah <[email protected]>

...

MAKEALL LIST_ARM9=" \ · line 512

Quoted 10 lines
MAKEALL +1 -0
@@ -506,6 +506,7 @@ LIST_ARM9="			\
 	lpd7a400		\
 	mx1ads			\
 	mx1fs2			\
+	mv88f6281gtw_ge		\
 	netstar			\
 	nmdk8815		\
 	omap1510inn		\

Please keep lists sorted.

Makefile DB64360_config: unconfig · line 2571

Quoted 13 lines
Makefile +3 -0
index 8bf36ce..eb2fdfb 100644
@@ -2564,6 +2564,9 @@ DB64360_config:	unconfig
 DB64460_config:	unconfig
 	@$(MKCONFIG) DB64460 ppc 74xx_7xx db64460 Marvell
 
+mv88f6281gtw_ge_config: unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 ELPPC_config: unconfig
 	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx elppc eltec

Please keep lists sorted.

Quoted 6 lines
board/Marvell/mv88f6281gtw_ge/bin_dep.sh new file +0 -0
new file mode 100755
index 0000000..5cb1e36
@@ -0,0 +1,74 @@

...

board/Marvell/mv88f6281gtw_ge/bin_dep.sh line 35

Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/bin_dep.sh new file +5 -0
+CUR_DIR=$2
+TOP_DIR=`pwd`
+BIN_FILE=$TOP_DIR/$1
+
+DOIMAGE=$TOP_DIR/cpu/arm926ejs/kirkwood/doimage/doimage

Please explain why this would be needed for?

Note that this most probably will not fork with out of tree builds.

...

Quoted 23 lines
board/Marvell/mv88f6281gtw_ge/dramregs_333h.txt new file +17 -0
new file mode 100644
index 0000000..d40a9c7
@@ -0,0 +1,27 @@
+0xFFD01400 0x43000a00
+0xFFD01404 0x38543000
+0xFFD01408 0x2202433D
+0xFFD0140C 0x0000002A
+0xFFD01410 0x0000000D
+0xFFD01414 0x00000000
+0xFFD01418 0x00000000
+0xFFD0141C 0x00000c52
+0xFFD01420 0x00000046
+0xFFD01424 0x0000F1FF
+0xFFD01428 0x00085520
+0xFFD0147c 0x00008552
+0xFFD01508 0x00000000
+0xFFD01504 0x07FFFFF1
+0xFFD0150C 0x00000000
+0xFFD01514 0x00000000
+0xFFD0151C 0x00000000

board/Marvell/mv88f6281gtw_ge/dramregs_333h.txt line 27

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/dramregs_333h.txt new file +10 -0
+0xFFD01494 0x00010001
+0xFFD01498 0x00000000
+0xFFD0149C 0x0000E811
+0xFFD01480 0x00000001
+0xFFD20204 0x00000000
+0xFFD100E0 0x1B1B1B9B
+0xFFD100D8 0x00000060
+0xFFD1007C 0x00000068
+0xFFD50430 0x00000008
+0x0 0x0

What sort of file is this? Under which license is it?

Quoted 6 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +0 -0
new file mode 100644
index 0000000..b88fe3e
@@ -0,0 +1,135 @@

...

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 28

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +4 -0
+#ifndef MV88F6281GTW_GE_DEBUG
+#define MV88F6281GTW_GE_DEBUG		0
+#endif
+#define DEBUG_PRINT		MV88F6281GTW_GE_DEBUG

Unused code? Delete!

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 31

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +2 -0
+#include <common.h>
+#include <debug_prints.h>

Non existent file included here.

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 34

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +2 -0
+/* this line must be removed after this machine name gets mainlined in mach_types.h*/
+#define MACH_TYPE_MV88F6281GTW_GE      1932

Please first register the MACH ID, then fix this, then resubmit.

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 41

Quoted 6 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +6 -0
+DECLARE_GLOBAL_DATA_PTR;
+
+#define MV88F6281GTW_GE_OE_VAL_LOW	(BIT20)	/*make GLED on */
+#define MV88F6281GTW_GE_OE_VAL_HIGH	((BIT6)|(BIT13)|(BIT16)|(BIT17))
+#define MV88F6281GTW_GE_OE_LOW		(~((BIT7) | (BIT20) | (BIT21)))	/*enable GLED,RLED */
+#define MV88F6281GTW_GE_OE_HIGH		(~((BIT4)|(BIT6)|(BIT7)|(BIT12)|(BIT13)|(BIT16)|(BIT17)))

Lines too long (also check in all other files).

Quoted 7 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +7 -0
+/*
+ * Default values for MPP registers
+ */
+#define MV88F6281GTW_GE_MPP0_7		0x01112222
+#define MV88F6281GTW_GE_MPP8_15		0x11103311
+#define MV88F6281GTW_GE_MPP16_23	0x00001111
+#define MV88F6281GTW_GE_MPP24_31	0x22222222

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 59

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +10 -0
+#define MV88F6281GTW_GE_MPP32_39	0x40440222
+#define MV88F6281GTW_GE_MPP40_47	0x00004444
+#define MV88F6281GTW_GE_MPP48_55	0x00000000
+
+/*
+ * function definitations
+ */
+#ifdef CONFIG_SWITCH_88E61XX
+extern int mv_switch_88e61xx_init(u32 eth_port_num);
+#endif

Do not use extern. Privde proper prototypes in the respective header files.

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +2 -0
+int board_init(void)
+{

...

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 97

Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +5 -0
+	/* relocate the exception vectors */
+	/* U-Boot is running from DRAM at this stage */
+	for (i = 0; i < 0x100; i += 4) {
+		*(unsigned int *)(0x0 + i) = *(unsigned int *)(TEXT_BASE + i);
+	}

Are you absolutely sure this code is correct?

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 105

Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +5 -0
+int dram_init(void)
+{
+	int i;
+
+	debug_print_ftrace();

You probably want to get rid of these. I don't think we will accept this.

Quoted 64 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +53 -0
new file mode 100644
index 0000000..0338757
@@ -0,0 +1,53 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	. = _start;
+	. = ALIGN(4);
+	.text	:
+	{
+	  cpu/arm926ejs/start.o	(.text)
+	  *(.text)
+	}
+	.rodata : { *(.rodata) }
+	. = ALIGN(4);
+	.data : { *(.data) }
+	. = ALIGN(4);
+	.got : { *(.got) }
+
+	. = .;
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	. = ALIGN(4);
+	__bss_start = .;
+	.bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
+	_end = .;
+}
+
include/configs/mv88f6281gtw_ge.h new file +0 -0
new file mode 100644
index 0000000..70e6dca

...

include/configs/mv88f6281gtw_ge.h line 55

Quoted 4 lines
include/configs/mv88f6281gtw_ge.h new file +4 -0
+/*
+ * Above definitions used in below file, do not change the sequence
+ */
+#include <configs/kirkwood.h>	/* CPU specific information */

include/configs/ is strictly for board specific information only; CPU specific data has no place there.

...

include/configs/mv88f6281gtw_ge.h line 90

Quoted 9 lines
include/configs/mv88f6281gtw_ge.h new file +9 -0
+#define	CONFIG_BOOTMAPSZ		(8<<20)	/* Initial Memmap for Linux */
+#define CONFIG_CMDLINE_TAG	1	/* enable passing of ATAGs  */
+#define CONFIG_INITRD_TAG	1	/* enable INITRD tag */
+#define CONFIG_SETUP_MEMORY_TAGS 1	/* enable memory tag */
+
+#define	CONFIG_SYS_PROMPT		"Marvell>> "	/* Command Prompt */
+#define	CONFIG_SYS_CBSIZE		1024	/* Console I/O Buff Size */
+#define	CONFIG_SYS_PBSIZE 		(CONFIG_SYS_CBSIZE \
+				+sizeof(CONFIG_SYS_PROMPT)+16)	/* Print Buff */

Lines too long, here and elsewhere. Please fix globally.

include/configs/mv88f6281gtw_ge.h line 99

Quoted 8 lines

+ * Commands configuration
+ */

include/configs/mv88f6281gtw_ge.h new file +6 -0
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_AUTOSCRIPT

AUTOSCRIPT is deprecated. Please use SOURCE instead.

include/configs/mv88f6281gtw_ge.h line 125

Quoted 4 lines
include/configs/mv88f6281gtw_ge.h new file +4 -0
+#ifdef CONFIG_SPI_FLASH
+#define CONFIG_ENV_IS_IN_SPI_FLASH	1
+#define CONFIG_ENV_SIZE			_64K	/* 1 spi flash block */
+#define CONFIG_ENV_SECT_SIZE		_64K

Please use real numbers and get rid of such "cool" constants.

include/configs/mv88f6281gtw_ge.h line 136

Quoted 4 lines
include/configs/mv88f6281gtw_ge.h new file +4 -0
+/* Default environment variables */
+#define CONFIG_BOOTCOMMAND	"$(x_bootcmd_kernel); setenv bootargs $(x_bootargs) $(x_bootargs_root); bootm 0x6400000; "
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"x_bootargs=console=ttyS0,115200 mtdparts=spi0.0:512k(uboot),512k at 512k(psm),2m at 1m(kernel),13m at 3m(rootfs)\0" \

Lines WAY too long.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Sometimes a feeling is all we humans have to go on.
	-- Kirk, "A Taste of Armageddon", stardate 3193.9
#7 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

From: prafulla_wadaskar <[email protected]>

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash
Note: doImage utility needed to convert u-boot.bin to u-boot-spiflash.bin, DRAM configuration will be part of this utility

---
Changelog
v2: updated as per first review comments by Wolfgang Denk debug_prints updated to debug

 MAKEALL                                         |    1 +
 Makefile                                        |    3 +
 board/Marvell/mv88f6281gtw_ge/Makefile          |   52 +++++++
 board/Marvell/mv88f6281gtw_ge/config.mk         |   25 +++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  118 ++++++++++++++
 board/Marvell/mv88f6281gtw_ge/u-boot.lds        |   53 +++++++
 include/configs/mv88f6281gtw_ge.h               |  185 +++++++++++++++++++++++
 7 files changed, 437 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/mv88f6281gtw_ge/Makefile
 create mode 100644 board/Marvell/mv88f6281gtw_ge/config.mk
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
 create mode 100644 board/Marvell/mv88f6281gtw_ge/u-boot.lds
 create mode 100644 include/configs/mv88f6281gtw_ge.h
MAKEALL +1 -0
index e4eb42b..1caf81d 100755
@@ -504,6 +504,7 @@ LIST_ARM9="			\
 	cp946es			\
 	cp966			\
 	lpd7a400		\
+	mv88f6281gtw_ge		\
 	mx1ads			\
 	mx1fs2			\
 	netstar			\
Makefile +3 -0
index d2c7c3f..709e4be 100644
@@ -2792,6 +2792,9 @@ lpd7a400_config \
 lpd7a404_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm lh7a40x lpd7a40x
 
+mv88f6281gtw_ge_config: unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 mx1ads_config	:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm920t mx1ads NULL imx
 
board/Marvell/mv88f6281gtw_ge/Makefile new file +52 -0

52 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/config.mk new file +25 -0
new file mode 100644
index 0000000..fb29a1b
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+TEXT_BASE = 0x00600000
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +118 -0

118 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +53 -0

53 lines not on this page · raw message

include/configs/mv88f6281gtw_ge.h new file +185 -0

185 lines not on this page · raw message

Signature · 1 line
1.5.3.3
#8 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 1 line · On Wednesday 08 April 2009 12:18:11 Prafulla Wadaskar wrote:

From: prafulla_wadaskar <[email protected]>

this part should be fixed as well
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090408/5e2bb153/attachment-0001.pgp

#9 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

In reply to Prafulla Wadaskar

Hi all,

This is much cleaner and smaller patch. Any comments or acceptance or flag to resend are welcomed.

Regards..
Prafulla . .

Quoted 572 lines

-----Original Message-----
From: Prafulla Wadaskar [mailto:prafulla at marvell.com]
Sent: Wednesday, April 08, 2009 9:48 PM
To: u-boot at lists.denx.de
Cc: Ronen Shitrit; Ashish Karkare; Prafulla Wadaskar
Subject: [PATCH v2] Marvell MV88F6281GTW_GE Board support

From: prafulla_wadaskar <[email protected]>

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash
Note: doImage utility needed to convert u-boot.bin to u-boot-spiflash.bin, DRAM configuration will be part of this utility

---
Changelog
v2: updated as per first review comments by Wolfgang Denk debug_prints updated to debug

 MAKEALL                                         |    1 +
 Makefile                                        |    3 +
 board/Marvell/mv88f6281gtw_ge/Makefile          |   52 +++++++
 board/Marvell/mv88f6281gtw_ge/config.mk         |   25 +++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  118 ++++++++++++++
 board/Marvell/mv88f6281gtw_ge/u-boot.lds        |   53 +++++++
 include/configs/mv88f6281gtw_ge.h               |  185
+++++++++++++++++++++++
 7 files changed, 437 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/mv88f6281gtw_ge/Makefile
 create mode 100644 board/Marvell/mv88f6281gtw_ge/config.mk
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
 create mode 100644 board/Marvell/mv88f6281gtw_ge/u-boot.lds
 create mode 100644 include/configs/mv88f6281gtw_ge.h
MAKEALL +1 -0
index e4eb42b..1caf81d 100755
@@ -504,6 +504,7 @@ LIST_ARM9="                       \
      cp946es                 \
      cp966                   \
      lpd7a400                \
+     mv88f6281gtw_ge         \
      mx1ads                  \
      mx1fs2                  \
      netstar                 \
Makefile +2 -0
index d2c7c3f..709e4be 100644
@@ -2792,6 +2792,9 @@ lpd7a400_config \
 lpd7a404_config:     unconfig
      @$(MKCONFIG) $(@:_config=) arm lh7a40x lpd7a40x
 
+mv88f6281gtw_ge_config: unconfig
+     @$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=)

Marvell kirkwood

Makefile +1 -0
+
 mx1ads_config        :       unconfig
      @$(MKCONFIG) $(@:_config=) arm arm920t mx1ads NULL imx
board/Marvell/mv88f6281gtw_ge/Makefile new file +45 -0
new file mode 100644
index 0000000..1b8cc6f
@@ -0,0 +1,52 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.        See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB  = $(obj)lib$(BOARD).a
+
+COBJS        := mv88f6281gtw_ge.o
+COBJS        += ../common/mv88e61xx.o
+
+SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS))
+SOBJS        := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):      $(obj).depend $(OBJS) $(SOBJS)
+     $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+clean:
+     rm -f $(SOBJS) $(OBJS)
+
+distclean:   clean
+     rm -f $(LIB) core *.bak .depend
+
+#############################################################

############

board/Marvell/mv88f6281gtw_ge/Makefile new file +7 -0
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#############################################################

############

board/Marvell/mv88f6281gtw_ge/config.mk new file +25 -0
new file mode 100644
index 0000000..fb29a1b
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+TEXT_BASE = 0x00600000
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +30 -0
new file mode 100644
index 0000000..617c87a
@@ -0,0 +1,118 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.       See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define MV88F6281GTW_GE_OE_LOW               (~((BIT7) | (BIT20) \
+                                       |(BIT21))) /*enable

GLED,RLED */
+#define MV88F6281GTW_GE_OE_HIGH
(~((BIT4)|(BIT6)|(BIT7)|(BIT12) \

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +87 -0
+                                       |(BIT13)|(BIT16)|(BIT17)))
+#define MV88F6281GTW_GE_OE_VAL_LOW   (BIT20) /*make GLED on */
+#define MV88F6281GTW_GE_OE_VAL_HIGH  ((BIT6)|(BIT13)|(BIT16)|(BIT17))
+
+/*
+ * Default values for MPP registers
+ */
+#define MV88F6281GTW_GE_MPP0_7               0x01112222
+#define MV88F6281GTW_GE_MPP8_15              0x11103311
+#define MV88F6281GTW_GE_MPP16_23     0x00001111
+#define MV88F6281GTW_GE_MPP24_31     0x22222222
+#define MV88F6281GTW_GE_MPP32_39     0x40440222
+#define MV88F6281GTW_GE_MPP40_47     0x00004444
+#define MV88F6281GTW_GE_MPP48_55     0x00000000
+
+/*
+ * function definitations
+ */
+#ifdef CONFIG_SWITCH_88E61XX
+extern int mv_switch_88e61xx_init(u32 eth_port_num);
+#endif
+
+int board_init(void)
+{
+     unsigned int i;
+
+     /* Board Parameters initializations */
+     kw_window_ctrl_reg_init();
+     kw_gpio_init(MV88F6281GTW_GE_OE_VAL_LOW,
+                     MV88F6281GTW_GE_OE_VAL_HIGH,
+                     MV88F6281GTW_GE_OE_LOW,
+                     MV88F6281GTW_GE_OE_HIGH);
+
+     kw_mpp_control_init(MV88F6281GTW_GE_MPP0_7,
+                     MV88F6281GTW_GE_MPP8_15,
+                     MV88F6281GTW_GE_MPP16_23,
+                     MV88F6281GTW_GE_MPP24_31,
+                     MV88F6281GTW_GE_MPP32_39,
+                     MV88F6281GTW_GE_MPP40_47,
+                     MV88F6281GTW_GE_MPP48_55);
+
+     /* init serial */
+     gd->baudrate = CONFIG_BAUDRATE;
+     gd->have_console = 1;
+     serial_init();
+     /*
+      * arch number of USED SOC
+      */
+     gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;
+
+     /* adress of boot parameters */
+     gd->bd->bi_boot_params = 0x00000100;
+
+     return 0;
+}
+
+int dram_init(void)
+{
+     int i;
+
+     for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+             gd->bd->bi_dram[i].start = kw_sdram_bar(i);
+             gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+     }
+     return 0;
+}
+
+int last_stage_init(void)
+{
+     return 0;
+}
+
+#if defined(CONFIG_MISC_INIT_R)
+/* miscellaneous platform dependent init */
+int misc_init_r(void)
+{
+     return kw_misc_init_r();
+}
+
+void reset_phy(void)
+{
+#ifdef CONFIG_SWITCH_88E61XX
+     mv_switch_88e61xx_init(ETH_0);
+#endif
+}
+
+#endif /* CONFIG_MISC_INIT_R */
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +25 -0
new file mode 100644
index 0000000..0338757
@@ -0,0 +1,53 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm",

"elf32-littlearm")

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +28 -0
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+     . = _start;
+     . = ALIGN(4);
+     .text   :
+     {
+       cpu/arm926ejs/start.o (.text)
+       *(.text)
+     }
+     .rodata : { *(.rodata) }
+     . = ALIGN(4);
+     .data : { *(.data) }
+     . = ALIGN(4);
+     .got : { *(.got) }
+
+     . = .;
+     __u_boot_cmd_start = .;
+     .u_boot_cmd : { *(.u_boot_cmd) }
+     __u_boot_cmd_end = .;
+
+     . = ALIGN(4);
+     __bss_start = .;
+     .bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
+     _end = .;
+}
+
include/configs/mv88f6281gtw_ge.h new file +38 -0
new file mode 100644
index 0000000..7f2b325
@@ -0,0 +1,185 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.       See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_MV88F6281GTW_GE_H
+#define _CONFIG_MV88F6281GTW_GE_H
+
+/*
+ * Version number information
+ */
+#define CONFIG_IDENT_STRING  "\nMarvell-MV88F6281GTW_GE-A0"
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_MARVELL               1
+#define CONFIG_ARM926EJS     1       /* Basic Architecture */
+#define CONFIG_FEROCEON_88FR131      1       /* CPU Core

subversion */

include/configs/mv88f6281gtw_ge.h new file +8 -0
+#define LE                   1       /* Specify LE/BE operation */
+#define CONFIG_KIRKWOOD              1       /* SOC Family Name */
+#define CONFIG_KW88F6281     1       /* SOC Name */
+#define CONFIG_KW88F6281_A0  1       /* SOC Revision */
+#define CONFIG_MV88F6281GTW_GE_A0 1  /* Board Name */
+
+#ifdef CONFIG_KIRKWOOD
+#define CONFIG_MD5   /* get_random_hex on krikwood needs MD5

support */
+#define CONFIG_KIRKWOOD_EGIGA_INIT /* Enable GbePort0/1
for kernel */
+#define CONFIG_KIRKWOOD_PCIE_INIT /* Enable PCIE Port0
for kernel */
+#define CONFIG_KIRKWOOD_RGMII_PAD_1V8 /* Set RGMII
Pad voltage to 1.8V */

include/configs/mv88f6281gtw_ge.h new file +10 -0
+#endif
+
+/*
+ * CLKs configurations
+ */
+#define CONFIG_SYS_HZ                1000
+
+/*
+ * Serial Port configuration
+ * The following definitions let you select what serial you

want to use
+ * for your console driver.
+ */

include/configs/mv88f6281gtw_ge.h new file +6 -0
+#define CONFIG_KW_SERIAL
+#define CONFIG_CONS_INDEX    0       /*Console on UART0 */
+
+#define CONFIG_BAUDRATE              115200  /* console baudrate */
+#define CONFIG_SYS_BAUDRATE_TABLE    { 9600, 19200, 38400, 57600, \
+                                       115200,230400,

460800, 921600 }

include/configs/mv88f6281gtw_ge.h new file +9 -0
+/* auto boot */
+#define CONFIG_BOOTDELAY     3       /* default enable autoboot */
+
+/*
+ * For booting Linux, the board info and command line data
+ * have to be in the first 8 MB of memory, since this is
+ * the maximum mapped by the Linux kernel during initialization.
+ */
+#define      CONFIG_BOOTMAPSZ        (8<<20) /* Initial

Memmap for Linux */

include/configs/mv88f6281gtw_ge.h new file +5 -0
+#define CONFIG_CMDLINE_TAG   1       /* enable passing of ATAGs  */
+#define CONFIG_INITRD_TAG    1       /* enable INITRD tag */
+#define CONFIG_SETUP_MEMORY_TAGS 1   /* enable memory tag */
+
+#define      CONFIG_SYS_PROMPT       "Marvell>> "    /*

Command Prompt */
+#define CONFIG_SYS_CBSIZE 1024 /* Console I/O
Buff Size */

include/configs/mv88f6281gtw_ge.h new file +21 -0
+#define      CONFIG_SYS_PBSIZE       (CONFIG_SYS_CBSIZE \
+                     +sizeof(CONFIG_SYS_PROMPT)+16)  /* Print Buff */
+/*
+ * Commands configuration
+ */
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_AUTOSCRIPT
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_SF
+
+/*
+ * Flash configuration
+ */
+#ifdef CONFIG_CMD_SF
+#define CONFIG_SYS_NO_FLASH          1       /* Declare no

NOR flash */

include/configs/mv88f6281gtw_ge.h new file +7 -0
+#define CONFIG_SPI_FLASH             1
+#define CONFIG_HARD_SPI                      1
+#define CONFIG_KIRKWOOD_SPI          1
+#define CONFIG_SPI_FLASH_MACRONIX    1
+#define CONFIG_ENV_SPI_BUS           0
+#define CONFIG_ENV_SPI_CS            0
+#define CONFIG_ENV_SPI_MAX_HZ                50000000

/*50Mhz */

include/configs/mv88f6281gtw_ge.h new file +8 -0
+#endif
+
+/*
+ *  Environment variables configurations
+ */
+#ifdef CONFIG_SPI_FLASH
+#define CONFIG_ENV_IS_IN_SPI_FLASH   1
+#define CONFIG_ENV_SIZE                      0x10000 /* spi

flash block (64k) */

include/configs/mv88f6281gtw_ge.h new file +3 -0
+#define CONFIG_ENV_SECT_SIZE         0x10000 /* _64K */
+#else
+#define CONFIG_ENV_IS_NOWHERE                1       /* if

env in SDRAM */
+#define CONFIG_ENV_SIZE 0x20000 /*
default 128k */

include/configs/mv88f6281gtw_ge.h new file +8 -0
+#endif
+#define CONFIG_ENV_ADDR                      0x20000
+#define CONFIG_ENV_OFFSET            0x20000 /* env starts here */
+
+/*
+ * Default environment variables
+ */
+#define CONFIG_BOOTCOMMAND           "$(x_bootcmd_kernel);

setenv bootargs " \

include/configs/mv88f6281gtw_ge.h new file +2 -0
+     "$(x_bootargs) $(x_bootargs_root); bootm 0x6400000;"
+#define CONFIG_EXTRA_ENV_SETTINGS

"x_bootargs=console=ttyS0,115200 " \
+
"mtdparts=spi0.0:512k(uboot),512k at 512k(psm),2m at 1m(kernel),13m@ 3m(rootfs)\0" \

include/configs/mv88f6281gtw_ge.h new file +18 -0
+     "x_bootcmd_kernel=cp.b 0xf8100000 0x6400000 0x200000\0" \
+     "x_bootargs_root=root=/dev/mtdblock3 ro rootfstype=squashfs\0"
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_SYS_MALLOC_LEN        0x00400000      /* 4M */
+/* size in bytes reserved for initial data */
+#define CONFIG_SYS_GBL_DATA_SIZE     128
+
+/*
+ * Other required minimal configurations
+ */
+#define CONFIG_CONSOLE_INFO_QUIET    /* some code reduction */
+#define CONFIG_MISC_INIT_R   1       /* call misc_init_r() */
+#define CONFIG_NR_DRAM_BANKS         4
+#define CONFIG_STACKSIZE     0x00100000      /* regular stack- 1M */
+#define CONFIG_SYS_LOAD_ADDR 0x00800000      /* default load

adr- 8M */

include/configs/mv88f6281gtw_ge.h new file +11 -0
+#define CONFIG_SYS_MEMTEST_START 0x00400000  /* 4M */
+#define CONFIG_SYS_MEMTEST_END       0x007fffff      /*(_8M -1) */
+#define CONFIG_SYS_RESET_ADDRESS 0xffff0000  /* Rst Vector Adr */
+#define CONFIG_SYS_MAXARGS   16      /* max number of command args */
+
+/*
+ * Ethernet Driver configuration
+ */
+#ifdef CONFIG_CMD_NET
+#define CONFIG_NETCONSOLE    /* include NetConsole support   */
+#define CONFIG_NET_MULTI     /* specify more that one ports

available */
+#define CONFIG_KIRKWOOD_EGIGA /* Enable SOC specific
Ethernet Gigabit

include/configs/mv88f6281gtw_ge.h new file +5 -0
+                                Controller Driver */
+#undef CONFIG_PHY_LINK_DETECT        /* detect link always on */
+                             /* specify ports to be used */
+#define CONFIG_KIRKWOOD_EGIGA_PORTS  {TRUE,FALSE}
+                             /* phy base addr for multi-chip

addressing */

include/configs/mv88f6281gtw_ge.h new file +10 -0
+#define CONFIG_IPADDR                192.168.5.44
+#define CONFIG_SERVERIP              192.168.5.30
+#define CONFIG_NETMASK               255.255.255.0
+#define CONFIG_ENV_OVERWRITE /* ethaddr can be reprogrammed */
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * Marvell 88Exxxx Switch configurations
+ */
+#define CONFIG_RESET_PHY_R      /* use reset_phy() to init

phy/swtich */
+#define CONFIG_SWITCH_88E61XX /* Enable mv88e61xx
switch driver */

include/configs/mv88f6281gtw_ge.h new file +6 -1
+#define CONFIG_SWITCH_MV88E6165      /* Used Switch is 88E6165 */
+                             /* p5 of 88E6165 connceted to CPU */
+#define CONFIG_SWITCH_88E61XX_CPU_PORT       5
+#define CONFIG_SWITCH_88E61XX_ENABLED_PORTS  (BIT0 | BIT1 | BIT2 | \
+                                             BIT3 | BIT4  | BIT5)
+#endif /* _CONFIG_MV88F6281GTW_GE_H */
--

1.5.3.3

#10 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

In reply to Prafulla Wadaskar
Quoted 5 lines · Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

Quoted 8 lines

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash
Note: doImage utility needed to convert u-boot.bin to u-boot-spiflash.bin, DRAM configuration will be part of this utility

btw where is the spi driver?

Quoted 51 lines

---
Changelog
v2: updated as per first review comments by Wolfgang Denk debug_prints updated to debug

 MAKEALL                                         |    1 +
 Makefile                                        |    3 +
 board/Marvell/mv88f6281gtw_ge/Makefile          |   52 +++++++
 board/Marvell/mv88f6281gtw_ge/config.mk         |   25 +++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  118 ++++++++++++++
 board/Marvell/mv88f6281gtw_ge/u-boot.lds        |   53 +++++++
 include/configs/mv88f6281gtw_ge.h               |  185 +++++++++++++++++++++++
 7 files changed, 437 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/mv88f6281gtw_ge/Makefile
 create mode 100644 board/Marvell/mv88f6281gtw_ge/config.mk
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
 create mode 100644 board/Marvell/mv88f6281gtw_ge/u-boot.lds
 create mode 100644 include/configs/mv88f6281gtw_ge.h
MAKEALL +1 -0
index e4eb42b..1caf81d 100755
@@ -504,6 +504,7 @@ LIST_ARM9="			\
 	cp946es			\
 	cp966			\
 	lpd7a400		\
+	mv88f6281gtw_ge		\
 	mx1ads			\
 	mx1fs2			\
 	netstar			\
Makefile +14 -1
index d2c7c3f..709e4be 100644
--- a/Makefile
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+

Makefile

Quoted 10 lines
Makefile +10 -0
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define MV88F6281GTW_GE_OE_LOW		(~((BIT7) | (BIT20) \
+					  |(BIT21))) /*enable GLED,RLED */
+#define MV88F6281GTW_GE_OE_HIGH		(~((BIT4)|(BIT6)|(BIT7)|(BIT12) \
+					  |(BIT13)|(BIT16)|(BIT17)))
+#define MV88F6281GTW_GE_OE_VAL_LOW	(BIT20)	/*make GLED on */
+#define MV88F6281GTW_GE_OE_VAL_HIGH	((BIT6)|(BIT13)|(BIT16)|(BIT17))

plese remove the BITxx

Makefile

Quoted 11 lines
Makefile +11 -0
+
+/*
+ * Default values for MPP registers
+ */
+#define MV88F6281GTW_GE_MPP0_7		0x01112222
+#define MV88F6281GTW_GE_MPP8_15		0x11103311
+#define MV88F6281GTW_GE_MPP16_23	0x00001111
+#define MV88F6281GTW_GE_MPP24_31	0x22222222
+#define MV88F6281GTW_GE_MPP32_39	0x40440222
+#define MV88F6281GTW_GE_MPP40_47	0x00004444
+#define MV88F6281GTW_GE_MPP48_55	0x00000000

please move all this define to a header
and if possible please use macro to describe the content

Makefile

Quoted 7 lines
Makefile +7 -0
+
+/*
+ * function definitations
+ */
+#ifdef CONFIG_SWITCH_88E61XX
+extern int mv_switch_88e61xx_init(u32 eth_port_num);
+#endif

please move it to a header

Quoted 14 lines
Makefile +14 -0
+
+int board_init(void)
+{
+	unsigned int i;
+
+	/* Board Parameters initializations */
+	kw_window_ctrl_reg_init();
+	kw_gpio_init(MV88F6281GTW_GE_OE_VAL_LOW,
+			MV88F6281GTW_GE_OE_VAL_HIGH,
+			MV88F6281GTW_GE_OE_LOW,
+			MV88F6281GTW_GE_OE_HIGH);
+
+	kw_mpp_control_init(MV88F6281GTW_GE_MPP0_7,
+			MV88F6281GTW_GE_MPP8_15,

Makefile

Quoted 10 lines
Makefile +10 -0
+			MV88F6281GTW_GE_MPP16_23,
+			MV88F6281GTW_GE_MPP24_31,
+			MV88F6281GTW_GE_MPP32_39,
+			MV88F6281GTW_GE_MPP40_47,
+			MV88F6281GTW_GE_MPP48_55);
+
+	/* init serial */
+	gd->baudrate = CONFIG_BAUDRATE;
+	gd->have_console = 1;
+	serial_init();

no need please remove the serial init is done by the lib_arm/board.c

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 43 lines
Makefile +42 -0
+	/*
+	 * arch number of USED SOC
+	 */
+	gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;
+
+	/* adress of boot parameters */
+	gd->bd->bi_boot_params = 0x00000100;
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		gd->bd->bi_dram[i].start = kw_sdram_bar(i);
+		gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+	}
+	return 0;
+}
+
+int last_stage_init(void)
+{
+	return 0;
+}
+
+#if defined(CONFIG_MISC_INIT_R)
+/* miscellaneous platform dependent init */
+int misc_init_r(void)
+{
+	return kw_misc_init_r();
+}
+
+void reset_phy(void)
+{
+#ifdef CONFIG_SWITCH_88E61XX
+	mv_switch_88e61xx_init(ETH_0);
+#endif
+}
+
+#endif /* CONFIG_MISC_INIT_R */
board/Marvell/mv88f6281gtw_ge/u-boot.lds +0 -0

is it possible to have a shorter name for the board?

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines

new file mode 100644
index 0000000..0338757

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +0 -0

as all kirkwood will use the same lds please move it to soc cpu/.../kirlwood/

Quoted 28 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +27 -0
@@ -0,0 +1,53 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)

board/Marvell/mv88f6281gtw_ge/u-boot.lds line 37

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +10 -0
+SECTIONS
+{
+	. = _start;
+	. = ALIGN(4);
+	.text	:
+	{
+	  cpu/arm926ejs/start.o	(.text)
+	  *(.text)
+	}
+	.rodata : { *(.rodata) }

please replace by this

	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
Quoted 51 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +16 -0
+	. = ALIGN(4);
+	.data : { *(.data) }
+	. = ALIGN(4);
+	.got : { *(.got) }
+
+	. = .;
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	. = ALIGN(4);
+	__bss_start = .;
+	.bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
+	_end = .;
+}
+
include/configs/mv88f6281gtw_ge.h new file +29 -0
new file mode 100644
index 0000000..7f2b325
@@ -0,0 +1,185 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_MV88F6281GTW_GE_H
+#define _CONFIG_MV88F6281GTW_GE_H
+
+/*
+ * Version number information

include/configs/mv88f6281gtw_ge.h line 39

Quoted 10 lines
include/configs/mv88f6281gtw_ge.h new file +10 -0
+ */
+#define CONFIG_IDENT_STRING	"\nMarvell-MV88F6281GTW_GE-A0"
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_MARVELL		1
+#define CONFIG_ARM926EJS	1	/* Basic Architecture */
+#define CONFIG_FEROCEON_88FR131	1	/* CPU Core subversion */
+#define LE			1	/* Specify LE/BE operation */

why?

include/configs/mv88f6281gtw_ge.h line 42

Quoted 3 lines
include/configs/mv88f6281gtw_ge.h new file +3 -0
+#define CONFIG_KIRKWOOD		1	/* SOC Family Name */
+#define CONFIG_KW88F6281	1	/* SOC Name */
+#define CONFIG_KW88F6281_A0	1	/* SOC Revision */

is is not possible to detect it?

Quoted 13 lines
include/configs/mv88f6281gtw_ge.h new file +13 -0
+#define CONFIG_MV88F6281GTW_GE_A0 1	/* Board Name */
+
+#ifdef CONFIG_KIRKWOOD
+#define CONFIG_MD5	/* get_random_hex on krikwood needs MD5 support */
+#define CONFIG_KIRKWOOD_EGIGA_INIT	/* Enable GbePort0/1 for kernel */
+#define CONFIG_KIRKWOOD_PCIE_INIT	/* Enable PCIE Port0 for kernel */
+#define CONFIG_KIRKWOOD_RGMII_PAD_1V8	/* Set RGMII Pad voltage to 1.8V */
+#endif
+
+/*
+ * CLKs configurations
+ */
+#define CONFIG_SYS_HZ		1000

include/configs/mv88f6281gtw_ge.h line 65

Quoted 10 lines
include/configs/mv88f6281gtw_ge.h new file +10 -0
+
+/*
+ * Serial Port configuration
+ * The following definitions let you select what serial you want to use
+ * for your console driver.
+ */
+#define CONFIG_KW_SERIAL
+#define CONFIG_CONS_INDEX	0	/*Console on UART0 */
+
+#define CONFIG_BAUDRATE         	115200	/* console baudrate */
			  ^^^^^^^^^

whitespace please remove

Quoted 6 lines
include/configs/mv88f6281gtw_ge.h new file +6 -0
+#define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
+					  115200,230400, 460800, 921600 }
+/* auto boot */
+#define CONFIG_BOOTDELAY	3	/* default enable autoboot */
+
+/*

include/configs/mv88f6281gtw_ge.h

Quoted 10 lines
include/configs/mv88f6281gtw_ge.h new file +10 -0
+ * For booting Linux, the board info and command line data
+ * have to be in the first 8 MB of memory, since this is
+ * the maximum mapped by the Linux kernel during initialization.
+ */
+#define	CONFIG_BOOTMAPSZ	(8<<20)	/* Initial Memmap for Linux */
+#define CONFIG_CMDLINE_TAG	1	/* enable passing of ATAGs  */
+#define CONFIG_INITRD_TAG	1	/* enable INITRD tag */
+#define CONFIG_SETUP_MEMORY_TAGS 1	/* enable memory tag */
+
+#define	CONFIG_SYS_PROMPT	"Marvell>> "	/* Command Prompt

why not Marvell> or a board name?

include/configs/mv88f6281gtw_ge.h line 84

Quoted 3 lines
include/configs/mv88f6281gtw_ge.h new file +3 -0
+#define	CONFIG_SYS_CBSIZE	1024	/* Console I/O Buff Size */
+#define	CONFIG_SYS_PBSIZE	(CONFIG_SYS_CBSIZE \
+			+sizeof(CONFIG_SYS_PROMPT)+16)	/* Print Buff */

please add space before and after '+'

Quoted 7 lines
include/configs/mv88f6281gtw_ge.h new file +7 -0
+/*
+ * Commands configuration
+ */
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_NET

include/configs/mv88f6281gtw_ge.h line 140

Quoted 10 lines
include/configs/mv88f6281gtw_ge.h new file +10 -0
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_AUTOSCRIPT
+#define CONFIG_CMD_MEMORY
+	"x_bootcmd_kernel=cp.b 0xf8100000 0x6400000 0x200000\0" \
+	"x_bootargs_root=root=/dev/mtdblock3 ro rootfstype=squashfs\0"
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_SYS_MALLOC_LEN	0x00400000	/* 4M */

4M?

include/configs/mv88f6281gtw_ge.h line 149

Quoted 9 lines
include/configs/mv88f6281gtw_ge.h new file +9 -0
+/* size in bytes reserved for initial data */
+#define CONFIG_SYS_GBL_DATA_SIZE	128
+
+/*
+ * Other required minimal configurations
+ */
+#define CONFIG_CONSOLE_INFO_QUIET	/* some code reduction */
+#define CONFIG_MISC_INIT_R	1	/* call misc_init_r() */
+#define CONFIG_NR_DRAM_BANKS 	4
			       ^

whitespace please remove

include/configs/mv88f6281gtw_ge.h line 153

Quoted 4 lines
include/configs/mv88f6281gtw_ge.h new file +4 -0
+#define CONFIG_STACKSIZE	0x00100000	/* regular stack- 1M */
+#define CONFIG_SYS_LOAD_ADDR	0x00800000	/* default load adr- 8M */
+#define CONFIG_SYS_MEMTEST_START 0x00400000	/* 4M */
+#define CONFIG_SYS_MEMTEST_END	0x007fffff	/*(_8M -1) */

_8M?

include/configs/mv88f6281gtw_ge.h line 161

Quoted 8 lines
include/configs/mv88f6281gtw_ge.h new file +8 -0
+#define CONFIG_SYS_RESET_ADDRESS 0xffff0000	/* Rst Vector Adr */
+#define CONFIG_SYS_MAXARGS	16	/* max number of command args */
+
+/*
+ * Ethernet Driver configuration
+ */
+#ifdef CONFIG_CMD_NET
+#define CONFIG_NETCONSOLE	/* include NetConsole support   */

whitespace please remove

include/configs/mv88f6281gtw_ge.h line 164

Quoted 3 lines
include/configs/mv88f6281gtw_ge.h new file +3 -0
+#define CONFIG_NET_MULTI	/* specify more that one ports available */
+#define CONFIG_KIRKWOOD_EGIGA	/* Enable SOC specific Ethernet Gigabit
+				   Controller Driver */

please use this style of multiple comment
/*
*
*/

include/configs/mv88f6281gtw_ge.h line 171

Quoted 7 lines
include/configs/mv88f6281gtw_ge.h new file +7 -0
+#undef CONFIG_PHY_LINK_DETECT	/* detect link always on */
+				/* specify ports to be used */
+#define CONFIG_KIRKWOOD_EGIGA_PORTS	{TRUE,FALSE}
+				/* phy base addr for multi-chip addressing */
+#define CONFIG_IPADDR		192.168.5.44
+#define CONFIG_SERVERIP		192.168.5.30
+#define CONFIG_NETMASK		255.255.255.0

please remove the IP params

include/configs/mv88f6281gtw_ge.h line 178

Quoted 7 lines
include/configs/mv88f6281gtw_ge.h new file +7 -0
+#define CONFIG_ENV_OVERWRITE	/* ethaddr can be reprogrammed */
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * Marvell 88Exxxx Switch configurations
+ */
+#define CONFIG_RESET_PHY_R      /* use reset_phy() to init phy/swtich */

whitespace please remove

include/configs/mv88f6281gtw_ge.h line 184

Quoted 6 lines
include/configs/mv88f6281gtw_ge.h new file +6 -0
+#define CONFIG_SWITCH_88E61XX	/* Enable mv88e61xx switch driver */
+#define CONFIG_SWITCH_MV88E6165	/* Used Switch is 88E6165 */
+				/* p5 of 88E6165 connceted to CPU */
+#define CONFIG_SWITCH_88E61XX_CPU_PORT	5
+#define CONFIG_SWITCH_88E61XX_ENABLED_PORTS	(BIT0 | BIT1 | BIT2 | \
+						BIT3 | BIT4  | BIT5)

please remobe this BITx

include/configs/mv88f6281gtw_ge.h line 185

Quoted 1 line
include/configs/mv88f6281gtw_ge.h new file +1 -0
+#endif /* _CONFIG_MV88F6281GTW_GE_H */

Best Regards,
J.

#11 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

Hi Jean

Thanks for your comments,
Please see my reply inlined...

Quoted 14 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Friday, April 17, 2009 1:15 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v2] Marvell MV88F6281GTW_GE Board support

Quoted 3 lines · Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

This is Marvell's 88F6281_A0 based custom board developed

for wireless

Quoted 2 lines

access point product

Quoted 8 lines
Quoted 7 lines

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash
Note: doImage utility needed to convert u-boot.bin to u-boot-spiflash.bin, DRAM configuration will be part of this utility

btw where is the spi driver?

Drivers/spi/kirkwood_spi.c through Kirkwood SOC support patch :-)

Quoted 7 lines
Quoted 1 line

+#define MV88F6281GTW_GE_OE_HIGH

(~((BIT4)|(BIT6)|(BIT7)|(BIT12) \

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +3 -0
+					  |(BIT13)|(BIT16)|(BIT17)))
+#define MV88F6281GTW_GE_OE_VAL_LOW	(BIT20)	/*make GLED on */
+#define MV88F6281GTW_GE_OE_VAL_HIGH	

((BIT6)|(BIT13)|(BIT16)|(BIT17))
plese remove the BITxx

Okay....

Quoted 5 lines
Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +5 -0
+
+/*
+ * Default values for MPP registers
+ */
+#define MV88F6281GTW_GE_MPP0_7		0x01112222
Quoted 8 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 45

Quoted 6 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +6 -0
+#define MV88F6281GTW_GE_MPP8_15		0x11103311
+#define MV88F6281GTW_GE_MPP16_23	0x00001111
+#define MV88F6281GTW_GE_MPP24_31	0x22222222
+#define MV88F6281GTW_GE_MPP32_39	0x40440222
+#define MV88F6281GTW_GE_MPP40_47	0x00004444
+#define MV88F6281GTW_GE_MPP48_55	0x00000000

please move all this define to a header
and if possible please use macro to describe the content

Okay I will creat and move them to header

Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 76

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +4 -0
+	/* init serial */
+	gd->baudrate = CONFIG_BAUDRATE;
+	gd->have_console = 1;
+	serial_init();

no need please remove the serial init is done by the lib_arm/board.c

Okay I will remove it

Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
(quoted diff) +2 -0
+
+#endif /* CONFIG_MISC_INIT_R */
board/Marvell/mv88f6281gtw_ge/u-boot.lds +0 -0

is it possible to have a shorter name for the board?

No Jean, not possible, kernel patches also represents the same name and machine is also register with the same name, pleas bear with this, thanks..

Quoted 3 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds line 37

Quoted 1 line
board/Marvell/mv88f6281gtw_ge/u-boot.lds +1 -0
+	.rodata : { *(.rodata) }

please replace by this

	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }

Okay I will do it

Quoted 10 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 7 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +6 -0
+	. = ALIGN(4);
+	.data : { *(.data) }
+	. = ALIGN(4);
+	.got : { *(.got) }
+/*
 
+#define CONFIG_FEROCEON_88FR131	1	/* CPU Core 

subversion */

Quoted 1 line

+#define LE 1 /* Specify LE/BE operation */

why?

Because SOC can be initialized to work in both the modes.

Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +3 -0
+#define CONFIG_KIRKWOOD		1	/* SOC Family Name */
+#define CONFIG_KW88F6281	1	/* SOC Name */
+#define CONFIG_KW88F6281_A0	1	/* SOC Revision */

is is not possible to detect it?

I will try to detect it.

Quoted 3 lines
Quoted 1 line

+#define CONFIG_BAUDRATE 115200 /* console baudrate */

			  ^^^^^^^^^

whitespace please remove

You mean spaces and tabs combination, I wll remove them

Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+
+#define	CONFIG_SYS_PROMPT	"Marvell>> "	/* 

Command Prompt
why not Marvell> or a board name?

This is to sync up with our current u-boot and the automation tools/documentation based on it Changing it to Marvell> is not a big deal but will involve lot of unwanted efforts.

Quoted 5 lines
Quoted 1 line

+#define CONFIG_SYS_CBSIZE 1024 /* Console I/O

Buff Size */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#define	CONFIG_SYS_PBSIZE	(CONFIG_SYS_CBSIZE \
+			+sizeof(CONFIG_SYS_PROMPT)+16)	/* Print Buff */

please add space before and after '+'

Okay..

Quoted 2 lines
Quoted 1 line

+#define CONFIG_SYS_MALLOC_LEN 0x00400000 /* 4M */

4M?

What it should be?

Quoted 10 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 8 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +8 -0
+/* size in bytes reserved for initial data */
+#define CONFIG_SYS_GBL_DATA_SIZE	128
+
+/*
+ * Other required minimal configurations  */
+#define CONFIG_CONSOLE_INFO_QUIET	/* some code reduction */
+#define CONFIG_MISC_INIT_R	1	/* call misc_init_r() */
+#define CONFIG_NR_DRAM_BANKS 	4
			       ^

whitespace please remove

Okay..

Quoted 6 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#define CONFIG_STACKSIZE	0x00100000	/* regular stack- 1M */
+#define CONFIG_SYS_LOAD_ADDR	0x00800000	/* 

default load adr- 8M */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#define CONFIG_SYS_MEMTEST_START 0x00400000	/* 4M */
+#define CONFIG_SYS_MEMTEST_END	0x007fffff	/*(_8M -1) */

_8M?

What it should be ?

Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines

+ */

board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#ifdef CONFIG_CMD_NET
+#define CONFIG_NETCONSOLE	/* include NetConsole support   */

whitespace please remove

Okay ..

Quoted 9 lines
Quoted 1 line

+#define CONFIG_NET_MULTI /* specify more that one ports

available */

Quoted 1 line

+#define CONFIG_KIRKWOOD_EGIGA /* Enable SOC specific

Ethernet Gigabit

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 1 line
board/Marvell/mv88f6281gtw_ge/u-boot.lds +1 -0
+				   Controller Driver */

please use this style of multiple comment
/*
*
*/

Okay..

Quoted 9 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +4 -0
+#undef CONFIG_PHY_LINK_DETECT	/* detect link always on */
+				/* specify ports to be used */
+#define CONFIG_KIRKWOOD_EGIGA_PORTS	{TRUE,FALSE}
+				/* phy base addr for multi-chip 

addressing */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +3 -0
+#define CONFIG_IPADDR		192.168.5.44
+#define CONFIG_SERVERIP		192.168.5.30
+#define CONFIG_NETMASK		255.255.255.0

please remove the IP params

Why ?

Quoted 9 lines
Quoted 1 line

+#define CONFIG_ENV_OVERWRITE /* ethaddr can be

reprogrammed */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +5 -0
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * Marvell 88Exxxx Switch configurations  */
+#define CONFIG_RESET_PHY_R      /* use reset_phy() to init 

phy/swtich */
whitespace please remove

Okay..

Quoted 9 lines
Quoted 1 line

+#define CONFIG_SWITCH_88E61XX /* Enable mv88e61xx

switch driver */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +4 -0
+#define CONFIG_SWITCH_MV88E6165	/* Used Switch is 88E6165 */
+				/* p5 of 88E6165 connceted to CPU */
+#define CONFIG_SWITCH_88E61XX_CPU_PORT	5
+#define CONFIG_SWITCH_88E61XX_ENABLED_PORTS	(BIT0 | 

BIT1 | BIT2 | \

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 1 line
board/Marvell/mv88f6281gtw_ge/u-boot.lds +1 -0
+						BIT3 | BIT4  | BIT5)

please remobe this BITx

Okay..

Quoted 4 lines
Quoted 1 line

+#endif /* _CONFIG_MV88F6281GTW_GE_H */

Best Regards,
J.

#12 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 20 lines
Quoted 9 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 45

Quoted 7 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +7 -0
+#define MV88F6281GTW_GE_MPP0_7		0x01112222
+#define MV88F6281GTW_GE_MPP8_15		0x11103311
+#define MV88F6281GTW_GE_MPP16_23	0x00001111
+#define MV88F6281GTW_GE_MPP24_31	0x22222222
+#define MV88F6281GTW_GE_MPP32_39	0x40440222
+#define MV88F6281GTW_GE_MPP40_47	0x00004444
+#define MV88F6281GTW_GE_MPP48_55	0x00000000

please move all this define to a header
and if possible please use macro to describe the content

Okay I will creat and move them to header

Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 76

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +4 -0
+	/* init serial */
+	gd->baudrate = CONFIG_BAUDRATE;
+	gd->have_console = 1;
+	serial_init();

no need please remove the serial init is done by the lib_arm/board.c

Okay I will remove it

Quoted 6 lines
Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
(quoted diff) +2 -0
+
+#endif /* CONFIG_MISC_INIT_R */
board/Marvell/mv88f6281gtw_ge/u-boot.lds +0 -0

is it possible to have a shorter name for the board?

No Jean, not possible, kernel patches also represents the same name and machine is also register with the same name, pleas bear with this, thanks..

ok if possible next time try a shorter name

Quoted 13 lines
Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds line 37

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +1 -0
+	.rodata : { *(.rodata) }

please replace by this

	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }

Okay I will do it

Quoted 5 lines
Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +5 -0
+	. = ALIGN(4);
+	.data : { *(.data) }
+	. = ALIGN(4);
+	.got : { *(.got) }
+/*
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+#define CONFIG_FEROCEON_88FR131 1 /* CPU Core

subversion */

Quoted 1 line

+#define LE 1 /* Specify LE/BE operation */

why?

Because SOC can be initialized to work in both the modes.

so the binary will be compile as LE or BE so __ARMEL__ or __ARMEB__ will be defined

Quoted 10 lines
Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +3 -0
+#define CONFIG_KIRKWOOD		1	/* SOC Family Name */
+#define CONFIG_KW88F6281	1	/* SOC Name */
+#define CONFIG_KW88F6281_A0	1	/* SOC Revision */

is is not possible to detect it?

I will try to detect it.

Quoted 3 lines
Quoted 1 line

+#define CONFIG_BAUDRATE 115200 /* console baudrate */

			  ^^^^^^^^^

whitespace please remove

Quoted 8 lines

You mean spaces and tabs combination, I wll remove them

Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+
+#define	CONFIG_SYS_PROMPT	"Marvell>> "	/* 

Command Prompt
why not Marvell> or a board name?

This is to sync up with our current u-boot and the automation tools/documentation based on it Changing it to Marvell> is not a big deal but will involve lot of unwanted efforts.

ok

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

+#define CONFIG_SYS_CBSIZE 1024 /* Console I/O

Buff Size */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#define	CONFIG_SYS_PBSIZE	(CONFIG_SYS_CBSIZE \
+			+sizeof(CONFIG_SYS_PROMPT)+16)	/* Print Buff */

please add space before and after '+'

Quoted 6 lines

Okay..

Quoted 2 lines
Quoted 1 line

+#define CONFIG_SYS_MALLOC_LEN 0x00400000 /* 4M */

4M?

What it should be?

just ask why do you need 4M of malloc?

Quoted 13 lines
Quoted 11 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 9 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +8 -0
+/* size in bytes reserved for initial data */
+#define CONFIG_SYS_GBL_DATA_SIZE	128
+
+/*
+ * Other required minimal configurations  */
+#define CONFIG_CONSOLE_INFO_QUIET	/* some code reduction */
+#define CONFIG_MISC_INIT_R	1	/* call misc_init_r() */
+#define CONFIG_NR_DRAM_BANKS 	4
			       ^

whitespace please remove

Okay..

Quoted 7 lines
Quoted 6 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#define CONFIG_STACKSIZE	0x00100000	/* regular stack- 1M */
+#define CONFIG_SYS_LOAD_ADDR	0x00800000	/* 

default load adr- 8M */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#define CONFIG_SYS_MEMTEST_START 0x00400000	/* 4M */
+#define CONFIG_SYS_MEMTEST_END	0x007fffff	/*(_8M -1) */

_8M?

What it should be ?

8M maybe

Quoted 24 lines
Quoted 6 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 5 lines

+ */

board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#ifdef CONFIG_CMD_NET
+#define CONFIG_NETCONSOLE	/* include NetConsole support   */

whitespace please remove

Okay ..

Quoted 9 lines
Quoted 1 line

+#define CONFIG_NET_MULTI /* specify more that one ports

available */

Quoted 1 line

+#define CONFIG_KIRKWOOD_EGIGA /* Enable SOC specific

Ethernet Gigabit

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 1 line
board/Marvell/mv88f6281gtw_ge/u-boot.lds +1 -0
+				   Controller Driver */

please use this style of multiple comment
/*
*
*/

Okay..

Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +4 -0
+#undef CONFIG_PHY_LINK_DETECT	/* detect link always on */
+				/* specify ports to be used */
+#define CONFIG_KIRKWOOD_EGIGA_PORTS	{TRUE,FALSE}
+				/* phy base addr for multi-chip 

addressing */

Quoted 5 lines
Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +3 -0
+#define CONFIG_IPADDR		192.168.5.44
+#define CONFIG_SERVERIP		192.168.5.30
+#define CONFIG_NETMASK		255.255.255.0

please remove the IP params

Why ?

it's board instance specific

Best Regards,
J.

#13 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
(quoted diff) +2 -0
+
+#endif /* CONFIG_MISC_INIT_R */
board/Marvell/mv88f6281gtw_ge/u-boot.lds +0 -0

is it possible to have a shorter name for the board?

No Jean, not possible, kernel patches also represents the

same name and machine is also register with the same name, pleas bear with this, thanks..
ok if possible next time try a shorter name

Sure... Except one more exception please "mv88f6192gtw_fe"
This is next board whose kernel support and board name registry is already done in linux, this will be the next board support patch from me after getting this stuff in. For next upcomming boards I will keep in mind

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

+#define LE 1 /* Specify

LE/BE operation */

Quoted 2 lines
Quoted 1 line

why?

Because SOC can be initialized to work in both the modes.

so the binary will be compile as LE or BE so __ARMEL__ or __ARMEB__ will be defined

Okay I will change accordingly

Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

+#define CONFIG_SYS_MALLOC_LEN 0x00400000 /* 4M */

4M?

What it should be?

just ask why do you need 4M of malloc?

In future to support all SOC drivers, I will keep it 4M if you agree

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

default load adr- 8M */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +2 -0
+#define CONFIG_SYS_MEMTEST_START 0x00400000	/* 4M */
+#define CONFIG_SYS_MEMTEST_END	0x007fffff	/*(_8M -1) */

_8M?

What it should be ?

8M maybe

:-) I will keep it 8M at this moment

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds +3 -0
+#define CONFIG_IPADDR		192.168.5.44
+#define CONFIG_SERVERIP		192.168.5.30
+#define CONFIG_NETMASK		255.255.255.0

please remove the IP params

Why ?

it's board instance specific

Okay I will remove them

Regards..
Prafulla . .

#14 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 5 lines · Prafulla Wadaskar
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 4 lines
(quoted diff) +2 -0
+
+#endif /* CONFIG_MISC_INIT_R */
board/Marvell/mv88f6281gtw_ge/u-boot.lds +0 -0

is it possible to have a shorter name for the board?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

No Jean, not possible, kernel patches also represents the

same name and machine is also register with the same name, pleas bear with this, thanks..
ok if possible next time try a shorter name

Sure... Except one more exception please "mv88f6192gtw_fe"
This is next board whose kernel support and board name registry is already done in linux, this will be the next board support patch from me after getting this stuff in. For next upcomming boards I will keep in mind

ok

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+#define LE 1 /* Specify

LE/BE operation */

Quoted 2 lines
Quoted 1 line

why?

Because SOC can be initialized to work in both the modes.

so the binary will be compile as LE or BE so __ARMEL__ or __ARMEB__ will be defined

Quoted 7 lines

Okay I will change accordingly

Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

+#define CONFIG_SYS_MALLOC_LEN 0x00400000 /* 4M */

4M?

What it should be?

just ask why do you need 4M of malloc?

In future to support all SOC drivers, I will keep it 4M if you agree

ok

Best Regards,
J.

#15 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

In reply to Prafulla Wadaskar

Hi Prafulla,

Prafulla Wadaskar wrote:
<snip>

Quoted 9 lines
Quoted 6 lines

include/configs/mv88f6281gtw_ge.h line 171

Quoted 4 lines
include/configs/mv88f6281gtw_ge.h new file +3 -0
+#define CONFIG_IPADDR		192.168.5.44
+#define CONFIG_SERVERIP		192.168.5.30
+#define CONFIG_NETMASK		255.255.255.0

please remove the IP params

Why ?

Because these values are only relevant to your lab network, not anybody else who's going to use your boards. Boards should start with a clean slate. This is a hard rule that we've been enforcing for a while now - no address or network parameter initializations in config files.

regards,
Ben

#16 lore raw

PATCH v2 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/configs/mv88f6281gtw_ge.h line 171

Quoted 6 lines
include/configs/mv88f6281gtw_ge.h new file +3 -0
+#define CONFIG_IPADDR		192.168.5.44
+#define CONFIG_SERVERIP		192.168.5.30
+#define CONFIG_NETMASK		255.255.255.0

please remove the IP params

Quoted 8 lines
Quoted 3 lines

Why ?

Because these values are only relevant to your lab network, not anybody else who's going to use your boards. Boards should start with a clean slate. This is a hard rule that we've been enforcing for a while now - no address or network parameter initializations in config files.

Thanks Ben for clarification.

Regards..
Prafulla . .

#17 lore raw

PATCH 1/1 Marvell 88EXXXX Switch/PHY init support

In reply to Prafulla Wadaskar

Dear Prafulla Wadaskar,

Quoted 7 lines · In message <[email protected]> you wrote:

From: prafulla_wadaskar <[email protected]>

Chips supprted:-
1. 88E61XX 6 port gbe swtich with 5 integrated PHYs
2. 88E6061 6 port fe swtich with 5 integrated PHYs
3. 88E1116 gbe transceiver

Quoted 6 lines

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

ben has already commented on the incorrect location of this code in the directory hierarchy. I will restrict my review to formal issues.

Quoted 5 lines
board/Marvell/common/mv88e1116.c new file +0 -0
new file mode 100644
index 0000000..87ec550

...

board/Marvell/common/mv88e1116.c line 34

Quoted 8 lines
board/Marvell/common/mv88e1116.c new file +8 -0
+#ifndef MV88E1116_DEBUG
+#define MV88E1116_DEBUG 0
+#endif
+#define DEBUG_PRINT	MV88E1116_DEBUG
+
+#include <common.h>
+#include <debug_prints.h>
+#include "../common/ppc_error_no.h"

See before (i. e. get rid of this stuff, here and everywhere else; it will make the code jkust simpler).

Quoted 5 lines
board/Marvell/common/mv88e60xx.c new file +0 -0
new file mode 100644
index 0000000..6034f7b

...

Quoted 7 lines
board/Marvell/common/mv88e60xx.c new file +7 -0
+static void mv_switch_88e60xx_vlan_init(u32 eth_port_num,
+					u32 switch_cpu_port,
+					u32 switch_max_ports_num,
+					u32 switch_ports_ofs,
+					u32 switch_enabled_ports_mask)
+{
+	u32 prt;

board/Marvell/common/mv88e60xx.c line 102

Quoted 10 lines
board/Marvell/common/mv88e60xx.c new file +10 -0
+	u16 reg;
+
+	debug_print_ftrace();
+	/* be sure all ports are disabled */
+	for (prt = 0; prt < switch_max_ports_num; prt++) {
+		mv_sw_eth_phy_reg_read(eth_port_num, (switch_ports_ofs + prt),
+				       MV88E60XX_PORT_CONTROL_REG, &reg);
+		reg &= ~0x3;
+		mv_sw_eth_phy_reg_write(eth_port_num, (switch_ports_ofs + prt),
+					MV88E60XX_PORT_CONTROL_REG, reg);

Please read the CodingStyle document about resonable choice oif namess for functions, variables, etc. Names like mv_switch_88e60xx_vlan_init(), mv_sw_eth_phy_reg_read(), switch_max_ports_num, etc. are a pain to write, and a bigger pain to read. Please use SIMPLE, readable names.

...

board/Marvell/common/mv88e60xx.c line 307

Quoted 7 lines
board/Marvell/common/mv88e60xx.c new file +7 -0
+U_BOOT_CMD(smi, CONFIG_SYS_MAXARGS, 1, do_smi,
+	   "smi - isues read/write command on smi for switch registers\n",
+	   "smi read [smiaddr] [regaddr] [page]\n"
+	   "    - read smi register command\n"
+	   "smi write [smiaddr] [regaddr] [value] [page]\n"
+	   "    - write <value> to <regaddr> register command\n"
+	   "    - run the commands in the environment variable(s) 'var'\n");

The definition of the U_BOOT_CMD macro has changed, please fix your

...

board/Marvell/common/mv88e60xx.c line 407

Quoted 5 lines
board/Marvell/common/mv88e60xx.c new file +5 -0
+U_BOOT_CMD(dump60xxphy, CONFIG_SYS_MAXARGS, 1, do_dump60xxphy,
+	   "dump60xxphy - dump 88360xx registers\n",
+	   "var [...]\n"
+	   "    - run the commands in the environment variable(s) 'var'\n");
+#endif /* CONFIG_CMD_DUMP60XXPHY */

Ditto.

Hm... if we the function of this is to "dump 88360xx registers", then why is the command name "dump60xxphy" ?

60xx != 88360xx ??

Ditto for the rest of the file.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Eeeek!
'eval' on strings should have been named 'evil'.    -- Tom Phoenix in
        <[email protected]>
#18 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

Chips supprted:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs
2. 88E6165 6 port gbe swtich with 5 integrated PHYs
Note: This driver is supported and tested against kirkwood egiga interface, other interfaces can be added

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments by Wolfgand Denk removed other two drivers form earlier patch debug_prints removed
driver moved to drivers/net/

 drivers/net/Makefile    |    1 +
 drivers/net/mv88e61xx.c |  291 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/mv88e61xx.c
drivers/net/Makefile +1 -0
index f0c5654..7482327 100644
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o
 COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
+COBJS-$(CONFIG_SWITCH_MV88E61XX) += mv88e61xx.o
 COBJS-$(CONFIG_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o
drivers/net/mv88e61xx.c new file +291 -0

291 lines not on this page · raw message

Signature · 1 line
1.5.3.3
#19 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

Quoted 5 lines · Prafulla Wadaskar

Chips supprted:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs
2. 88E6165 6 port gbe swtich with 5 integrated PHYs
Note: This driver is supported and tested against kirkwood egiga interface, other interfaces can be added

We are going to be using this chip in a project, so I'm happy to see this code come by :-) A few comments sprinkled around below.

Quoted 10 lines

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments by Wolfgand Denk

It's always good to spell the name of the guy with commit access right :-)

Quoted 86 lines

removed other two drivers form earlier patch
debug_prints removed
driver moved to drivers/net/

?drivers/net/Makefile ? ?| ? ?1 +
?drivers/net/mv88e61xx.c | ?291 +++++++++++++++++++++++++++++++++++++++++++++++ ?2 files changed, 292 insertions(+), 0 deletions(-)
?create mode 100644 drivers/net/mv88e61xx.c

drivers/net/Makefile +0 -0
index f0c5654..7482327 100644
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o

?COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o ?COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o ?COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o +COBJS-$(CONFIG_SWITCH_MV88E61XX) += mv88e61xx.o ?COBJS-$(CONFIG_NATSEMI) += natsemi.o ?COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o ?COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o

drivers/net/mv88e61xx.c new file +59 -0
new file mode 100644
index 0000000..8167919
@@ -0,0 +1,291 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+#if defined (CONFIG_SWITCH_MV88E61XX)
+
+/* Enabled ports can be enabled in board header file */
+#if defined (CONFIG_MV88E61XX_ENABLED_PORTS)
+#define MV88E61XX_ENABLED_PORTS CONFIG_MV88E61XX_ENABLED_PORTS
+#else
+#define MV88E61XX_ENABLED_PORTS (BIT0 | BIT1 | BIT2 | \
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BIT3 | BIT4 | BIT5)
+#endif
+
+#if defined (CONFIG_88E6161)
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E6161"
+#elif defined (CONFIG_88E6165)
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E6165"
+#else
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E61XX"
+#endif
+
+#define MV88E61XX_PHY_TIMEOUT ? ? ? ? ?100000
+#define MV88E61XX_MAX_PORTS_NUM ? ? ? ? ? ? ? ?0x6
+/* CPU port can be configured in board header file */
+#if defined (CONFIG_MV88E61XX_CPU_PORT)
+#define MV88E61XX_CPU_PORT ? ? ? ? ? ? CONFIG_MV88E61XX_CPU_PORT
+#else
+#define MV88E61XX_CPU_PORT ? ? ? ? ? ? 0x5
+#endif
+
+#define MV88E61XX_PRT_STS_REG ? ? ? ? ?0x1
+#define MV88E61XX_PRT_CTRL_REG ? ? ? ? 0x4
+#define MV88E61XX_PRT_VMAP_REG ? ? ? ? 0x6
+#define MV88E61XX_PRT_VID_REG ? ? ? ? ?0x7
+
+#define MV88E61XX_PRT_OFST ? ? ? ? ? ? 0x10

drivers/net/mv88e61xx.c line 69

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+#define MV88E61XX_PHY_CMD ? ? ? ? ? ? ?0x18
+#define MV88E61XX_PHY_DATA ? ? ? ? ? ? 0x19
+#define MV88E61XX_GLOBAL2_REG_DEVADR ? 0x1C
+
+#ifdef CONFIG_KIRKWOOD_EGIGA
+#define smi_wr_reg ? ? eth_smi_reg_write
+#define smi_rd_reg ? ? eth_smi_reg_read
+#else /* add new interface above this */
+#error Unsupported interface
+#endif

As far as I understand it, "SMI" for the 88E6161 is really just the physical MII layer with some changes in the register definitions. Would it not make more sense to use the existing u-boot miiphy code in common/miiphyutil.c to define the access functions? This allows for platform code to register mii access functions and gets platform specific stuff like this out of the driver.

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+/* Chip Address mode
+ * The Switch support two modes of operation
+ * 1. single chip mode and
+ * 2. Multi-chip mode
+ * Refer chip documentation for more details
+ *
+ * By default single chip mode is configured
+ * multichip mode operation can be configured in board header
+ */

drivers/net/mv88e61xx.c

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
+#define mv88e61xx_wr_phy smi_wr_reg
+#define mv88e61xx_rd_phy smi_rd_reg
+#else
+void mv88e61xx_wr_phy(u32 port, u32 phy_adr, u32 reg_ofs, u16 data)
+{
+ ? ? ? u16 reg;
+ ? ? ? u32 smi_dev_addr;
+
+ ? ? ? smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));

if CONFIG_MV88E61XX_MULTICHIP_ADRMODE is defined you're going to reference the KW_REG_READ and KW_ETH_PHY_ADDR_REG macros, which don't seem to be defined in this file. I'm assuming this is platform specific stuff.

drivers/net/mv88e61xx.c line 93

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+ ? ? ? do {
+ ? ? ? ? ? ? ? smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+ ? ? ? } while ((reg & BIT15));
+ ? ? ? /* Poll till SMIBusy bit is clear */

How about a timeout here? I'm not a C style maven, but the extra () in the test could probably go away. Some constants for register names and bit functions would help as well. This code appears several times, so maybe could be factored out. Also the commenting style is a bit random through the file - sometimes the comment is before the action, other times afterwards.

drivers/net/mv88e61xx.c line 106

Quoted 13 lines
drivers/net/mv88e61xx.c new file +13 -0
+ ? ? ? smi_wr_reg(port, smi_dev_addr, 0x1, data);
+ ? ? ? /* Write data to Switch indirect data register */
+ ? ? ? smi_wr_reg(port, smi_dev_addr, 0x0,
+ ? ? ? ? ? ? ? ? ?reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+ ? ? ? /* Write command to Switch indirect command register (write) */
+}
+
+void mv88e61xx_rd_phy(u32 port, u32 phy_adr, u32 reg_ofs, u16 * data)
+{
+ ? ? ? u16 reg;
+ ? ? ? u32 smi_dev_addr;
+
+ ? ? ? smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));

ditto above regarding the KW* macros

Quoted 20 lines
drivers/net/mv88e61xx.c new file +20 -0
+ ? ? ? do {
+ ? ? ? ? ? ? ? smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+ ? ? ? } while ((reg & BIT15));
+ ? ? ? /* Poll till SMIBusy bit is clear */
+ ? ? ? smi_wr_reg(port, smi_dev_addr, 0x0,
+ ? ? ? ? ? ? ? ? ?reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+ ? ? ? /* Write command to Switch indirect command register (read) */
+ ? ? ? do {
+ ? ? ? ? ? ? ? smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+ ? ? ? } while ((reg & BIT15));
+ ? ? ? /* Poll till SMIBusy bit is clear */
+ ? ? ? smi_rd_reg(port, smi_dev_addr, 0x1, (u16 *) & data);
+ ? ? ? /* Read data from Switch indirect data register */
+}
+#endif /* CONFIG_MV88E61XX_MULTICHIP_ADRMODE */
+
+static void mv88e61xx_vlaninit(u32 port, u32 cpu_port, u32 max_prtnum,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?u32 ports_ofs, u32 port_mask)
+{
+ ? ? ? u32 prt;

drivers/net/mv88e61xx.c line 136

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ ? ? ? u16 reg;
+
+ ? ? ? /* be sure all ports are disabled */
+ ? ? ? for (prt = 0; prt < max_prtnum; prt++) {
+ ? ? ? ? ? ? ? mv88e61xx_rd_phy(port, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&reg);
+ ? ? ? ? ? ? ? reg &= ~0x3;
+ ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?reg);
+ ? ? ? }

Would this code (and similar code below) work on the 88E6123 which (IIRC) only has ports 0, 1, and 5?

Quoted 86 lines
drivers/net/mv88e61xx.c new file +86 -0
+ ? ? ? /* Set CPU port VID to 0x1 */
+ ? ? ? mv88e61xx_rd_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ?&reg);
+ ? ? ? reg &= ~0xfff;
+ ? ? ? reg |= 0x1;
+ ? ? ? mv88e61xx_wr_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ?reg);
+
+ ? ? ? /* Setting ?Port default priority for all ports to zero */
+ ? ? ? for (prt = 0; prt < max_prtnum; prt++) {
+ ? ? ? ? ? ? ? mv88e61xx_rd_phy(port, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&reg);
+ ? ? ? ? ? ? ? reg &= ~0xc000;
+ ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?reg);
+ ? ? ? }
+ ? ? ? /* Setting VID and VID map for all ports except CPU port */
+ ? ? ? for (prt = 0; prt < max_prtnum; prt++) {
+ ? ? ? ? ? ? ? /* only for enabled ports */
+ ? ? ? ? ? ? ? if ((1 << prt) & port_mask) {
+ ? ? ? ? ? ? ? ? ? ? ? /* skip CPU port */
+ ? ? ? ? ? ? ? ? ? ? ? if (prt == cpu_port)
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? continue;
+
+ ? ? ? ? ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ? ? ? ? ?* ?set Ports VLAN Mapping.
+ ? ? ? ? ? ? ? ? ? ? ? ?* ? ? ?port prt <--> MV88E61XX_CPU_PORT VLAN #prt+1.
+ ? ? ? ? ? ? ? ? ? ? ? ?*/
+
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_rd_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_VID_REG, &reg);
+ ? ? ? ? ? ? ? ? ? ? ? reg &= ~0x0fff;
+ ? ? ? ? ? ? ? ? ? ? ? reg |= (prt + 1);
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_VID_REG, reg);
+
+ ? ? ? ? ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ? ? ? ? ?* Set Vlan map table for all ports to send only to
+ ? ? ? ? ? ? ? ? ? ? ? ?* MV88E61XX_CPU_PORT
+ ? ? ? ? ? ? ? ? ? ? ? ?*/
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_rd_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_VMAP_REG, &reg);
+ ? ? ? ? ? ? ? ? ? ? ? reg &= ~((1 << max_prtnum) - 1);
+ ? ? ? ? ? ? ? ? ? ? ? reg |= (1 << cpu_port);
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_VMAP_REG, reg);
+ ? ? ? ? ? ? ? }
+ ? ? ? }
+ ? ? ? /* Set Vlan map table for MV88E61XX_CPU_PORT to see all ports */
+ ? ? ? mv88e61xx_rd_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ?&reg);
+ ? ? ? reg &= ~((1 << max_prtnum) - 1);
+ ? ? ? reg |= port_mask & ~(1 << cpu_port);
+ ? ? ? mv88e61xx_wr_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+ ? ? ? ? ? ? ? ? ? ? ? ?reg);
+
+ ? ? ? /*
+ ? ? ? ?* enable only appropriate ports to forwarding mode
+ ? ? ? ?* and disable the others
+ ? ? ? ?*/
+ ? ? ? for (prt = 0; prt < max_prtnum; prt++) {
+ ? ? ? ? ? ? ? if ((1 << prt) & port_mask) {
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_rd_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_CTRL_REG, &reg);
+ ? ? ? ? ? ? ? ? ? ? ? reg |= 0x3;
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_CTRL_REG, reg);
+ ? ? ? ? ? ? ? } else {
+ ? ? ? ? ? ? ? ? ? ? ? /* Disable port */
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_rd_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_CTRL_REG, &reg);
+ ? ? ? ? ? ? ? ? ? ? ? reg &= ~0x3;
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, ports_ofs + prt,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_CTRL_REG, reg);
+ ? ? ? ? ? ? ? }
+ ? ? ? }
+}
+
+/*
+ * Marvell 88E61XX Switch initialization
+ */
+int mv_switch_88e61xx_init(u32 port)
+{
+ ? ? ? u32 prt;
+ ? ? ? u16 reg;
+ ? ? ? volatile u32 timeout;

drivers/net/mv88e61xx.c line 232

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+ ? ? ? /* Init vlan */
+ ? ? ? mv88e61xx_vlaninit(port, MV88E61XX_CPU_PORT, MV88E61XX_MAX_PORTS_NUM,
+ ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PRT_OFST, MV88E61XX_ENABLED_PORTS);
+
+ ? ? ? /* Enable RGMII delay on Tx and Rx for CPU port */
+ ? ? ? mv88e61xx_wr_phy(port, 0x14, 0x1a, 0x81e7);
+ ? ? ? mv88e61xx_rd_phy(port, 0x15, 0x1a, &reg);
+ ? ? ? mv88e61xx_wr_phy(port, 0x15, 0x1a, 0x18);
+ ? ? ? mv88e61xx_wr_phy(port, 0x14, 0x1a, 0xc1e7);

^ -- lots of magic numbers above and below here -- v

In the middle of the above sequence you read the phy, but don't seem to do anything with 'reg'. Is this required?

What if I don't want RGMII delay as I'm using GMII on my platform?

Quoted 35 lines
drivers/net/mv88e61xx.c new file +35 -0
+
+ ? ? ? for (prt = 0; prt < MV88E61XX_MAX_PORTS_NUM; prt++) {
+ ? ? ? ? ? ? ? if (prt != MV88E61XX_CPU_PORT) {
+ ? ? ? ? ? ? ? ? ? ? ? /*Enable Phy power up */
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PHY_DATA, 0x3360);
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PHY_CMD,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(0x9410 | (prt << 5)));
+
+ ? ? ? ? ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ? ? ? ? ?* Make sure SMIBusy bit cleared before another
+ ? ? ? ? ? ? ? ? ? ? ? ?* SMI operation can take place
+ ? ? ? ? ? ? ? ? ? ? ? ?*/
+ ? ? ? ? ? ? ? ? ? ? ? timeout = MV88E61XX_PHY_TIMEOUT;
+ ? ? ? ? ? ? ? ? ? ? ? do {
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_rd_phy(port,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_GLOBAL2_REG_DEVADR,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PHY_CMD, &reg);
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (timeout-- == 0) {
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf("SMI busy timeout\n");
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return -1;
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
+ ? ? ? ? ? ? ? ? ? ? ? } while (reg & BIT28); ?/* busy mask */
+
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PHY_DATA, 0x1140);
+ ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PHY_CMD,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(0x9400 | (prt << 5)));
+
+ ? ? ? ? ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ? ? ? ? ?* Make sure SMIBusy bit cleared before another
+ ? ? ? ? ? ? ? ? ? ? ? ?* SMI operation can take place
+ ? ? ? ? ? ? ? ? ? ? ? ?*/

drivers/net/mv88e61xx.c line 277

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ ? ? ? ? ? ? ? ? ? ? ? timeout = MV88E61XX_PHY_TIMEOUT;
+ ? ? ? ? ? ? ? ? ? ? ? do {
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? mv88e61xx_rd_phy(port,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_GLOBAL2_REG_DEVADR,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MV88E61XX_PHY_CMD, &reg);
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (timeout-- == 0) {
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf("SMI busy timeout\n");
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return -1;
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
+ ? ? ? ? ? ? ? ? ? ? ? } while (reg & BIT28); ?/* busy mask */

replicated status polling code, might want to factor it out.

drivers/net/mv88e61xx.c line 285

Quoted 8 lines
drivers/net/mv88e61xx.c new file +8 -0
+ ? ? ? ? ? ? ? }
+
+ ? ? ? ? ? ? ? /*Enable port */
+ ? ? ? ? ? ? ? mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST + prt, 4, 0x7f);
+ ? ? ? }
+ ? ? ? /*Force CPU port to RGMII FDX 1000Base */
+ ? ? ? mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST + MV88E61XX_CPU_PORT, 1,
+ ? ? ? ? ? ? ? ? ? ? ? ?0x3e);

This last write seems very platform specific, for example in our case we want GMII, not RGMII. On another project we might want ports 4 & 5 to use the copper phy.

Quoted 14 lines
drivers/net/mv88e61xx.c new file +6 -1
+
+ ? ? ? printf(MV88E61XX_NAME " Initialized\n");
+ ? ? ? return 0;
+}
+
+#endif /* CONFIG_SWITCH_MV88E61XX */
--

1.5.3.3

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 2 lines
Hardware, n.:
        The parts of a computer system that can be kicked.
#20 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

Dear Andrew Dyer,

Quoted 4 lines · In message <[email protected]> you…
Quoted 2 lines

v2: updated as per review comments by Wolfgand Denk

It's always good to spell the name of the guy with commit access right :-)

He. I'm not Russell King.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"This is a test of the Emergency Broadcast System. If this had been an
actual emergency, do you really think we'd stick around to tell you?"
#21 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

In reply to Andrew Dyer
Quoted 14 lines

-----Original Message-----
From: Andrew Dyer [mailto:amdyer at gmail.com]
Sent: Thursday, April 09, 2009 4:03 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v2] Marvell MV88E61XX Switch Driver support

Quoted 2 lines · Prafulla Wadaskar

Chips supprted:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs 2.

Quoted 7 lines

88E6165 6 port

Quoted 3 lines

gbe swtich with 5 integrated PHYs
Note: This driver is supported and tested against kirkwood egiga interface, other interfaces can be added

We are going to be using this chip in a project, so I'm happy to see this code come by :-) A few comments sprinkled around below.

Welcome...

Quoted 102 lines
Quoted 11 lines

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments by Wolfgand Denk

It's always good to spell the name of the guy with commit access right :-)

Quoted 14 lines

removed other two drivers form earlier patch debug_prints removed driver moved to drivers/net/

 drivers/net/Makefile    |    1 +
 drivers/net/mv88e61xx.c |  291
+++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/mv88e61xx.c
drivers/net/Makefile index renamed from drivers/net/Makefile +0 -0

f0c5654..7482327 100644

drivers/net/Makefile COBJS-$(CONFIG_MACB) += macb.o · line 53

Quoted 7 lines
drivers/net/Makefile +1 -0
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o
 COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
+COBJS-$(CONFIG_SWITCH_MV88E61XX) += mv88e61xx.o
 COBJS-$(CONFIG_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o

diff --git

Quoted 14 lines

a/drivers/net/mv88e61xx.c b/drivers/net/mv88e61xx.c new file mode 100644 index 0000000..8167919

drivers/net/mv88e61xx.c new file +9 -0
@@ -0,0 +1,291 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or

drivers/net/mv88e61xx.c line 19

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General

Public License

drivers/net/mv88e61xx.c line 29

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+#if defined (CONFIG_SWITCH_MV88E61XX)
+
+/* Enabled ports can be enabled in board header file */

#if defined

drivers/net/mv88e61xx.c line 31

Quoted 2 lines
drivers/net/mv88e61xx.c new file +2 -0
+(CONFIG_MV88E61XX_ENABLED_PORTS) #define MV88E61XX_ENABLED_PORTS
+CONFIG_MV88E61XX_ENABLED_PORTS #else #define

MV88E61XX_ENABLED_PORTS

Quoted 11 lines
drivers/net/mv88e61xx.c new file +11 -0
+(BIT0 | BIT1 | BIT2 | \
+                                 BIT3 | BIT4 | BIT5) #endif
+
+#if defined (CONFIG_88E6161)
+#define MV88E61XX_NAME                 "88E6161"
+#elif defined (CONFIG_88E6165)
+#define MV88E61XX_NAME                 "88E6165"
+#else
+#define MV88E61XX_NAME                 "88E61XX"
+#endif
+

drivers/net/mv88e61xx.c

Quoted 10 lines
drivers/net/mv88e61xx.c new file +9 -0
+#define MV88E61XX_PHY_TIMEOUT          100000 #define
+MV88E61XX_MAX_PORTS_NUM                0x6
+/* CPU port can be configured in board header file */ #if defined
+(CONFIG_MV88E61XX_CPU_PORT) #define MV88E61XX_CPU_PORT
+CONFIG_MV88E61XX_CPU_PORT #else #define MV88E61XX_CPU_PORT
 
+0x5 #endif
+
+#define MV88E61XX_PRT_STS_REG          0x1 #define
+MV88E61XX_PRT_CTRL_REG         0x4 #define

MV88E61XX_PRT_VMAP_REG

drivers/net/mv88e61xx.c

Quoted 3 lines

+0x6 #define MV88E61XX_PRT_VID_REG 0x7

drivers/net/mv88e61xx.c new file +2 -0
+
+#define MV88E61XX_PRT_OFST             0x10 #define

MV88E61XX_PHY_CMD

Quoted 16 lines

drivers/net/mv88e61xx.c

Quoted 7 lines

+0x18 #define MV88E61XX_PHY_DATA 0x19 #define

drivers/net/mv88e61xx.c new file +6 -0
+MV88E61XX_GLOBAL2_REG_DEVADR   0x1C
+
+#ifdef CONFIG_KIRKWOOD_EGIGA
+#define smi_wr_reg     eth_smi_reg_write #define smi_rd_reg
+eth_smi_reg_read #else /* add new interface above this */ #error
+Unsupported interface #endif

As far as I understand it, "SMI" for the 88E6161 is really just the physical MII layer with some changes in the register definitions.
Would it not make more sense to use the existing u-boot miiphy code in common/miiphyutil.c to define the access functions? This allows for platform code to register mii access functions and gets platform specific stuff like this out of the driver.

Thanks..miiphy is used for the same

Quoted 21 lines
Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+
+/* Chip Address mode
+ * The Switch support two modes of operation
+ * 1. single chip mode and

drivers/net/mv88e61xx.c

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ * 2. Multi-chip mode
+ * Refer chip documentation for more details
+ *
+ * By default single chip mode is configured
+ * multichip mode operation can be configured in board header  */
+#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
+#define mv88e61xx_wr_phy smi_wr_reg
+#define mv88e61xx_rd_phy smi_rd_reg
+#else
+void mv88e61xx_wr_phy(u32 port, u32 phy_adr, u32 reg_ofs,

u16 data) {

drivers/net/mv88e61xx.c line 89

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+       u16 reg;
+       u32 smi_dev_addr;
+
+       smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));
Quoted 4 lines

if CONFIG_MV88E61XX_MULTICHIP_ADRMODE is defined you're going to reference the KW_REG_READ and KW_ETH_PHY_ADDR_REG macros, which don't seem to be defined in this file. I'm assuming this is platform specific stuff.

It is more egiga driver specific,
you need to read phy address programmed for respective egga port on
Gbe controller to establish communication,
this settings is done in egiga driver, but there is no generic interface to read this To make it more generic I have used miiphy api
i.e.
miiphy_read(name, 0xEE, 0xEE, &mii_dev_adr);
Values 0xEE are dummy to identify phy_address read.

Hope this will help,
we can define special interface in future if this becomes generic usecase

Quoted 6 lines

drivers/net/mv88e61xx.c line 93

Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+       do {
+               smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+       } while ((reg & BIT15));
+       /* Poll till SMIBusy bit is clear */
Quoted 7 lines

How about a timeout here? I'm not a C style maven, but the extra () in the test could probably go away. Some constants for register names and bit functions would help as well. This code appears several times, so maybe could be factored out. Also the commenting style is a bit random through the file - sometimes the comment is before the action, other times afterwards.

Corrected....
Code factored too..

Quoted 49 lines

drivers/net/mv88e61xx.c

Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+       smi_wr_reg(port, smi_dev_addr, 0x1, data);
+       /* Write data to Switch indirect data register */
+       smi_wr_reg(port, smi_dev_addr, 0x0,
+                  reg_ofs | (phy_adr << 5) | BIT10 | BIT12

| BIT15);

Quoted 1 line

+ /* Write command to Switch indirect command

register (write)

drivers/net/mv88e61xx.c

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+*/ }
+
+void mv88e61xx_rd_phy(u32 port, u32 phy_adr, u32 reg_ofs,

u16 * data)

drivers/net/mv88e61xx.c line 89

Quoted 5 lines
drivers/net/mv88e61xx.c new file +5 -0
+{
+       u16 reg;
+       u32 smi_dev_addr;
+
+       smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));

ditto above regarding the KW* macros

drivers/net/mv88e61xx.c

Quoted 6 lines
drivers/net/mv88e61xx.c new file +6 -0
+       do {
+               smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+       } while ((reg & BIT15));
+       /* Poll till SMIBusy bit is clear */
+       smi_wr_reg(port, smi_dev_addr, 0x0,
+                  reg_ofs | (phy_adr << 5) | BIT10 | BIT12

| BIT15);

Quoted 1 line

+ /* Write command to Switch indirect command

register (read) */

drivers/net/mv88e61xx.c line 119

Quoted 6 lines
drivers/net/mv88e61xx.c new file +6 -0
+       do {
+               smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+       } while ((reg & BIT15));
+       /* Poll till SMIBusy bit is clear */
+       smi_rd_reg(port, smi_dev_addr, 0x1, (u16 *) & data);
+       /* Read data from Switch indirect data register */

} #endif /*

Quoted 13 lines
drivers/net/mv88e61xx.c new file +13 -0
+CONFIG_MV88E61XX_MULTICHIP_ADRMODE */
+
+static void mv88e61xx_vlaninit(u32 port, u32 cpu_port, u32
+max_prtnum,
+                              u32 ports_ofs, u32 port_mask) {
+       u32 prt;
+       u16 reg;
+
+       /* be sure all ports are disabled */
+       for (prt = 0; prt < max_prtnum; prt++) {
+               mv88e61xx_rd_phy(port, ports_ofs + prt,
+ MV88E61XX_PRT_CTRL_REG,
+                                &reg);
Quoted 8 lines

drivers/net/mv88e61xx.c line 211

Quoted 5 lines
drivers/net/mv88e61xx.c new file +5 -0
+               reg &= ~0x3;
+               mv88e61xx_wr_phy(port, ports_ofs + prt,
+ MV88E61XX_PRT_CTRL_REG,
+                                reg);
+       }

Would this code (and similar code below) work on the 88E6123 which (IIRC) only has ports 0, 1, and 5?

It should.... I have added detection logic for 88E6123 too

Quoted 118 lines
Quoted 22 lines
drivers/net/mv88e61xx.c new file +21 -0
+       /* Set CPU port VID to 0x1 */
+       mv88e61xx_rd_phy(port, (ports_ofs + cpu_port),
+ MV88E61XX_PRT_VID_REG,
+                        &reg);
+       reg &= ~0xfff;
+       reg |= 0x1;
+       mv88e61xx_wr_phy(port, (ports_ofs + cpu_port),
+ MV88E61XX_PRT_VID_REG,
+                        reg);
+
+       /* Setting  Port default priority for all ports to zero */
+       for (prt = 0; prt < max_prtnum; prt++) {
+               mv88e61xx_rd_phy(port, ports_ofs + prt,
+ MV88E61XX_PRT_VID_REG,
+                                &reg);
+               reg &= ~0xc000;
+               mv88e61xx_wr_phy(port, ports_ofs + prt,
+ MV88E61XX_PRT_VID_REG,
+                                reg);
+       }
+       /* Setting VID and VID map for all ports except CPU port */

drivers/net/mv88e61xx.c

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+       for (prt = 0; prt < max_prtnum; prt++) {
+               /* only for enabled ports */
+               if ((1 << prt) & port_mask) {
+                       /* skip CPU port */
+                       if (prt == cpu_port)
+                               continue;
+
+                       /*
+                        *  set Ports VLAN Mapping.
+                        *      port prt <-->

MV88E61XX_CPU_PORT VLAN #prt+1.

drivers/net/mv88e61xx.c line 172

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+                        */
+
+                       mv88e61xx_rd_phy(port, ports_ofs + prt,
+

MV88E61XX_PRT_VID_REG, &reg);

drivers/net/mv88e61xx.c line 172

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+                       reg &= ~0x0fff;
+                       reg |= (prt + 1);
+                       mv88e61xx_wr_phy(port, ports_ofs + prt,
+

MV88E61XX_PRT_VID_REG, reg);

drivers/net/mv88e61xx.c line 214

Quoted 13 lines
drivers/net/mv88e61xx.c new file +13 -0
+
+                       /*
+                        * Set Vlan map table for all ports to send
+ only to
+                        * MV88E61XX_CPU_PORT
+                        */
+                       mv88e61xx_rd_phy(port, ports_ofs + prt,
+                                        MV88E61XX_PRT_VMAP_REG,
+ &reg);
+                       reg &= ~((1 << max_prtnum) - 1);
+                       reg |= (1 << cpu_port);
+                       mv88e61xx_wr_phy(port, ports_ofs + prt,
+

MV88E61XX_PRT_VMAP_REG, reg);

drivers/net/mv88e61xx.c

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+               }
+       }
+       /* Set Vlan map table for MV88E61XX_CPU_PORT to see

all ports

Quoted 12 lines

+ */

drivers/net/mv88e61xx.c new file +11 -0
+       mv88e61xx_rd_phy(port, (ports_ofs + cpu_port),
+ MV88E61XX_PRT_VMAP_REG,
+                        &reg);
+       reg &= ~((1 << max_prtnum) - 1);
+       reg |= port_mask & ~(1 << cpu_port);
+       mv88e61xx_wr_phy(port, (ports_ofs + cpu_port),
+ MV88E61XX_PRT_VMAP_REG,
+                        reg);
+
+       /*
+        * enable only appropriate ports to forwarding mode

drivers/net/mv88e61xx.c line 214

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+        * and disable the others
+        */
+       for (prt = 0; prt < max_prtnum; prt++) {
+               if ((1 << prt) & port_mask) {
+                       mv88e61xx_rd_phy(port, ports_ofs + prt,
+                                        MV88E61XX_PRT_CTRL_REG,
+&reg);
+                       reg |= 0x3;
+                       mv88e61xx_wr_phy(port, ports_ofs + prt,
+

MV88E61XX_PRT_CTRL_REG, reg);

drivers/net/mv88e61xx.c line 214

Quoted 8 lines
drivers/net/mv88e61xx.c new file +8 -0
+               } else {
+                       /* Disable port */
+                       mv88e61xx_rd_phy(port, ports_ofs + prt,
+                                        MV88E61XX_PRT_CTRL_REG,
+&reg);
+                       reg &= ~0x3;
+                       mv88e61xx_wr_phy(port, ports_ofs + prt,
+

MV88E61XX_PRT_CTRL_REG, reg);

Quoted 12 lines
drivers/net/mv88e61xx.c new file +12 -0
+               }
+       }
+}
+
+/*
+ * Marvell 88E61XX Switch initialization  */ int
+mv_switch_88e61xx_init(u32 port) {
+       u32 prt;
+       u16 reg;
+       volatile u32 timeout;
+
+       /* Init vlan */

drivers/net/mv88e61xx.c line 232

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+       mv88e61xx_vlaninit(port, MV88E61XX_CPU_PORT,
+ MV88E61XX_MAX_PORTS_NUM,
+                          MV88E61XX_PRT_OFST,
+ MV88E61XX_ENABLED_PORTS);
+
+       /* Enable RGMII delay on Tx and Rx for CPU port */
+       mv88e61xx_wr_phy(port, 0x14, 0x1a, 0x81e7);
+       mv88e61xx_rd_phy(port, 0x15, 0x1a, &reg);
+       mv88e61xx_wr_phy(port, 0x15, 0x1a, 0x18);
+       mv88e61xx_wr_phy(port, 0x14, 0x1a, 0xc1e7);

^ -- lots of magic numbers above and below here -- v

Quoted 2 lines

In the middle of the above sequence you read the phy, but don't seem to do anything with 'reg'. Is this required?

I am sorry at this moment, I will replace them latter since I don't have enough data

Quoted 2 lines

What if I don't want RGMII delay as I'm using GMII on my platform?

For GMII/MII above settings not required... I have encapsulated them with CONFIG_SYS_RGMII_MODE

Quoted 74 lines

drivers/net/mv88e61xx.c line 257

Quoted 8 lines
drivers/net/mv88e61xx.c new file +7 -0
+
+       for (prt = 0; prt < MV88E61XX_MAX_PORTS_NUM; prt++) {
+               if (prt != MV88E61XX_CPU_PORT) {
+                       /*Enable Phy power up */
+                       mv88e61xx_wr_phy(port,
+ MV88E61XX_GLOBAL2_REG_DEVADR,
+

MV88E61XX_PHY_DATA, 0x3360);

Quoted 9 lines
drivers/net/mv88e61xx.c new file +9 -0
+                       mv88e61xx_wr_phy(port,
+ MV88E61XX_GLOBAL2_REG_DEVADR,
+                                        MV88E61XX_PHY_CMD,
+                                        (0x9410 | (prt << 5)));
+
+                       /*
+                        * Make sure SMIBusy bit cleared before
+ another
+                        * SMI operation can take place

drivers/net/mv88e61xx.c

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+                        */
+                       timeout = MV88E61XX_PHY_TIMEOUT;
+                       do {
+                               mv88e61xx_rd_phy(port,
+
+ MV88E61XX_GLOBAL2_REG_DEVADR,
+                                                MV88E61XX_PHY_CMD,
+ &reg);
+                               if (timeout-- == 0) {
+                                       printf("SMI busy

timeout\n");

drivers/net/mv88e61xx.c line 279

Quoted 7 lines
drivers/net/mv88e61xx.c new file +7 -0
+                                       return -1;
+                               }
+                       } while (reg & BIT28);  /* busy mask */
+
+                       mv88e61xx_wr_phy(port,
+ MV88E61XX_GLOBAL2_REG_DEVADR,
+

MV88E61XX_PHY_DATA, 0x1140);

Quoted 9 lines
drivers/net/mv88e61xx.c new file +9 -0
+                       mv88e61xx_wr_phy(port,
+ MV88E61XX_GLOBAL2_REG_DEVADR,
+                                        MV88E61XX_PHY_CMD,
+                                        (0x9400 | (prt << 5)));
+
+                       /*
+                        * Make sure SMIBusy bit cleared before
+ another
+                        * SMI operation can take place

drivers/net/mv88e61xx.c

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+                        */
+                       timeout = MV88E61XX_PHY_TIMEOUT;
+                       do {
+                               mv88e61xx_rd_phy(port,
+
+ MV88E61XX_GLOBAL2_REG_DEVADR,
+                                                MV88E61XX_PHY_CMD,
+ &reg);
+                               if (timeout-- == 0) {
+                                       printf("SMI busy

timeout\n");

drivers/net/mv88e61xx.c line 256

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+                                       return -1;
+                               }
+                       } while (reg & BIT28);  /* busy mask */

replicated status polling code, might want to factor it out.

drivers/net/mv88e61xx.c line 285

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+               }
+
+               /*Enable port */
+               mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST + prt, 4,
+ 0x7f);
+       }
+       /*Force CPU port to RGMII FDX 1000Base */
+       mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST +
+ MV88E61XX_CPU_PORT, 1,
+                        0x3e);
Quoted 1 line

This last write seems very platform specific, for example in

These lines removed, by default switch detects speed normaly

Quoted 2 lines

our case we want GMII, not RGMII. On another project we might want ports 4 & 5 to use the copper phy.

In this case this driver many need updates, or we need to provide such interface.
Any was current objective of this driver it to power up Phy and configure switch in managed mode. Also there are several h/s settings that go on the board which configures switch on power on Reset.

Thanks for feedback, I have updated the driver, will post v3 soon

Regards..
Prafulla . .

Quoted 22 lines
Quoted 10 lines
drivers/net/mv88e61xx.c new file +6 -1
+
+       printf(MV88E61XX_NAME " Initialized\n");
+       return 0;
+}
+
+#endif /* CONFIG_SWITCH_MV88E61XX */
--

1.5.3.3

Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

--
Hardware, n.:
The parts of a computer system that can be kicked.

#22 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

In reply to Prafulla Wadaskar
Quoted 36 lines · Prafulla Wadaskar
drivers/net/mv88e61xx.c new file +33 -0
@@ -0,0 +1,291 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+#if defined (CONFIG_SWITCH_MV88E61XX)
+
+/* Enabled ports can be enabled in board header file */
+#if defined (CONFIG_MV88E61XX_ENABLED_PORTS)
+#define MV88E61XX_ENABLED_PORTS CONFIG_MV88E61XX_ENABLED_PORTS
+#else
+#define MV88E61XX_ENABLED_PORTS (BIT0 | BIT1 | BIT2 | \

drivers/net/mv88e61xx.c line 43

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BIT3 | BIT4 | BIT5)
+#endif
+
+#if defined (CONFIG_88E6161)
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E6161"
+#elif defined (CONFIG_88E6165)
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E6165"
+#else
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E61XX"
+#endif

Is this discoverable at runtime? What if there's a system that supports using multiple different types of MV88E61xx? I know it's a bit of a crazy idea, but board designers like to screw around with software developers like that.

drivers/net/mv88e61xx.c line 46

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+
+#define MV88E61XX_PHY_TIMEOUT ? ? ? ? ?100000
+#define MV88E61XX_MAX_PORTS_NUM ? ? ? ? ? ? ? ?0x6

Is this a limitation of the 88e61xx architecture, or just the max number on all of the currently shipping versions?

drivers/net/mv88e61xx.c line 69

Quoted 7 lines
drivers/net/mv88e61xx.c new file +7 -0
+
+#ifdef CONFIG_KIRKWOOD_EGIGA
+#define smi_wr_reg ? ? eth_smi_reg_write
+#define smi_rd_reg ? ? eth_smi_reg_read
+#else /* add new interface above this */
+#error Unsupported interface
+#endif

This sort of thing is discouraged. Why does this driver need to know about the ethernet controller? Perhaps function pointers are needed?

Andy

#23 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

Quoted 57 lines

-----Original Message-----
From: Andy Fleming [mailto:afleming at gmail.com]
Sent: Thursday, April 09, 2009 4:43 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v2] Marvell MV88E61XX Switch Driver support

Quoted 12 lines · Prafulla Wadaskar
drivers/net/mv88e61xx.c new file +9 -0
@@ -0,0 +1,291 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or

drivers/net/mv88e61xx.c line 19

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General 

Public License

Quoted 22 lines
drivers/net/mv88e61xx.c new file +22 -0
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+#if defined (CONFIG_SWITCH_MV88E61XX)
+
+/* Enabled ports can be enabled in board header file */
+#if defined (CONFIG_MV88E61XX_ENABLED_PORTS)
+#define MV88E61XX_ENABLED_PORTS CONFIG_MV88E61XX_ENABLED_PORTS
+#else
+#define MV88E61XX_ENABLED_PORTS (BIT0 | BIT1 | BIT2 | \
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BIT3 | BIT4 | BIT5)
+#endif
+
+#if defined (CONFIG_88E6161)
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E6161"
+#elif defined (CONFIG_88E6165)
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E6165"
+#else
Quoted 8 lines

drivers/net/mv88e61xx.c line 43

Quoted 2 lines
drivers/net/mv88e61xx.c new file +2 -0
+#define MV88E61XX_NAME ? ? ? ? ? ? ? ? "88E61XX"
+#endif

Is this discoverable at runtime? What if there's a system that supports using multiple different types of MV88E61xx? I know it's a bit of a crazy idea, but board designers like to screw around with software developers like that.

Yes... I have done it, you will find it in PATCH v3

Quoted 8 lines

drivers/net/mv88e61xx.c line 46

Quoted 5 lines
drivers/net/mv88e61xx.c new file +3 -0
+
+#define MV88E61XX_PHY_TIMEOUT ? ? ? ? ?100000
+#define MV88E61XX_MAX_PORTS_NUM ? ? ? ? ? ? ? ?0x6

Is this a limitation of the 88e61xx architecture, or just the max number on all of the currently shipping versions?

No this represents how many maximum ports there are in 6161/6165 and those are 6

Quoted 12 lines

drivers/net/mv88e61xx.c line 69

Quoted 8 lines
drivers/net/mv88e61xx.c new file +7 -0
+
+#ifdef CONFIG_KIRKWOOD_EGIGA
+#define smi_wr_reg ? ? eth_smi_reg_write
+#define smi_rd_reg ? ? eth_smi_reg_read
+#else /* add new interface above this */
+#error Unsupported interface
+#endif

This sort of thing is discouraged. Why does this driver need to know about the ethernet controller? Perhaps function pointers are needed?

Yes this is removed and the interface is addressed through miiphy_read/write Thanks ...
Regards..
Prafulla . .

Quoted 2 lines

Andy

#24 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

In reply to Prafulla Wadaskar

Hi Prafulla,

Quoted 29 lines · Prafulla Wadaskar

Chips supprted:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs
2. 88E6165 6 port gbe swtich with 5 integrated PHYs
Note: This driver is supported and tested against kirkwood egiga interface, other interfaces can be added

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments by Wolfgand Denk removed other two drivers form earlier patch debug_prints removed
driver moved to drivers/net/

 drivers/net/Makefile    |    1 +
 drivers/net/mv88e61xx.c |  291 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/mv88e61xx.c
drivers/net/Makefile +0 -0
index f0c5654..7482327 100644

drivers/net/Makefile COBJS-$(CONFIG_MACB) += macb.o · line 51

Quoted 5 lines
drivers/net/Makefile +1 -0
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o
 COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
+COBJS-$(CONFIG_SWITCH_MV88E61XX) += mv88e61xx.o
 

Please change this to CONFIG_MV88E61XX_SWITCH

Quoted 27 lines
drivers/net/Makefile +0 -0
 COBJS-$(CONFIG_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o

COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o

drivers/net/mv88e61xx.c new file +17 -0
new file mode 100644
index 0000000..8167919
@@ -0,0 +1,291 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.

drivers/net/mv88e61xx.c line 27

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+#if defined (CONFIG_SWITCH_MV88E61XX)

This is not needed - the makefile takes care of the conditional compilation

Quoted 8 lines
drivers/net/mv88e61xx.c new file +7 -0
+
+/* Enabled ports can be enabled in board header file */
+#if defined (CONFIG_MV88E61XX_ENABLED_PORTS)
+#define MV88E61XX_ENABLED_PORTS CONFIG_MV88E61XX_ENABLED_PORTS
+#else
+#define MV88E61XX_ENABLED_PORTS (BIT0 | BIT1 | BIT2 | \
+                                 BIT3 | BIT4 | BIT5)

drivers/net/mv88e61xx.c line 44

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+#endif
+
+#if defined (CONFIG_88E6161)
+#define MV88E61XX_NAME			"88E6161"
+#elif defined (CONFIG_88E6165)
+#define MV88E61XX_NAME			"88E6165"
+#else
+#define MV88E61XX_NAME			"88E61XX"
+#endif
+

There doesn't appear to be any code difference between the different chips. What's the point of differentiating them here? If it is meaningful, you should at least #warning if none of the known-about variants is mentioned.

Quoted 17 lines
drivers/net/mv88e61xx.c new file +16 -0
+#define MV88E61XX_PHY_TIMEOUT		100000
+#define MV88E61XX_MAX_PORTS_NUM		0x6
+/* CPU port can be configured in board header file */
+#if defined (CONFIG_MV88E61XX_CPU_PORT)
+#define MV88E61XX_CPU_PORT		CONFIG_MV88E61XX_CPU_PORT
+#else
+#define MV88E61XX_CPU_PORT		0x5
+#endif
+
+#define MV88E61XX_PRT_STS_REG		0x1
+#define MV88E61XX_PRT_CTRL_REG		0x4
+#define MV88E61XX_PRT_VMAP_REG		0x6
+#define MV88E61XX_PRT_VID_REG		0x7
+
+#define MV88E61XX_PRT_OFST		0x10
+#define MV88E61XX_PHY_CMD		0x18

drivers/net/mv88e61xx.c line 70

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+#define MV88E61XX_PHY_DATA		0x19
+#define MV88E61XX_GLOBAL2_REG_DEVADR	0x1C
+
+#ifdef CONFIG_KIRKWOOD_EGIGA
+#define smi_wr_reg	eth_smi_reg_write
+#define smi_rd_reg 	eth_smi_reg_read
+#else /* add new interface above this */
+#error Unsupported interface
+#endif
+

Please find a better way to do this. Board-specific code doesn't belong in a driver.

Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+/* Chip Address mode
+ * The Switch support two modes of operation
+ * 1. single chip mode and
+ * 2. Multi-chip mode

drivers/net/mv88e61xx.c line 84

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ * Refer chip documentation for more details
+ *
+ * By default single chip mode is configured
+ * multichip mode operation can be configured in board header
+ */
+#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
+#define mv88e61xx_wr_phy smi_wr_reg
+#define mv88e61xx_rd_phy smi_rd_reg
+#else
+void mv88e61xx_wr_phy(u32 port, u32 phy_adr, u32 reg_ofs, u16 data)

If you're going to play games with macros & function names, please do it in a header file

drivers/net/mv88e61xx.c line 92

Quoted 9 lines
drivers/net/mv88e61xx.c new file +8 -0
+{
+	u16 reg;
+	u32 smi_dev_addr;
+
+	smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));
+	do {
+		smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+	} while ((reg & BIT15));

Is there any possibility this (and all the others) will become infinite loops?

Quoted 121 lines
drivers/net/mv88e61xx.c new file +120 -0
+	/* Poll till SMIBusy bit is clear */
+	smi_wr_reg(port, smi_dev_addr, 0x1, data);
+	/* Write data to Switch indirect data register */
+	smi_wr_reg(port, smi_dev_addr, 0x0,
+		   reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+	/* Write command to Switch indirect command register (write) */
+}
+
+void mv88e61xx_rd_phy(u32 port, u32 phy_adr, u32 reg_ofs, u16 * data)
+{
+	u16 reg;
+	u32 smi_dev_addr;
+
+	smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));
+	do {
+		smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+	} while ((reg & BIT15));
+	/* Poll till SMIBusy bit is clear */
+	smi_wr_reg(port, smi_dev_addr, 0x0,
+		   reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+	/* Write command to Switch indirect command register (read) */
+	do {
+		smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+	} while ((reg & BIT15));
+	/* Poll till SMIBusy bit is clear */
+	smi_rd_reg(port, smi_dev_addr, 0x1, (u16 *) & data);
+	/* Read data from Switch indirect data register */
+}
+#endif /* CONFIG_MV88E61XX_MULTICHIP_ADRMODE */
+
+static void mv88e61xx_vlaninit(u32 port, u32 cpu_port, u32 max_prtnum,
+			       u32 ports_ofs, u32 port_mask)
+{
+	u32 prt;
+	u16 reg;
+
+	/* be sure all ports are disabled */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		mv88e61xx_rd_phy(port, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+				 &reg);
+		reg &= ~0x3;
+		mv88e61xx_wr_phy(port, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+				 reg);
+	}
+	/* Set CPU port VID to 0x1 */
+	mv88e61xx_rd_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+			 &reg);
+	reg &= ~0xfff;
+	reg |= 0x1;
+	mv88e61xx_wr_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+			 reg);
+
+	/* Setting  Port default priority for all ports to zero */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		mv88e61xx_rd_phy(port, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+				 &reg);
+		reg &= ~0xc000;
+		mv88e61xx_wr_phy(port, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+				 reg);
+	}
+	/* Setting VID and VID map for all ports except CPU port */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		/* only for enabled ports */
+		if ((1 << prt) & port_mask) {
+			/* skip CPU port */
+			if (prt == cpu_port)
+				continue;
+
+			/*
+			 *  set Ports VLAN Mapping.
+			 *      port prt <--> MV88E61XX_CPU_PORT VLAN #prt+1.
+			 */
+
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VID_REG, &reg);
+			reg &= ~0x0fff;
+			reg |= (prt + 1);
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VID_REG, reg);
+
+			/*
+			 * Set Vlan map table for all ports to send only to
+			 * MV88E61XX_CPU_PORT
+			 */
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VMAP_REG, &reg);
+			reg &= ~((1 << max_prtnum) - 1);
+			reg |= (1 << cpu_port);
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VMAP_REG, reg);
+		}
+	}
+	/* Set Vlan map table for MV88E61XX_CPU_PORT to see all ports */
+	mv88e61xx_rd_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+			 &reg);
+	reg &= ~((1 << max_prtnum) - 1);
+	reg |= port_mask & ~(1 << cpu_port);
+	mv88e61xx_wr_phy(port, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+			 reg);
+
+	/*
+	 * enable only appropriate ports to forwarding mode
+	 * and disable the others
+	 */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		if ((1 << prt) & port_mask) {
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, &reg);
+			reg |= 0x3;
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, reg);
+		} else {
+			/* Disable port */
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, &reg);
+			reg &= ~0x3;
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, reg);
+		}
+	}

drivers/net/mv88e61xx.c line 222

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+}
+
+/*
+ * Marvell 88E61XX Switch initialization
+ */
+int mv_switch_88e61xx_init(u32 port)
+{
+	u32 prt;
+	u16 reg;
+	volatile u32 timeout;

Why is this marked volatile?

drivers/net/mv88e61xx.c line 232

Quoted 11 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+	/* Init vlan */
+	mv88e61xx_vlaninit(port, MV88E61XX_CPU_PORT, MV88E61XX_MAX_PORTS_NUM,
+			   MV88E61XX_PRT_OFST, MV88E61XX_ENABLED_PORTS);
+
+	/* Enable RGMII delay on Tx and Rx for CPU port */
+	mv88e61xx_wr_phy(port, 0x14, 0x1a, 0x81e7);
+	mv88e61xx_rd_phy(port, 0x15, 0x1a, &reg);
+	mv88e61xx_wr_phy(port, 0x15, 0x1a, 0x18);
+	mv88e61xx_wr_phy(port, 0x14, 0x1a, 0xc1e7);

Please define these magic numbers somewhere

drivers/net/mv88e61xx.c line 242

Quoted 11 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+	for (prt = 0; prt < MV88E61XX_MAX_PORTS_NUM; prt++) {
+		if (prt != MV88E61XX_CPU_PORT) {
+			/*Enable Phy power up */
+			mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+					 MV88E61XX_PHY_DATA, 0x3360);
+			mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+					 MV88E61XX_PHY_CMD,
+					 (0x9410 | (prt << 5)));
+

Same comment about magic numbers

Quoted 34 lines
drivers/net/mv88e61xx.c new file +33 -0
+			/*
+			 * Make sure SMIBusy bit cleared before another
+			 * SMI operation can take place
+			 */
+			timeout = MV88E61XX_PHY_TIMEOUT;
+			do {
+				mv88e61xx_rd_phy(port,
+						 MV88E61XX_GLOBAL2_REG_DEVADR,
+						 MV88E61XX_PHY_CMD, &reg);
+				if (timeout-- == 0) {
+					printf("SMI busy timeout\n");
+					return -1;
+				}
+			} while (reg & BIT28);	/* busy mask */
+
+			mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+					 MV88E61XX_PHY_DATA, 0x1140);
+			mv88e61xx_wr_phy(port, MV88E61XX_GLOBAL2_REG_DEVADR,
+					 MV88E61XX_PHY_CMD,
+					 (0x9400 | (prt << 5)));
+
+			/*
+			 * Make sure SMIBusy bit cleared before another
+			 * SMI operation can take place
+			 */
+			timeout = MV88E61XX_PHY_TIMEOUT;
+			do {
+				mv88e61xx_rd_phy(port,
+						 MV88E61XX_GLOBAL2_REG_DEVADR,
+						 MV88E61XX_PHY_CMD, &reg);
+				if (timeout-- == 0) {
+					printf("SMI busy timeout\n");
+					return -1;

drivers/net/mv88e61xx.c line 285

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+				}
+			} while (reg & BIT28);	/* busy mask */
+		}
+
+		/*Enable port */
+		mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST + prt, 4, 0x7f);
+	}
+	/*Force CPU port to RGMII FDX 1000Base */
+	mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST + MV88E61XX_CPU_PORT, 1,
+			 0x3e);

Is RGMII the only mode this chip supports? If not, why are you forcing it so?

drivers/net/mv88e61xx.c line 287

Quoted 3 lines
drivers/net/mv88e61xx.c new file +2 -0
+
+	printf(MV88E61XX_NAME " Initialized\n");

Shouldn't this message include the port number?

Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+	return 0;
+}
+
+#endif /* CONFIG_SWITCH_MV88E61XX */
#25 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

Quoted 37 lines

-----Original Message-----
From: Ben Warren [mailto:biggerbadderben at gmail.com]
Sent: Thursday, April 09, 2009 4:46 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v2] Marvell MV88E61XX Switch Driver support

Hi Prafulla,

Quoted 19 lines · Prafulla Wadaskar

Chips supprted:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs
2. 88E6165 6 port gbe swtich with 5 integrated PHYs
Note: This driver is supported and tested against kirkwood egiga interface, other interfaces can be added

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments by Wolfgand Denk removed other two drivers form earlier patch debug_prints removed
driver moved to drivers/net/

Quoted 2 lines
 drivers/net/Makefile    |    1 +
 drivers/net/mv88e61xx.c |  291 

+++++++++++++++++++++++++++++++++++++++++++++++

Quoted 3 lines
 2 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/mv88e61xx.c
Quoted 11 lines

drivers/net/Makefile COBJS-$(CONFIG_MACB) += macb.o · line 51

Quoted 10 lines
drivers/net/Makefile +1 -0
index f0c5654..7482327 100644
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o
 COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
+COBJS-$(CONFIG_SWITCH_MV88E61XX) += mv88e61xx.o
 

Please change this to CONFIG_MV88E61XX_SWITCH

Changed....

Quoted 29 lines
Quoted 18 lines
drivers/net/Makefile +0 -0
 COBJS-$(CONFIG_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o

COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o

drivers/net/mv88e61xx.c new file +9 -0
new file mode 100644
index 0000000..8167919
@@ -0,0 +1,291 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or

drivers/net/mv88e61xx.c line 19

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General 

Public License

Quoted 11 lines

drivers/net/mv88e61xx.c line 27

Quoted 9 lines
drivers/net/mv88e61xx.c new file +8 -0
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+#if defined (CONFIG_SWITCH_MV88E61XX)

This is not needed - the makefile takes care of the conditional compilation

Removed...

Quoted 14 lines
Quoted 14 lines
drivers/net/mv88e61xx.c new file +14 -0
+
+/* Enabled ports can be enabled in board header file */
+#if defined (CONFIG_MV88E61XX_ENABLED_PORTS)
+#define MV88E61XX_ENABLED_PORTS CONFIG_MV88E61XX_ENABLED_PORTS
+#else
+#define MV88E61XX_ENABLED_PORTS (BIT0 | BIT1 | BIT2 | \
+                                 BIT3 | BIT4 | BIT5)
+#endif
+
+#if defined (CONFIG_88E6161)
+#define MV88E61XX_NAME			"88E6161"
+#elif defined (CONFIG_88E6165)
+#define MV88E61XX_NAME			"88E6165"
+#else
Quoted 8 lines

drivers/net/mv88e61xx.c line 44

Quoted 4 lines
drivers/net/mv88e61xx.c new file +3 -0
+#define MV88E61XX_NAME			"88E61XX"
+#endif
+

There doesn't appear to be any code difference between the different chips. What's the point of differentiating them here? If it is meaningful, you should at least #warning if none of the known-about variants is mentioned.

This part of code removed...
Chip Id is read from PHY_Id reg and displayed now.

Quoted 22 lines
Quoted 22 lines
drivers/net/mv88e61xx.c new file +22 -0
+#define MV88E61XX_PHY_TIMEOUT		100000
+#define MV88E61XX_MAX_PORTS_NUM		0x6
+/* CPU port can be configured in board header file */
+#if defined (CONFIG_MV88E61XX_CPU_PORT)
+#define MV88E61XX_CPU_PORT		CONFIG_MV88E61XX_CPU_PORT
+#else
+#define MV88E61XX_CPU_PORT		0x5
+#endif
+
+#define MV88E61XX_PRT_STS_REG		0x1
+#define MV88E61XX_PRT_CTRL_REG		0x4
+#define MV88E61XX_PRT_VMAP_REG		0x6
+#define MV88E61XX_PRT_VID_REG		0x7
+
+#define MV88E61XX_PRT_OFST		0x10
+#define MV88E61XX_PHY_CMD		0x18
+#define MV88E61XX_PHY_DATA		0x19
+#define MV88E61XX_GLOBAL2_REG_DEVADR	0x1C
+
+#ifdef CONFIG_KIRKWOOD_EGIGA
+#define smi_wr_reg	eth_smi_reg_write
+#define smi_rd_reg 	eth_smi_reg_read
Quoted 8 lines

drivers/net/mv88e61xx.c line 70

Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+#else /* add new interface above this */
+#error Unsupported interface
+#endif
+

Please find a better way to do this. Board-specific code doesn't belong
in a driver.

this is now implemented using miiphy_read/write calls

Quoted 10 lines
Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+/* Chip Address mode
+ * The Switch support two modes of operation
+ * 1. single chip mode and
+ * 2. Multi-chip mode
+ * Refer chip documentation for more details
+ *
+ * By default single chip mode is configured
+ * multichip mode operation can be configured in board header
+ */
+#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
Quoted 8 lines

drivers/net/mv88e61xx.c line 84

Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+#define mv88e61xx_wr_phy smi_wr_reg
+#define mv88e61xx_rd_phy smi_rd_reg
+#else
+void mv88e61xx_wr_phy(u32 port, u32 phy_adr, u32 reg_ofs, u16 data)

If you're going to play games with macros & function names, please do it
in a header file

Void .. Removed....

Quoted 4 lines
Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+{
+	u16 reg;
+	u32 smi_dev_addr;
+
Quoted 8 lines

drivers/net/mv88e61xx.c line 92

Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+	smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));
+	do {
+		smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+	} while ((reg & BIT15));

Is there any possibility this (and all the others) will become infinite
loops?

No there is no such posibility, but at safer side I put there time out

Quoted 136 lines

drivers/net/mv88e61xx.c

Quoted 9 lines
drivers/net/mv88e61xx.c new file +9 -0
+	/* Poll till SMIBusy bit is clear */
+	smi_wr_reg(port, smi_dev_addr, 0x1, data);
+	/* Write data to Switch indirect data register */
+	smi_wr_reg(port, smi_dev_addr, 0x0,
+		   reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+	/* Write command to Switch indirect command register (write) */
+}
+
+void mv88e61xx_rd_phy(u32 port, u32 phy_adr, u32 reg_ofs, 

u16 * data)

Quoted 12 lines
drivers/net/mv88e61xx.c new file +12 -0
+{
+	u16 reg;
+	u32 smi_dev_addr;
+
+	smi_dev_addr = KW_REG_READ(KW_ETH_PHY_ADDR_REG(port));
+	do {
+		smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+	} while ((reg & BIT15));
+	/* Poll till SMIBusy bit is clear */
+	smi_wr_reg(port, smi_dev_addr, 0x0,
+		   reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+	/* Write command to Switch indirect command register (read) */

drivers/net/mv88e61xx.c

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+	do {
+		smi_rd_reg(port, smi_dev_addr, 0x0, &reg);
+	} while ((reg & BIT15));
+	/* Poll till SMIBusy bit is clear */
+	smi_rd_reg(port, smi_dev_addr, 0x1, (u16 *) & data);
+	/* Read data from Switch indirect data register */
+}
+#endif /* CONFIG_MV88E61XX_MULTICHIP_ADRMODE */
+
+static void mv88e61xx_vlaninit(u32 port, u32 cpu_port, u32 

max_prtnum,

drivers/net/mv88e61xx.c line 166

Quoted 8 lines
drivers/net/mv88e61xx.c new file +8 -0
+			       u32 ports_ofs, u32 port_mask)
+{
+	u32 prt;
+	u16 reg;
+
+	/* be sure all ports are disabled */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		mv88e61xx_rd_phy(port, ports_ofs + prt, 

MV88E61XX_PRT_CTRL_REG,

drivers/net/mv88e61xx.c line 170

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+				 &reg);
+		reg &= ~0x3;
+		mv88e61xx_wr_phy(port, ports_ofs + prt, 

MV88E61XX_PRT_CTRL_REG,

drivers/net/mv88e61xx.c

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+				 reg);
+	}
+	/* Set CPU port VID to 0x1 */
+	mv88e61xx_rd_phy(port, (ports_ofs + cpu_port), 

MV88E61XX_PRT_VID_REG,

drivers/net/mv88e61xx.c

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+			 &reg);
+	reg &= ~0xfff;
+	reg |= 0x1;
+	mv88e61xx_wr_phy(port, (ports_ofs + cpu_port), 

MV88E61XX_PRT_VID_REG,

drivers/net/mv88e61xx.c line 166

Quoted 5 lines
drivers/net/mv88e61xx.c new file +5 -0
+			 reg);
+
+	/* Setting  Port default priority for all ports to zero */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		mv88e61xx_rd_phy(port, ports_ofs + prt, 

MV88E61XX_PRT_VID_REG,

drivers/net/mv88e61xx.c line 170

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+				 &reg);
+		reg &= ~0xc000;
+		mv88e61xx_wr_phy(port, ports_ofs + prt, 

MV88E61XX_PRT_VID_REG,

drivers/net/mv88e61xx.c

Quoted 13 lines
drivers/net/mv88e61xx.c new file +13 -0
+				 reg);
+	}
+	/* Setting VID and VID map for all ports except CPU port */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		/* only for enabled ports */
+		if ((1 << prt) & port_mask) {
+			/* skip CPU port */
+			if (prt == cpu_port)
+				continue;
+
+			/*
+			 *  set Ports VLAN Mapping.
+			 *      port prt <--> 

MV88E61XX_CPU_PORT VLAN #prt+1.

drivers/net/mv88e61xx.c

Quoted 11 lines
drivers/net/mv88e61xx.c new file +11 -0
+			 */
+
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VID_REG, &reg);
+			reg &= ~0x0fff;
+			reg |= (prt + 1);
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VID_REG, reg);
+
+			/*
+			 * Set Vlan map table for all ports to 

send only to

drivers/net/mv88e61xx.c

Quoted 12 lines
drivers/net/mv88e61xx.c new file +12 -0
+			 * MV88E61XX_CPU_PORT
+			 */
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VMAP_REG, &reg);
+			reg &= ~((1 << max_prtnum) - 1);
+			reg |= (1 << cpu_port);
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_VMAP_REG, reg);
+		}
+	}
+	/* Set Vlan map table for MV88E61XX_CPU_PORT to see all ports */
+	mv88e61xx_rd_phy(port, (ports_ofs + cpu_port), 

MV88E61XX_PRT_VMAP_REG,

drivers/net/mv88e61xx.c

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+			 &reg);
+	reg &= ~((1 << max_prtnum) - 1);
+	reg |= port_mask & ~(1 << cpu_port);
+	mv88e61xx_wr_phy(port, (ports_ofs + cpu_port), 

MV88E61XX_PRT_VMAP_REG,

Quoted 26 lines
drivers/net/mv88e61xx.c new file +26 -0
+			 reg);
+
+	/*
+	 * enable only appropriate ports to forwarding mode
+	 * and disable the others
+	 */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		if ((1 << prt) & port_mask) {
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, &reg);
+			reg |= 0x3;
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, reg);
+		} else {
+			/* Disable port */
+			mv88e61xx_rd_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, &reg);
+			reg &= ~0x3;
+			mv88e61xx_wr_phy(port, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, reg);
+		}
+	}
+}
+
+/*
+ * Marvell 88E61XX Switch initialization
Quoted 8 lines

drivers/net/mv88e61xx.c line 222

Quoted 7 lines
drivers/net/mv88e61xx.c new file +6 -0
+ */
+int mv_switch_88e61xx_init(u32 port)
+{
+	u32 prt;
+	u16 reg;
+	volatile u32 timeout;

Why is this marked volatile?

Sorry .. Removed.....

Quoted 4 lines

drivers/net/mv88e61xx.c

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+
+	/* Init vlan */
+	mv88e61xx_vlaninit(port, MV88E61XX_CPU_PORT, 

MV88E61XX_MAX_PORTS_NUM,

Quoted 9 lines

drivers/net/mv88e61xx.c line 232

Quoted 8 lines
drivers/net/mv88e61xx.c new file +7 -0
+			   MV88E61XX_PRT_OFST, MV88E61XX_ENABLED_PORTS);
+
+	/* Enable RGMII delay on Tx and Rx for CPU port */
+	mv88e61xx_wr_phy(port, 0x14, 0x1a, 0x81e7);
+	mv88e61xx_rd_phy(port, 0x15, 0x1a, &reg);
+	mv88e61xx_wr_phy(port, 0x15, 0x1a, 0x18);
+	mv88e61xx_wr_phy(port, 0x14, 0x1a, 0xc1e7);

Please define these magic numbers somewhere

I am sorry,
At this moment I can't, since I do not have sufficient data. I got this info from h/w team, data sheets yet to update :-( I will do it latter..

Quoted 6 lines

drivers/net/mv88e61xx.c

Quoted 5 lines
drivers/net/mv88e61xx.c new file +5 -0
+
+	for (prt = 0; prt < MV88E61XX_MAX_PORTS_NUM; prt++) {
+		if (prt != MV88E61XX_CPU_PORT) {
+			/*Enable Phy power up */
+			mv88e61xx_wr_phy(port, 

MV88E61XX_GLOBAL2_REG_DEVADR,

Quoted 8 lines

drivers/net/mv88e61xx.c line 239

Quoted 2 lines
drivers/net/mv88e61xx.c new file +2 -0
+					 MV88E61XX_PHY_DATA, 0x3360);
+			mv88e61xx_wr_phy(port, 

MV88E61XX_GLOBAL2_REG_DEVADR,

drivers/net/mv88e61xx.c line 242

Quoted 4 lines
drivers/net/mv88e61xx.c new file +3 -0
+					 MV88E61XX_PHY_CMD,
+					 (0x9410 | (prt << 5)));
+

Same comment about magic numbers

Put some comments there..

Quoted 55 lines

drivers/net/mv88e61xx.c line 257

Quoted 8 lines
drivers/net/mv88e61xx.c new file +8 -0
+			/*
+			 * Make sure SMIBusy bit cleared before another
+			 * SMI operation can take place
+			 */
+			timeout = MV88E61XX_PHY_TIMEOUT;
+			do {
+				mv88e61xx_rd_phy(port,
+						 

MV88E61XX_GLOBAL2_REG_DEVADR,

drivers/net/mv88e61xx.c line 251

Quoted 1 line
drivers/net/mv88e61xx.c new file +1 -0
+						 

MV88E61XX_PHY_CMD, &reg);

drivers/net/mv88e61xx.c

Quoted 7 lines
drivers/net/mv88e61xx.c new file +7 -0
+				if (timeout-- == 0) {
+					printf("SMI busy timeout\n");
+					return -1;
+				}
+			} while (reg & BIT28);	/* busy mask */
+
+			mv88e61xx_wr_phy(port, 

MV88E61XX_GLOBAL2_REG_DEVADR,

drivers/net/mv88e61xx.c line 260

Quoted 2 lines
drivers/net/mv88e61xx.c new file +2 -0
+					 MV88E61XX_PHY_DATA, 0x1140);
+			mv88e61xx_wr_phy(port, 

MV88E61XX_GLOBAL2_REG_DEVADR,

drivers/net/mv88e61xx.c line 279

Quoted 11 lines
drivers/net/mv88e61xx.c new file +11 -0
+					 MV88E61XX_PHY_CMD,
+					 (0x9400 | (prt << 5)));
+
+			/*
+			 * Make sure SMIBusy bit cleared before another
+			 * SMI operation can take place
+			 */
+			timeout = MV88E61XX_PHY_TIMEOUT;
+			do {
+				mv88e61xx_rd_phy(port,
+						 

MV88E61XX_GLOBAL2_REG_DEVADR,

drivers/net/mv88e61xx.c line 272

Quoted 1 line
drivers/net/mv88e61xx.c new file +1 -0
+						 

MV88E61XX_PHY_CMD, &reg);

drivers/net/mv88e61xx.c

Quoted 9 lines
drivers/net/mv88e61xx.c new file +9 -0
+				if (timeout-- == 0) {
+					printf("SMI busy timeout\n");
+					return -1;
+				}
+			} while (reg & BIT28);	/* busy mask */
+		}
+
+		/*Enable port */
+		mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST + 

prt, 4, 0x7f);

drivers/net/mv88e61xx.c

Quoted 3 lines
drivers/net/mv88e61xx.c new file +3 -0
+	}
+	/*Force CPU port to RGMII FDX 1000Base */
+	mv88e61xx_wr_phy(port, MV88E61XX_PRT_OFST + 

MV88E61XX_CPU_PORT, 1,

drivers/net/mv88e61xx.c line 285

Quoted 2 lines
drivers/net/mv88e61xx.c new file +1 -0
+			 0x3e);

Is RGMII the only mode this chip supports? If not, why are you forcing
it so?

Quoted 4 lines

drivers/net/mv88e61xx.c line 287

Quoted 3 lines
drivers/net/mv88e61xx.c new file +2 -0
+
+	printf(MV88E61XX_NAME " Initialized\n");

Shouldn't this message include the port number?

Added port name to the string

I am sending v3 patch for the same

Reagards..

Prafulla . .

Quoted 7 lines
Quoted 5 lines
drivers/net/mv88e61xx.c new file +4 -0
+	return 0;
+}
+
+#endif /* CONFIG_SWITCH_MV88E61XX */
#26 lore raw

PATCH v3 1/1 Marvell MV88E61XX Switch Driver support

In reply to Ben Warren

Chips supported:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs
2. 88E6165 6 port gbe swtich with 5 integrated PHYs
2. 88E6132 3 port gbe swtich with 2 integrated PHYs

Note: This driver is supported and tested against
kirkwood egiga interface

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments for v1
removed other two drivers form earlier patch
debug_prints removed
driver moved to drivers/net/

v3: updated as per review comments for v2
miiphy interface used, platform specific dependency resolved Chip id detection and printing added
common code forked out
some cosmetic and magic number fixes

 drivers/net/Makefile    |    1 +
 drivers/net/mv88e61xx.c |  299 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 300 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/mv88e61xx.c
drivers/net/Makefile +1 -0
index f0c5654..9e8787c 100644
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o
 COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
+COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o
 COBJS-$(CONFIG_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o
drivers/net/mv88e61xx.c new file +299 -0

299 lines not on this page · raw message

Signature · 1 line
1.5.3.3
#27 lore raw

PATCH v3 1/1 Marvell MV88E61XX Switch Driver support

Quoted 21 lines · Prafulla Wadaskar

Chips supported:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs
2. 88E6165 6 port gbe swtich with 5 integrated PHYs
2. 88E6132 3 port gbe swtich with 2 integrated PHYs

Note: This driver is supported and tested against
kirkwood egiga interface

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments for v1
removed other two drivers form earlier patch
debug_prints removed
driver moved to drivers/net/

Quoted 8 lines

v3: updated as per review comments for v2
miiphy interface used, platform specific dependency resolved Chip id detection and printing added
common code forked out
some cosmetic and magic number fixes

 drivers/net/Makefile    |    1 +
 drivers/net/mv88e61xx.c |  299 +++++++++++++++++++++++++++++++++++++++++++++++

the m88e61xx is a switch so have it in drivers/net/phy could make more sense

Quoted 44 lines
 2 files changed, 300 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/mv88e61xx.c
drivers/net/Makefile +1 -0
index f0c5654..9e8787c 100644
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o
 COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
+COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o
 COBJS-$(CONFIG_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o
drivers/net/mv88e61xx.c new file +23 -0
new file mode 100644
index 0000000..31a6fa6
@@ -0,0 +1,299 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */

drivers/net/mv88e61xx.c line 33

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+#include <common.h>
+#include <miiphy.h>
+
+/* Enabled ports can be enabled in board header file */
+#if defined (CONFIG_MV88E61XX_ENABLED_PORTS)
+#define MV88E61XX_ENABLED_PORTS CONFIG_MV88E61XX_ENABLED_PORTS
+#else
+#define MV88E61XX_ENABLED_PORTS (BIT0 | BIT1 | BIT2 | \
+                                 BIT3 | BIT4 | BIT5)

please avoid this BITx macrot

drivers/net/mv88e61xx.c line 44

Quoted 11 lines
drivers/net/mv88e61xx.c new file +11 -0
+#endif
+
+#define MV88E61XX_PHY_TIMEOUT		100000
+#define MV88E61XX_MAX_PORTS_NUM		0x6
+
+/* CPU port can be configured in board header file */
+#if defined (CONFIG_MV88E61XX_CPU_PORT)
+#define MV88E61XX_CPU_PORT		CONFIG_MV88E61XX_CPU_PORT
+#else
+#define MV88E61XX_CPU_PORT		0x5
+#endif

this cpu port is normally configured by latch resistor you may could detect it

drivers/net/mv88e61xx.c line 54

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+#define MV88E61XX_PRT_STS_REG		0x1
+#define MV88E61XX_PRT_CTRL_REG		0x4
+#define MV88E61XX_PRT_VMAP_REG		0x6
+#define MV88E61XX_PRT_VID_REG		0x7
+
+#define MV88E61XX_PRT_OFST		0x10
+#define MV88E61XX_PHY_CMD		0x18
+#define MV88E61XX_PHY_DATA		0x19
+#define MV88E61XX_GLOBAL2_REG_DEVADR	0x1C

GLOBAL2_REGISTER will be better

Quoted 53 lines
drivers/net/mv88e61xx.c new file +53 -0
+
+/* Chip Address mode
+ * The Switch support two modes of operation
+ * 1. single chip mode and
+ * 2. Multi-chip mode
+ * Refer chip documentation for more details
+ *
+ * By default single chip mode is configured
+ * multichip mode operation can be configured in board header
+ */
+#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
+#define mv88e61xx_wr_phy miiphy_write
+#define mv88e61xx_rd_phy miiphy_read
+#else
+
+int mv88e61xx_busychk_multic(u32 devaddr)
+{
+	u32 reg = 0;
+	u32 timeout = MV88E61XX_PHY_TIMEOUT;
+
+	/* Poll till SMIBusy bit is clear */
+	do {
+		miiphy_read(name, devaddr, 0x0, &reg);
+		if (timeout-- == 0) {
+			printf("SMI busy timeout\n");
+			return -1;
+		}
+	} while (reg & BIT15);
+	return 0;
+}
+
+void mv88e61xx_wr_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 data)
+{
+	u16 reg;
+	u32 mii_dev_addr;
+
+	/* command to read PHY dev address */
+	miiphy_read(name, 0xEE, 0xEE, &mii_dev_addr);
+	mv88e61xx_busychk_multic(mii_dev_addr);
+	/* Write data to Switch indirect data register */
+	miiphy_write(name, mii_dev_addr, 0x1, data);
+	/* Write command to Switch indirect command register (write) */
+	miiphy_write(name, mii_dev_addr, 0x0,
+		     reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+}
+
+void mv88e61xx_rd_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 * data)
+{
+	u16 reg;
+	u32 mii_dev_addr;
+
+	/* command to read PHY dev address */
+	miiphy_read(name, 0xEE, 0xEE, &mii_dev_addr);

drivers/net/mv88e61xx.c line 117

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+	mv88e61xx_busychk_multic(mii_dev_addr);
+	/* Write command to Switch indirect command register (read) */
+	miiphy_write(name, mii_dev_addr, 0x0,
+		     reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+	mv88e61xx_busychk_multic(mii_dev_addr);
+	/* Read data from Switch indirect data register */
+	miiphy_read(name, mii_dev_addr, 0x1, (u16 *) & data);
+}
+#endif /* CONFIG_MV88E61XX_MULTICHIP_ADRMODE */
+

a doc explaining how to us it will be nice

Quoted 117 lines
drivers/net/mv88e61xx.c new file +117 -0
+static void mv88e61xx_vlaninit(char *name, u32 cpu_port, u32 max_prtnum,
+			       u32 ports_ofs, u32 port_mask)
+{
+	u32 prt;
+	u16 reg;
+
+	/* be sure all ports are disabled */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		mv88e61xx_rd_phy(name, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+				 &reg);
+		reg &= ~0x3;
+		mv88e61xx_wr_phy(name, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+				 reg);
+	}
+	/* Set CPU port VID to 0x1 */
+	mv88e61xx_rd_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+			 &reg);
+	reg &= ~0xfff;
+	reg |= 0x1;
+	mv88e61xx_wr_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+			 reg);
+
+	/* Setting  Port default priority for all ports to zero */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		mv88e61xx_rd_phy(name, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+				 &reg);
+		reg &= ~0xc000;
+		mv88e61xx_wr_phy(name, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+				 reg);
+	}
+	/* Setting VID and VID map for all ports except CPU port */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		/* only for enabled ports */
+		if ((1 << prt) & port_mask) {
+			/* skip CPU port */
+			if (prt == cpu_port)
+				continue;
+
+			/*
+			 *  set Ports VLAN Mapping.
+			 *      port prt <--> MV88E61XX_CPU_PORT VLAN #prt+1.
+			 */
+
+			mv88e61xx_rd_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_VID_REG, &reg);
+			reg &= ~0x0fff;
+			reg |= (prt + 1);
+			mv88e61xx_wr_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_VID_REG, reg);
+
+			/*
+			 * Set Vlan map table for all ports to send only to
+			 * MV88E61XX_CPU_PORT
+			 */
+			mv88e61xx_rd_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_VMAP_REG, &reg);
+			reg &= ~((1 << max_prtnum) - 1);
+			reg |= (1 << cpu_port);
+			mv88e61xx_wr_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_VMAP_REG, reg);
+		}
+	}
+	/* Set Vlan map table for MV88E61XX_CPU_PORT to see all ports */
+	mv88e61xx_rd_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+			 &reg);
+	reg &= ~((1 << max_prtnum) - 1);
+	reg |= port_mask & ~(1 << cpu_port);
+	mv88e61xx_wr_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+			 reg);
+
+	/*
+	 * enable only appropriate ports to forwarding mode
+	 * and disable the others
+	 */
+	for (prt = 0; prt < max_prtnum; prt++) {
+		if ((1 << prt) & port_mask) {
+			mv88e61xx_rd_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, &reg);
+			reg |= 0x3;
+			mv88e61xx_wr_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, reg);
+		} else {
+			/* Disable port */
+			mv88e61xx_rd_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, &reg);
+			reg &= ~0x3;
+			mv88e61xx_wr_phy(name, ports_ofs + prt,
+					 MV88E61XX_PRT_CTRL_REG, reg);
+		}
+	}
+}
+
+/*
+ * Make sure SMIBusy bit cleared before another
+ * SMI operation can take place
+ */
+int mv88361xx_busychk(char *name)
+{
+	u32 reg = 0;
+	u32 timeout = MV88E61XX_PHY_TIMEOUT;
+	do {
+		mv88e61xx_rd_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+				 MV88E61XX_PHY_CMD, &reg);
+		if (timeout-- == 0) {
+			printf("SMI busy timeout\n");
+			return -1;
+		}
+	} while (reg & BIT28);	/* busy mask */
+	return 0;
+}
+
+/*
+ * Marvell 88E61XX Switch initialization
+ */
+int mv_switch_88e61xx_init(char *name)
+{
+	u32 prt;

drivers/net/mv88e61xx.c line 244

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+	u16 reg;
+
+	if (miiphy_set_current_dev(name)) {
+		printf("%s failed\n", __FUNCTION__);
+		return -1;
+	}
+
+	/* Init vlan */
+	mv88e61xx_vlaninit(name, MV88E61XX_CPU_PORT, MV88E61XX_MAX_PORTS_NUM,
+			   MV88E61XX_PRT_OFST, MV88E61XX_ENABLED_PORTS);

this is board specific

drivers/net/mv88e61xx.c line 252

Quoted 8 lines
drivers/net/mv88e61xx.c new file +8 -0
+
+#ifdef CONFIG_SYS_RGMII_MODE
+	/* Enable RGMII delay on Tx and Rx for CPU port */
+	mv88e61xx_wr_phy(name, 0x14, 0x1a, 0x81e7);
+	mv88e61xx_rd_phy(name, 0x15, 0x1a, &reg);
+	mv88e61xx_wr_phy(name, 0x15, 0x1a, 0x18);
+	mv88e61xx_wr_phy(name, 0x14, 0x1a, 0xc1e7);
+#endif

this too

Quoted 24 lines
drivers/net/mv88e61xx.c new file +24 -0
+
+	for (prt = 0; prt < MV88E61XX_MAX_PORTS_NUM; prt++) {
+		if (prt != MV88E61XX_CPU_PORT) {
+			/* Write Copper Specific control reg1 (0x14) for-
+			 * Enable Phy power up
+			 * Energy Detect on (sense&Xmit NLP Periodically
+			 * reset other settings default
+			 */
+			mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+					 MV88E61XX_PHY_DATA, 0x3360);
+			mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+					 MV88E61XX_PHY_CMD,
+					 (0x9410 | (prt << 5)));
+
+			if (mv88361xx_busychk(name))
+				return -1;
+
+			/* Write PHY ctrl reg (0x0) to apply
+			 * Phy reset (BIT15=low)
+			 * reset other default values
+			 */
+			mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+					 MV88E61XX_PHY_DATA, 0x1140);
+			mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,

drivers/net/mv88e61xx.c line 286

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+					 MV88E61XX_PHY_CMD,
+					 (0x9400 | (prt << 5)));
+
+			if (mv88361xx_busychk(name))
+				return -1;
+		}
+
+		/*Enable port */
+		mv88e61xx_wr_phy(name, MV88E61XX_PRT_OFST + prt, 4, 0x7f);
+	}

this too

drivers/net/mv88e61xx.c line 295

Quoted 9 lines
drivers/net/mv88e61xx.c new file +9 -0
+
+	mv88e61xx_rd_phy(name, MV88E61XX_PRT_OFST, PHY_PHYIDR2, &reg);
+	reg &= 0xfff0;
+	if (reg == 0x1610)
+		printf("88E6161");
+	if (reg == 0x1650)
+		printf("88E6165");
+	if (reg == 0x1210)
+		printf("88E6123");

by detecting the switch model you will capable to identify the numbers of ports and their capability

drivers/net/mv88e61xx.c line 299

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+
+	printf(" Initialized on %s\n", name);
+	return 0;
+}

Best Regards,
J.

#28 lore raw

PATCH v3 1/1 Marvell MV88E61XX Switch Driver support

Dear Jean,

Thanks for your comments
Please see my inlined reply

________________________________________
From: Jean-Christophe PLAGNIOL-VILLARD [plagnioj at jcrosoft.com]
Sent: Tuesday, April 14, 2009 3:49 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v3] Marvell MV88E61XX Switch Driver support

Quoted 21 lines · Prafulla Wadaskar

Chips supported:-
1. 88E6161 6 port gbe swtich with 5 integrated PHYs
2. 88E6165 6 port gbe swtich with 5 integrated PHYs
2. 88E6132 3 port gbe swtich with 2 integrated PHYs

Note: This driver is supported and tested against
kirkwood egiga interface

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

---
Changelog:-
v2: updated as per review comments for v1
removed other two drivers form earlier patch
debug_prints removed
driver moved to drivers/net/

Quoted 8 lines

v3: updated as per review comments for v2
miiphy interface used, platform specific dependency resolved Chip id detection and printing added
common code forked out
some cosmetic and magic number fixes

 drivers/net/Makefile    |    1 +
 drivers/net/mv88e61xx.c |  299 +++++++++++++++++++++++++++++++++++++++++++++++

the m88e61xx is a switch so have it in drivers/net/phy could make more sense
Prafulla: This driver represents the mv88e61xx chips which uses miiphy interface provided externally so I think drivers/net/ it correct place for it. drivers/net/phy/ generally has phy read/write modules code like bitbang mii interface.

Quoted 44 lines
 2 files changed, 300 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/mv88e61xx.c
drivers/net/Makefile +1 -0
index f0c5654..9e8787c 100644
@@ -47,6 +47,7 @@ COBJS-$(CONFIG_MACB) += macb.o
 COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 COBJS-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
+COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o
 COBJS-$(CONFIG_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 COBJS-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o
drivers/net/mv88e61xx.c new file +23 -0
new file mode 100644
index 0000000..31a6fa6
@@ -0,0 +1,299 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.       See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */

drivers/net/mv88e61xx.c line 33

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+#include <common.h>
+#include <miiphy.h>
+
+/* Enabled ports can be enabled in board header file */
+#if defined (CONFIG_MV88E61XX_ENABLED_PORTS)
+#define MV88E61XX_ENABLED_PORTS CONFIG_MV88E61XX_ENABLED_PORTS
+#else
+#define MV88E61XX_ENABLED_PORTS (BIT0 | BIT1 | BIT2 | \
+                                 BIT3 | BIT4 | BIT5)

please avoid this BITx macrot
Prafulla: OK, I will hardcode this value, but in my view it looks better (readable) using these macros provided those are available on other platforms, mostly it should be, how about renaming them as PORTx ?

drivers/net/mv88e61xx.c line 44

Quoted 11 lines
drivers/net/mv88e61xx.c new file +11 -0
+#endif
+
+#define MV88E61XX_PHY_TIMEOUT                100000
+#define MV88E61XX_MAX_PORTS_NUM              0x6
+
+/* CPU port can be configured in board header file */
+#if defined (CONFIG_MV88E61XX_CPU_PORT)
+#define MV88E61XX_CPU_PORT           CONFIG_MV88E61XX_CPU_PORT
+#else
+#define MV88E61XX_CPU_PORT           0x5
+#endif

this cpu port is normally configured by latch resistor
you may could detect it
Prafulla: There are two ports on 6165/6161 and one port on 6123 which can be used for CPU interface, this is decided by board h/w. we offer this configuration to board header file, default value is port5
Prafulla: I could not find "latch register" in the switch documentation, can you pls explain this?

drivers/net/mv88e61xx.c line 54

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+
+#define MV88E61XX_PRT_STS_REG                0x1
+#define MV88E61XX_PRT_CTRL_REG               0x4
+#define MV88E61XX_PRT_VMAP_REG               0x6
+#define MV88E61XX_PRT_VID_REG                0x7
+
+#define MV88E61XX_PRT_OFST           0x10
+#define MV88E61XX_PHY_CMD            0x18
+#define MV88E61XX_PHY_DATA           0x19
+#define MV88E61XX_GLOBAL2_REG_DEVADR 0x1C

GLOBAL2_REGISTER will be better
Prafulla: Actually I has used similar name earlier (v1) but wolfgang suggested to use smaller names so I trimmed them and others too, I am planning to trim it further to MV88E61XX_GLB2REG_DEVADR in next release

Quoted 53 lines
drivers/net/mv88e61xx.c new file +53 -0
+
+/* Chip Address mode
+ * The Switch support two modes of operation
+ * 1. single chip mode and
+ * 2. Multi-chip mode
+ * Refer chip documentation for more details
+ *
+ * By default single chip mode is configured
+ * multichip mode operation can be configured in board header
+ */
+#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
+#define mv88e61xx_wr_phy miiphy_write
+#define mv88e61xx_rd_phy miiphy_read
+#else
+
+int mv88e61xx_busychk_multic(u32 devaddr)
+{
+     u32 reg = 0;
+     u32 timeout = MV88E61XX_PHY_TIMEOUT;
+
+     /* Poll till SMIBusy bit is clear */
+     do {
+             miiphy_read(name, devaddr, 0x0, &reg);
+             if (timeout-- == 0) {
+                     printf("SMI busy timeout\n");
+                     return -1;
+             }
+     } while (reg & BIT15);
+     return 0;
+}
+
+void mv88e61xx_wr_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 data)
+{
+     u16 reg;
+     u32 mii_dev_addr;
+
+     /* command to read PHY dev address */
+     miiphy_read(name, 0xEE, 0xEE, &mii_dev_addr);
+     mv88e61xx_busychk_multic(mii_dev_addr);
+     /* Write data to Switch indirect data register */
+     miiphy_write(name, mii_dev_addr, 0x1, data);
+     /* Write command to Switch indirect command register (write) */
+     miiphy_write(name, mii_dev_addr, 0x0,
+                  reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+}
+
+void mv88e61xx_rd_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 * data)
+{
+     u16 reg;
+     u32 mii_dev_addr;
+
+     /* command to read PHY dev address */
+     miiphy_read(name, 0xEE, 0xEE, &mii_dev_addr);

drivers/net/mv88e61xx.c line 117

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+     mv88e61xx_busychk_multic(mii_dev_addr);
+     /* Write command to Switch indirect command register (read) */
+     miiphy_write(name, mii_dev_addr, 0x0,
+                  reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
+     mv88e61xx_busychk_multic(mii_dev_addr);
+     /* Read data from Switch indirect data register */
+     miiphy_read(name, mii_dev_addr, 0x1, (u16 *) & data);
+}
+#endif /* CONFIG_MV88E61XX_MULTICHIP_ADRMODE */
+

a doc explaining how to us it will be nice
Prafulla: I can give here reference to the relevant chapter in data sheet

Quoted 117 lines
drivers/net/mv88e61xx.c new file +117 -0
+static void mv88e61xx_vlaninit(char *name, u32 cpu_port, u32 max_prtnum,
+                            u32 ports_ofs, u32 port_mask)
+{
+     u32 prt;
+     u16 reg;
+
+     /* be sure all ports are disabled */
+     for (prt = 0; prt < max_prtnum; prt++) {
+             mv88e61xx_rd_phy(name, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+                              &reg);
+             reg &= ~0x3;
+             mv88e61xx_wr_phy(name, ports_ofs + prt, MV88E61XX_PRT_CTRL_REG,
+                              reg);
+     }
+     /* Set CPU port VID to 0x1 */
+     mv88e61xx_rd_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+                      &reg);
+     reg &= ~0xfff;
+     reg |= 0x1;
+     mv88e61xx_wr_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VID_REG,
+                      reg);
+
+     /* Setting  Port default priority for all ports to zero */
+     for (prt = 0; prt < max_prtnum; prt++) {
+             mv88e61xx_rd_phy(name, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+                              &reg);
+             reg &= ~0xc000;
+             mv88e61xx_wr_phy(name, ports_ofs + prt, MV88E61XX_PRT_VID_REG,
+                              reg);
+     }
+     /* Setting VID and VID map for all ports except CPU port */
+     for (prt = 0; prt < max_prtnum; prt++) {
+             /* only for enabled ports */
+             if ((1 << prt) & port_mask) {
+                     /* skip CPU port */
+                     if (prt == cpu_port)
+                             continue;
+
+                     /*
+                      *  set Ports VLAN Mapping.
+                      *      port prt <--> MV88E61XX_CPU_PORT VLAN #prt+1.
+                      */
+
+                     mv88e61xx_rd_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_VID_REG, &reg);
+                     reg &= ~0x0fff;
+                     reg |= (prt + 1);
+                     mv88e61xx_wr_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_VID_REG, reg);
+
+                     /*
+                      * Set Vlan map table for all ports to send only to
+                      * MV88E61XX_CPU_PORT
+                      */
+                     mv88e61xx_rd_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_VMAP_REG, &reg);
+                     reg &= ~((1 << max_prtnum) - 1);
+                     reg |= (1 << cpu_port);
+                     mv88e61xx_wr_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_VMAP_REG, reg);
+             }
+     }
+     /* Set Vlan map table for MV88E61XX_CPU_PORT to see all ports */
+     mv88e61xx_rd_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+                      &reg);
+     reg &= ~((1 << max_prtnum) - 1);
+     reg |= port_mask & ~(1 << cpu_port);
+     mv88e61xx_wr_phy(name, (ports_ofs + cpu_port), MV88E61XX_PRT_VMAP_REG,
+                      reg);
+
+     /*
+      * enable only appropriate ports to forwarding mode
+      * and disable the others
+      */
+     for (prt = 0; prt < max_prtnum; prt++) {
+             if ((1 << prt) & port_mask) {
+                     mv88e61xx_rd_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_CTRL_REG, &reg);
+                     reg |= 0x3;
+                     mv88e61xx_wr_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_CTRL_REG, reg);
+             } else {
+                     /* Disable port */
+                     mv88e61xx_rd_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_CTRL_REG, &reg);
+                     reg &= ~0x3;
+                     mv88e61xx_wr_phy(name, ports_ofs + prt,
+                                      MV88E61XX_PRT_CTRL_REG, reg);
+             }
+     }
+}
+
+/*
+ * Make sure SMIBusy bit cleared before another
+ * SMI operation can take place
+ */
+int mv88361xx_busychk(char *name)
+{
+     u32 reg = 0;
+     u32 timeout = MV88E61XX_PHY_TIMEOUT;
+     do {
+             mv88e61xx_rd_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+                              MV88E61XX_PHY_CMD, &reg);
+             if (timeout-- == 0) {
+                     printf("SMI busy timeout\n");
+                     return -1;
+             }
+     } while (reg & BIT28);  /* busy mask */
+     return 0;
+}
+
+/*
+ * Marvell 88E61XX Switch initialization
+ */
+int mv_switch_88e61xx_init(char *name)
+{
+     u32 prt;

drivers/net/mv88e61xx.c line 244

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+     u16 reg;
+
+     if (miiphy_set_current_dev(name)) {
+             printf("%s failed\n", __FUNCTION__);
+             return -1;
+     }
+
+     /* Init vlan */
+     mv88e61xx_vlaninit(name, MV88E61XX_CPU_PORT, MV88E61XX_MAX_PORTS_NUM,
+                        MV88E61XX_PRT_OFST, MV88E61XX_ENABLED_PORTS);

this is board specific
Prafulla : the objective of this driver it to power up switch h/w to enable data path for Ethernet controller in switch managed mode (CPU <-> all other ports).
Prafulla: I think this is the functionality specific

drivers/net/mv88e61xx.c line 252

Quoted 8 lines
drivers/net/mv88e61xx.c new file +8 -0
+
+#ifdef CONFIG_SYS_RGMII_MODE
+     /* Enable RGMII delay on Tx and Rx for CPU port */
+     mv88e61xx_wr_phy(name, 0x14, 0x1a, 0x81e7);
+     mv88e61xx_rd_phy(name, 0x15, 0x1a, &reg);
+     mv88e61xx_wr_phy(name, 0x15, 0x1a, 0x18);
+     mv88e61xx_wr_phy(name, 0x14, 0x1a, 0xc1e7);
+#endif

this too
Prafulla: this will be needed only if RGMII interface is used for this switch on any platform, so is needed here.

Quoted 24 lines
drivers/net/mv88e61xx.c new file +24 -0
+
+     for (prt = 0; prt < MV88E61XX_MAX_PORTS_NUM; prt++) {
+             if (prt != MV88E61XX_CPU_PORT) {
+                     /* Write Copper Specific control reg1 (0x14) for-
+                      * Enable Phy power up
+                      * Energy Detect on (sense&Xmit NLP Periodically
+                      * reset other settings default
+                      */
+                     mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+                                      MV88E61XX_PHY_DATA, 0x3360);
+                     mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+                                      MV88E61XX_PHY_CMD,
+                                      (0x9410 | (prt << 5)));
+
+                     if (mv88361xx_busychk(name))
+                             return -1;
+
+                     /* Write PHY ctrl reg (0x0) to apply
+                      * Phy reset (BIT15=low)
+                      * reset other default values
+                      */
+                     mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,
+                                      MV88E61XX_PHY_DATA, 0x1140);
+                     mv88e61xx_wr_phy(name, MV88E61XX_GLOBAL2_REG_DEVADR,

drivers/net/mv88e61xx.c line 286

Quoted 10 lines
drivers/net/mv88e61xx.c new file +10 -0
+                                      MV88E61XX_PHY_CMD,
+                                      (0x9400 | (prt << 5)));
+
+                     if (mv88361xx_busychk(name))
+                             return -1;
+             }
+
+             /*Enable port */
+             mv88e61xx_wr_phy(name, MV88E61XX_PRT_OFST + prt, 4, 0x7f);
+     }

this too
Prafulla : No :-) ... switch objective..., if I abstract your platform specific comments, there is nothing special in it to keep it in drivers/net/
Prafulla: so on any platform if this switch is used, this driver can be enabled, currently it provides copper specific init, can be extended further for fiber optics and other needs

drivers/net/mv88e61xx.c line 295

Quoted 9 lines
drivers/net/mv88e61xx.c new file +9 -0
+
+     mv88e61xx_rd_phy(name, MV88E61XX_PRT_OFST, PHY_PHYIDR2, &reg);
+     reg &= 0xfff0;
+     if (reg == 0x1610)
+             printf("88E6161");
+     if (reg == 0x1650)
+             printf("88E6165");
+     if (reg == 0x1210)
+             printf("88E6123");

by detecting the switch model you will capable to identify the numbers of ports and their capability
Prafulla: sure, but which port to be used will be again question to be asked to board header

drivers/net/mv88e61xx.c line 299

Quoted 4 lines
drivers/net/mv88e61xx.c new file +4 -0
+
+     printf(" Initialized on %s\n", name);
+     return 0;
+}

Best Regards,
J.

#29 lore raw

PATCH v3 1/1 Marvell MV88E61XX Switch Driver support

Dear Jean

I have updated this driver with platform specific abstraction support, That satisfy most of your review feedback, also taken care of your other review comments I am sending patch v4 for the same

Regards..
Prafulla . .

#30 lore raw

PATCH v2 1/1 Marvell MV88E61XX Switch Driver support

In reply to Prafulla Wadaskar

Hi Prafulla,

We have a custom designed board with the M88E6185 and M88E6131 switch. The u-boot patches are very usefull, even though I already finished some code to initialize the switches.

In our application it's more easy to "fully" provision the switches when the linux kernel is up and running.
So I wonder:
Is "M88E61XX switch driver support" planned for the linux kernel ? In other words: is there any chance similar patches will be released for the linux kernel any time soon ?

---
N. van Bolhuis.

#31 lore raw

PATCH 1/1 Marvell 88EXXXX Switch/PHY init support

In reply to Prafulla Wadaskar

Hi,

Any updates with this switches support in uboot?

2009/4/3 Prafulla Wadaskar <[email protected]>:

Quoted 15 lines

From: prafulla_wadaskar <[email protected]>

Chips supprted:-
1. 88E61XX 6 port gbe swtich with 5 integrated PHYs
2. 88E6061 6 port fe swtich with 5 integrated PHYs
3. 88E1116 gbe transceiver

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>
---

Signature · 2 lines
Best Regards,
Sergey Nikulov
#32 lore raw

PATCH 1/1 Marvell 88EXXXX Switch/PHY init support

Quoted 10 lines

-----Original Message-----
From: Sergey Nikulov [mailto:sergey.nikulov at gmail.com]
Sent: Thursday, May 21, 2009 4:20 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH] Marvell 88EXXXX Switch/PHY init support

Hi,

Any updates with this switches support in uboot?

Hi Sergey
You can find patch here. This will be merged soon
http://git.denx.de/?p=u-boot/u-boot-net.git;a=commit;h=b67f915a20e7bcb0206021decfb6d7f2013892f2

There are few updates to it that will follow the same path
http://lists.denx.de/pipermail/u-boot/2009-May/052905.html

Regards..
Prafulla . .

#33 lore raw

PATCH 1/1 Marvell 88EXXXX Switch/PHY init support

Well, actually I'm more interested in mv88e60xx.c support :)

#34 lore raw

PATCH 1/1 Marvell 88EXXXX Switch/PHY init support

Quoted 2 lines

Well, actually I'm more interested in mv88e60xx.c support :)

BTW: Which specific chip support you are looking for? I will try if I can help you

Quoted 6 lines

From log I can see
"
Marvell MV88E61XX Switch Driver support
"
are MV88E61XX and MV88E60XX the same?

Not really...

Regards..
Prafulla . .

#35 lore raw

PATCH 1/1 Gbe Controller driver support for kirkwood SOCs

In reply to Prafulla Wadaskar
Quoted 12 lines · On Friday 03 April 2009 18:39:28 Prafulla Wadaskar wrote:
net/eth.c +1 -0
@@ -73,6 +73,7 @@ int board_eth_init(bd_t *bis) __attribute((weak,
 alias("__def_eth_init")));
 
 extern int mv6436x_eth_initialize(bd_t *);
 extern int mv6446x_eth_initialize(bd_t *);
+extern int kirkwood_egiga_initialize(bd_t*);
 
 #ifdef CONFIG_API

extern void (*push_packet)(volatile void *, int);

net/eth.c int eth_initialize(bd_t *bis) · line 214

Quoted 9 lines
net/eth.c +3 -0
@@ -205,6 +206,9 @@ int eth_initialize(bd_t *bis)
 #if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx)
 	mv6446x_eth_initialize(bis);
 #endif
+#ifdef CONFIG_KIRKWOOD_EGIGA
+       kirkwood_egiga_initialize(bis);
+#endif
 	if (!eth_devices) {
 		puts ("No ethernet found.\n");
 		show_boot_progress (-64);

this should be dying, not new additions. define board_eth_init() like everyone else now.
-mike

#36 lore raw

PATCH 1/1 Gbe Controller driver support for kirkwood SOCs

In reply to Prafulla Wadaskar
Quoted 10 lines · Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>
---

<snip>

Quoted 14 lines
net/eth.c +1 -0
index 4bbf84b..77fa8a5 100644
@@ -73,6 +73,7 @@ int board_eth_init(bd_t *bis) __attribute((weak, alias("__def_eth_init")));
 
 extern int mv6436x_eth_initialize(bd_t *);
 extern int mv6446x_eth_initialize(bd_t *);
+extern int kirkwood_egiga_initialize(bd_t*);
 
 #ifdef CONFIG_API
 extern void (*push_packet)(volatile void *, int);

net/eth.c int eth_initialize(bd_t *bis) · line 214

Quoted 9 lines
net/eth.c +3 -0
@@ -205,6 +206,9 @@ int eth_initialize(bd_t *bis)
 #if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx)
 	mv6446x_eth_initialize(bis);
 #endif
+#ifdef CONFIG_KIRKWOOD_EGIGA
+       kirkwood_egiga_initialize(bis);
+#endif
 	if (!eth_devices) {
 		puts ("No ethernet found.\n");
 		show_boot_progress (-64);

I believe Mike mentioned this already, but you shouldn't be initializing your drivers here. You'll notice that this area of code is much smaller than it used to be, and the only drivers left are Marvell ones. I started cleaning them up, but the work was huge and lacking hardware I was nervous about breaking things. IIRC, the MV6436X and MV6446X drivers duplicate code > 99%.

regards,
Ben

#37 lore raw

PATCH 1/1 Gbe Controller driver support for kirkwood SOCs

Quoted 45 lines

-----Original Message-----
From: Ben Warren [mailto:biggerbadderben at gmail.com]
Sent: Saturday, April 04, 2009 12:44 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH] Gbe Controller driver support for kirkwood SOCs

Quoted 7 lines · Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by:

Quoted 3 lines

Ronen Shitrit <[email protected]>
---

<snip>

Quoted 12 lines
net/eth.c +1 -0
index 4bbf84b..77fa8a5 100644
@@ -73,6 +73,7 @@ int board_eth_init(bd_t *bis) __attribute((weak, 
 alias("__def_eth_init")));
 
 extern int mv6436x_eth_initialize(bd_t *);  extern int 
 mv6446x_eth_initialize(bd_t *);
+extern int kirkwood_egiga_initialize(bd_t*);
 
 #ifdef CONFIG_API
Quoted 1 line

extern void (*push_packet)(volatile void *, int); @@

-205,6 +206,9 @@

net/eth.c int eth_initialize(bd_t *bis) · line 214

Quoted 10 lines

int eth_initialize(bd_t *bis) #if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx)

      mv6446x_eth_initialize(bis);

#endif

net/eth.c +2 -0
+#ifdef CONFIG_KIRKWOOD_EGIGA
+       kirkwood_egiga_initialize(bis); #endif
      if (!eth_devices) {
              puts ("No ethernet found.\n");
              show_boot_progress (-64);
Quoted 7 lines

I believe Mike mentioned this already, but you shouldn't be initializing your drivers here. You'll notice that this area of code is much smaller than it used to be, and the only drivers left are Marvell ones. I started cleaning them up, but the work was huge and lacking hardware I was nervous about breaking things. IIRC, the MV6436X and MV6446X drivers duplicate code > 99%.

Hi Ben
Neither I have all other hardware with me.
While creating this driver I had this question in my mind But at safer side I decided not to broke other things...

It will be my pleasure to co-operate to sort this out..

Regards..
Prafulla ..

Quoted 4 lines

regards,
Ben

#38 lore raw

PATCH 1/1 Gbe Controller driver support for kirkwood SOCs

In reply to Prafulla Wadaskar

Dear Prafulla Wadaskar,

Quoted 8 lines · In message <[email protected]> you wrote:

From: prafulla_wadaskar <[email protected]>

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

...

cpu/arm926ejs/kirkwood/Makefile COBJS-y = timer.o · line 33

Quoted 9 lines
cpu/arm926ejs/kirkwood/Makefile +1 -0
index 41ac8d7..3e20898 100644
@@ -30,6 +30,7 @@ COBJS-y	= timer.o
 COBJS-y	+= serial.o
 COBJS-y	+= kwcore.o
 COBJS-y	+= dram.o
+COBJS-y	+= egiga.o

Please sort such lists.

...

cpu/arm926ejs/kirkwood/Makefile COBJS-y = timer.o

Quoted 7 lines
cpu/arm926ejs/kirkwood/Makefile +7 -0
+int eth_smi_reg_read(u32 eth_port_num, u32 phy_adr, u32 reg_ofs, u16 * data)
+{
+	u32 smi_reg;
+	volatile u32 timeout;
+
+	/* check parameters */
+	if ((phy_adr << ETH_PHY_SMI_DEV_ADDR_OFFS) & ~ETH_PHY_SMI_DEV_ADDR_MASK) {

Line too long. (Hint: consider using shorter names! :-)

...

cpu/arm926ejs/kirkwood/Makefile

Quoted 5 lines
cpu/arm926ejs/kirkwood/Makefile +5 -0
+	/* fill the phy address and regiser offset and read opcode */
+	smi_reg =
+	    (phy_adr << ETH_PHY_SMI_DEV_ADDR_OFFS) | (reg_ofs <<
+						      KW_ETH_SMI_REG_ADDR_OFFS)
+	    | ETH_PHY_SMI_OPCODE_READ;

Please clean up indentation here.

...

Quoted 22 lines
cpu/arm926ejs/kirkwood/Makefile +22 -0
+static int egiga_free_rx_rings(struct eth_device *dev)
+{
+	u32 queue;
+	ETH_PORT_INFO *ethernet_private;
+	struct egiga_priv *port_private;
+	u32 port_num;
+	volatile ETH_RX_DESC *p_rx_curr_desc;
+
+	ethernet_private = (ETH_PORT_INFO *) dev->priv;
+	port_private = (struct egiga_priv *)ethernet_private->port_private;
+	port_num = port_private->port_num;
+
+	/* Stop RX Queues */
+	KW_REG_WRITE(KW_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 0x0000ff00);
+
+	/* Free RX rings */
+	debug_print("Clearing previously allocated RX queues... ");
+	for (queue = 0; queue < KW_RX_QUEUE_NUM; queue++) {
+		/* Free preallocated skb's on RX rings */
+		for (p_rx_curr_desc =
+		     ethernet_private->p_rx_desc_area_base[queue];
+		     (((u32)p_rx_curr_desc <

cpu/arm926ejs/kirkwood/Makefile

Quoted 10 lines
cpu/arm926ejs/kirkwood/Makefile +10 -0
+		       ((u32)ethernet_private->
+			p_rx_desc_area_base[queue] +
+			ethernet_private->rx_desc_area_size[queue])));
+		     p_rx_curr_desc =
+		     (ETH_RX_DESC *) ((u32)p_rx_curr_desc +
+				      RX_DESC_ALIGNED_SIZE)) {
+			if (p_rx_curr_desc->return_info != 0) {
+				p_rx_curr_desc->return_info = 0;
+				debug_print("freed");
+			}

... and here. Such code is basicly unreadable.

...

Quoted 5 lines
cpu/arm926ejs/kirkwood/Makefile +5 -0
+static ETH_FUNC_RET_STATUS eth_port_send(ETH_PORT_INFO * p_eth_port_ctrl,
+					 ETH_QUEUE tx_queue,
+					 PKT_INFO * p_pkt_info)
+{
+	volatile ETH_TX_DESC *p_tx_desc_first;

cpu/arm926ejs/kirkwood/Makefile

Quoted 10 lines
cpu/arm926ejs/kirkwood/Makefile +10 -0
+	volatile ETH_TX_DESC *p_tx_desc_curr;
+	volatile ETH_TX_DESC *p_tx_next_desc_curr;
+	volatile ETH_TX_DESC *p_tx_desc_used;
+	u32 command_status;
+
+#ifdef CONFIG_TX_PKT_DISPLAY
+	{
+		u16 pcnt = p_pkt_info->byte_cnt;
+		u8 *prndt = (char *)p_pkt_info->buf_ptr;
+		printf("cnt=%d ", pcnt);

Blank line after declarations, please (check gloabally, please).

Also, pelase try to acoid such nested blocks with additional declarations.

Quoted 9 lines
cpu/arm926ejs/kirkwood/Makefile +9 -0
+		while (pcnt) {
+			printf("%02x,", prndt[0]);
+			prndt++;
+			pcnt--;
+		}
+		printf(" pckend \n");
+
+	}
+#endif

...

Quoted 6 lines
cpu/arm926ejs/kirkwood/egiga.h new file +0 -0
new file mode 100644
index 0000000..83dc4b3
@@ -0,0 +1,707 @@

...

cpu/arm926ejs/kirkwood/egiga.h line 43

Quoted 6 lines
cpu/arm926ejs/kirkwood/egiga.h new file +6 -0
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif

Omit?

...

Quoted 33 lines
cpu/arm926ejs/kirkwood/egiga.h new file +33 -0
+struct net_device_stats {
+	u32 rx_packets;	/* total packets received       */
+	u32 tx_packets;	/* total packets transmitted    */
+	u32 rx_bytes;	/* total bytes received         */
+	u32 tx_bytes;	/* total bytes transmitted      */
+	u32 rx_errors;	/* bad packets received         */
+	u32 tx_errors;	/* packet transmit problems     */
+	u32 rx_dropped;	/* no space in linux buffers    */
+	u32 tx_dropped;	/* no space available in linux  */
+	u32 multicast;	/* multicast packets received   */
+	u32 collisions;
+	/* detailed rx_errors: */
+	u32 rx_length_errors;
+	u32 rx_over_errors;	/* receiver ring buff overflow  */
+	u32 rx_crc_errors;	/* recved pkt with crc error    */
+	u32 rx_frame_errors;	/* recv'd frame alignment error */
+	u32 rx_fifo_errors;	/* recv'r fifo overrun          */
+	u32 rx_missed_errors;	/* receiver missed packet       */
+	/* detailed tx_errors */
+	u32 tx_aborted_errors;
+	u32 tx_carrier_errors;
+	u32 tx_fifo_errors;
+	u32 tx_heartbeat_errors;
+	u32 tx_window_errors;
+	/* for cslip etc */
+	u32 rx_compressed;
+	u32 tx_compressed;
+};
+
+/* Private data structure used for ethernet device */
+struct egiga_priv {
+	u32 port_num;
+	struct net_device_stats *stats;

cpu/arm926ejs/kirkwood/egiga.h line 137

Quoted 10 lines
cpu/arm926ejs/kirkwood/egiga.h new file +10 -0
+	/* to buffer area aligned */
+	char *p_eth_tx_buffer[KW_TX_QUEUE_SIZE + 1];
+	char *p_eth_rx_buffer[KW_RX_QUEUE_SIZE + 1];
+	/* Size of Tx Ring per queue */
+	u32 tx_ring_size[MAX_TX_QUEUE_NUM];
+	/* Size of Rx Ring per queue */
+	u32 rx_ring_size[MAX_RX_QUEUE_NUM];
+	/* Magic Number for Ethernet running */
+	u32 eth_running;
+};

Please use TABs for vertical alignment to make the code readable.

...

Quoted 4 lines
cpu/arm926ejs/kirkwood/egiga.h new file +4 -0
+/* Gap define */
+#define ETH_BAR_GAP			0x8
+#define ETH_SIZE_REG_GAP		0x8
+#define ETH_HIGH_ADDR_REMAP_REG_GAP	0x4

cpu/arm926ejs/kirkwood/egiga.h line 252

Quoted 10 lines
cpu/arm926ejs/kirkwood/egiga.h new file +10 -0
+#define ETH_PORT_ACCESS_CTRL_GAP	0x4
+/* MIB Counters register definitions */
+#define ETH_MIB_GOOD_OCTETS_RECEIVED_LOW   0x0
+#define ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH  0x4
+#define ETH_MIB_BAD_OCTETS_RECEIVED	   0x8
+#define ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR  0xc
+#define ETH_MIB_GOOD_FRAMES_RECEIVED	   0x10
+#define ETH_MIB_BAD_FRAMES_RECEIVED	   0x14
+#define ETH_MIB_BROADCAST_FRAMES_RECEIVED  0x18
+#define ETH_MIB_MULTICAST_FRAMES_RECEIVED  0x1c

... and so on:

Please use TABs for vertical alignment to make the code better readable.

This applies to the rest of file, too.

Quoted 5 lines
cpu/arm926ejs/kirkwood/egiga_regs.h new file +0 -0
new file mode 100644
index 0000000..a24fa04

...

cpu/arm926ejs/kirkwood/egiga_regs.h line 42

Quoted 9 lines
cpu/arm926ejs/kirkwood/egiga_regs.h new file +9 -0
+/*
+ *Ethernet Controller Registers
+ */
+#define KW_ETH_PHY_ADDR_REG(port)			(0x72000 + (port<<14))
+#define KW_ETH_SMI_REG(port)				(0x72004 + (port<<14))
+#define KW_ETH_UNIT_DEFAULT_ADDR_REG(port)		(0x72008 + (port<<14))
+#define KW_ETH_UNIT_DEFAULTID_REG(port)			(0x7200c + (port<<14))
+#define KW_ETH_UNIT_INTERRUPT_CAUSE_REG(port)		(0x72080 + (port<<14))
+#define KW_ETH_UNIT_INTERRUPT_MASK_REG(port)		(0x72084 + (port<<14))

...

Use C structures to describe the device layout, and you can get rid of this ugly code.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
I've got a bad feeling about this.
#39 lore raw

PATCH 1/1 Marvell Kirkwood family SOC support

In reply to Prafulla Wadaskar

Dear Prafulla Wadaskar,

Quoted 23 lines · In message <[email protected]> you wrote:

From: prafulla_wadaskar <[email protected]>

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0

Other supported features:-
1) Doimage utility needed to create binaries with
bootROM header
2) get_random_hex() fucntion
3) SPI port controller driver
4) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

...

Quoted 8 lines
 board/Marvell/common/kw_lowlevel_init.S        |   45 +
 board/Marvell/include/core.h                   |    4 +
 cpu/arm926ejs/kirkwood/Makefile                |   52 +
 cpu/arm926ejs/kirkwood/bin_dep.sh              |   50 +
 cpu/arm926ejs/kirkwood/config.mk               |   25 +
 cpu/arm926ejs/kirkwood/doimage/Makefile        |  112 ++
 cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h |   88 ++
 cpu/arm926ejs/kirkwood/doimage/doimage         |  Bin 0 -> 17712 bytes

Never ever add binaries !!!

Quoted 15 lines
board/Marvell/include/core.h +2 -0
@@ -12,9 +12,11 @@ space). The macros take care of Big/Little endian conversions.
 #ifndef __INCcoreh
 #define __INCcoreh
 
+#ifndef CONFIG_KIRKWOOD
 #include "mv_gen_reg.h"
 
 extern unsigned int INTERNAL_REG_BASE_ADDR;
+#endif /* CONFIG_KIRKWOOD */
 
 /****************************************/
 /*	    GENERAL Definitions			*/

board/Marvell/include/core.h extern unsigned int INTERNAL_REG_BASE_ADDR; · line 94

Quoted 2 lines
board/Marvell/include/core.h +0 -0
@@ -91,10 +93,12 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;
 #define _1G		0x40000000
 #define _2G		0x80000000

Please get rid of these "cool" (actually stupid) macros.

board/Marvell/include/core.h extern unsigned int INTERNAL_REG_BASE_ADDR; · line 103

Quoted 8 lines
board/Marvell/include/core.h +2 -0
+#ifndef __ASSEMBLY__
 #ifndef	BOOL_WAS_DEFINED
 #define BOOL_WAS_DEFINED
 typedef enum _bool{false,true} bool;
 #endif
+#endif
 
 /* Little to Big endian conversion macros */

Please also use standard macros here, and clean up these proprietary definitions.

Quoted 5 lines
cpu/arm926ejs/kirkwood/bin_dep.sh new file +0 -0
new file mode 100755
index 0000000..1b36e91

...

Quoted 7 lines
cpu/arm926ejs/kirkwood/bin_dep.sh new file +7 -0
+TOP_DIR=`pwd`
+CUR_DIR=$2
+BIN_FILE=$TOP_DIR/$1
+
+if [ "clean" == "$1" ]; then
+	# erase created doimage utility
+	rm -f $CUR_DIR/doimage/doimage

cpu/arm926ejs/kirkwood/bin_dep.sh line 49

Quoted 10 lines
cpu/arm926ejs/kirkwood/bin_dep.sh new file +10 -0
+	exit 0
+fi
+
+if [ ! -f $BIN_FILE ]; then
+	echo Error.. could not find $BIN_FILE
+	exit 1
+else
+	make -C $CUR_DIR/doimage
+	exit 0
+fi

Please get rid of this. It doesn't for for out-of-tree builds anyway.

...

Quoted 6 lines
cpu/arm926ejs/kirkwood/doimage/Makefile new file +0 -0
new file mode 100644
index 0000000..219ae1e
@@ -0,0 +1,112 @@

..

Quoted 10 lines
cpu/arm926ejs/kirkwood/doimage/Makefile new file +10 -0
+BIN_FILES	= doimage$(SFX)
+
+OBJ_LINKS	=
+OBJ_FILES	= doimage.o
+
+LIBFDT_OBJ_FILES	=
+
+#-------------------------------------------------------------------------
+
+HOSTARCH := $(shell uname -m | \

cpu/arm926ejs/kirkwood/doimage/Makefile line 51

Quoted 10 lines
cpu/arm926ejs/kirkwood/doimage/Makefile new file +10 -0
+	sed -e s/i.86/i386/ \
+	    -e s/sun4u/sparc64/ \
+	    -e s/arm.*/arm/ \
+	    -e s/sa110/arm/ \
+	    -e s/powerpc/ppc/ \
+	    -e s/Power\ Macintosh/ppc/ \
+	    -e s/macppc/ppc/)
+
+HOSTOS := $(shell uname -s | tr A-Z a-z | \
+	sed -e 's/\(cygwin\).*/cygwin/')

Why is this needed? You should get this from the top level Makefile.

cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h

Quoted 6 lines
cpu/arm926ejs/kirkwood/doimage/Makefile new file +1 -0
+#########################################################################
cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h new file +0 -0
new file mode 100644
index 0000000..8782206

Do you REEALLY need all this stuff?

Why? What is the rationale behind it?

Did I miss the documentation for it?

Apropos documentation... how about entries to the MAINTAINERS file, MAKEALL, etc. ?

...

Quoted 4 lines
cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h new file +4 -0
+/* typedefs */
+
+typedef char s8;
+typedef unsigned char u8;

cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h line 42

Quoted 10 lines
cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h new file +10 -0
+
+typedef int s32;
+typedef unsigned int u32;
+
+typedef short s16;
+typedef unsigned short u16;
+
+typedef long s64;
+typedef unsigned long u64;
+

Why is theis needed? Please include the respexctive standard headers.

cpu/arm926ejs/kirkwood/doimage/doimage

Quoted 8 lines
cpu/arm926ejs/kirkwood/doimage/doimage new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..9fee11740454ff880c081a64be0d692b1da4c19a
GIT binary patch

...

Never, never ever do this again.

cpu/arm926ejs/kirkwood/doimage/doimage.c

Quoted 6 lines
cpu/arm926ejs/kirkwood/doimage/doimage.c new file +0 -0
new file mode 100644
index 0000000..0c484b2
@@ -0,0 +1,1341 @@

Why is this needed?

...

cpu/arm926ejs/kirkwood/doimage/doimage.c line 58

Quoted 13 lines
cpu/arm926ejs/kirkwood/doimage/doimage.c new file +13 -0
+#define DOIMAGE_VERSION		"1.00"
+void print_usage(void);
+int f_in = -1;
+int f_out = -1;
+int f_header = -1;
+typedef enum { IMG_SATA, IMG_UART, IMG_FLASH, IMG_BOOTROM, IMG_NAND, IMG_HEX,
+	IMG_BIN, IMG_PEX, IMG_I2C
+} IMG_TYPE;
+typedef enum { HDR_IMG_ONE_FILE = 1,	/* Create one file with header and image */
+	HDR_IMG_TWO_FILES = 2,	/* Create seperate header and image files */
+	HDR_ONLY = 3,		/* Create only header */
+	IMG_ONLY = 4		/* Create only image */
+} HEADER_MODE;

Why do you have to reinvent your own image format here?

U-Boot already has a prtty powerful and flexible format - uns this. [Keep in mind that one day you want to add this to Linux, too. RMK will be much more draconic about such stuff than me.]

Quoted 2 lines
cpu/arm926ejs/kirkwood/doimage/doimage.c new file +2 -0
+/* 8 bit checksum */
+u8 checksum8(void *start, u32 len, u8 csum)

...

Quoted 2 lines
cpu/arm926ejs/kirkwood/doimage/doimage.c new file +2 -0
+/* 32 bit checksum */
+u32 checksum32(void *start, u32 len, u32 csum)

...

Quoted 1 line

+void make_crc_table(u32 * crc_table)

No, no, no. You really re-invent all parts of the wheel.

Stop here. Don't. NAK.

...

Quoted 62 lines
cpu/arm926ejs/kirkwood/doimage/doimage.c new file +62 -0
+void print_usage(void)
+{
+	printf("\n");
+	printf("Marvell doimage Tool version %s\n", DOIMAGE_VERSION);
+	printf("Supported SoC devices: \n");
+	printf("    Marvell 88F6082 - A1\n");
+	printf("    Marvell 88F6180 - A0\n");
+	printf("    Marvell 88F6192 - A0\n");
+	printf("    Marvell 88F6190 - A0\n");
+	printf("    Marvell 88F6281 - A0\n");
+	printf("\n");
+	printf("usage: \n");
+	printf
+	    ("doimage <must_options> [other_options] image_in image_out [header_out]\n");
+	printf("\n<must_options> - can be one or more of the following:\n\n");
+	printf("-T image_type:   sata\\uart\\flash\\bootrom\\nand\\hex\\pex\n");
+	printf("                 if image_type is sata, the image_out will\n");
+	printf("                 include header only.\n");
+	printf("-D image_dest:   image destination in dram (in hex)\n");
+	printf("-E image_exec:   execution address in dram (in hex)\n");
+	printf
+	    ("                 if image_type is 'flash' and image_dest is 0xffffffff\n");
+	printf("                 then execution address on the flash\n");
+	printf
+	    ("-S image_source: if image_type is sata then the starting sector of\n");
+	printf
+	    ("                 the source image on the disk - mandatory for sata\n");
+	printf
+	    ("                 if image_type is flash\\nand then the starting offset of\n");
+	printf
+	    ("                 the source image at the flash - optional for flash\\nand\n");
+	printf("-W hex_width :   HEX file width, can be 8,16,32,64 \n");
+	printf
+	    ("-M twsi_file:    ascii file name that contains the I2C init regs set by h/w.\n");
+	printf("                 this is used in i2c boot only\n");
+	printf
+	    ("\n<other_options> - optional and can be one or more of the following:\n\n");
+	printf
+	    ("-R dram_file: ascii file name that contains the list of dram regs\n");
+	printf("-P nand_page_size (decimal 512, 2048, ..): NAND Page size\n");
+	printf("-C nand_ecc_mode (1=Hamming, 2=RS, 3=None)\n");
+	printf("-L delay in mili seconds before DRAM init\n");
+	printf("-I copy image in PIO mode (valid for SATA only)\n");
+	printf("-X pre_padding_size (hex)\n");
+	printf("-Y post_padding_size (hex)\n");
+	printf("-H header_mode: Header mode, can be:\n");
+	printf
+	    ("   -H 1 :will create one file (image_out) for header and image\n");
+	printf
+	    ("   -H 2 :will create two files, (image_out) for image , (header_out) for header\n");
+	printf("   -H 3 :will create one file (image_out) for header only \n");
+	printf("   -H 4 :will create one file (image_out) for image only \n");
+	printf("\ncommand possibilities: \n\n");
+	printf("doimage -T hex -W width image_in image_out\n");
+	printf("doimage -T bootrom image_in image_out\n");
+	printf("doimage -T sata -S sector -D image_dest -E image_exec\n");
+	printf("         [other_options] image_in image_out header_out\n\n");
+	printf("doimage -T flash -D image_dest -E image_exec [-S address]\n");
+	printf("         [other_options] image_in image_out\n\n");
+	printf("doimage -T pex -D image_dest -E image_exec \n");
+	printf("         [other_options] image_in image_out\n\n");
+	printf

cpu/arm926ejs/kirkwood/doimage/doimage.c line 1340

Quoted 10 lines
cpu/arm926ejs/kirkwood/doimage/doimage.c new file +10 -0
+	    ("doimage -T nand -D image_dest -E image_exec [-S address] -P page_size\n");
+	printf("         [other_options] image_in image_out\n\n");
+	printf("doimage -T uart -D image_dest -E image_exec\n");
+	printf("         [other_options] image_in image_out\n\n");
+	printf("doimage -T pex -D image_dest -E image_exec \n");
+	printf("         [other_options] image_in image_out\n\n");
+	printf
+	    ("doimage -T i2c -D image_dest -E image_exec -M twsi_init_file\n");
+	printf("         [other_options] image_in image_out\n\n");
+	printf("\n\n\n");

Instead of splitting this into a zillion or printf() statements (where puts() would be sifficient, too), just feed the text into one statement.

But anyway - I think you need to re-think this concept.

Such code has zero chance to go into mainline - not this image building code, and not the U-Boot implementation that obviusly requires that.

Quoted 5 lines
cpu/arm926ejs/kirkwood/dram.c new file +0 -0
new file mode 100644
index 0000000..41f1316

...

cpu/arm926ejs/kirkwood/dram.c line 35

Quoted 9 lines
cpu/arm926ejs/kirkwood/dram.c new file +9 -0
+u32 kw_get_dram_bank_base_addr(MEMORY_BANK bank)
+{
+	u32 result = 0;
+	u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));
+
+	if ((!enable) || (bank > BANK3))
+		return 0;
+
+	result = KW_REG_READ((0x1500 + bank * 8));

Here and everywhere: do not access any device registers based on address plus offset. Provide proper C structures instead, and access the struct elements so the compiler can perform appropriate type checking.

And please do not re-invent your own private accessor macros / functions.

cpu/arm926ejs/kirkwood/dram.c line 48

Quoted 10 lines
cpu/arm926ejs/kirkwood/dram.c new file +10 -0
+u32 kw_get_dram_bank_size(MEMORY_BANK bank)
+{
+	u32 result = 0;
+	u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));
+
+	if ((!enable) || (bank > BANK3))
+		return 0;
+	result = (0xff000000 & KW_REG_READ((0x1504 + bank * 8)));
+	result += 0x01000000;
+	return result;

Consider to auto-size the RAM ionstead of using static information from some registers (which may or may not be correct).

cpu/arm926ejs/kirkwood/dram.c

Quoted 6 lines
cpu/arm926ejs/kirkwood/dram.c new file +6 -0
+/*
+ * Generates Ramdom hex number reading some time varient system registers
+ * and using md5 algorithm
+ */
+unsigned char get_random_hex(void)
+{

You probably want to make this optional, so it can be omitted. Always requesting the full md5 code just to get some random numbers is a lot of overhead.

BTW - what do you need random numbers for in U-Boot? Nobody else needs this...

...

cpu/arm926ejs/kirkwood/dram.c

Quoted 1 line
cpu/arm926ejs/kirkwood/dram.c new file +1 -0
+	return KW_OK;

Here and everywhere: please write readable code and avoid custom macros like these.

...

cpu/arm926ejs/kirkwood/dram.c

Quoted 3 lines
cpu/arm926ejs/kirkwood/dram.c new file +3 -0
+	debug_print_ftrace();
+	/*CPU streaming & write allocate */
+	env = getenv("enaWrAllo");

Documentation for all these variables missing.

Please use readable / writable variable names. CamelCase is strongly deprecated.

cpu/arm926ejs/kirkwood/dram.c

Quoted 11 lines
cpu/arm926ejs/kirkwood/dram.c new file +11 -0
+	/* Verify write allocate and streaming */
+	printf("\n");
+	__asm__ __volatile__("mrc p15, 1, %0, c15, c1, 0":"=r"(temp));
+	if (temp & BIT29)
+		info_print("Streaming enabled");
+	else
+		info_print("Streaming disabled");
+	if (temp & BIT28)
+		info_print("Write allocate enabled");
+	else
+		info_print("Write allocate disabled");

Yet another set of proprietary functions. Get rid of these!

Quoted 6 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +0 -0
new file mode 100644
index 0000000..0ddc6a8
@@ -0,0 +1,141 @@

...

cpu/arm926ejs/kirkwood/kwcore.h line 46

Quoted 11 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +11 -0
+/* Controler environment registers offsets */
+#define KW_REG_MPP_CONTROL0		(0x10000)
+#define KW_REG_MPP_CONTROL1		(0x10004)
+#define KW_REG_MPP_CONTROL2		(0x10008)
+#define KW_REG_MPP_CONTROL3		(0x1000C)
+#define KW_REG_MPP_CONTROL4		(0x10010)
+#define KW_REG_MPP_CONTROL5		(0x10014)
+#define KW_REG_MPP_CONTROL6		(0x10018)
+#define KW_REG_MPP_SMPL_AT_RST		(0x10030)
+#define KW_REG_CHIP_BOND		(0x10034)
+#define KW_REG_MPP_OUT_DRV_REG		(0x100E0)

...

Use C structures instead of offset tables!

Quoted 6 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +6 -0
+/*
+ * Macros
+ * CPU architecture dependent I/O read/write
+ */
+#define KW_REG_WRITE(addr, data)	\
+    ((*((volatile unsigned int*)(KW_REGISTER(addr)))) \

cpu/arm926ejs/kirkwood/kwcore.h line 105

Quoted 10 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +10 -0
+		 = ((unsigned int)WORD_SWAP((data))))
+
+#define KW_REG_READ(addr)       	\
+    WORD_SWAP(((*((volatile unsigned int*)(KW_REGISTER(addr))))))
+
+#define KW_REG_BITS_SET(adr, bits)	(KW_REG_WRITE(adr, KW_REG_READ(adr)\
+					| ((unsigned int)WORD_SWAP(bits))))
+
+#define KW_REG_BITS_RESET(adr, bits)	(KW_REG_WRITE(adr, KW_REG_READ(adr)\
+					& ~((unsigned int)WORD_SWAP(bits))))

Do not reinvent the wheel, do not pollute the code with tons of redundand proprietary versions of maros that exist elsewhere.

cpu/arm926ejs/kirkwood/kwcore.h line 109

Quoted 3 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +3 -0
+#define KW_REG_READ_ASM(toReg, tmpReg, regOffs)	\
+        ldr     tmpReg, =KW_REGISTER(regOffs);  	\
+        ldr     toReg, [tmpReg];  			\

Indentation not by TAB. Please fix globally.

Quoted 2 lines
cpu/arm926ejs/kirkwood/serial.c new file +0 -0

...

Quoted 9 lines
cpu/arm926ejs/kirkwood/serial.c new file +9 -0
+/* This structure describes the registers offsets for one UART port/channel */
+typedef struct kwUartPort {
+	u8 rbr;			/* 0 = 0-3 */
+	u8 pad1[3];
+	u8 ier;			/* 1 = 4-7 */
+	u8 pad2[3];
+	u8 fcr;			/* 2 = 8-b */
+	u8 pad3[3];
+	u8 lcr;			/* 3 = c-f */

cpu/arm926ejs/kirkwood/serial.c line 80

Quoted 10 lines
cpu/arm926ejs/kirkwood/serial.c new file +10 -0
+	u8 pad4[3];
+	u8 mcr;			/* 4 = 10-13 */
+	u8 pad5[3];
+	u8 lsr;			/* 5 = 14-17 */
+	u8 pad6[3];
+	u8 msr;			/* 6 =18-1b */
+	u8 pad7[3];
+	u8 scr;			/* 7 =1c-1f */
+	u8 pad8[3];
+} kw_uart_port;

NAK.

We will definiteli not accept yet another version of 16550 compatible UART register definitions. Please use the existing code (but wait until Detlev Zundel's cleanup patch from today has been applied).

...

Quoted 5 lines
cpu/arm926ejs/kirkwood/spi.c new file +0 -0
new file mode 100644
index 0000000..a334d95

...

cpu/arm926ejs/kirkwood/spi.c line 147

Quoted 8 lines
cpu/arm926ejs/kirkwood/spi.c new file +8 -0
+	/*
+	 * handle data in 8-bit chunks
+	 * TBD: 2byte xfer mode to be enabled
+	 */
+	while (bitlen > 4) {
+		debug_print("loopstart bitlen %d\n", bitlen);
+		tmpdout = 0;
+		if (1) {	//bitlen <= 8) {

No C++ comments, please (fix globally).

Quoted 5 lines
cpu/arm926ejs/kirkwood/timer.c new file +0 -0
new file mode 100644
index 0000000..4ab1a54

...

cpu/arm926ejs/kirkwood/timer.c line 98

Quoted 11 lines
cpu/arm926ejs/kirkwood/timer.c new file +11 -0
+ulong get_timer_masked(void)
+{
+	ulong now = READ_TIMER;
+
+	if (lastdec >= now) {
+		/* normal mode */
+		timestamp += lastdec - now;
+	} else {
+		/* we have an overflow ... */
+		timestamp +=
+		    lastdec + (TIMER_LOAD_VAL / (CONFIG_SYS_TCLK / 1000)) - now;

Indentation not by TAB. Please check and fix globally.

include/configs/kirkwood.h line 6

Quoted 12 lines
include/configs/kirkwood.h new file +6 -0
new file mode 100644
index 0000000..eec04c2
@@ -0,0 +1,46 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for the Marvell's Feroceon CPU core.

NAK.

The include/configs/ directory is for board configuration files only.

CPU specific code has no place there.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"In Christianity neither morality nor religion come into contact with
reality at any point."                          - Friedrich Nietzsche
#40 lore raw

PATCH 1/1 Marvell Kirkwood family SOC support

In reply to Prafulla Wadaskar

Hi,

I'll provide you two seperate comment one for the file location and global comment and an other for code review

Quoted 17 lines · Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0

Other supported features:-
1) Doimage utility needed to create binaries with
bootROM header
2) get_random_hex() fucntion
3) SPI port controller driver
4) PCI Express port initialization

Quoted 8 lines

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Reviewed by: Ronen Shitrit <[email protected]>

---
 board/Marvell/common/kw_lowlevel_init.S        |   45 +

is this init are Marvell common or Kirkwood common?

Quoted 3 lines
 board/Marvell/include/core.h                   |    4 +
 cpu/arm926ejs/kirkwood/Makefile                |   52 +
 cpu/arm926ejs/kirkwood/bin_dep.sh              |   50 +

what it this file?

Quoted 2 lines
 cpu/arm926ejs/kirkwood/config.mk               |   25 +
 cpu/arm926ejs/kirkwood/doimage/Makefile        |  112 ++

tools must go to tools/

Quoted 2 lines
 cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h |   88 ++
 cpu/arm926ejs/kirkwood/doimage/doimage         |  Bin 0 -> 17712 bytes

please remove and a .gitignore entry for it

Quoted 3 lines
 cpu/arm926ejs/kirkwood/doimage/doimage.c       | 1341 ++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/dram.c                  |   49 +
 cpu/arm926ejs/kirkwood/kw88f6192.h             |   34 +

please move define to include/asm-arm/arch-<somthing> the same as linux

Quoted 4 lines
 cpu/arm926ejs/kirkwood/kw88f6281.h             |   34 +
 cpu/arm926ejs/kirkwood/kwcore.c                |  262 +++++
 cpu/arm926ejs/kirkwood/kwcore.h                |  141 +++
 cpu/arm926ejs/kirkwood/serial.c                |  187 ++++

please move to drivers/serial/

Quoted 1 line
 cpu/arm926ejs/kirkwood/soc_init.S              |  156 +++

please call it lowlevel_init.S

Quoted 1 line
 cpu/arm926ejs/kirkwood/spi.c                   |  213 ++++

please move to drivers/spi/

Quoted 2 lines
 cpu/arm926ejs/kirkwood/timer.c                 |  165 +++
 include/configs/kirkwood.h                     |   46 +

include/configs/ are only for boards config

Best Regards,
J.

#41 lore raw

PATCH 1/1 Marvell Kirkwood family SOC support

Quoted 36 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Saturday, April 04, 2009 9:55 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ronen Shitrit; Nicolas Pitre
Subject: Re: [U-Boot] [PATCH] Marvell Kirkwood family SOC support

Hi,

I'll provide you two seperate comment one for the file location and global comment and an other for code review

Quoted 21 lines · Prafulla Wadaskar

From: prafulla_wadaskar <[email protected]>

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0

Other supported features:-
1) Doimage utility needed to create binaries with
bootROM header
2) get_random_hex() fucntion
3) SPI port controller driver
4) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

Quoted 6 lines
Quoted 1 line

Reviewed by:

Quoted 3 lines

Ronen Shitrit <[email protected]>

---
 board/Marvell/common/kw_lowlevel_init.S        |   45 +

is this init are Marvell common or Kirkwood common?

This is Marvell common, this is board specific but since it is used for each supported board I have moved it to common folder.

Quoted 4 lines
Quoted 3 lines
 board/Marvell/include/core.h                   |    4 +
 cpu/arm926ejs/kirkwood/Makefile                |   52 +
 cpu/arm926ejs/kirkwood/bin_dep.sh              |   50 +

what it this file?

This was supported file to build doImage form tools context Removed..

Quoted 3 lines
Quoted 2 lines
 cpu/arm926ejs/kirkwood/config.mk               |   25 +
 cpu/arm926ejs/kirkwood/doimage/Makefile        |  112 ++

tools must go to tools/

Removed..

Quoted 4 lines
Quoted 2 lines
 cpu/arm926ejs/kirkwood/doimage/bootstrap_def.h |   88 ++
 cpu/arm926ejs/kirkwood/doimage/doimage         |  Bin 0 -> 

17712 bytes
please remove and a .gitignore entry for it

Removed..

Quoted 6 lines
Quoted 1 line
 cpu/arm926ejs/kirkwood/doimage/doimage.c       | 1341 

++++++++++++++++++++++++

Quoted 2 lines
 cpu/arm926ejs/kirkwood/dram.c                  |   49 +
 cpu/arm926ejs/kirkwood/kw88f6192.h             |   34 +

please move define to include/asm-arm/arch-<somthing> the same as linux

Moved...

Quoted 5 lines
Quoted 4 lines
 cpu/arm926ejs/kirkwood/kw88f6281.h             |   34 +
 cpu/arm926ejs/kirkwood/kwcore.c                |  262 +++++
 cpu/arm926ejs/kirkwood/kwcore.h                |  141 +++
 cpu/arm926ejs/kirkwood/serial.c                |  187 ++++

please move to drivers/serial/

Moved...

Quoted 2 lines
Quoted 1 line
 cpu/arm926ejs/kirkwood/soc_init.S              |  156 +++

please call it lowlevel_init.S

Renamed..

Quoted 2 lines
Quoted 1 line
 cpu/arm926ejs/kirkwood/spi.c                   |  213 ++++

please move to drivers/spi/

Moved...

Quoted 3 lines
Quoted 2 lines
 cpu/arm926ejs/kirkwood/timer.c                 |  165 +++
 include/configs/kirkwood.h                     |   46 +

include/configs/ are only for boards config

Moved this file to asm-arm/arch-kirkwood/

I am in process accumulating and testing changes
I will send you updated patch (v2) for the same

Thanks....

Regards..
Prafulla . .

Quoted 4 lines

Best Regards,
J.

#42 lore raw

PATCH v2 1/1 Marvell Kirkwood family SOC support

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0

Other supported features:-
1) get_random_hex() fucntion
2) SPI port controller driver
3) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

---
Changelog:
v2: crated arch-kirkwood and moved some header files there renamed and moved spi.c to drivers/spi/
renamed and moved serial.c to drivers/serial/ doimage utility removed
soc_init.S renamed as lowlevel_init.S
debug prints removed

 board/Marvell/include/core.h              |    4 +
 cpu/arm926ejs/kirkwood/Makefile           |   50 ++++++
 cpu/arm926ejs/kirkwood/config.mk          |   25 +++
 cpu/arm926ejs/kirkwood/dram.c             |   55 +++++++
 cpu/arm926ejs/kirkwood/kwcore.c           |  250 +++++++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/kwcore.h           |   47 ++++++
 cpu/arm926ejs/kirkwood/lowlevel_init.S    |  183 +++++++++++++++++++++
 cpu/arm926ejs/kirkwood/timer.c            |  165 +++++++++++++++++++
 drivers/serial/Makefile                   |    1 +
 drivers/serial/kirkwood_serial.c          |  187 +++++++++++++++++++++
 drivers/spi/Makefile                      |    1 +
 drivers/spi/kirkwood_spi.c                |  199 +++++++++++++++++++++++
 include/asm-arm/arch-kirkwood/kirkwood.h  |  142 ++++++++++++++++
 include/asm-arm/arch-kirkwood/kw88f6192.h |   37 +++++
 include/asm-arm/arch-kirkwood/kw88f6281.h |   43 +++++
 include/asm-arm/config.h                  |    4 +
 16 files changed, 1393 insertions(+), 0 deletions(-)
 create mode 100644 cpu/arm926ejs/kirkwood/Makefile
 create mode 100644 cpu/arm926ejs/kirkwood/config.mk
 create mode 100644 cpu/arm926ejs/kirkwood/dram.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.h
 create mode 100644 cpu/arm926ejs/kirkwood/lowlevel_init.S
 create mode 100644 cpu/arm926ejs/kirkwood/timer.c
 create mode 100644 drivers/serial/kirkwood_serial.c
 create mode 100644 drivers/spi/kirkwood_spi.c
 create mode 100644 include/asm-arm/arch-kirkwood/kirkwood.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6192.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6281.h
board/Marvell/include/core.h +4 -0
index c413439..ecc4682 100644
@@ -12,9 +12,11 @@ space). The macros take care of Big/Little endian conversions.
 #ifndef __INCcoreh
 #define __INCcoreh
 
+#ifndef CONFIG_KIRKWOOD
 #include "mv_gen_reg.h"
 
 extern unsigned int INTERNAL_REG_BASE_ADDR;
+#endif /* CONFIG_KIRKWOOD */
 
 /****************************************/
 /*	    GENERAL Definitions			*/
@@ -91,10 +93,12 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;
 #define _1G		0x40000000
 #define _2G		0x80000000
 
+#ifndef __ASSEMBLY__
 #ifndef	BOOL_WAS_DEFINED
 #define BOOL_WAS_DEFINED
 typedef enum _bool{false,true} bool;
 #endif
+#endif
 
 /* Little to Big endian conversion macros */
 
cpu/arm926ejs/kirkwood/Makefile new file +50 -0

50 lines not on this page · raw message

cpu/arm926ejs/kirkwood/config.mk new file +25 -0
new file mode 100644
index 0000000..000eeb4
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+PLATFORM_CPPFLAGS += -march=armv5te
cpu/arm926ejs/kirkwood/dram.c new file +55 -0

55 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.c new file +250 -0

250 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.h new file +47 -0

47 lines not on this page · raw message

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +183 -0

183 lines not on this page · raw message

cpu/arm926ejs/kirkwood/timer.c new file +165 -0

165 lines not on this page · raw message

drivers/serial/Makefile +1 -0
index bb99a34..dd59ff8 100644
@@ -28,6 +28,7 @@ LIB	:= $(obj)libserial.a
 COBJS-$(CONFIG_ARM_DCC) += arm_dcc.o
 COBJS-$(CONFIG_AT91RM9200_USART) += at91rm9200_usart.o
 COBJS-$(CONFIG_ATMEL_USART) += atmel_usart.o
+COBJS-$(CONFIG_KIRKWOOD) += kirkwood_serial.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_NS9750_UART) += ns9750_serial.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
drivers/serial/kirkwood_serial.c new file +187 -0

187 lines not on this page · raw message

drivers/spi/Makefile +1 -0
index 1350f3e..7ffa47d 100644
@@ -28,6 +28,7 @@ LIB	:= $(obj)libspi.a
 COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
 COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
+COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
 COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/kirkwood_spi.c new file +199 -0

199 lines not on this page · raw message

include/asm-arm/arch-kirkwood/kirkwood.h new file +142 -0

142 lines not on this page · raw message

include/asm-arm/arch-kirkwood/kw88f6192.h new file +37 -0
new file mode 100644
index 0000000..000fc16
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6192 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_KW88F6192_H
+#define _CONFIG_KW88F6192_H
+
+/* SOC specific definations */
+#define KW88F6192_REGS_PHYS_BASE	0xf1000000
+#define KW_REGS_PHY_BASE		KW88F6192_REGS_PHYS_BASE
+
+/* TCLK Core Clock defination */
+#define CONFIG_SYS_TCLK         166000000 /* 166MHz */
+
+#endif /* _CONFIG_KW88F6192_H */
include/asm-arm/arch-kirkwood/kw88f6281.h new file +43 -0

43 lines not on this page · raw message

include/asm-arm/config.h +4 -0
index 049c44e..5d52f15 100644
@@ -21,4 +21,8 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#if defined (CONFIG_KIRKWOOD)
+#include <asm-arm/arch-kirkwood/kirkwood.h>
+#endif /* CONFIG_KIRKWOOD */
+
 #endif
Signature · 1 line
1.5.3.3
#43 lore raw

PATCH v2 1/1 Marvell Kirkwood family SOC support

Hi all,

Any comments welcomed...
Or Shall I consider this patch is accepted ;-)
.....Shall I send it again ?

Regards..
Prafulla . .

Quoted 1,692 lines

-----Original Message-----
From: Prafulla Wadaskar [mailto:prafulla at marvell.com]
Sent: Wednesday, April 08, 2009 5:33 PM
To: u-boot at lists.denx.de
Cc: Ronen Shitrit; Ashish Karkare; Prafulla Wadaskar
Subject: [PATCH v2] Marvell Kirkwood family SOC support

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0

Other supported features:-
1) get_random_hex() fucntion
2) SPI port controller driver
3) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

---
Changelog:
v2: crated arch-kirkwood and moved some header files there renamed and moved spi.c to drivers/spi/
renamed and moved serial.c to drivers/serial/ doimage utility removed
soc_init.S renamed as lowlevel_init.S
debug prints removed

 board/Marvell/include/core.h              |    4 +
 cpu/arm926ejs/kirkwood/Makefile           |   50 ++++++
 cpu/arm926ejs/kirkwood/config.mk          |   25 +++
 cpu/arm926ejs/kirkwood/dram.c             |   55 +++++++
 cpu/arm926ejs/kirkwood/kwcore.c           |  250
+++++++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/kwcore.h           |   47 ++++++
 cpu/arm926ejs/kirkwood/lowlevel_init.S    |  183
+++++++++++++++++++++
 cpu/arm926ejs/kirkwood/timer.c            |  165 +++++++++++++++++++
 drivers/serial/Makefile                   |    1 +
 drivers/serial/kirkwood_serial.c          |  187
+++++++++++++++++++++
 drivers/spi/Makefile                      |    1 +
 drivers/spi/kirkwood_spi.c                |  199
+++++++++++++++++++++++
 include/asm-arm/arch-kirkwood/kirkwood.h  |  142 ++++++++++++++++
 include/asm-arm/arch-kirkwood/kw88f6192.h |   37 +++++
 include/asm-arm/arch-kirkwood/kw88f6281.h |   43 +++++
 include/asm-arm/config.h                  |    4 +
 16 files changed, 1393 insertions(+), 0 deletions(-)
 create mode 100644 cpu/arm926ejs/kirkwood/Makefile
 create mode 100644 cpu/arm926ejs/kirkwood/config.mk
 create mode 100644 cpu/arm926ejs/kirkwood/dram.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.h
 create mode 100644 cpu/arm926ejs/kirkwood/lowlevel_init.S
 create mode 100644 cpu/arm926ejs/kirkwood/timer.c
 create mode 100644 drivers/serial/kirkwood_serial.c
 create mode 100644 drivers/spi/kirkwood_spi.c
 create mode 100644 include/asm-arm/arch-kirkwood/kirkwood.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6192.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6281.h
board/Marvell/include/core.h +0 -0
index c413439..ecc4682 100644
@@ -12,9 +12,11 @@ space). The macros take care of Big/Little

endian conversions.
#ifndef __INCcoreh
#define __INCcoreh

board/Marvell/include/core.h +4 -0
+#ifndef CONFIG_KIRKWOOD
 #include "mv_gen_reg.h"
 
 extern unsigned int INTERNAL_REG_BASE_ADDR;
+#endif /* CONFIG_KIRKWOOD */
 
 /****************************************/
 /*       GENERAL Definitions                 */
@@ -91,10 +93,12 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;
 #define _1G          0x40000000
 #define _2G          0x80000000
 
+#ifndef __ASSEMBLY__
 #ifndef      BOOL_WAS_DEFINED
 #define BOOL_WAS_DEFINED
 typedef enum _bool{false,true} bool;
 #endif
+#endif
 
 /* Little to Big endian conversion macros */
 
cpu/arm926ejs/kirkwood/Makefile new file +43 -0
new file mode 100644
index 0000000..c917f0d
@@ -0,0 +1,50 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB  = $(obj)lib$(SOC).a
+
+COBJS-y      = dram.o
+COBJS-y      += kwcore.o
+COBJS-y      += timer.o
+
+SOBJS        = lowlevel_init.o
+
+SRCS    := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS    := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
+
+all: $(obj).depend $(LIB)
+
+$(LIB):      $(OBJS)
+     $(AR) $(ARFLAGS) $@ $(OBJS)
+
+#############################################################

############

cpu/arm926ejs/kirkwood/Makefile new file +7 -0
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#############################################################

############

cpu/arm926ejs/kirkwood/config.mk new file +25 -0
new file mode 100644
index 0000000..000eeb4
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+PLATFORM_CPPFLAGS += -march=armv5te
cpu/arm926ejs/kirkwood/dram.c new file +55 -0
new file mode 100644
index 0000000..80e2b13
@@ -0,0 +1,55 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+/*
+ * kw_sdram_bar - reads SDRAM Base Address Register
+ */
+u32 kw_sdram_bar(MEMORY_BANK bank)
+{
+     u32 result = 0;
+     u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));
+
+     if ((!enable) || (bank > BANK3))
+             return 0;
+
+     result = KW_REG_READ((0x1500 + bank * 8));
+     return result;
+}
+
+/*
+ * kw_sdram_bs - reads SDRAM Bank size
+ */
+u32 kw_sdram_bs(MEMORY_BANK bank)
+{
+     u32 result = 0;
+     u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));
+
+     if ((!enable) || (bank > BANK3))
+             return 0;
+     result = (0xff000000 & KW_REG_READ((0x1504 + bank * 8)));
+     result += 0x01000000;
+     return result;
+}
cpu/arm926ejs/kirkwood/kwcore.c new file +36 -0
new file mode 100644
index 0000000..2e887d5
@@ -0,0 +1,250 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+#include <u-boot/md5.h>
+
+void reset_cpu(unsigned long ignored)
+{
+     KW_REG_BITS_SET(KW_REG_CPU_RSTOUTN_MASK, BIT2);
+     KW_REG_BITS_SET(KW_REG_CPU_SYS_SOFT_RST, BIT0);
+     while (1) ;
+}
+
+/*
+ * Generates Ramdom hex number reading some time varient

system registers
+ * and using md5 algorithm
+ */

cpu/arm926ejs/kirkwood/kwcore.c new file +76 -0
+unsigned char get_random_hex(void)
+{
+     int i;
+     u32 inbuf[16];
+     u8 outbuf[16];
+
+#if defined (CONFIG_KW88F6281_Z0)
+     KW_REG_BITS_SET(0x1478, BIT7);
+#elif defined (CONFIG_KW88F6281_A0) || defined (CONFIG_KW88F6192_A0)
+     /*
+      * in case of 88F6281/88F6192 A0,
+      * BIT7 need to reset to generate random values in 0x1470
+      */
+     KW_REG_BITS_RESET(0x1478, BIT7);
+#else
+#error Undefined SOC Revision
+#endif
+     for (i = 0; i < 16; i++) {
+             inbuf[i] = KW_REG_READ(0x1470);
+     }
+     md5((u8 *) inbuf, 64, outbuf);
+     return outbuf[outbuf[7] % 0x0f];
+}
+
+/*
+ * kw_window_ctrl_reg_init - Mbus-L to Mbus Bridge Registers init.
+ */
+int kw_window_ctrl_reg_init(void)
+{
+     KW_REG_WRITE(KW_REG_WIN_CTRL(0), 0x0fffe841);
+     KW_REG_WRITE(KW_REG_WIN_BASE(0), 0x90000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(0), 0x90000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(0), 0x00000000);
+
+     KW_REG_WRITE(KW_REG_WIN_CTRL(1), 0x007f2f11);
+     KW_REG_WRITE(KW_REG_WIN_BASE(1), 0xF9000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(1), 0xF9000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(1), 0x00000000);
+
+     KW_REG_WRITE(KW_REG_WIN_CTRL(2), 0x00ffe041);
+     KW_REG_WRITE(KW_REG_WIN_BASE(2), 0xF0000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(2), 0xC0000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(2), 0x00000000);
+
+     KW_REG_WRITE(KW_REG_WIN_CTRL(3), 0x00ff1e11);
+     KW_REG_WRITE(KW_REG_WIN_BASE(3), 0xF8000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(3), 0x00000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(3), 0x00000000);
+
+     KW_REG_WRITE(KW_REG_WIN_CTRL(4), 0x00ff1d11);
+     KW_REG_WRITE(KW_REG_WIN_BASE(4), 0xFF000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(4), 0x00000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(4), 0x00000000);
+
+     KW_REG_WRITE(KW_REG_WIN_CTRL(5), 0x07ff1e10);
+     KW_REG_WRITE(KW_REG_WIN_BASE(5), 0xE8000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(5), 0x00000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(5), 0x00000000);
+
+     KW_REG_WRITE(KW_REG_WIN_CTRL(6), 0x07ff1d10);
+     KW_REG_WRITE(KW_REG_WIN_BASE(6), 0xF0000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(6), 0x00000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(6), 0x00000000);
+
+     KW_REG_WRITE(KW_REG_WIN_CTRL(7), 0x00000131);
+     KW_REG_WRITE(KW_REG_WIN_BASE(7), 0xFB000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(7), 0x00000000);
+     KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(7), 0x00000000);
+
+     return KW_OK;
+}
+
+/*
+ * kw_gpio_init - Init gpios for default values
+ */
+void kw_gpio_init(u32 gpp0_oe_val, u32 gpp1_oe_val, u32

gpp0_oe, u32 gpp1_oe)

cpu/arm926ejs/kirkwood/kwcore.c new file +10 -0
+{
+     /* Init GPIOS to default values as per board requirement */
+     KW_REG_WRITE(KW_REG_GPP0_DATA_OUT, gpp0_oe_val);
+     KW_REG_WRITE(KW_REG_GPP1_DATA_OUT, gpp1_oe_val);
+     KW_REG_WRITE(KW_REG_GPP0_DATA_OUT_EN, gpp0_oe);
+     KW_REG_WRITE(KW_REG_GPP1_DATA_OUT_EN, gpp1_oe);
+}
+
+/*
+ * kw_mpp_control_init - initialize mpp for board specific

functionality
+ */
+int kw_mpp_control_init(u32 mpp0_7, u32 mpp8_15, u32 mpp16_23, u32 mpp24_31,

cpu/arm926ejs/kirkwood/kwcore.c new file +15 -0
+                     u32 mpp32_39, u32 mpp40_47, u32 mpp48_55)
+{
+     /* program mpp registers */
+     KW_REG_WRITE(KW_REG_MPP_CONTROL0, mpp0_7);
+     KW_REG_WRITE(KW_REG_MPP_CONTROL1, mpp8_15);
+     KW_REG_WRITE(KW_REG_MPP_CONTROL2, mpp16_23);
+     KW_REG_WRITE(KW_REG_MPP_CONTROL3, mpp24_31);
+     KW_REG_WRITE(KW_REG_MPP_CONTROL4, mpp32_39);
+     KW_REG_WRITE(KW_REG_MPP_CONTROL5, mpp40_47);
+     KW_REG_WRITE(KW_REG_MPP_CONTROL6, mpp48_55);
+     return KW_OK;
+}
+
+/*
+ * kw_misc_init_r - SOC specific misc init (mainly cache

initialization)
+ */

cpu/arm926ejs/kirkwood/kwcore.c new file +8 -0
+int kw_misc_init_r(void)
+{
+     char *env;
+     volatile unsigned int temp;
+
+     /*CPU streaming & write allocate */
+     env = getenv("enaWrAllo");
+     if (env && ((strcmp(env, "yes") == 0) || (strcmp(env,

"Yes") == 0))) {
+ __asm__ __volatile__("mrc p15, 1, %0, c15, c1,
0":"=r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -0
+             temp |= BIT28;
+             __asm__ __volatile__("mcr p15, 1, %0, c15, c1,

0"::"r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +3 -0
+
+     } else {
+             __asm__ __volatile__("mrc p15, 1, %0, c15, c1,

0":"=r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -0
+             temp &= ~BIT28;
+             __asm__ __volatile__("mcr p15, 1, %0, c15, c1,

0"::"r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +4 -0
+     }
+
+     env = getenv("enaCpuStream");
+     if (!env || (strcmp(env, "no") == 0) || (strcmp(env,

"No") == 0)) {
+ __asm__ __volatile__("mrc p15, 1, %0, c15, c1,
0":"=r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -0
+             temp &= ~BIT29;
+             __asm__ __volatile__("mcr p15, 1, %0, c15, c1,

0"::"r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -0
+     } else {
+             __asm__ __volatile__("mrc p15, 1, %0, c15, c1,

0":"=r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -0
+             temp |= BIT29;
+             __asm__ __volatile__("mcr p15, 1, %0, c15, c1,

0"::"r"(temp));

cpu/arm926ejs/kirkwood/kwcore.c new file +17 -0
+     }
+
+     /* Verify write allocate and streaming */
+     printf("\n");
+     __asm__ __volatile__("mrc p15, 1, %0, c15, c1, 0":"=r"(temp));
+     if (temp & BIT29)
+             printf("Streaming enabled\n");
+     else
+             printf("Streaming disabled\n");
+     if (temp & BIT28)
+             printf("Write allocate enabled\n");
+     else
+             printf("Write allocate disabled\n");
+
+     /* DCache Pref  */
+     env = getenv("enaDCPref");
+     if (env && ((strcmp(env, "yes") == 0) || (strcmp(env,

"Yes") == 0))) {

cpu/arm926ejs/kirkwood/kwcore.c new file +6 -0
+             temp = KW_REG_READ(KW_REG_CPU_CONFIG);
+             temp |= BIT17; /* Set CCR_DCACH_PREF_BUF_ENABLE */
+             KW_REG_WRITE(KW_REG_CPU_CONFIG, temp);
+     }
+
+     if (env && ((strcmp(env, "no") == 0) || (strcmp(env,

"No") == 0))) {

cpu/arm926ejs/kirkwood/kwcore.c new file +8 -0
+             temp = KW_REG_READ(KW_REG_CPU_CONFIG);
+             temp &= ~BIT17; /* Reset CCR_DCACH_PREF_BUF_ENABLE */
+             KW_REG_WRITE(KW_REG_CPU_CONFIG, temp);
+     }
+
+     /* ICache Pref  */
+     env = getenv("enaICPref");
+     if (env && ((strcmp(env, "yes") == 0) || (strcmp(env,

"Yes") == 0))) {

cpu/arm926ejs/kirkwood/kwcore.c new file +6 -0
+             temp = KW_REG_READ(KW_REG_CPU_CONFIG);
+             temp |= BIT16; /* Set CCR_ICACH_PREF_BUF_ENABLE */
+             KW_REG_WRITE(KW_REG_CPU_CONFIG, temp);
+     }
+
+     if (env && ((strcmp(env, "no") == 0) || (strcmp(env,

"No") == 0))) {

cpu/arm926ejs/kirkwood/kwcore.c new file +8 -0
+             temp = KW_REG_READ(KW_REG_CPU_CONFIG);
+             temp &= ~BIT16; /* Reset CCR_ICACH_PREF_BUF_ENABLE */
+             KW_REG_WRITE(KW_REG_CPU_CONFIG, temp);
+     }
+     /* Set L2C WT mode - Set bit 4 */
+     temp = KW_REG_READ(KW_REG_CPU_L2_CONFIG);
+     env = getenv("setL2CacheWT");
+     if (!env || ((strcmp(env, "yes") == 0) || (strcmp(env,

"Yes") == 0))) {

cpu/arm926ejs/kirkwood/kwcore.c new file +11 -0
+             temp |= BIT4;
+     } else
+             temp &= ~BIT4;
+     KW_REG_WRITE(KW_REG_CPU_L2_CONFIG, temp);
+
+     /* L2Cache settings */
+     asm("mrc p15, 1, %0, c15, c1, 0":"=r"(temp));
+
+     /* Disable L2C pre fetch - Set bit 24 */
+     env = getenv("disL2Prefetch");
+     if (env && ((strcmp(env, "no") == 0) || (strcmp(env,

"No") == 0)))

cpu/arm926ejs/kirkwood/kwcore.c new file +7 -0
+             temp &= ~BIT24;
+     else
+             temp |= BIT24;
+
+     /* enable L2C - Set bit 22 */
+     env = getenv("disL2Cache");
+     if (!env || ((strcmp(env, "no") == 0) || (strcmp(env,

"No") == 0)))

cpu/arm926ejs/kirkwood/kwcore.c new file +18 -0
+             temp |= BIT22;
+     else
+             temp &= ~BIT22;
+
+     asm("mcr p15, 1, %0, c15, c1, 0": :"r"(temp));
+
+     /* Enable i cache */
+     asm("mrc p15, 0, %0, c1, c0, 0":"=r"(temp));
+     temp |= BIT12;
+     asm("mcr p15, 0, %0, c1, c0, 0": :"r"(temp));
+     /* Change reset vector to address 0x0 */
+     asm("mrc p15, 0, %0, c1, c0, 0":"=r"(temp));
+     temp &= ~BIT13;
+     asm("mcr p15, 0, %0, c1, c0, 0": :"r"(temp));
+
+     return (0);
+}
+
cpu/arm926ejs/kirkwood/kwcore.h new file +47 -0
new file mode 100644
index 0000000..8d2a8cc
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _KWCORE_H
+#define _KWCORE_H
+
+/*
+ * functions
+ */
+#ifndef __ASSEMBLY__
+void reset_cpu(unsigned long ignored);
+unsigned char get_random_hex(void);
+typedef enum _memory_bank { BANK0, BANK1, BANK2, BANK3 } MEMORY_BANK;
+unsigned int kw_sdram_bar(MEMORY_BANK bank);
+unsigned int kw_sdram_bs(MEMORY_BANK bank);
+int kw_window_ctrl_reg_init(void);
+void kw_gpio_init(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
+               unsigned int gpp0_oe, unsigned int gpp1_oe);
+int kw_mpp_control_init(unsigned int mpp0_7, unsigned int mpp8_15,
+                     unsigned int mpp16_23, unsigned int mpp24_31,
+                     unsigned int mpp32_39, unsigned int mpp40_47,
+                     unsigned int mpp48_55);
+int kw_misc_init_r(void);
+#endif                               /* __ASSEMBLY__ */
+
+#endif                               /* _KWCORE_H */
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +28 -0
new file mode 100644
index 0000000..169e58b
@@ -0,0 +1,183 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#define CCR_CPU_2_MBUSL_TICK_DRV_OFFS                8
+#define CCR_CPU_2_MBUSL_TICK_DRV_MASK                (0xF <<

CCR_CPU_2_MBUSL_TICK_DRV_OFFS)

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +2 -0
+#define CCR_CPU_2_MBUSL_TICK_SMPL_OFFS               12
+#define CCR_CPU_2_MBUSL_TICK_SMPL_MASK               (0xF <<

CCR_CPU_2_MBUSL_TICK_SMPL_OFFS)

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +3 -0
+
+#define MSAR_DDRCLCK_RTIO_OFFS                       5
+#define MSAR_DDRCLCK_RTIO_MASK                       (0xF <<

MSAR_DDRCLCK_RTIO_OFFS)

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +7 -0
+
+/* Ratio options for CPU to DDR for 6281/6192/6180 */
+#define CPU_2_DDR_CLK_1x2                    2
+#define CPU_2_DDR_CLK_1x3                    4
+#define CPU_2_DDR_CLK_1x4                    6
+
+/* Default values for CPU to Mbus-L DDR Interface Tick

Driver and */

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +12 -0
+/* CPU to Mbus-L Tick Sample fields in CPU config register
      */
+
+#define TICK_DRV_1x1                         0
+#define TICK_DRV_1x2                         0
+#define TICK_DRV_1x3                         1
+#define TICK_DRV_1x4                         2
+#define TICK_SMPL_1x1                                0
+#define TICK_SMPL_1x2                                1
+#define TICK_SMPL_1x3                                2
+#define TICK_SMPL_1x4                                3
+#define CPU_2_MBUSL_DDR_CLK_1x2
              \
+              ((TICK_DRV_1x2  <<

CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +3 -0
+               (TICK_SMPL_1x2 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+#define CPU_2_MBUSL_DDR_CLK_1x3
              \
+              ((TICK_DRV_1x3  <<

CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +3 -0
+               (TICK_SMPL_1x3 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+#define CPU_2_MBUSL_DDR_CLK_1x4
              \
+              ((TICK_DRV_1x4  <<

CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +22 -0
+               (TICK_SMPL_1x4 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+
+
+     .globl kw_cpu_if_pre_init
+kw_cpu_if_pre_init:
+
+        mov     r11, LR              /* Save link register */
+
+        /*
+      * Configures the I/O voltage of the pads connected to Egigabit
+      * Ethernet interface to 1.8V
+      * By defult it is set to 3.3V
+      */
+#ifdef CONFIG_KIRKWOOD_RGMII_PAD_1V8
+        KW_REG_READ_ASM (r7, r5, KW_REG_MPP_OUT_DRV_REG)
+        ldr    r5, =BIT7
+        orr    r7, r7, r5       /* Set RGMII PADS Voltage to 1.8V */
+        KW_REG_WRITE_ASM (r7, r5, KW_REG_MPP_OUT_DRV_REG)
+#endif
+        /*
+      * Set egiga port0/1 in normal functional mode
+      * This is required becasue on kirkwood by default

ports are in reset mode
+ * OS egiga driver may not have provision to set them
in normal mode
+ * and if u-boot is build without network support,
network may fail at OS level

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +48 -0
+      */
+#ifdef CONFIG_KIRKWOOD_EGIGA_INIT
+        KW_REG_READ_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(0))
+        ldr    r5, =~(BIT4)
+        and    r7, r7, r5       /* Clear PortReset Bit */
+        KW_REG_WRITE_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(0))
+
+        KW_REG_READ_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(1))
+        ldr    r5, =~(BIT4)
+        and    r7, r7, r5       /* Clear PortReset Bit */
+        KW_REG_WRITE_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(1))
+#endif
+
+     /*
+      * Enable PCI Express Port0
+      */
+#ifdef CONFIG_KIRKWOOD_PCIE_INIT
+        KW_REG_READ_ASM (r7, r5, KW_REG_CPU_CTRL_STAT)
+        ldr    r5, =BIT0
+        orr    r7, r7, r5       /* Set PEX0En Bit */
+        KW_REG_WRITE_ASM (r7, r5, KW_REG_CPU_CTRL_STAT)
+#endif
+
+#ifdef CONFIG_KW88F6281_Z0
+        /* Get the "sample on reset" register */
+     KW_REG_READ_ASM (r4, r5, KW_REG_MPP_SMPL_AT_RST)
+        ldr    r5, =MSAR_DDRCLCK_RTIO_MASK
+        and    r5, r4, r5
+     mov    r5, r5, lsr #MSAR_DDRCLCK_RTIO_OFFS
+
+        ldr    r4, =CPU_2_MBUSL_DDR_CLK_1x2
+        cmp    r5, #CPU_2_DDR_CLK_1x2
+        beq    set_config_reg
+
+        ldr    r4, =CPU_2_MBUSL_DDR_CLK_1x3
+        cmp    r5, #CPU_2_DDR_CLK_1x3
+        beq    set_config_reg
+
+        ldr    r4, =CPU_2_MBUSL_DDR_CLK_1x4
+        cmp    r5, #CPU_2_DDR_CLK_1x4
+        beq    set_config_reg
+
+        ldr    r4, =0
+
+set_config_reg:
+        /* Read CPU Config register */
+        KW_REG_READ_ASM (r7, r5, KW_REG_CPU_CONFIG)
+        ldr    r5, =~(CCR_CPU_2_MBUSL_TICK_DRV_MASK |

CCR_CPU_2_MBUSL_TICK_SMPL_MASK)

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +2 -0
+        and    r7, r7, r5       /* Clear register fields */
+        orr    r7, r7, r4       /* Set the values according

to the findings */

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +26 -0
+        KW_REG_WRITE_ASM (r7, r5, KW_REG_CPU_CONFIG)
+
+done:
+#endif
+        mov     PC, r11         /* r11 is saved link register */
+
+     .globl kw_enable_invalidate_l2_cache
+kw_enable_invalidate_l2_cache:
+        mov     r11, LR      /* Save link register */
+
+     /* Enable L2 cache in write through mode */
+     KW_REG_READ_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)
+     orr     r4, r4, #0x18
+     KW_REG_WRITE_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)
+     /* Read operation to make sure the L2 bit is set */
+     KW_REG_READ_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)
+
+     /* invalidate L2 cache */
+     mov     r0, #0
+     mcr     p15, 1, r0, c15, c11, 0
+
+        mov     PC, r11         /* r11 is saved link register */
+
+        .globl lowlevel_init
+lowlevel_init:
+        /* Linux expects` the internal registers to be at

0xf1000000 */

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +25 -0
+        ldr r1, = KW_OFFSET_REG
+        ldr r3, = KW_REGS_PHY_BASE
+        str r3,[r1]
+
+        /* save Link Registers */
+        mov r2, lr
+
+        /* Enable L2 cache in write through mode */
+        bl kw_enable_invalidate_l2_cache
+
+#ifdef CONFIG_BOARD_LOWLEVEL_INIT
+        /*
+      * if Kirkwood is configured not to use its internal bootROM
+      * This will be needed specially for DRAM configuration
+      */
+        bl board_lowlevel_init
+#endif
+
+        /*
+      * Initialize BUS-L to DDR configuration parameters
+      * Must be done prior to DDR operation
+      */
+        bl kw_cpu_if_pre_init
+        mov lr, r2
+        mov pc, lr
cpu/arm926ejs/kirkwood/timer.c new file +45 -0
new file mode 100644
index 0000000..4ab1a54
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+#define UBOOT_CNTR   0       /* counter to use for uboot timer */
+
+/*
+ * ARM Timers Registers Map
+ */
+#define CNTMR_CTRL_REG                       KW_REG_TMR_CTRL
+#define CNTMR_RELOAD_REG(tmrNum)     (KW_REG_TMR_RELOAD + tmrNum*8)
+#define CNTMR_VAL_REG(tmrNum)                (KW_REG_TMR_VAL
+ tmrNum*8)
+
+/*
+ * ARM Timers Control Register
+ * CPU_TIMERS_CTRL_REG (CTCR)
+ */
+#define TIMER0_NUM                           0
+#define TIMER1_NUM                           1
+#define WATCHDOG_NUM                         2
+
+#define CTCR_ARM_TIMER_EN_OFFS(cntr)         (cntr * 2)
+#define CTCR_ARM_TIMER_EN_MASK(cntr)         (1 <<

CTCR_ARM_TIMER_EN_OFFS)
+#define CTCR_ARM_TIMER_EN(cntr) (1 <<
CTCR_ARM_TIMER_EN_OFFS(cntr))
+#define CTCR_ARM_TIMER_DIS(cntr) (0 <<
CTCR_ARM_TIMER_EN_OFFS(cntr))

cpu/arm926ejs/kirkwood/timer.c new file +4 -0
+
+#define CTCR_ARM_TIMER_AUTO_OFFS(cntr)       ((cntr * 2) + 1)
+#define CTCR_ARM_TIMER_AUTO_MASK(cntr)       BIT1
+#define CTCR_ARM_TIMER_AUTO_EN(cntr) (1 <<

CTCR_ARM_TIMER_AUTO_OFFS(cntr))
+#define CTCR_ARM_TIMER_AUTO_DIS(cntr) (0 <<
CTCR_ARM_TIMER_AUTO_OFFS(cntr))

cpu/arm926ejs/kirkwood/timer.c new file +25 -0
+
+/*
+ * ARM Timer\Watchdog Reload Register
+ * CNTMR_RELOAD_REG (TRR)
+ */
+#define TRG_ARM_TIMER_REL_OFFS                       0
+#define TRG_ARM_TIMER_REL_MASK                       0xffffffff
+
+/*
+ * ARM Timer\Watchdog Register
+ * CNTMR_VAL_REG (TVRG)
+ */
+#define TVR_ARM_TIMER_OFFS                   0
+#define TVR_ARM_TIMER_MASK                   0xffffffff
+#define TVR_ARM_TIMER_MAX                    0xffffffff
+#define TIMER_LOAD_VAL                               0xffffffff
+
+/* This enumerator describe counters\watchdog numbers       */
+typedef enum _kwCntmrID {
+     TIMER0 = 0,
+     TIMER1,
+     WATCHDOG
+} KW_CNTMR_ID;
+
+#define READ_TIMER

(KW_REG_READ(CNTMR_VAL_REG(UBOOT_CNTR))/(CONFIG_SYS_TCLK/1000))

cpu/arm926ejs/kirkwood/timer.c new file +22 -0
+
+static ulong timestamp;
+static ulong lastdec;
+
+void reset_timer_masked(void)
+{
+     /* reset time */
+     lastdec = READ_TIMER;
+     timestamp = 0;
+}
+
+ulong get_timer_masked(void)
+{
+     ulong now = READ_TIMER;
+
+     if (lastdec >= now) {
+             /* normal mode */
+             timestamp += lastdec - now;
+     } else {
+             /* we have an overflow ... */
+             timestamp +=
+                 lastdec + (TIMER_LOAD_VAL /

(CONFIG_SYS_TCLK / 1000)) - now;

cpu/arm926ejs/kirkwood/timer.c new file +32 -0
+     }
+     lastdec = now;
+
+     return timestamp;
+}
+
+void reset_timer(void)
+{
+     reset_timer_masked();
+}
+
+ulong get_timer(ulong base)
+{
+     return get_timer_masked() - base;
+}
+
+void set_timer(ulong t)
+{
+     timestamp = t;
+}
+
+void udelay(unsigned long usec)
+{
+     uint current;
+     ulong delayticks;
+
+     current = KW_REG_READ(CNTMR_VAL_REG(UBOOT_CNTR));
+     delayticks = (usec * (CONFIG_SYS_TCLK / 1000000));
+
+     if (current < delayticks) {
+             delayticks -= current;
+             while (KW_REG_READ(CNTMR_VAL_REG(UBOOT_CNTR)) <

current) ;

cpu/arm926ejs/kirkwood/timer.c new file +26 -0
+             while ((TIMER_LOAD_VAL - delayticks) <
+                    KW_REG_READ(CNTMR_VAL_REG(UBOOT_CNTR))) ;
+     } else {
+             while (KW_REG_READ(CNTMR_VAL_REG(UBOOT_CNTR)) >
+                    (current - delayticks)) ;
+     }
+}
+
+/*
+ * init the counter
+ */
+int timer_init(void)
+{
+     unsigned int cntmrCtrl;
+
+     /* load value onto counter\timer */
+     KW_REG_WRITE(CNTMR_RELOAD_REG(UBOOT_CNTR), TIMER_LOAD_VAL);
+     KW_REG_WRITE(CNTMR_VAL_REG(UBOOT_CNTR), TIMER_LOAD_VAL);
+
+     /* set the counter to load in the first time */
+     KW_REG_WRITE(CNTMR_VAL_REG(UBOOT_CNTR), TIMER_LOAD_VAL);
+
+     /* set control for timer \ cunter and enable */
+     /* read control register */
+     cntmrCtrl = KW_REG_READ(CNTMR_CTRL_REG);
+     cntmrCtrl |= CTCR_ARM_TIMER_EN(UBOOT_CNTR);     /*

enable cnt\timer */
+ cntmrCtrl |= CTCR_ARM_TIMER_AUTO_EN(UBOOT_CNTR);
/* Auto mode */

cpu/arm926ejs/kirkwood/timer.c new file +8 -0
+
+     KW_REG_WRITE(CNTMR_CTRL_REG, cntmrCtrl);
+
+     /* init the timestamp and lastdec value */
+     reset_timer_masked();
+
+     return 0;
+}
drivers/serial/Makefile +1 -0
index bb99a34..dd59ff8 100644
@@ -28,6 +28,7 @@ LIB := $(obj)libserial.a
 COBJS-$(CONFIG_ARM_DCC) += arm_dcc.o
 COBJS-$(CONFIG_AT91RM9200_USART) += at91rm9200_usart.o
 COBJS-$(CONFIG_ATMEL_USART) += atmel_usart.o
+COBJS-$(CONFIG_KIRKWOOD) += kirkwood_serial.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_NS9750_UART) += ns9750_serial.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
drivers/serial/kirkwood_serial.c new file +33 -0
new file mode 100644
index 0000000..6422ab2
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+/* registers feilds */
+#define FCR_FIFO_EN          BIT0    /* fifo enable */
+#define FCR_RXSR             BIT1    /* receiver soft reset */
+#define FCR_TXSR             BIT2    /* transmitter soft reset */
+#define MCR_RTS              BIT1    /* ready to send */
+
+#define LCR_WLS_OFFS         0
+#define LCR_WLS_MASK                 0x3 << LCR_WLS_OFFS

/* character length mask */
+#define LCR_WLS_5 0x0 << LCR_WLS_OFFS /* 5
bit character length */
+#define LCR_WLS_6 0x1 << LCR_WLS_OFFS /* 6
bit character length */
+#define LCR_WLS_7 0x2 << LCR_WLS_OFFS /* 7
bit character length */
+#define LCR_WLS_8 0x3 << LCR_WLS_OFFS /* 8
bit character length */

drivers/serial/kirkwood_serial.c new file +2 -0
+#define LCR_STP_OFFS         2
+#define LCR_1_STB                    0x0 << LCR_STP_OFFS

/* Number of stop Bits */
+#define LCR_2_STB 0x1 << LCR_STP_OFFS
/* Number of stop Bits */

drivers/serial/kirkwood_serial.c new file +3 -0
+#define LCR_PEN              0x8     /* Parity enable */
+#define LCR_PS_OFFS          4
+#define LCR_EPS              0x1 << LCR_PS_OFFS      /* Even

Parity Select */
+#define LCR_OPS 0x0 << LCR_PS_OFFS /* Odd
Parity Select */

drivers/serial/kirkwood_serial.c new file +4 -0
+#define LCR_SBRK_OFFS                0x6
+#define LCR_SBRK             0x1 << LCR_SBRK_OFFS    /* Set Break */
+#define LCR_DIVL_OFFS                7
+#define LCR_DIVL_EN                  0x1 << LCR_DIVL_OFFS

/* Divisior latch enable */

drivers/serial/kirkwood_serial.c new file +7 -0
+
+#define LSR_DR               BIT0    /* Data ready */
+#define LSR_OE               BIT1    /* Overrun */
+#define LSR_PE               BIT2    /* Parity error */
+#define LSR_FE               BIT3    /* Framing error */
+#define LSR_BI               BIT4    /* Break */
+#define LSR_THRE             BIT5    /* Xmit holding

register empty */

drivers/serial/kirkwood_serial.c new file +7 -0
+#define LSR_TEMT             BIT6    /* Xmitter empty */
+#define LSR_ERR              BIT7    /* Error */
+
+/* useful defaults for LCR*/
+#define LCR_8N1              LCR_WLS_8 | LCR_1_STB
+
+/* This structure describes the registers offsets for one

UART port/channel */

drivers/serial/kirkwood_serial.c new file +29 -0
+typedef struct kwUartPort {
+     u8 rbr;                 /* 0 = 0-3 */
+     u8 pad1[3];
+     u8 ier;                 /* 1 = 4-7 */
+     u8 pad2[3];
+     u8 fcr;                 /* 2 = 8-b */
+     u8 pad3[3];
+     u8 lcr;                 /* 3 = c-f */
+     u8 pad4[3];
+     u8 mcr;                 /* 4 = 10-13 */
+     u8 pad5[3];
+     u8 lsr;                 /* 5 = 14-17 */
+     u8 pad6[3];
+     u8 msr;                 /* 6 =18-1b */
+     u8 pad7[3];
+     u8 scr;                 /* 7 =1c-1f */
+     u8 pad8[3];
+} kw_uart_port;
+
+/* aliases - for registers which has the same offsets */
+#define thr rbr
+#define iir fcr
+#define dll rbr
+#define dlm ier
+
+/* static variables */
+#if defined (CONFIG_CONS_INDEX)      /* comes from board config */
+#if (CONFIG_CONS_INDEX == 0 )
+static volatile kw_uart_port *p_uart_port = (void

*)KW_REGISTER(KW_UART0_BASE);

drivers/serial/kirkwood_serial.c new file +2 -0
+#elif (CONFIG_CONS_INDEX == 1 )
+static volatile kw_uart_port *p_uart_port = (void

*)KW_REGISTER(KW_UART1_BASE);

drivers/serial/kirkwood_serial.c new file +17 -0
+#endif
+#else
+#error CONFIG_CONS_INDEX not defined correctly
+#endif
+
+#define CONFIG_KW_UART_PORTS { (void *)KW_UART0_BASE, \
+                               (void *)KW_UART1_BASE }
+
+/*
+ * Serial init banner is kept simplest one
+ * if required can be created good one
+ */
+int serial_init(void)
+{
+     serial_setbrg();
+     printf
+

("\n*************************************************************");

drivers/serial/kirkwood_serial.c new file +77 -0
+     return (0);
+}
+
+void kwUartPutc(u8 c)
+{
+     while ((p_uart_port->lsr & LSR_THRE) == 0) ;
+     p_uart_port->thr = c;
+     return;
+}
+
+void serial_putc(const char c)
+{
+     if (c == '\n')
+             kwUartPutc('\r');
+
+     kwUartPutc(c);
+}
+
+int serial_getc(void)
+{
+     while ((p_uart_port->lsr & LSR_DR) == 0) ;
+     return (p_uart_port->rbr);
+}
+
+int serial_tstc(void)
+{
+     return ((p_uart_port->lsr & LSR_DR) != 0);
+}
+
+void serial_setbrg(void)
+{
+     DECLARE_GLOBAL_DATA_PTR;
+
+     int clock_divisor = (CONFIG_SYS_TCLK / 16) / gd->baudrate;
+
+     p_uart_port->ier = 0x00;
+     p_uart_port->lcr = LCR_DIVL_EN; /* Access baud rate */
+     p_uart_port->dll = clock_divisor & 0xff;        /* 9600 baud */
+     p_uart_port->dlm = (clock_divisor >> 8) & 0xff;
+     p_uart_port->lcr = LCR_8N1;     /* 8 data, 1 stop, no parity */
+     /* Clear & enable FIFOs */
+     p_uart_port->fcr = FCR_FIFO_EN | FCR_RXSR | FCR_TXSR;
+     return;
+}
+
+void serial_puts(const char *s)
+{
+     while (*s) {
+             serial_putc(*s++);
+     }
+}
+
+#ifdef CONFIG_CMD_KGDB
+void kgdb_serial_init(void)
+{
+}
+
+void putDebugChar(int c)
+{
+     serial_putc(c);
+}
+
+void putDebugStr(const char *str)
+{
+     serial_puts(str);
+}
+
+int getDebugChar(void)
+{
+     return serial_getc();
+}
+
+void kgdb_interruptible(int yes)
+{
+     return;
+}
+#endif /* CONFIG_CMD_KGDB */
drivers/spi/Makefile +1 -0
index 1350f3e..7ffa47d 100644
@@ -28,6 +28,7 @@ LIB := $(obj)libspi.a
 COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
 COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
+COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
 COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/kirkwood_spi.c new file +42 -0
new file mode 100644
index 0000000..f0bc3a7
@@ -0,0 +1,199 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Derived from drivers/spi/mpc8xxx_spi.c
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <spi.h>
+
+/* SPI Registers on kirkwood SOC */
+#define KW_REG_SPI_CTRL              (0x10600)
+#define KW_REG_SPI_CONFIG    (0x10604)
+#define KW_REG_SPI_DATA_OUT  (0x10608)
+#define KW_REG_SPI_DATA_IN   (0x1060c)
+#define KW_REG_SPI_IRQ_CAUSE (0x10610)
+#define KW_REG_SPI_IRQ_MASK  (0x10614)
+
+#define KW_SPI_TIMEOUT               10000
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+                               unsigned int max_hz, unsigned

int mode)

drivers/spi/kirkwood_spi.c new file +26 -0
+{
+     struct spi_slave *slave;
+     u32 data;
+
+     if (!spi_cs_is_valid(bus, cs))
+             return NULL;
+
+     slave = malloc(sizeof(struct spi_slave));
+     if (!slave)
+             return NULL;
+
+     slave->bus = bus;
+     slave->cs = cs;
+
+     KW_REG_WRITE(KW_REG_SPI_CTRL, 0x00000002);
+     /* program spi clock prescaller using max_hz */
+     data = ((CONFIG_SYS_TCLK / 2) / max_hz) & 0x0000000f;
+     debug("data = 0x%08x \n", data);
+     KW_REG_WRITE(KW_REG_SPI_CONFIG, 0x00000210 | data);
+     KW_REG_WRITE(KW_REG_SPI_IRQ_CAUSE, 0x00000001);
+     KW_REG_WRITE(KW_REG_SPI_IRQ_MASK, 0x00000000);
+
+     /* program mpp registers to select  SPI_CSn */
+     if (cs)
+             KW_REG_WRITE(KW_REG_MPP_CONTROL0,
+                          ((KW_REG_READ(KW_REG_MPP_CONTROL0)

& 0x0fffffff) |

drivers/spi/kirkwood_spi.c new file +4 -0
+                           0x20000000));
+     else
+             KW_REG_WRITE(KW_REG_MPP_CONTROL0,
+                          ((KW_REG_READ(KW_REG_MPP_CONTROL0)

& 0xfffffff0) |

drivers/spi/kirkwood_spi.c new file +42 -0
+                           0x00000002));
+
+     return slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+     free(slave);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+     return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+}
+
+#ifndef CONFIG_SPI_CS_IS_VALID
+/*
+ * you can define this function board specific
+ * define above CONFIG in board specific config file and
+ * provide the function in board specific src file
+ */
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+     return (bus == 0 && (cs == 0 || cs == 1));
+}
+#endif
+
+void spi_cs_activate(struct spi_slave *slave)
+{
+     KW_REG_BITS_SET(KW_REG_SPI_CTRL, BIT0);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+     KW_REG_BITS_RESET(KW_REG_SPI_CTRL, BIT0);
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,

const void *dout,

drivers/spi/kirkwood_spi.c new file +35 -0
+          void *din, unsigned long flags)
+{
+     unsigned int tmpdout, tmpdin;
+     int tm, isRead = 0;
+
+     debug("spi_xfer: slave %u:%u dout %08X din %08X bitlen %u\n",
+                 slave->bus, slave->cs, dout, din, bitlen);
+
+     if (flags & SPI_XFER_BEGIN)
+             spi_cs_activate(slave);
+
+     /*
+      * handle data in 8-bit chunks
+      * TBD: 2byte xfer mode to be enabled
+      */
+     while (bitlen > 4) {
+             debug("loopstart bitlen %d\n", bitlen);
+             tmpdout = 0;
+             if (1) {        //bitlen <= 8) {
+                     /*1 byte xfer mode */
+                     KW_REG_BITS_RESET(KW_REG_SPI_CONFIG, BIT5);
+                     /* Shift data so it's msb-justified */
+                     if (dout) {
+                             tmpdout = *(u32 *) dout & 0x0ff;
+                     }
+             } else {
+                     /*2 byte xfer mode */
+                     KW_REG_BITS_SET(KW_REG_SPI_CONFIG, BIT5);
+                     /* Shift data so it's msb-justified */
+                     if (dout) {
+                             tmpdout = *(u32 *) dout & 0x0ffff;
+                     }
+             }
+
+             KW_REG_WRITE(KW_REG_SPI_IRQ_CAUSE, 0x0);

/* clear bit */
+ KW_REG_WRITE(KW_REG_SPI_DATA_OUT, tmpdout);
/* Write the data out */

drivers/spi/kirkwood_spi.c new file +12 -0
+             debug("*** spi_xfer: ... %08x written, bitlen %d\n",
+                         tmpdout, bitlen);
+
+             /*
+              * Wait for SPI transmit to get out
+              * or time out (1 second = 1000 ms)
+              * The NE event must be read and cleared first
+              */
+             for (tm = 0, isRead = 0; tm < KW_SPI_TIMEOUT; ++tm) {
+                     if (KW_REG_READ(KW_REG_SPI_IRQ_CAUSE)) {
+                             isRead = 1;
+                             tmpdin =

KW_REG_READ(KW_REG_SPI_DATA_IN);

drivers/spi/kirkwood_spi.c new file +2 -0
+                             debug
+                                 ("*** spi_xfer: din %08X

... %08x read\n",

drivers/spi/kirkwood_spi.c new file +5 -0
+                                  din, tmpdin);
+
+                             if (1) {        //bitlen <= 8) {
+                                     if (din) {
+                                             *((u8 *) din) =

(u8) tmpdin;

drivers/spi/kirkwood_spi.c new file +8 -0
+                                             din += 1;
+                                     }
+                                     if (dout)
+                                             dout += 1;
+                                     bitlen -= 8;
+                             } else {
+                                     if (din) {
+                                             *((u16 *) din)

= (u16) tmpdin;

drivers/spi/kirkwood_spi.c new file +13 -0
+                                             din += 1;
+                                     }
+                                     if (dout)
+                                             dout += 1;
+                                     bitlen -= 16;
+                             }
+                     }
+                     if (isRead)
+                             break;
+             }
+             if (tm >= KW_SPI_TIMEOUT)
+                     printf
+                         ("*** spi_xfer: Time out during SPI

transfer\n");

drivers/spi/kirkwood_spi.c new file +9 -0
+
+             debug("loopend bitlen %d\n", bitlen);
+     }
+
+     if (flags & SPI_XFER_END)
+             spi_cs_deactivate(slave);
+
+     return 0;
+}
include/asm-arm/arch-kirkwood/kirkwood.h new file +35 -0
new file mode 100644
index 0000000..67d94dc
@@ -0,0 +1,142 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for the Marvell's Feroceon CPU core.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _ASM_ARCH_KIRKWOOD_H
+#define _ASM_ARCH_KIRKWOOD_H
+
+#ifndef __ASSEMBLY__
+#include <asm-arm/types.h>
+#endif /* __ASSEMBLY__ */
+#include <../board/Marvell/include/core.h>
+
+#if defined (CONFIG_FEROCEON_88FR131) || defined

(CONFIG_SHEEVA_88SV131)

include/asm-arm/arch-kirkwood/kirkwood.h new file +9 -0
+#if defined (CONFIG_KIRKWOOD)
+#include <../cpu/arm926ejs/kirkwood/kwcore.h>
+
+/* SOC specific definations */
+#define INTREG_BASE                  0xd0000000
+#define KW_REGISTER(x)                       (KW_REGS_PHY_BASE | x)
+#define KW_OFFSET_REG                        (INTREG_BASE | 0x20080)
+
+#define KW_UART0_BASE                        (0x12000)

/* UArt 0 */
+#define KW_UART1_BASE (0x13000)
/* UArt 1 */

include/asm-arm/arch-kirkwood/kirkwood.h new file +67 -0
+
+/* Controler environment registers offsets */
+#define KW_REG_MPP_CONTROL0          (0x10000)
+#define KW_REG_MPP_CONTROL1          (0x10004)
+#define KW_REG_MPP_CONTROL2          (0x10008)
+#define KW_REG_MPP_CONTROL3          (0x1000C)
+#define KW_REG_MPP_CONTROL4          (0x10010)
+#define KW_REG_MPP_CONTROL5          (0x10014)
+#define KW_REG_MPP_CONTROL6          (0x10018)
+#define KW_REG_MPP_SMPL_AT_RST               (0x10030)
+#define KW_REG_CHIP_BOND             (0x10034)
+#define KW_REG_MPP_OUT_DRV_REG               (0x100E0)
+
+#define KW_REG_GPP0_DATA_OUT         (0x10100)
+#define KW_REG_GPP0_DATA_OUT_EN              (0x10104)
+#define KW_REG_GPP0_BLINK_EN         (0x10108)
+#define KW_REG_GPP0_DATA_IN_POL              (0x1010C)
+#define KW_REG_GPP0_DATA_IN          (0x10110)
+#define KW_REG_GPP0_INT_CAUSE                (0x10114)
+#define KW_REG_GPP0_INT_MASK         (0x10118)
+#define KW_REG_GPP0_INT_LVL          (0x1011c)
+
+#define KW_REG_GPP1_DATA_OUT         (0x10140)
+#define KW_REG_GPP1_DATA_OUT_EN              (0x10144)
+#define KW_REG_GPP1_BLINK_EN         (0x10148)
+#define KW_REG_GPP1_DATA_IN_POL              (0x1014C)
+#define KW_REG_GPP1_DATA_IN          (0x10150)
+#define KW_REG_GPP1_INT_CAUSE                (0x10154)
+#define KW_REG_GPP1_INT_MASK         (0x10158)
+#define KW_REG_GPP1_INT_LVL          (0x1015c)
+
+#define KW_REG_NAND_READ_PARAM               (0x10418)
+#define KW_REG_NAND_WRITE_PARAM              (0x1041c)
+#define KW_REG_NAND_CTRL             (0x10470)
+
+#define KW_REG_WIN_CTRL(x)           (0x20000+(x*0x10))
+#define KW_REG_WIN_BASE(x)           (0x20004+(x*0x10))
+#define KW_REG_WIN_REMAP_LOW(x)              (0x20008+(x*0x10))
+#define KW_REG_WIN_REMAP_HIGH(x)     (0x2000c+(x*0x10))
+
+#define KW_REG_CPU_CONFIG            (0x20100)
+#define KW_REG_CPU_CTRL_STAT         (0x20104)
+#define KW_REG_CPU_RSTOUTN_MASK              (0x20108)
+#define KW_REG_CPU_SYS_SOFT_RST              (0x2010C)
+#define KW_REG_CPU_AHB_MBUS_CAUSE_INT        (0x20110)
+#define KW_REG_CPU_AHB_MBUS_MASK_INT (0x20114)
+#define KW_REG_CPU_FTDLL_CONFIG              (0x20120)
+#define KW_REG_CPU_L2_CONFIG         (0x20128)
+#define KW_REG_L2_RAM_TIMING0                (0x20134)
+#define KW_REG_L2_RAM_TIMING1                (0x20138)
+
+#define KW_REG_TMR_CTRL                      (0x20300)
+#define KW_REG_TMR_RELOAD            (0x20310)
+#define KW_REG_TMR_VAL                       (0x20314)
+
+/*
+ * Macros
+ * CPU architecture dependent I/O read/write
+ */
+#define KW_REG_WRITE(addr, data)     \
+    ((*((volatile unsigned int*)(KW_REGISTER(addr)))) \
+              = ((unsigned int)WORD_SWAP((data))))
+
+#define KW_REG_READ(addr)            \
+    WORD_SWAP(((*((volatile unsigned int*)(KW_REGISTER(addr))))))
+
+#define KW_REG_BITS_SET(adr, bits)   (KW_REG_WRITE(adr,

KW_REG_READ(adr)\
+ | ((unsigned
int)WORD_SWAP(bits))))

include/asm-arm/arch-kirkwood/kirkwood.h new file +2 -0
+
+#define KW_REG_BITS_RESET(adr, bits) (KW_REG_WRITE(adr,

KW_REG_READ(adr)\
+ & ~((unsigned
int)WORD_SWAP(bits))))

include/asm-arm/arch-kirkwood/kirkwood.h new file +26 -0
+
+#define KW_REG_READ_ASM(toReg, tmpReg, regOffs)      \
+        ldr     tmpReg, =KW_REGISTER(regOffs);       \
+        ldr     toReg, [tmpReg];                     \
+                             /*WORD_SWAP_ASM(toReg,tmpReg) */
+
+#define KW_REG_WRITE_ASM(fromReg, tmpReg, regOffs)   \
+        /*WORD_SWAP_ASM(fromReg,tmpReg)*/;           \
+        ldr     tmpReg, =KW_REGISTER(regOffs);               \
+        str     fromReg, [tmpReg]
+
+/*
+ * Error codes
+ */
+#define KW_ERROR     (-1)
+#define KW_OK                (0)
+
+#if defined (CONFIG_KW88F6281)
+#include "kw88f6281.h"
+#endif /* CONFIG_KW88F6281 */
+#if defined (CONFIG_KW88F6192)
+#include "kw88f6192.h"
+#endif /* CONFIG_KW88F6192 */
+#endif /* CONFIG_KIRKWOOD */
+#endif /* CONFIG_FEROCEON_88FR131 */
+#endif /* _ASM_ARCH_KIRKWOOD_H */
include/asm-arm/arch-kirkwood/kw88f6192.h new file +37 -0
new file mode 100644
index 0000000..000fc16
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6192 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_KW88F6192_H
+#define _CONFIG_KW88F6192_H
+
+/* SOC specific definations */
+#define KW88F6192_REGS_PHYS_BASE     0xf1000000
+#define KW_REGS_PHY_BASE             KW88F6192_REGS_PHYS_BASE
+
+/* TCLK Core Clock defination */
+#define CONFIG_SYS_TCLK         166000000 /* 166MHz */
+
+#endif /* _CONFIG_KW88F6192_H */
include/asm-arm/arch-kirkwood/kw88f6281.h new file +43 -0
new file mode 100644
index 0000000..45098fb
@@ -0,0 +1,43 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6281 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _ASM_ARCH_KW88F6281_H
+#define _ASM_ARCH_KW88F6281_H
+
+/* SOC specific definations */
+#define KW88F6281_REGS_PHYS_BASE     0xf1000000
+#define KW_REGS_PHY_BASE             KW88F6281_REGS_PHYS_BASE
+
+/* TCLK Core Clock defination*/
+#if defined (CONFIG_KW88F6281_Z0)
+#define CONFIG_SYS_TCLK         166000000 /* 166MHz */
+#elif defined (CONFIG_KW88F6281_A0)
+#define CONFIG_SYS_TCLK         200000000 /* 200MHz */
+#else
+#error       "CONFIG_SYS_TCLK not defined"
+#endif
+
+#endif /* _ASM_ARCH_KW88F6281_H */
include/asm-arm/config.h +4 -1
index 049c44e..5d52f15 100644
@@ -21,4 +21,8 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#if defined (CONFIG_KIRKWOOD)
+#include <asm-arm/arch-kirkwood/kirkwood.h>
+#endif /* CONFIG_KIRKWOOD */
+
 #endif
--

1.5.3.3

#44 lore raw

PATCH v2 1/1 Marvell Kirkwood family SOC support

In reply to Prafulla Wadaskar
Quoted 203 lines · Prafulla Wadaskar

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0

Other supported features:-
1) get_random_hex() fucntion
2) SPI port controller driver
3) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

---
Changelog:
v2: crated arch-kirkwood and moved some header files there renamed and moved spi.c to drivers/spi/
renamed and moved serial.c to drivers/serial/ doimage utility removed
soc_init.S renamed as lowlevel_init.S
debug prints removed

 board/Marvell/include/core.h              |    4 +
 cpu/arm926ejs/kirkwood/Makefile           |   50 ++++++
 cpu/arm926ejs/kirkwood/config.mk          |   25 +++
 cpu/arm926ejs/kirkwood/dram.c             |   55 +++++++
 cpu/arm926ejs/kirkwood/kwcore.c           |  250 +++++++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/kwcore.h           |   47 ++++++
 cpu/arm926ejs/kirkwood/lowlevel_init.S    |  183 +++++++++++++++++++++
 cpu/arm926ejs/kirkwood/timer.c            |  165 +++++++++++++++++++
 drivers/serial/Makefile                   |    1 +
 drivers/serial/kirkwood_serial.c          |  187 +++++++++++++++++++++
 drivers/spi/Makefile                      |    1 +
 drivers/spi/kirkwood_spi.c                |  199 +++++++++++++++++++++++
 include/asm-arm/arch-kirkwood/kirkwood.h  |  142 ++++++++++++++++
 include/asm-arm/arch-kirkwood/kw88f6192.h |   37 +++++
 include/asm-arm/arch-kirkwood/kw88f6281.h |   43 +++++
 include/asm-arm/config.h                  |    4 +
 16 files changed, 1393 insertions(+), 0 deletions(-)
 create mode 100644 cpu/arm926ejs/kirkwood/Makefile
 create mode 100644 cpu/arm926ejs/kirkwood/config.mk
 create mode 100644 cpu/arm926ejs/kirkwood/dram.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.h
 create mode 100644 cpu/arm926ejs/kirkwood/lowlevel_init.S
 create mode 100644 cpu/arm926ejs/kirkwood/timer.c
 create mode 100644 drivers/serial/kirkwood_serial.c
 create mode 100644 drivers/spi/kirkwood_spi.c
 create mode 100644 include/asm-arm/arch-kirkwood/kirkwood.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6192.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6281.h
board/Marvell/include/core.h +4 -0
index c413439..ecc4682 100644
@@ -12,9 +12,11 @@ space). The macros take care of Big/Little endian conversions.
 #ifndef __INCcoreh
 #define __INCcoreh
 
+#ifndef CONFIG_KIRKWOOD
 #include "mv_gen_reg.h"
 
 extern unsigned int INTERNAL_REG_BASE_ADDR;
+#endif /* CONFIG_KIRKWOOD */
 
 /****************************************/
 /*	    GENERAL Definitions			*/
@@ -91,10 +93,12 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;
 #define _1G		0x40000000
 #define _2G		0x80000000
 
+#ifndef __ASSEMBLY__
 #ifndef	BOOL_WAS_DEFINED
 #define BOOL_WAS_DEFINED
 typedef enum _bool{false,true} bool;
 #endif
+#endif
 
 /* Little to Big endian conversion macros */
 
cpu/arm926ejs/kirkwood/Makefile new file +50 -0
new file mode 100644
index 0000000..c917f0d
@@ -0,0 +1,50 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).a
+
+COBJS-y	= dram.o
+COBJS-y	+= kwcore.o
+COBJS-y	+= timer.o
+
+SOBJS	= lowlevel_init.o
+
+SRCS    := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS    := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
cpu/arm926ejs/kirkwood/config.mk new file +25 -0
new file mode 100644
index 0000000..000eeb4
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+PLATFORM_CPPFLAGS += -march=armv5te
cpu/arm926ejs/kirkwood/dram.c new file +23 -0
new file mode 100644
index 0000000..80e2b13
@@ -0,0 +1,55 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */

cpu/arm926ejs/kirkwood/dram.c line 33

Quoted 10 lines
cpu/arm926ejs/kirkwood/dram.c new file +10 -0
+
+#include <config.h>
+
+/*
+ * kw_sdram_bar - reads SDRAM Base Address Register
+ */
+u32 kw_sdram_bar(MEMORY_BANK bank)
+{
+	u32 result = 0;
+	u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));

please create macro for these registers
please use readx/writex (madatory)

Quoted 49 lines
cpu/arm926ejs/kirkwood/dram.c new file +22 -0
+
+	if ((!enable) || (bank > BANK3))
+		return 0;
+
+	result = KW_REG_READ((0x1500 + bank * 8));
+	return result;
+}
+
+/*
+ * kw_sdram_bs - reads SDRAM Bank size
+ */
+u32 kw_sdram_bs(MEMORY_BANK bank)
+{
+	u32 result = 0;
+	u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));
+
+	if ((!enable) || (bank > BANK3))
+		return 0;
+	result = (0xff000000 & KW_REG_READ((0x1504 + bank * 8)));
+	result += 0x01000000;
+	return result;
+}
cpu/arm926ejs/kirkwood/kwcore.c new file +21 -0
new file mode 100644
index 0000000..2e887d5
@@ -0,0 +1,250 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,

cpu/arm926ejs/kirkwood/kwcore.c line 31

Quoted 10 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +10 -0
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+#include <u-boot/md5.h>
+
+void reset_cpu(unsigned long ignored)
+{
+	KW_REG_BITS_SET(KW_REG_CPU_RSTOUTN_MASK, BIT2);
+	KW_REG_BITS_SET(KW_REG_CPU_SYS_SOFT_RST, BIT0);

plase use readx/writex
everywhere

Quoted 6 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +6 -0
+	while (1) ;
+}
+
+/*
+ * Generates Ramdom hex number reading some time varient system registers
+ * and using md5 algorithm

cpu/arm926ejs/kirkwood/kwcore.c line 47

Quoted 10 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +10 -0
+ */
+unsigned char get_random_hex(void)
+{
+	int i;
+	u32 inbuf[16];
+	u8 outbuf[16];
+
+#if defined (CONFIG_KW88F6281_Z0)
+	KW_REG_BITS_SET(0x1478, BIT7);
+#elif defined (CONFIG_KW88F6281_A0) || defined (CONFIG_KW88F6192_A0)

could you detect it

cpu/arm926ejs/kirkwood/kwcore.c line 52

Quoted 5 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +5 -0
+	/*
+	 * in case of 88F6281/88F6192 A0,
+	 * BIT7 need to reset to generate random values in 0x1470
+	 */
+	KW_REG_BITS_RESET(0x1478, BIT7);

please use macro everywhere instead of hardcode value

Quoted 5 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +5 -0
+#else
+#error Undefined SOC Revision
+#endif
+	for (i = 0; i < 16; i++) {
+		inbuf[i] = KW_REG_READ(0x1470);

cpu/arm926ejs/kirkwood/kwcore.c line 67

Quoted 10 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +10 -0
+	}
+	md5((u8 *) inbuf, 64, outbuf);
+	return outbuf[outbuf[7] % 0x0f];
+}
+
+/*
+ * kw_window_ctrl_reg_init - Mbus-L to Mbus Bridge Registers init.
+ */
+int kw_window_ctrl_reg_init(void)
+{

coudl explain a few more what you do and try use macro instead of hardcode value

Quoted 74 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +74 -0
+	KW_REG_WRITE(KW_REG_WIN_CTRL(0), 0x0fffe841);
+	KW_REG_WRITE(KW_REG_WIN_BASE(0), 0x90000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(0), 0x90000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(0), 0x00000000);
+
+	KW_REG_WRITE(KW_REG_WIN_CTRL(1), 0x007f2f11);
+	KW_REG_WRITE(KW_REG_WIN_BASE(1), 0xF9000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(1), 0xF9000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(1), 0x00000000);
+
+	KW_REG_WRITE(KW_REG_WIN_CTRL(2), 0x00ffe041);
+	KW_REG_WRITE(KW_REG_WIN_BASE(2), 0xF0000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(2), 0xC0000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(2), 0x00000000);
+
+	KW_REG_WRITE(KW_REG_WIN_CTRL(3), 0x00ff1e11);
+	KW_REG_WRITE(KW_REG_WIN_BASE(3), 0xF8000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(3), 0x00000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(3), 0x00000000);
+
+	KW_REG_WRITE(KW_REG_WIN_CTRL(4), 0x00ff1d11);
+	KW_REG_WRITE(KW_REG_WIN_BASE(4), 0xFF000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(4), 0x00000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(4), 0x00000000);
+
+	KW_REG_WRITE(KW_REG_WIN_CTRL(5), 0x07ff1e10);
+	KW_REG_WRITE(KW_REG_WIN_BASE(5), 0xE8000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(5), 0x00000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(5), 0x00000000);
+
+	KW_REG_WRITE(KW_REG_WIN_CTRL(6), 0x07ff1d10);
+	KW_REG_WRITE(KW_REG_WIN_BASE(6), 0xF0000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(6), 0x00000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(6), 0x00000000);
+
+	KW_REG_WRITE(KW_REG_WIN_CTRL(7), 0x00000131);
+	KW_REG_WRITE(KW_REG_WIN_BASE(7), 0xFB000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(7), 0x00000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(7), 0x00000000);
+
+	return KW_OK;
+}
+
+/*
+ * kw_gpio_init - Init gpios for default values
+ */
+void kw_gpio_init(u32 gpp0_oe_val, u32 gpp1_oe_val, u32 gpp0_oe, u32 gpp1_oe)
+{
+	/* Init GPIOS to default values as per board requirement */
+	KW_REG_WRITE(KW_REG_GPP0_DATA_OUT, gpp0_oe_val);
+	KW_REG_WRITE(KW_REG_GPP1_DATA_OUT, gpp1_oe_val);
+	KW_REG_WRITE(KW_REG_GPP0_DATA_OUT_EN, gpp0_oe);
+	KW_REG_WRITE(KW_REG_GPP1_DATA_OUT_EN, gpp1_oe);
+}
+
+/*
+ * kw_mpp_control_init - initialize mpp for board specific functionality
+ */
+int kw_mpp_control_init(u32 mpp0_7, u32 mpp8_15, u32 mpp16_23, u32 mpp24_31,
+			u32 mpp32_39, u32 mpp40_47, u32 mpp48_55)
+{
+	/* program mpp registers */
+	KW_REG_WRITE(KW_REG_MPP_CONTROL0, mpp0_7);
+	KW_REG_WRITE(KW_REG_MPP_CONTROL1, mpp8_15);
+	KW_REG_WRITE(KW_REG_MPP_CONTROL2, mpp16_23);
+	KW_REG_WRITE(KW_REG_MPP_CONTROL3, mpp24_31);
+	KW_REG_WRITE(KW_REG_MPP_CONTROL4, mpp32_39);
+	KW_REG_WRITE(KW_REG_MPP_CONTROL5, mpp40_47);
+	KW_REG_WRITE(KW_REG_MPP_CONTROL6, mpp48_55);
+	return KW_OK;
+}
+
+/*
+ * kw_misc_init_r - SOC specific misc init (mainly cache initialization)

cpu/arm926ejs/kirkwood/kwcore.c line 151

Quoted 10 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +10 -0
+ */
+int kw_misc_init_r(void)
+{
+	char *env;
+	volatile unsigned int temp;
+
+	/*CPU streaming & write allocate */
+	env = getenv("enaWrAllo");
+	if (env && ((strcmp(env, "yes") == 0) || (strcmp(env, "Yes") == 0))) {
+		__asm__ __volatile__("mrc p15, 1, %0, c15, c1, 0":"=r"(temp));

please cp15 api (the same as the kernel)
set_cr/get_cr

btw could explain why do you need to do it via env?

be aware that we have cache API

Quoted 9 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +9 -0
+		temp |= BIT28;
+		__asm__ __volatile__("mcr p15, 1, %0, c15, c1, 0"::"r"(temp));
+
+	} else {
+		__asm__ __volatile__("mrc p15, 1, %0, c15, c1, 0":"=r"(temp));
+		temp &= ~BIT28;
+		__asm__ __volatile__("mcr p15, 1, %0, c15, c1, 0"::"r"(temp));
+	}
+

<snip>

Quoted 31 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +1 -0
+
cpu/arm926ejs/kirkwood/kwcore.h new file +24 -0
new file mode 100644
index 0000000..8d2a8cc
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+

cpu/arm926ejs/kirkwood/kwcore.h line 34

Quoted 10 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +10 -0
+#ifndef _KWCORE_H
+#define _KWCORE_H
+
+/*
+ * functions
+ */
+#ifndef __ASSEMBLY__
+void reset_cpu(unsigned long ignored);
+unsigned char get_random_hex(void);
+typedef enum _memory_bank { BANK0, BANK1, BANK2, BANK3 } MEMORY_BANK;

please do not use upper case

Quoted 69 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +13 -0
+unsigned int kw_sdram_bar(MEMORY_BANK bank);
+unsigned int kw_sdram_bs(MEMORY_BANK bank);
+int kw_window_ctrl_reg_init(void);
+void kw_gpio_init(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
+		  unsigned int gpp0_oe, unsigned int gpp1_oe);
+int kw_mpp_control_init(unsigned int mpp0_7, unsigned int mpp8_15,
+			unsigned int mpp16_23, unsigned int mpp24_31,
+			unsigned int mpp32_39, unsigned int mpp40_47,
+			unsigned int mpp48_55);
+int kw_misc_init_r(void);
+#endif				/* __ASSEMBLY__ */
+
+#endif				/* _KWCORE_H */
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +50 -0
new file mode 100644
index 0000000..169e58b
@@ -0,0 +1,183 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#define CCR_CPU_2_MBUSL_TICK_DRV_OFFS		8
+#define CCR_CPU_2_MBUSL_TICK_DRV_MASK		(0xF << CCR_CPU_2_MBUSL_TICK_DRV_OFFS)
+#define CCR_CPU_2_MBUSL_TICK_SMPL_OFFS		12
+#define CCR_CPU_2_MBUSL_TICK_SMPL_MASK		(0xF << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS)
+
+#define MSAR_DDRCLCK_RTIO_OFFS			5
+#define MSAR_DDRCLCK_RTIO_MASK			(0xF << MSAR_DDRCLCK_RTIO_OFFS)
+
+/* Ratio options for CPU to DDR for 6281/6192/6180 */
+#define CPU_2_DDR_CLK_1x2	    		2
+#define CPU_2_DDR_CLK_1x3	    		4
+#define CPU_2_DDR_CLK_1x4	    		6
+
+/* Default values for CPU to Mbus-L DDR Interface Tick Driver and 	*/
+/* CPU to Mbus-L Tick Sample fields in CPU config register		*/
+
+#define TICK_DRV_1x1				0
+#define TICK_DRV_1x2				0
+#define TICK_DRV_1x3				1
+#define TICK_DRV_1x4				2
+#define TICK_SMPL_1x1				0
+#define TICK_SMPL_1x2				1
+#define TICK_SMPL_1x3				2
+#define TICK_SMPL_1x4				3

cpu/arm926ejs/kirkwood/lowlevel_init.S line 60

Quoted 10 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +10 -0
+#define CPU_2_MBUSL_DDR_CLK_1x2						\
+		 ((TICK_DRV_1x2  << CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | 	\
+		  (TICK_SMPL_1x2 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+#define CPU_2_MBUSL_DDR_CLK_1x3						\
+		 ((TICK_DRV_1x3  << CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | 	\
+		  (TICK_SMPL_1x3 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+#define CPU_2_MBUSL_DDR_CLK_1x4						\
+		 ((TICK_DRV_1x4  << CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | 	\
+		  (TICK_SMPL_1x4 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+

please move all this define to header corresponding of the functionallity/IP

cpu/arm926ejs/kirkwood/lowlevel_init.S line 63

Quoted 3 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +3 -0
+
+	.globl kw_cpu_if_pre_init
+kw_cpu_if_pre_init:

do you really need to do this before relocation

cpu/arm926ejs/kirkwood/lowlevel_init.S line 65

Quoted 2 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +2 -0
+
+        mov     r11, LR     		/* Save link register */

will you call a sub routine?

Quoted 69 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +69 -0
+
+        /*
+	 * Configures the I/O voltage of the pads connected to Egigabit
+	 * Ethernet interface to 1.8V
+	 * By defult it is set to 3.3V
+	 */
+#ifdef CONFIG_KIRKWOOD_RGMII_PAD_1V8
+        KW_REG_READ_ASM (r7, r5, KW_REG_MPP_OUT_DRV_REG)
+        ldr    r5, =BIT7
+        orr    r7, r7, r5       /* Set RGMII PADS Voltage to 1.8V */
+        KW_REG_WRITE_ASM (r7, r5, KW_REG_MPP_OUT_DRV_REG)
+#endif
+        /*
+	 * Set egiga port0/1 in normal functional mode
+	 * This is required becasue on kirkwood by default ports are in reset mode
+	 * OS egiga driver may not have provision to set them in normal mode
+	 * and if u-boot is build without network support, network may fail at OS level
+	 */
+#ifdef CONFIG_KIRKWOOD_EGIGA_INIT
+        KW_REG_READ_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(0))
+        ldr    r5, =~(BIT4)
+        and    r7, r7, r5       /* Clear PortReset Bit */
+        KW_REG_WRITE_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(0))
+
+        KW_REG_READ_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(1))
+        ldr    r5, =~(BIT4)
+        and    r7, r7, r5       /* Clear PortReset Bit */
+        KW_REG_WRITE_ASM (r7, r5, KW_ETH_PORT_SERIAL_CONTROL1_REG(1))
+#endif
+
+	/*
+	 * Enable PCI Express Port0
+	 */
+#ifdef CONFIG_KIRKWOOD_PCIE_INIT
+        KW_REG_READ_ASM (r7, r5, KW_REG_CPU_CTRL_STAT)
+        ldr    r5, =BIT0
+        orr    r7, r7, r5       /* Set PEX0En Bit */
+        KW_REG_WRITE_ASM (r7, r5, KW_REG_CPU_CTRL_STAT)
+#endif
+
+#ifdef CONFIG_KW88F6281_Z0
+        /* Get the "sample on reset" register */
+	KW_REG_READ_ASM (r4, r5, KW_REG_MPP_SMPL_AT_RST)
+        ldr    r5, =MSAR_DDRCLCK_RTIO_MASK
+        and    r5, r4, r5
+	mov    r5, r5, lsr #MSAR_DDRCLCK_RTIO_OFFS
+
+        ldr    r4, =CPU_2_MBUSL_DDR_CLK_1x2
+        cmp    r5, #CPU_2_DDR_CLK_1x2
+        beq    set_config_reg
+
+        ldr    r4, =CPU_2_MBUSL_DDR_CLK_1x3
+        cmp    r5, #CPU_2_DDR_CLK_1x3
+        beq    set_config_reg
+
+        ldr    r4, =CPU_2_MBUSL_DDR_CLK_1x4
+        cmp    r5, #CPU_2_DDR_CLK_1x4
+        beq    set_config_reg
+
+        ldr    r4, =0
+
+set_config_reg:
+        /* Read CPU Config register */
+        KW_REG_READ_ASM (r7, r5, KW_REG_CPU_CONFIG)
+        ldr    r5, =~(CCR_CPU_2_MBUSL_TICK_DRV_MASK | CCR_CPU_2_MBUSL_TICK_SMPL_MASK)
+        and    r7, r7, r5       /* Clear register fields */
+        orr    r7, r7, r4       /* Set the values according to the findings */
+        KW_REG_WRITE_ASM (r7, r5, KW_REG_CPU_CONFIG)
+

cpu/arm926ejs/kirkwood/lowlevel_init.S line 144

Quoted 10 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +10 -0
+done:
+#endif
+        mov     PC, r11         /* r11 is saved link register */
+
+	.globl kw_enable_invalidate_l2_cache
+kw_enable_invalidate_l2_cache:
+        mov     r11, LR     	/* Save link register */
+
+	/* Enable L2 cache in write through mode */
+	KW_REG_READ_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)

please remove thhis KW_RED_READ_ASM
or do it via asm macro as we have done for sh2/3/4

cpu/arm926ejs/kirkwood/lowlevel_init.S line 152

Quoted 8 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +8 -0
+	orr     r4, r4, #0x18
+	KW_REG_WRITE_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)
+	/* Read operation to make sure the L2 bit is set */
+	KW_REG_READ_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)
+
+	/* invalidate L2 cache */
+	mov	r0, #0
+	mcr	p15, 1, r0, c15, c11, 0

please create a macro for this

cpu/arm926ejs/kirkwood/lowlevel_init.S line 156

Quoted 4 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +4 -0
+
+        mov     PC, r11         /* r11 is saved link register */
+
+        .globl lowlevel_init

in this case call it arch_lowlevel_init

and update start.S to call it just be the lowlevel_init

which is board lowlevel init

cpu/arm926ejs/kirkwood/lowlevel_init.S line 157

Quoted 1 line
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +1 -0
+lowlevel_init:

if you have multple sub call use the stack will be beter

Quoted 55 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +26 -0
+        /* Linux expects` the internal registers to be at 0xf1000000 */
+        ldr r1, = KW_OFFSET_REG
+        ldr r3, = KW_REGS_PHY_BASE
+        str r3,[r1]
+
+        /* save Link Registers */
+        mov r2, lr
+
+        /* Enable L2 cache in write through mode */
+        bl kw_enable_invalidate_l2_cache
+
+#ifdef CONFIG_BOARD_LOWLEVEL_INIT
+        /*
+	 * if Kirkwood is configured not to use its internal bootROM
+	 * This will be needed specially for DRAM configuration
+	 */
+        bl board_lowlevel_init
+#endif
+
+        /*
+	 * Initialize BUS-L to DDR configuration parameters
+	 * Must be done prior to DDR operation
+	 */
+        bl kw_cpu_if_pre_init
+        mov lr, r2
+        mov pc, lr
cpu/arm926ejs/kirkwood/timer.c new file +23 -0
new file mode 100644
index 0000000..4ab1a54
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+

cpu/arm926ejs/kirkwood/timer.c line 33

Quoted 10 lines
cpu/arm926ejs/kirkwood/timer.c new file +10 -0
+#include <common.h>
+
+#define UBOOT_CNTR	0	/* counter to use for uboot timer */
+
+/*
+ * ARM Timers Registers Map
+ */
+#define CNTMR_CTRL_REG			KW_REG_TMR_CTRL
+#define CNTMR_RELOAD_REG(tmrNum)	(KW_REG_TMR_RELOAD + tmrNum*8)
+#define CNTMR_VAL_REG(tmrNum)		(KW_REG_TMR_VAL + tmrNum*8)

please no uppercase in the var name

Quoted 23 lines
cpu/arm926ejs/kirkwood/timer.c new file +23 -0
+
+/*
+ * ARM Timers Control Register
+ * CPU_TIMERS_CTRL_REG (CTCR)
+ */
+#define TIMER0_NUM				0
+#define TIMER1_NUM				1
+#define WATCHDOG_NUM				2
+
+#define CTCR_ARM_TIMER_EN_OFFS(cntr)		(cntr * 2)
+#define CTCR_ARM_TIMER_EN_MASK(cntr)		(1 << CTCR_ARM_TIMER_EN_OFFS)
+#define CTCR_ARM_TIMER_EN(cntr)			(1 << CTCR_ARM_TIMER_EN_OFFS(cntr))
+#define CTCR_ARM_TIMER_DIS(cntr)		(0 << CTCR_ARM_TIMER_EN_OFFS(cntr))
+
+#define CTCR_ARM_TIMER_AUTO_OFFS(cntr)	((cntr * 2) + 1)
+#define CTCR_ARM_TIMER_AUTO_MASK(cntr)	BIT1
+#define CTCR_ARM_TIMER_AUTO_EN(cntr)	(1 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
+#define CTCR_ARM_TIMER_AUTO_DIS(cntr)	(0 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
+
+/*
+ * ARM Timer\Watchdog Reload Register
+ * CNTMR_RELOAD_REG (TRR)
+ */

cpu/arm926ejs/kirkwood/timer.c line 66

Quoted 10 lines
cpu/arm926ejs/kirkwood/timer.c new file +10 -0
+#define TRG_ARM_TIMER_REL_OFFS			0
+#define TRG_ARM_TIMER_REL_MASK			0xffffffff
+
+/*
+ * ARM Timer\Watchdog Register
+ * CNTMR_VAL_REG (TVRG)
+ */
+#define TVR_ARM_TIMER_OFFS			0
+#define TVR_ARM_TIMER_MASK			0xffffffff
+#define TVR_ARM_TIMER_MAX			0xffffffff

please move all this define to a header

and nearly all precedent comment can be apply to the rest of the patch

Best Regards,
J.

#45 lore raw

PATCH v2 1/1 Marvell Kirkwood family SOC support

Hi Jean

Thanks for your review comments.

Quoted 16 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Friday, April 17, 2009 2:52 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v2] Marvell Kirkwood family SOC support

Quoted 8 lines · Prafulla Wadaskar

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0
Quoted 11 lines

cpu/arm926ejs/kirkwood/dram.c line 33

Quoted 10 lines

Other supported features:-
1) get_random_hex() fucntion
2) SPI port controller driver
3) PCI Express port initialization

cpu/arm926ejs/kirkwood/dram.c new file +6 -0
+/*
+ * kw_sdram_bar - reads SDRAM Base Address Register  */
+u32 kw_sdram_bar(MEMORY_BANK bank)
+{
+	u32 result = 0;
+	u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));

please create macro for these registers

This will be taken care....

Quoted 1 line

please use readx/writex (madatory)

You mean instead of KW_REG_READ to be used readx() ?

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c line 31

Quoted 4 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +4 -0
+
+void reset_cpu(unsigned long ignored) {
+	KW_REG_BITS_SET(KW_REG_CPU_RSTOUTN_MASK, BIT2);
+	KW_REG_BITS_SET(KW_REG_CPU_SYS_SOFT_RST, BIT0);

plase use readx/writex
everywhere

Okay...

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 4 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +4 -0
+
+#if defined (CONFIG_KW88F6281_Z0)
+	KW_REG_BITS_SET(0x1478, BIT7);
+#elif defined (CONFIG_KW88F6281_A0) || defined 

(CONFIG_KW88F6192_A0)
could you detect it

I should be able to detect it, I will check and update the same

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c line 52

Quoted 5 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +5 -0
+	/*
+	 * in case of 88F6281/88F6192 A0,
+	 * BIT7 need to reset to generate random values in 0x1470
+	 */
+	KW_REG_BITS_RESET(0x1478, BIT7);

please use macro everywhere instead of hardcode value

Okay..

Quoted 8 lines

cpu/arm926ejs/kirkwood/kwcore.c line 67

Quoted 6 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +6 -0
+
+/*
+ * kw_window_ctrl_reg_init - Mbus-L to Mbus Bridge Registers init.
+ */
+int kw_window_ctrl_reg_init(void)
+{

coudl explain a few more what you do and try use macro instead of hardcode value

Macros will be used..
I will put the explaination in the comment for this function

Quoted 11 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 10 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +9 -0
+	KW_REG_WRITE(KW_REG_WIN_CTRL(0), 0x0fffe841);
+	KW_REG_WRITE(KW_REG_WIN_BASE(0), 0x90000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(0), 0x90000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(0), 0x00000000);
+
 
+#ifndef __ASSEMBLY__
+void reset_cpu(unsigned long ignored); unsigned char 
+get_random_hex(void); typedef enum _memory_bank { BANK0, BANK1, 
+BANK2, BANK3 } MEMORY_BANK;

please do not use upper case

You mean MEMORY_BANK, right? I will change it

Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		  (TICK_SMPL_1x3 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+#define CPU_2_MBUSL_DDR_CLK_1x4				
		\

Review

Quoted 1 line
(quoted diff) +1 -0
+		 ((TICK_DRV_1x4  << 

CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \

cpu/arm926ejs/kirkwood/lowlevel_init.S line 60

Quoted 2 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +2 -0
+		  (TICK_SMPL_1x4 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+

please move all this define to header corresponding of the functionallity/IP

I thought these are only settings limited to this file only, any way I will create and move them to header file

Quoted 4 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 63

Quoted 3 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +3 -0
+
+	.globl kw_cpu_if_pre_init
+kw_cpu_if_pre_init:

do you really need to do this before relocation

Yes..

Quoted 3 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+        mov     r11, LR     		/* Save link register */

will you call a sub routine?

I will do it?

Quoted 8 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 144

Quoted 6 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +6 -0
+	.globl kw_enable_invalidate_l2_cache
+kw_enable_invalidate_l2_cache:
+        mov     r11, LR     	/* Save link register */
+
+	/* Enable L2 cache in write through mode */
+	KW_REG_READ_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)

please remove thhis KW_RED_READ_ASM
or do it via asm macro as we have done for sh2/3/4

I will check this...

Quoted 5 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 152

Quoted 4 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +4 -0
+
+	/* invalidate L2 cache */
+	mov	r0, #0
+	mcr	p15, 1, r0, c15, c11, 0

please create a macro for this

Okay...

Quoted 8 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 156

Quoted 4 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +4 -0
+
+        mov     PC, r11         /* r11 is saved link register */
+
+        .globl lowlevel_init

in this case call it arch_lowlevel_init

and update start.S to call it just be the lowlevel_init

You mean to add support for arch_lowlevel_init, using some CONFIG_ option ?

Quoted 5 lines

which is board lowlevel init

Quoted 1 line

+lowlevel_init:

if you have multple sub call use the stack will be beter

That's good idea, I will do it

Quoted 8 lines

cpu/arm926ejs/kirkwood/timer.c

Quoted 6 lines
cpu/arm926ejs/kirkwood/timer.c new file +6 -0
+/*
+ * ARM Timers Registers Map
+ */
+#define CNTMR_CTRL_REG			KW_REG_TMR_CTRL
+#define CNTMR_RELOAD_REG(tmrNum)	(KW_REG_TMR_RELOAD + tmrNum*8)
+#define CNTMR_VAL_REG(tmrNum)		(KW_REG_TMR_VAL 

+ tmrNum*8)
please no uppercase in the var name

Okay..

Quoted 8 lines

cpu/arm926ejs/kirkwood/timer.c line 66

Quoted 7 lines
cpu/arm926ejs/kirkwood/timer.c new file +7 -0
+/*
+ * ARM Timer\Watchdog Register
+ * CNTMR_VAL_REG (TVRG)
+ */
+#define TVR_ARM_TIMER_OFFS			0
+#define TVR_ARM_TIMER_MASK			0xffffffff
+#define TVR_ARM_TIMER_MAX			0xffffffff

please move all this define to a header

Okay...

Thanks and regards....
Prafulla . .

Quoted 6 lines

and nearly all precedent comment can be apply to the rest of the patch

Best Regards,
J.

#46 lore raw

PATCH v2 1/1 Marvell Kirkwood family SOC support

Quoted 31 lines · Prafulla Wadaskar

Hi Jean

Thanks for your review comments.

Quoted 16 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Friday, April 17, 2009 2:52 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v2] Marvell Kirkwood family SOC support

Quoted 8 lines · Prafulla Wadaskar

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-

1) 88F6281-Z0       define CONFIG_KW88F6281_Z0
2) 88F6281-A0       define CONFIG_KW88F6281_A0
3) 88F6192-A0       define CONFIG_KW88F6192_A0
Quoted 11 lines

cpu/arm926ejs/kirkwood/dram.c line 33

Quoted 10 lines

Other supported features:-
1) get_random_hex() fucntion
2) SPI port controller driver
3) PCI Express port initialization

cpu/arm926ejs/kirkwood/dram.c new file +6 -0
+/*
+ * kw_sdram_bar - reads SDRAM Base Address Register  */
+u32 kw_sdram_bar(MEMORY_BANK bank)
+{
+	u32 result = 0;
+	u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));

please create macro for these registers

Quoted 3 lines

This will be taken care....

Quoted 1 line

please use readx/writex (madatory)

You mean instead of KW_REG_READ to be used readx() ?

readl I guess

take a look in include/arm-asm/io.h

Quoted 42 lines
Quoted 7 lines

cpu/arm926ejs/kirkwood/kwcore.c line 31

Quoted 5 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +4 -0
+
+void reset_cpu(unsigned long ignored) {
+	KW_REG_BITS_SET(KW_REG_CPU_RSTOUTN_MASK, BIT2);
+	KW_REG_BITS_SET(KW_REG_CPU_SYS_SOFT_RST, BIT0);

plase use readx/writex
everywhere

Okay...

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 4 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +4 -0
+
+#if defined (CONFIG_KW88F6281_Z0)
+	KW_REG_BITS_SET(0x1478, BIT7);
+#elif defined (CONFIG_KW88F6281_A0) || defined 

(CONFIG_KW88F6192_A0)
could you detect it

I should be able to detect it, I will check and update the same

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c line 52

Quoted 5 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +5 -0
+	/*
+	 * in case of 88F6281/88F6192 A0,
+	 * BIT7 need to reset to generate random values in 0x1470
+	 */
+	KW_REG_BITS_RESET(0x1478, BIT7);

please use macro everywhere instead of hardcode value

Okay..

Quoted 8 lines

cpu/arm926ejs/kirkwood/kwcore.c line 67

Quoted 6 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +6 -0
+
+/*
+ * kw_window_ctrl_reg_init - Mbus-L to Mbus Bridge Registers init.
+ */
+int kw_window_ctrl_reg_init(void)
+{

coudl explain a few more what you do and try use macro instead of hardcode value

Macros will be used..
I will put the explaination in the comment for this function

Quoted 5 lines
Quoted 5 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +5 -0
+	KW_REG_WRITE(KW_REG_WIN_CTRL(0), 0x0fffe841);
+	KW_REG_WRITE(KW_REG_WIN_BASE(0), 0x90000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_LOW(0), 0x90000000);
+	KW_REG_WRITE(KW_REG_WIN_REMAP_HIGH(0), 0x00000000);
+
Quoted 6 lines
Quoted 5 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+#ifndef __ASSEMBLY__
+void reset_cpu(unsigned long ignored); unsigned char 
+get_random_hex(void); typedef enum _memory_bank { BANK0, BANK1, 
+BANK2, BANK3 } MEMORY_BANK;

please do not use upper case

You mean MEMORY_BANK, right? I will change it

yes

Quoted 11 lines
Quoted 11 lines

Review

Quoted 4 lines
(quoted diff) +2 -0
+		  (TICK_SMPL_1x3 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+#define CPU_2_MBUSL_DDR_CLK_1x4				
		\

Review

Quoted 1 line
(quoted diff) +1 -0
+		 ((TICK_DRV_1x4  << 

CCR_CPU_2_MBUSL_TICK_DRV_OFFS) | \

cpu/arm926ejs/kirkwood/lowlevel_init.S line 60

Quoted 2 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +2 -0
+		  (TICK_SMPL_1x4 << CCR_CPU_2_MBUSL_TICK_SMPL_OFFS))
+

please move all this define to header corresponding of the functionallity/IP

Quoted 7 lines

I thought these are only settings limited to this file only, any way I will create and move them to header file

Quoted 4 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 63

Quoted 3 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +3 -0
+
+	.globl kw_cpu_if_pre_init
+kw_cpu_if_pre_init:

do you really need to do this before relocation

Yes..

could add comment to explain why

Quoted 14 lines
Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+
+        mov     r11, LR     		/* Save link register */

will you call a sub routine?

I will do it?

Quoted 8 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 144

Quoted 6 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +6 -0
+	.globl kw_enable_invalidate_l2_cache
+kw_enable_invalidate_l2_cache:
+        mov     r11, LR     	/* Save link register */
+
+	/* Enable L2 cache in write through mode */
+	KW_REG_READ_ASM(r4, r1, KW_REG_CPU_L2_CONFIG)

please remove thhis KW_RED_READ_ASM
or do it via asm macro as we have done for sh2/3/4

Quoted 1 line

I will check this...

attached a first version of macro.h file for arm

Quoted 16 lines
Quoted 7 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 152

Quoted 6 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +4 -0
+
+	/* invalidate L2 cache */
+	mov	r0, #0
+	mcr	p15, 1, r0, c15, c11, 0

please create a macro for this

Okay...

Quoted 7 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 156

Quoted 4 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +4 -0
+
+        mov     PC, r11         /* r11 is saved link register */
+
+        .globl lowlevel_init

in this case call it arch_lowlevel_init

Quoted 2 lines
Quoted 1 line

and update start.S to call it just be the lowlevel_init

You mean to add support for arch_lowlevel_init, using some CONFIG_ option ?

yes
CONFIG_ARCH_LOWLEVEL_INIT

Best Regards,
J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: macro.h
Type: text/x-chdr
Size: 1374 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090418/9678bb62/attachment-0001.h

#47 lore raw

PATCH v2 1/1 Marvell Kirkwood family SOC support

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	u32 enable = (0x01 & KW_REG_READ((0x1504 + bank * 8)));

please create macro for these registers

This will be taken care....

Quoted 1 line

please use readx/writex (madatory)

You mean instead of KW_REG_READ to be used readx() ?

readl I guess

take a look in include/arm-asm/io.h

I understood... Thanks

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

cpu/arm926ejs/kirkwood/lowlevel_init.S line 63

Quoted 3 lines
cpu/arm926ejs/kirkwood/lowlevel_init.S new file +3 -0
+
+	.globl kw_cpu_if_pre_init
+kw_cpu_if_pre_init:

do you really need to do this before relocation

Yes..

could add comment to explain why

Okay I will add..

Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

please remove thhis KW_RED_READ_ASM
or do it via asm macro as we have done for sh2/3/4

I will check this...

attached a first version of macro.h file for arm

Thanks ....

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

and update start.S to call it just be the lowlevel_init

You mean to add support for arch_lowlevel_init, using some

CONFIG_ option ?
yes
CONFIG_ARCH_LOWLEVEL_INIT

Okay, I will release a small separate patch for this because this will be generic to arm other SOCs too

Regards..
Prafulla . .

Quoted 4 lines

Best Regards,
J.

#48 lore raw

PATCH v3 1/1 Marvell Kirkwood family SOC support

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-
1) 88F6281-A0 define CONFIG_KW88F6281_A0
2) 88F6192-A0 define CONFIG_KW88F6192_A0

Other supported features:-
1) get_random_hex() function
2) SPI port controller driver
3) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

---
Change log:
v2: crated arch-kirkwood and moved some header files there renamed and moved spi.c to drivers/spi/
renamed and moved serial.c to drivers/serial/ doimage utility removed
soc_init.S renamed as lowlevel_init.S
debug prints removed

v3: lowlevel_init.S converted to lowlevel_init.c removed BITxx macros, removed entire assembly code Added CONFIG_ARCH_LOWLEVE_INIT support for arm926ejs core updated as per review comments for v2

 board/Marvell/include/core.h              |    4 +
 cpu/arm926ejs/kirkwood/Makefile           |   49 +++++
 cpu/arm926ejs/kirkwood/config.mk          |   25 +++
 cpu/arm926ejs/kirkwood/dram.c             |   57 ++++++
 cpu/arm926ejs/kirkwood/kwcore.c           |  304 +++++++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/kwcore.h           |  112 +++++++++++
 cpu/arm926ejs/kirkwood/lowlevel_init.c    |   93 +++++++++
 cpu/arm926ejs/kirkwood/timer.c            |  165 ++++++++++++++++
 cpu/arm926ejs/start.S                     |    7 +-
 drivers/serial/Makefile                   |    1 +
 drivers/serial/kirkwood_serial.c          |  187 ++++++++++++++++++
 drivers/spi/Makefile                      |    1 +
 drivers/spi/kirkwood_spi.c                |  199 +++++++++++++++++++
 include/asm-arm/arch-kirkwood/kirkwood.h  |  140 +++++++++++++
 include/asm-arm/arch-kirkwood/kw88f6192.h |   37 ++++
 include/asm-arm/arch-kirkwood/kw88f6281.h |   37 ++++
 include/asm-arm/config.h                  |    4 +
 17 files changed, 1421 insertions(+), 1 deletions(-)
 create mode 100644 cpu/arm926ejs/kirkwood/Makefile
 create mode 100644 cpu/arm926ejs/kirkwood/config.mk
 create mode 100644 cpu/arm926ejs/kirkwood/dram.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.h
 create mode 100644 cpu/arm926ejs/kirkwood/lowlevel_init.c
 create mode 100644 cpu/arm926ejs/kirkwood/timer.c
 create mode 100644 drivers/serial/kirkwood_serial.c
 create mode 100644 drivers/spi/kirkwood_spi.c
 create mode 100644 include/asm-arm/arch-kirkwood/kirkwood.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6192.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6281.h
board/Marvell/include/core.h +4 -0
index c413439..ecc4682 100644
@@ -12,9 +12,11 @@ space). The macros take care of Big/Little endian conversions.
 #ifndef __INCcoreh
 #define __INCcoreh
 
+#ifndef CONFIG_KIRKWOOD
 #include "mv_gen_reg.h"
 
 extern unsigned int INTERNAL_REG_BASE_ADDR;
+#endif /* CONFIG_KIRKWOOD */
 
 /****************************************/
 /*         GENERAL Definitions                 */
@@ -91,10 +93,12 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;
 #define _1G            0x40000000
 #define _2G            0x80000000
 
+#ifndef __ASSEMBLY__
 #ifndef        BOOL_WAS_DEFINED
 #define BOOL_WAS_DEFINED
 typedef enum _bool{false,true} bool;
 #endif
+#endif
 
 /* Little to Big endian conversion macros */
 
cpu/arm926ejs/kirkwood/Makefile new file +49 -0

49 lines not on this page · raw message

cpu/arm926ejs/kirkwood/config.mk new file +25 -0
new file mode 100644
index 0000000..000eeb4
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+PLATFORM_CPPFLAGS += -march=armv5te
cpu/arm926ejs/kirkwood/dram.c new file +57 -0

57 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.c new file +304 -0

304 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.h new file +112 -0

112 lines not on this page · raw message

cpu/arm926ejs/kirkwood/lowlevel_init.c new file +93 -0

93 lines not on this page · raw message

cpu/arm926ejs/kirkwood/timer.c new file +165 -0

165 lines not on this page · raw message

cpu/arm926ejs/start.S +6 -1
index ed4932a..520dcef 100644
@@ -201,7 +201,7 @@ _start_armboot:
  *
  *************************************************************************
  */
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined (CONFIG_ARCH_LOWLEVEL_INIT)
 cpu_init_crit:
        /*
         * flush v4 I/D caches
@@ -224,7 +224,12 @@ cpu_init_crit:
         * Go setup Memory and board specific bits prior to relocation.
         */
        mov     ip, lr          /* perserve link reg across call */
+#ifdef CONFIG_ARCH_LOWLEVEL_INIT
+       bl      arch_lowlevel_init      /* go setup arch specific init */
+#endif /* CONFIG_ARCH_LOWLEVEL_INIT */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
        bl      lowlevel_init   /* go setup pll,mux,memory */
+#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
        mov     lr, ip          /* restore link */
        mov     pc, lr          /* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
drivers/serial/Makefile +1 -0
index bb99a34..dd59ff8 100644
@@ -28,6 +28,7 @@ LIB   := $(obj)libserial.a
 COBJS-$(CONFIG_ARM_DCC) += arm_dcc.o
 COBJS-$(CONFIG_AT91RM9200_USART) += at91rm9200_usart.o
 COBJS-$(CONFIG_ATMEL_USART) += atmel_usart.o
+COBJS-$(CONFIG_KIRKWOOD) += kirkwood_serial.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_NS9750_UART) += ns9750_serial.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
drivers/serial/kirkwood_serial.c new file +187 -0

187 lines not on this page · raw message

drivers/spi/Makefile +1 -0
index 1350f3e..7ffa47d 100644
@@ -28,6 +28,7 @@ LIB   := $(obj)libspi.a
 COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
 COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
+COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
 COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/kirkwood_spi.c new file +199 -0

199 lines not on this page · raw message

include/asm-arm/arch-kirkwood/kirkwood.h new file +140 -0

140 lines not on this page · raw message

include/asm-arm/arch-kirkwood/kw88f6192.h new file +37 -0
new file mode 100644
index 0000000..000fc16
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6192 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_KW88F6192_H
+#define _CONFIG_KW88F6192_H
+
+/* SOC specific definations */
+#define KW88F6192_REGS_PHYS_BASE       0xf1000000
+#define KW_REGS_PHY_BASE               KW88F6192_REGS_PHYS_BASE
+
+/* TCLK Core Clock defination */
+#define CONFIG_SYS_TCLK         166000000 /* 166MHz */
+
+#endif /* _CONFIG_KW88F6192_H */
include/asm-arm/arch-kirkwood/kw88f6281.h new file +37 -0
new file mode 100644
index 0000000..270d931
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6281 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _ASM_ARCH_KW88F6281_H
+#define _ASM_ARCH_KW88F6281_H
+
+/* SOC specific definations */
+#define KW88F6281_REGS_PHYS_BASE       0xf1000000
+#define KW_REGS_PHY_BASE               KW88F6281_REGS_PHYS_BASE
+
+/* TCLK Core Clock defination*/
+#define CONFIG_SYS_TCLK         200000000 /* 200MHz */
+
+#endif /* _ASM_ARCH_KW88F6281_H */
include/asm-arm/config.h +4 -0
index 049c44e..5d52f15 100644
@@ -21,4 +21,8 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#if defined (CONFIG_KIRKWOOD)
+#include <asm-arm/arch-kirkwood/kirkwood.h>
+#endif /* CONFIG_KIRKWOOD */
+
 #endif

--
1.5.3.4

#49 lore raw

PATCH v3 1/1 Marvell Kirkwood family SOC support

Quoted 12 lines · Prafulla Wadaskar

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-
1) 88F6281-A0 define CONFIG_KW88F6281_A0
2) 88F6192-A0 define CONFIG_KW88F6192_A0

Other supported features:-
1) get_random_hex() function
2) SPI port controller driver
3) PCI Express port initialization

Quoted 6 lines

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <[email protected]

a general comment please sue tab for indentation not space

Quoted 29 lines

---
Change log:
v2: crated arch-kirkwood and moved some header files there renamed and moved spi.c to drivers/spi/
renamed and moved serial.c to drivers/serial/ doimage utility removed
soc_init.S renamed as lowlevel_init.S
debug prints removed

v3: lowlevel_init.S converted to lowlevel_init.c removed BITxx macros, removed entire assembly code Added CONFIG_ARCH_LOWLEVE_INIT support for arm926ejs core updated as per review comments for v2

 board/Marvell/include/core.h              |    4 +
 cpu/arm926ejs/kirkwood/Makefile           |   49 +++++
 cpu/arm926ejs/kirkwood/config.mk          |   25 +++
 cpu/arm926ejs/kirkwood/dram.c             |   57 ++++++
 cpu/arm926ejs/kirkwood/kwcore.c           |  304 +++++++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/kwcore.h           |  112 +++++++++++
 cpu/arm926ejs/kirkwood/lowlevel_init.c    |   93 +++++++++
 cpu/arm926ejs/kirkwood/timer.c            |  165 ++++++++++++++++
 cpu/arm926ejs/start.S                     |    7 +-
 drivers/serial/kirkwood_serial.c          |  187 ++++++++++++++++++
 drivers/spi/Makefile                      |    1 +
 drivers/spi/kirkwood_spi.c                |  199 +++++++++++++++++++
 include/asm-arm/arch-kirkwood/kirkwood.h  |  140 +++++++++++++
 include/asm-arm/arch-kirkwood/kw88f6192.h |   37 ++++
 include/asm-arm/arch-kirkwood/kw88f6281.h |   37 ++++

cpu/arm926ejs/kirkwood/kwcore.c line 278

Quoted 9 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +9 -0
+       } else
+               temp &= ~1<<4;
+       writel(KW_REG_CPU_L2_CONFIG, temp);
+
+       /* L2Cache settings */
+       asm("mrc p15, 1, %0, c15, c1, 0":"=r"(temp));
+
+       /* Disable L2C pre fetch - Set bit 24 */
+       env = getenv("disL2Prefetch");

sorry I've forget about it precedently btw please add a doc about all this env var

cpu/arm926ejs/kirkwood/kwcore.c line 291

Quoted 13 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +13 -0
+       if (env && ((strcmp(env, "no") == 0) || (strcmp(env, "No") == 0)))
+               temp &= ~1<<24;
+       else
+               temp |= 1<<24;
+
+       /* enable L2C - Set bit 22 */
+       env = getenv("disL2Cache");
+       if (!env || ((strcmp(env, "no") == 0) || (strcmp(env, "No") == 0)))
+               temp |= 1<<22;
+       else
+               temp &= ~1<<22;
+
+       asm("mcr p15, 1, %0, c15, c1, 0": :"r"(temp));

please use set/get_cr

cpu/arm926ejs/kirkwood/kwcore.c line 293

Quoted 2 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +2 -0
+
+       /* Enable i cache */

we have a cache management framework now
please take a look on the lib_arm/cache-cp15.c

Quoted 16 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +11 -0
+       asm("mrc p15, 0, %0, c1, c0, 0":"=r"(temp));
+       temp |= 1<<12;
+       asm("mcr p15, 0, %0, c1, c0, 0": :"r"(temp));
+       /* Change reset vector to address 0x0 */
+       asm("mrc p15, 0, %0, c1, c0, 0":"=r"(temp));
+       temp &= ~1<<13;
+       asm("mcr p15, 0, %0, c1, c0, 0": :"r"(temp));
+
+       return (0);
+}
+
cpu/arm926ejs/kirkwood/kwcore.h new file +0 -0
new file mode 100644
index 0000000..feec86b

cpu/arm926ejs/kirkwood/kwcore.h line 86

Quoted 9 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +9 -0
+       asm volatile("mcr p15, 1, %0, c15, c1, 0        @ writefr exfr"
+         : : "r" (val) : "cc");
+       isb();
+}
+
+/*
+ * Invalidate L2 Cache using co-proc instruction
+ */
+static inline void invalidate_l2_cache(void)

we need to have the same api for l2_cache management so please add it in include/asm-arm/cache.h

Quoted 46 lines
cpu/arm926ejs/kirkwood/kwcore.h new file +26 -0
+{
+       unsigned int val=0;
+
+       asm volatile("mcr p15, 1, %0, c15, c11, 0       @ invl l2 cache"
+         : : "r" (val) : "cc");
+       isb();
+}
+
+/*
+ * functions
+ */
+void reset_cpu(unsigned long ignored);
+unsigned char get_random_hex(void);
+unsigned int kw_sdram_bar(enum memory_bank bank);
+unsigned int kw_sdram_bs(enum memory_bank bank);
+int kw_window_ctrl_reg_init(void);
+void kw_gpio_init(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
+                 unsigned int gpp0_oe, unsigned int gpp1_oe);
+int kw_mpp_control_init(unsigned int mpp0_7, unsigned int mpp8_15,
+                       unsigned int mpp16_23, unsigned int mpp24_31,
+                       unsigned int mpp32_39, unsigned int mpp40_47,
+                       unsigned int mpp48_55);
+int kw_misc_init_r(void);
+#endif /* __ASSEMBLY__ */
+
+#endif /* _KWCORE_H */
cpu/arm926ejs/kirkwood/lowlevel_init.c new file +14 -0
new file mode 100644
index 0000000..21bfc81
@@ -0,0 +1,93 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,

cpu/arm926ejs/kirkwood/lowlevel_init.c line 24

Quoted 10 lines
cpu/arm926ejs/kirkwood/lowlevel_init.c new file +10 -0
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+

I'm not a fan of c init but if you prefer ok

cpu/arm926ejs/kirkwood/timer.c

Quoted 37 lines
cpu/arm926ejs/kirkwood/lowlevel_init.c new file +30 -0
+#include <config.h>
+
+void kw_cpu_if_pre_init(void)
+{
+       u32 reg;
+
+#ifdef CONFIG_KIRKWOOD_RGMII_PAD_1V8
+       /*
+        * Configures the I/O voltage of the pads connected to Egigabit
+        * Ethernet interface to 1.8V
+        * By defult it is set to 3.3V
+        */
+       reg = readl(KW_REG_MPP_OUT_DRV_REG);
+       reg |= 1 << 7;
+       writel(KW_REG_MPP_OUT_DRV_REG, &reg);
+#endif
+#ifdef CONFIG_KIRKWOOD_EGIGA_INIT
+       /*
+        * Set egiga port0/1 in normal functional mode
+        * This is required becasue on kirkwood by default ports are in reset mode
+        * OS egiga driver may not have provision to set them in normal mode
+        * and if u-boot is build without network support, network may fail at OS level
+        */
+       reg = readl((KW_EGIGA0_BASE + 0x44c));  /* PORT_SERIAL_CONTROL1_REG */
+       reg &= ~(1 << 4);       /* Clear PortReset Bit */
+       writel((KW_EGIGA0_BASE + 0x44c), &reg); /* PORT_SERIAL_CONTROL1_REG */
 
+        * so must be done prior to DDR operation
+        */
+       kw_cpu_if_pre_init();
+}
cpu/arm926ejs/kirkwood/timer.c new file +0 -0
new file mode 100644
index 0000000..c6e1a26
@@ -0,0 +1,165 @@

as I've ask for the ARM925T timer update please provice the precision and resolution on you timer in the code

Quoted 22 lines
cpu/arm926ejs/kirkwood/timer.c new file +22 -0
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */

cpu/arm926ejs/kirkwood/timer.c line 32

Quoted 10 lines
cpu/arm926ejs/kirkwood/timer.c new file +10 -0
+
+#include <common.h>
+
+#define UBOOT_CNTR     0       /* counter to use for uboot timer */
+
+/*
+ * ARM Timers Registers Map
+ */
+#define CNTMR_CTRL_REG                 KW_REG_TMR_CTRL
+#define CNTMR_RELOAD_REG(tmrnum)       (KW_REG_TMR_RELOAD + tmrnum*8)

please add a space before and after the '*'
and so on

Quoted 28 lines
cpu/arm926ejs/kirkwood/timer.c new file +28 -0
+#define CNTMR_VAL_REG(tmrnum)          (KW_REG_TMR_VAL + tmrnum*8)
+
+/*
+ * ARM Timers Control Register
+ * CPU_TIMERS_CTRL_REG (CTCR)
+ */
+#define TIMER0_NUM                             0
+#define TIMER1_NUM                             1
+#define WATCHDOG_NUM                           2
+
+#define CTCR_ARM_TIMER_EN_OFFS(cntr)           (cntr * 2)
+#define CTCR_ARM_TIMER_EN_MASK(cntr)           (1 << CTCR_ARM_TIMER_EN_OFFS)
+#define CTCR_ARM_TIMER_EN(cntr)                        (1 << CTCR_ARM_TIMER_EN_OFFS(cntr))
+#define CTCR_ARM_TIMER_DIS(cntr)               (0 << CTCR_ARM_TIMER_EN_OFFS(cntr))
+
+#define CTCR_ARM_TIMER_AUTO_OFFS(cntr) ((cntr * 2) + 1)
+#define CTCR_ARM_TIMER_AUTO_MASK(cntr) 1<<1
+#define CTCR_ARM_TIMER_AUTO_EN(cntr)   (1 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
+#define CTCR_ARM_TIMER_AUTO_DIS(cntr)  (0 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
+
+/*
+ * ARM Timer\Watchdog Reload Register
+ * CNTMR_RELOAD_REG (TRR)
+ */
+#define TRG_ARM_TIMER_REL_OFFS                 0
+#define TRG_ARM_TIMER_REL_MASK                 0xffffffff
+
+/*

cpu/arm926ejs/kirkwood/timer.c line 70

Quoted 10 lines
cpu/arm926ejs/kirkwood/timer.c new file +10 -0
+ * ARM Timer\Watchdog Register
+ * CNTMR_VAL_REG (TVRG)
+ */
+#define TVR_ARM_TIMER_OFFS                     0
+#define TVR_ARM_TIMER_MASK                     0xffffffff
+#define TVR_ARM_TIMER_MAX                      0xffffffff
+#define TIMER_LOAD_VAL                                 0xffffffff
+
+/* This enumerator describe counters\watchdog numbers       */
+typedef enum _kwCntmrID {

please no Uppercase

cpu/arm926ejs/kirkwood/timer.c line 76

Quoted 6 lines
cpu/arm926ejs/kirkwood/timer.c new file +6 -0
+       TIMER0 = 0,
+       TIMER1,
+       WATCHDOG
+} KW_CNTMR_ID;
+
+#define READ_TIMER     (readl(CNTMR_VAL_REG(UBOOT_CNTR))/(CONFIG_SYS_TCLK/1000))

please add a space before and after the '/'

Quoted 55 lines
cpu/arm926ejs/kirkwood/timer.c new file +49 -0
+static ulong timestamp;
+static ulong lastdec;
+
+void reset_timer_masked(void)
+{
+       /* reset time */
+       lastdec = READ_TIMER;
+       timestamp = 0;
+}
+
+ulong get_timer_masked(void)
+{
+       ulong now = READ_TIMER;
+
+       if (lastdec >= now) {
+               /* normal mode */
+               timestamp += lastdec - now;
+       } else {
+               /* we have an overflow ... */
+               timestamp +=
+                   lastdec + (TIMER_LOAD_VAL / (CONFIG_SYS_TCLK / 1000)) - now;
+       }
+       lastdec = now;
+
+       return timestamp;
+}
+
+void reset_timer(void)
+{
+       reset_timer_masked();
+}
+
+ulong get_timer(ulong base)
+{
+       return get_timer_masked() - base;
+}
+
+void set_timer(ulong t)
+{
+       timestamp = t;
+}
+
+void udelay(unsigned long usec)
+{
+       uint current;
+       ulong delayticks;
+
+       current = readl(CNTMR_VAL_REG(UBOOT_CNTR));
 
+}
cpu/arm926ejs/start.S +0 -0
index ed4932a..520dcef 100644

cpu/arm926ejs/start.S _start_armboot: · line 204

Quoted 5 lines
cpu/arm926ejs/start.S +1 -1
@@ -201,7 +201,7 @@ _start_armboot:
  *
  *************************************************************************
  */
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined (CONFIG_ARCH_LOWLEVEL_INIT)

we will call the ARCH_LOWLEVEL_INIT only if we do not skip the the LOWLEVEL INIT

Quoted 21 lines
cpu/arm926ejs/start.S +5 -0
 cpu_init_crit:
        /*
         * flush v4 I/D caches
@@ -224,7 +224,12 @@ cpu_init_crit:
         * Go setup Memory and board specific bits prior to relocation.
         */
        mov     ip, lr          /* perserve link reg across call */
+#ifdef CONFIG_ARCH_LOWLEVEL_INIT
+       bl      arch_lowlevel_init      /* go setup arch specific init */
+#endif /* CONFIG_ARCH_LOWLEVEL_INIT */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
        bl      lowlevel_init   /* go setup pll,mux,memory */
+#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
        mov     lr, ip          /* restore link */
        mov     pc, lr          /* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
drivers/serial/Makefile +0 -0
index bb99a34..dd59ff8 100644

drivers/serial/Makefile LIB := $(obj)libserial.a · line 31

Quoted 4 lines
drivers/serial/Makefile +1 -0
@@ -28,6 +28,7 @@ LIB   := $(obj)libserial.a
 COBJS-$(CONFIG_ARM_DCC) += arm_dcc.o
 COBJS-$(CONFIG_AT91RM9200_USART) += at91rm9200_usart.o
 COBJS-$(CONFIG_ATMEL_USART) += atmel_usart.o
+COBJS-$(CONFIG_KIRKWOOD) += kirkwood_serial.o

please use the same CONFIG_ as the kernel

Quoted 59 lines
drivers/serial/Makefile +0 -0
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_NS9750_UART) += ns9750_serial.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
drivers/serial/kirkwood_serial.c new file +50 -0
new file mode 100644
index 0000000..6422ab2
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+
+/* registers feilds */
+#define FCR_FIFO_EN            1<<0    /* fifo enable */
+#define FCR_RXSR               1<<1    /* receiver soft reset */
+#define FCR_TXSR               1<<2    /* transmitter soft reset */
+#define MCR_RTS                1<<1    /* ready to send */
+
+#define LCR_WLS_OFFS           0
+#define LCR_WLS_MASK           0x3 << LCR_WLS_OFFS     /* character length mask  */
+#define LCR_WLS_5              0x0 << LCR_WLS_OFFS     /* 5 bit character length */
+#define LCR_WLS_6              0x1 << LCR_WLS_OFFS     /* 6 bit character length */
+#define LCR_WLS_7              0x2 << LCR_WLS_OFFS     /* 7 bit character length */
+#define LCR_WLS_8              0x3 << LCR_WLS_OFFS     /* 8 bit character length */
+#define LCR_STP_OFFS           2
+#define LCR_1_STB              0x0 << LCR_STP_OFFS     /* Number of stop Bits */
+#define LCR_2_STB              0x1 << LCR_STP_OFFS     /* Number of stop Bits */
+#define LCR_PEN                0x8     /* Parity enable */
+#define LCR_PS_OFFS            4
+#define LCR_EPS                0x1 << LCR_PS_OFFS      /* Even Parity Select */
+#define LCR_OPS                0x0 << LCR_PS_OFFS      /* Odd Parity Select */
+#define LCR_SBRK_OFFS          0x6
+#define LCR_SBRK               0x1 << LCR_SBRK_OFFS    /* Set Break */
+#define LCR_DIVL_OFFS          7
+#define LCR_DIVL_EN                    0x1 << LCR_DIVL_OFFS    /* Divisior latch enable */
+
+#define LSR_DR                 1<<0    /* Data ready */

drivers/serial/kirkwood_serial.c line 60

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+#define LSR_OE                 1<<1    /* Overrun */
+#define LSR_PE                 1<<2    /* Parity error */
+#define LSR_FE                 1<<3    /* Framing error */
+#define LSR_BI                 1<<4    /* Break */
+#define LSR_THRE               1<<5    /* Xmit holding register empty */
+#define LSR_TEMT               1<<6    /* Xmitter empty */
+#define LSR_ERR                1<<7    /* Error */
+
+/* useful defaults for LCR*/
+#define LCR_8N1                LCR_WLS_8 | LCR_1_STB

please move this macro to a header
as include/asm/arch/serial.h as example

Quoted 44 lines
drivers/serial/kirkwood_serial.c new file +44 -0
+
+/* This structure describes the registers offsets for one UART port/channel */
+typedef struct kwUartPort {
+       u8 rbr;                 /* 0 = 0-3 */
+       u8 pad1[3];
+       u8 ier;                 /* 1 = 4-7 */
+       u8 pad2[3];
+       u8 fcr;                 /* 2 = 8-b */
+       u8 pad3[3];
+       u8 lcr;                 /* 3 = c-f */
+       u8 pad4[3];
+       u8 mcr;                 /* 4 = 10-13 */
+       u8 pad5[3];
+       u8 lsr;                 /* 5 = 14-17 */
+       u8 pad6[3];
+       u8 msr;                 /* 6 =18-1b */
+       u8 pad7[3];
+       u8 scr;                 /* 7 =1c-1f */
+       u8 pad8[3];
+} kw_uart_port;
+
+/* aliases - for registers which has the same offsets */
+#define thr rbr
+#define iir fcr
+#define dll rbr
+#define dlm ier
+
+/* static variables */
+#if defined (CONFIG_CONS_INDEX)        /* comes from board config */
+#if (CONFIG_CONS_INDEX == 0 )
+static volatile kw_uart_port *p_uart_port = (void *)KW_REGISTER(KW_UART0_BASE);
+#elif (CONFIG_CONS_INDEX == 1 )
+static volatile kw_uart_port *p_uart_port = (void *)KW_REGISTER(KW_UART1_BASE);
+#endif
+#else
+#error CONFIG_CONS_INDEX not defined correctly
+#endif
+
+#define CONFIG_KW_UART_PORTS   { (void *)KW_UART0_BASE, \
+                                 (void *)KW_UART1_BASE }
+
+/*
+ * Serial init banner is kept simplest one
+ * if required can be created good one

drivers/serial/kirkwood_serial.c line 114

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+ */
+int serial_init(void)
+{
+       serial_setbrg();
+       printf
+           ("\n*************************************************************");
+       return (0);
+}
+
+void kwUartPutc(u8 c)

please no upper case
and please add static, this function is not use outside

Quoted 51 lines
drivers/serial/kirkwood_serial.c new file +50 -0
+{
+       while ((p_uart_port->lsr & LSR_THRE) == 0) ;
+       p_uart_port->thr = c;
+       return;
+}
+
+void serial_putc(const char c)
+{
+       if (c == '\n')
+               kwUartPutc('\r');
+
+       kwUartPutc(c);
+}
+
+int serial_getc(void)
+{
+       while ((p_uart_port->lsr & LSR_DR) == 0) ;
+       return (p_uart_port->rbr);
+}
+
+int serial_tstc(void)
+{
+       return ((p_uart_port->lsr & LSR_DR) != 0);
+}
+
 
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Derived from drivers/spi/mpc8xxx_spi.c
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>

drivers/serial/kirkwood_serial.c

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+#include <malloc.h>
+#include <spi.h>
+
+/* SPI Registers on kirkwood SOC */
+#define KW_REG_SPI_CTRL                (0x10600)
+#define KW_REG_SPI_CONFIG      (0x10604)
+#define KW_REG_SPI_DATA_OUT    (0x10608)
+#define KW_REG_SPI_DATA_IN     (0x1060c)
+#define KW_REG_SPI_IRQ_CAUSE   (0x10610)
+#define KW_REG_SPI_IRQ_MASK    (0x10614)

please move this to a header
include/asm/arch/spi.h as example

Quoted 59 lines
drivers/serial/kirkwood_serial.c new file +59 -0
+
+#define KW_SPI_TIMEOUT         10000
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+                                 unsigned int max_hz, unsigned int mode)
+{
+       struct spi_slave *slave;
+       u32 data;
+
+       if (!spi_cs_is_valid(bus, cs))
+               return NULL;
+
+       slave = malloc(sizeof(struct spi_slave));
+       if (!slave)
+               return NULL;
+
+       slave->bus = bus;
+       slave->cs = cs;
+
+       writel(KW_REG_SPI_CTRL, 0x00000002);
+       /* program spi clock prescaller using max_hz */
+       data = ((CONFIG_SYS_TCLK / 2) / max_hz) & 0x0000000f;
+       debug("data = 0x%08x \n", data);
+       writel(KW_REG_SPI_CONFIG, 0x00000210 | data);
+       writel(KW_REG_SPI_IRQ_CAUSE, 0x00000001);
+       writel(KW_REG_SPI_IRQ_MASK, 0x00000000);
+
+       /* program mpp registers to select  SPI_CSn */
+       if (cs)
+               writel(KW_REG_MPP_CONTROL0,
+                            ((readl(KW_REG_MPP_CONTROL0) & 0x0fffffff) |
+                             0x20000000));
+       else
+               writel(KW_REG_MPP_CONTROL0,
+                            ((readl(KW_REG_MPP_CONTROL0) & 0xfffffff0) |
+                             0x00000002));
+
+       return slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+       free(slave);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+       return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+}
+
+#ifndef CONFIG_SPI_CS_IS_VALID
+/*
+ * you can define this function board specific
+ * define above CONFIG in board specific config file and
+ * provide the function in board specific src file

drivers/serial/kirkwood_serial.c

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+ */
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+       return (bus == 0 && (cs == 0 || cs == 1));
+}
+#endif
+
+void spi_cs_activate(struct spi_slave *slave)
+{
+       writel_set_bits(KW_REG_SPI_CTRL, 1<<0);

I prefer writel(t, readl(t) |?1);

drivers/serial/kirkwood_serial.c

Quoted 5 lines
drivers/serial/kirkwood_serial.c new file +5 -0
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       writel_reset_bits(KW_REG_SPI_CTRL, 1<<0);

please add a space before and after '<<'

drivers/serial/kirkwood_serial.c

Quoted 7 lines
drivers/serial/kirkwood_serial.c new file +7 -0
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
+            void *din, unsigned long flags)
+{
+       unsigned int tmpdout, tmpdin;
+       int tm, isRead = 0;

please no upper case

Quoted 5 lines
drivers/serial/kirkwood_serial.c new file +5 -0
+
+       debug("spi_xfer: slave %u:%u dout %08X din %08X bitlen %u\n",
+                   slave->bus, slave->cs, dout, din, bitlen);
+
+       if (flags & SPI_XFER_BEGIN)

drivers/serial/kirkwood_serial.c

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+               spi_cs_activate(slave);
+
+       /*
+        * handle data in 8-bit chunks
+        * TBD: 2byte xfer mode to be enabled
+        */
+       while (bitlen > 4) {
+               debug("loopstart bitlen %d\n", bitlen);
+               tmpdout = 0;
+               if (1) {        //bitlen <= 8) {

please no dead code

Quoted 57 lines
drivers/serial/kirkwood_serial.c new file +57 -0
+                       /*1 byte xfer mode */
+                       writel_reset_bits(KW_REG_SPI_CONFIG, 1<<5);
+                       /* Shift data so it's msb-justified */
+                       if (dout) {
+                               tmpdout = *(u32 *) dout & 0x0ff;
+                       }
+               } else {
+                       /*2 byte xfer mode */
+                       writel_set_bits(KW_REG_SPI_CONFIG, 1<<5);
+                       /* Shift data so it's msb-justified */
+                       if (dout) {
+                               tmpdout = *(u32 *) dout & 0x0ffff;
+                       }
+               }
+
+               writel(KW_REG_SPI_IRQ_CAUSE, 0x0);      /* clear bit */
+               writel(KW_REG_SPI_DATA_OUT, tmpdout);   /* Write the data out */
+               debug("*** spi_xfer: ... %08x written, bitlen %d\n",
+                           tmpdout, bitlen);
+
+               /*
+                * Wait for SPI transmit to get out
+                * or time out (1 second = 1000 ms)
+                * The NE event must be read and cleared first
+                */
+               for (tm = 0, isRead = 0; tm < KW_SPI_TIMEOUT; ++tm) {
+                       if (readl(KW_REG_SPI_IRQ_CAUSE)) {
+                               isRead = 1;
+                               tmpdin = readl(KW_REG_SPI_DATA_IN);
+                               debug
+                                   ("*** spi_xfer: din %08X ... %08x read\n",
+                                    din, tmpdin);
+
+                               if (1) {        //bitlen <= 8) {
+                                       if (din) {
+                                               *((u8 *) din) = (u8) tmpdin;
+                                               din += 1;
+                                       }
+                                       if (dout)
+                                               dout += 1;
+                                       bitlen -= 8;
+                               } else {
+                                       if (din) {
+                                               *((u16 *) din) = (u16) tmpdin;
+                                               din += 1;
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA

drivers/serial/kirkwood_serial.c

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+ */
+
+#ifndef _ASM_ARCH_KIRKWOOD_H
+#define _ASM_ARCH_KIRKWOOD_H
+
+#if defined (__ARMEL__)
+#define LE
+#else
+#define BE
+#endif /* __ARMEL__ */

no need please remove

Quoted 43 lines
drivers/serial/kirkwood_serial.c new file +43 -0
+
+#ifndef __ASSEMBLY__
+#include <asm-arm/types.h>
+#endif /* __ASSEMBLY__ */
+#include <../board/Marvell/include/core.h>
+
+#if defined (CONFIG_FEROCEON_88FR131) || defined (CONFIG_SHEEVA_88SV131)
+#if defined (CONFIG_KIRKWOOD)
+#include <../cpu/arm926ejs/kirkwood/kwcore.h>
+
+/* SOC specific definations */
+#define INTREG_BASE                    0xd0000000
+#define KW_REGISTER(x)                 (KW_REGS_PHY_BASE | x)
+#define KW_OFFSET_REG                  (INTREG_BASE | 0x20080)
+
+#define KW_UART0_BASE                  (0x12000)       /* UArt 0 */
+#define KW_UART1_BASE                  (0x13000)       /* UArt 1 */
+
+/* Controler environment registers offsets */
+#define KW_REG_MPP_CONTROL0            (0x10000)
+#define KW_REG_MPP_CONTROL1            (0x10004)
+#define KW_REG_MPP_CONTROL2            (0x10008)
+#define KW_REG_MPP_CONTROL3            (0x1000C)
+#define KW_REG_MPP_CONTROL4            (0x10010)
+#define KW_REG_MPP_CONTROL5            (0x10014)
+#define KW_REG_MPP_CONTROL6            (0x10018)
+#define KW_REG_MPP_SMPL_AT_RST         (0x10030)
+#define KW_REG_DEVICE_ID               (0x10034)
+#define KW_REG_MPP_OUT_DRV_REG         (0x100E0)
+
+#define KW_REG_GPP0_DATA_OUT           (0x10100)
+#define KW_REG_GPP0_DATA_OUT_EN                (0x10104)
+#define KW_REG_GPP0_BLINK_EN           (0x10108)
+#define KW_REG_GPP0_DATA_IN_POL                (0x1010C)
+#define KW_REG_GPP0_DATA_IN            (0x10110)
+#define KW_REG_GPP0_INT_CAUSE          (0x10114)
+#define KW_REG_GPP0_INT_MASK           (0x10118)
+#define KW_REG_GPP0_INT_LVL            (0x1011c)
+
+#define KW_REG_GPP1_DATA_OUT           (0x10140)
+#define KW_REG_GPP1_DATA_OUT_EN                (0x10144)
+#define KW_REG_GPP1_BLINK_EN           (0x10148)
+#define KW_REG_GPP1_DATA_IN_POL                (0x1014C)

drivers/serial/kirkwood_serial.c

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+#define KW_REG_GPP1_DATA_IN            (0x10150)
+#define KW_REG_GPP1_INT_CAUSE          (0x10154)
+#define KW_REG_GPP1_INT_MASK           (0x10158)
+#define KW_REG_GPP1_INT_LVL            (0x1015c)
+
+#define KW_REG_NAND_READ_PARAM         (0x10418)
+#define KW_REG_NAND_WRITE_PARAM                (0x1041c)
+#define KW_REG_NAND_CTRL               (0x10470)
+
+#define KW_REG_WIN_CTRL(x)             (0x20000+(x*0x10))

please add a space before and after '+' '*'

Quoted 18 lines
drivers/serial/kirkwood_serial.c new file +18 -0
+#define KW_REG_WIN_BASE(x)             (0x20004+(x*0x10))
+#define KW_REG_WIN_REMAP_LOW(x)                (0x20008+(x*0x10))
+#define KW_REG_WIN_REMAP_HIGH(x)       (0x2000c+(x*0x10))
+
+#define KW_REG_CPU_CONFIG              (0x20100)
+#define KW_REG_CPU_CTRL_STAT           (0x20104)
+#define KW_REG_CPU_RSTOUTN_MASK                (0x20108)
+#define KW_REG_CPU_SYS_SOFT_RST                (0x2010C)
+#define KW_REG_CPU_AHB_MBUS_CAUSE_INT  (0x20110)
+#define KW_REG_CPU_AHB_MBUS_MASK_INT   (0x20114)
+#define KW_REG_CPU_FTDLL_CONFIG                (0x20120)
+#define KW_REG_CPU_L2_CONFIG           (0x20128)
+#define KW_REG_L2_RAM_TIMING0          (0x20134)
+#define KW_REG_L2_RAM_TIMING1          (0x20138)
+
+#define KW_REG_TMR_CTRL                        (0x20300)
+#define KW_REG_TMR_RELOAD              (0x20310)
+#define KW_REG_TMR_VAL                 (0x20314)

drivers/serial/kirkwood_serial.c

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+
+#define KW_REG_PCIE_BASE               (0x40000)
+
+/*
+ * Macros
+ * CPU architecture dependent I/O read/write
+ */
+#define writel(addr, data)     \
+    (*((volatile unsigned int*)(KW_REGISTER(addr))) \
+                = (unsigned int)WORD_SWAP((data)))

no need please use generic arm/io.h (mandatory)

Quoted 5 lines
drivers/serial/kirkwood_serial.c new file +5 -0
+
+#define readl(addr)            \
+    (WORD_SWAP(*((volatile unsigned int*)(KW_REGISTER(addr)))))
+
+#define writel_set_bits(adr, bits)     (writel(adr, readl(adr)\

drivers/serial/kirkwood_serial.c

Quoted 10 lines
drivers/serial/kirkwood_serial.c new file +10 -0
+                                       | ((unsigned int)WORD_SWAP(bits))))
+
+#define writel_reset_bits(adr, bits)   (writel(adr, readl(adr)\
+                                       & ~((unsigned int)WORD_SWAP(bits))))
+
+/*
+ * Error codes
+ */
+#define KW_ERROR       (-1)
+#define KW_OK          (0)

no need please remove

Quoted 1 line

+

Best Regards,
J.

#50 lore raw

PATCH v4 1/1 Marvell Kirkwood family SOC support

Kirkwood family controllers are highly integrated SOCs based on Feroceon-88FR131/Sheeva-88SV131 cpu core.

SOC versions supported:-
1) 88F6281-A0 define CONFIG_KW88F6281_A0
2) 88F6192-A0 define CONFIG_KW88F6192_A0

Other supported features:-
1) get_random_hex() fucntion
2) SPI port controller driver
3) PCI Express port initialization

Contributors:
Yotam Admon <[email protected]>
Michael Blostein <michaelbl at marvell.com

---
Change log:
v2: crated arch-kirkwood and moved some header files there renamed and moved spi.c to drivers/spi/
renamed and moved serial.c to drivers/serial/ doimage utility removed
soc_init.S renamed as lowlevel_init.S
debug prints removed

v3: lowlevel_init.S converted to lowlevel_init.c removed BITxx macros, removed entire assembly code Added CONFIG_ARCH_LOWLEVE_INIT support for arm926ejs core updated as per review commens for v2

v4: updated as per review comments for v3 print_cpuinfo used to display Soc info arch_misc_init support created and used for lib_arm mandatory readl/write macros used
asm/cache.h asm/arch/spi.h asm//arch/serial.h created and used

 cpu/arm926ejs/kirkwood/Makefile           |   50 +++++
 cpu/arm926ejs/kirkwood/config.mk          |   25 +++
 cpu/arm926ejs/kirkwood/dram.c             |   57 ++++++
 cpu/arm926ejs/kirkwood/kwcore.c           |  284 +++++++++++++++++++++++++++++
 cpu/arm926ejs/kirkwood/kwcore.h           |   99 ++++++++++
 cpu/arm926ejs/kirkwood/lowlevel_init.S    |   43 +++++
 cpu/arm926ejs/kirkwood/timer.c            |  159 ++++++++++++++++
 cpu/arm926ejs/start.S                     |    9 +-
 drivers/serial/Makefile                   |    1 +
 drivers/serial/kirkwood_serial.c          |  128 +++++++++++++
 drivers/spi/Makefile                      |    1 +
 drivers/spi/kirkwood_spi.c                |  167 +++++++++++++++++
 include/asm-arm/arch-kirkwood/kirkwood.h  |  118 ++++++++++++
 include/asm-arm/arch-kirkwood/kw88f6192.h |   37 ++++
 include/asm-arm/arch-kirkwood/kw88f6281.h |   37 ++++
 include/asm-arm/arch-kirkwood/serial.h    |   89 +++++++++
 include/asm-arm/arch-kirkwood/spi.h       |   39 ++++
 include/asm-arm/cache.h                   |   49 +++++
 include/asm-arm/config.h                  |    4 +
 include/common.h                          |    1 +
 lib_arm/board.c                           |    4 +
 21 files changed, 1399 insertions(+), 2 deletions(-)
 create mode 100644 cpu/arm926ejs/kirkwood/Makefile
 create mode 100644 cpu/arm926ejs/kirkwood/config.mk
 create mode 100644 cpu/arm926ejs/kirkwood/dram.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.c
 create mode 100644 cpu/arm926ejs/kirkwood/kwcore.h
 create mode 100644 cpu/arm926ejs/kirkwood/lowlevel_init.S
 create mode 100644 cpu/arm926ejs/kirkwood/timer.c
 create mode 100644 drivers/serial/kirkwood_serial.c
 create mode 100644 drivers/spi/kirkwood_spi.c
 create mode 100644 include/asm-arm/arch-kirkwood/kirkwood.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6192.h
 create mode 100644 include/asm-arm/arch-kirkwood/kw88f6281.h
 create mode 100644 include/asm-arm/arch-kirkwood/serial.h
 create mode 100644 include/asm-arm/arch-kirkwood/spi.h
 create mode 100644 include/asm-arm/cache.h
cpu/arm926ejs/kirkwood/Makefile new file +50 -0
new file mode 100644
index 0000000..781a3c6
@@ -0,0 +1,50 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).a
+
+COBJS-y	= dram.o
+COBJS-y	+= kwcore.o
+COBJS-y	+= timer.o
+
+SOBJS	= lowlevel_init.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS-y))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
cpu/arm926ejs/kirkwood/config.mk new file +25 -0
new file mode 100644
index 0000000..000eeb4
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+PLATFORM_CPPFLAGS += -march=armv5te
cpu/arm926ejs/kirkwood/dram.c new file +57 -0

57 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.c new file +284 -0

284 lines not on this page · raw message

cpu/arm926ejs/kirkwood/kwcore.h new file +99 -0

99 lines not on this page · raw message

cpu/arm926ejs/kirkwood/lowlevel_init.S new file +43 -0

43 lines not on this page · raw message

cpu/arm926ejs/kirkwood/timer.c new file +159 -0

159 lines not on this page · raw message

cpu/arm926ejs/start.S +7 -2
index ed4932a..bdbb7e0 100644
@@ -139,7 +139,7 @@ reset:
 	 * we do sys-critical inits only at reboot,
 	 * not when booting from ram!
 	 */
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined (CONFIG_ARCH_LOWLEVEL_INIT)
 	bl	cpu_init_crit
 #endif
 
@@ -201,7 +201,7 @@ _start_armboot:
  *
  *************************************************************************
  */
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined (CONFIG_ARCH_LOWLEVEL_INIT)
 cpu_init_crit:
 	/*
 	 * flush v4 I/D caches
@@ -224,7 +224,12 @@ cpu_init_crit:
 	 * Go setup Memory and board specific bits prior to relocation.
 	 */
 	mov	ip, lr		/* perserve link reg across call */
+#ifdef CONFIG_ARCH_LOWLEVEL_INIT
+	bl	arch_lowlevel_init	/* go setup arch specific init */
+#endif /* CONFIG_ARCH_LOWLEVEL_INIT */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
 	bl	lowlevel_init	/* go setup pll,mux,memory */
+#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
 	mov	lr, ip		/* restore link */
 	mov	pc, lr		/* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
drivers/serial/Makefile +1 -0
index bb99a34..8003447 100644
@@ -28,6 +28,7 @@ LIB	:= $(obj)libserial.a
 COBJS-$(CONFIG_ARM_DCC) += arm_dcc.o
 COBJS-$(CONFIG_AT91RM9200_USART) += at91rm9200_usart.o
 COBJS-$(CONFIG_ATMEL_USART) += atmel_usart.o
+COBJS-$(CONFIG_KIRKWOOD_SERIAL) += kirkwood_serial.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_NS9750_UART) += ns9750_serial.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
drivers/serial/kirkwood_serial.c new file +128 -0

128 lines not on this page · raw message

drivers/spi/Makefile +1 -0
index 1350f3e..7ffa47d 100644
@@ -28,6 +28,7 @@ LIB	:= $(obj)libspi.a
 COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
 COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
+COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
 COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/kirkwood_spi.c new file +167 -0

167 lines not on this page · raw message

include/asm-arm/arch-kirkwood/kirkwood.h new file +118 -0

118 lines not on this page · raw message

include/asm-arm/arch-kirkwood/kw88f6192.h new file +37 -0
new file mode 100644
index 0000000..000fc16
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6192 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_KW88F6192_H
+#define _CONFIG_KW88F6192_H
+
+/* SOC specific definations */
+#define KW88F6192_REGS_PHYS_BASE	0xf1000000
+#define KW_REGS_PHY_BASE		KW88F6192_REGS_PHYS_BASE
+
+/* TCLK Core Clock defination */
+#define CONFIG_SYS_TCLK         166000000 /* 166MHz */
+
+#endif /* _CONFIG_KW88F6192_H */
include/asm-arm/arch-kirkwood/kw88f6281.h new file +37 -0
new file mode 100644
index 0000000..270d931
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Header file for Feroceon CPU core 88FR131 Based KW88F6281 SOC.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _ASM_ARCH_KW88F6281_H
+#define _ASM_ARCH_KW88F6281_H
+
+/* SOC specific definations */
+#define KW88F6281_REGS_PHYS_BASE	0xf1000000
+#define KW_REGS_PHY_BASE		KW88F6281_REGS_PHYS_BASE
+
+/* TCLK Core Clock defination*/
+#define CONFIG_SYS_TCLK         200000000 /* 200MHz */
+
+#endif /* _ASM_ARCH_KW88F6281_H */
include/asm-arm/arch-kirkwood/serial.h new file +89 -0

89 lines not on this page · raw message

include/asm-arm/arch-kirkwood/spi.h new file +39 -0
new file mode 100644
index 0000000..0fd9131
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * Derived from drivers/spi/mpc8xxx_spi.c
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef __KW_SPI_H__
+#define __KW_SPI_H__
+
+/* SPI Registers on kirkwood SOC */
+#define KW_REG_SPI_CTRL		KW_REGISTER(0x10600)
+#define KW_REG_SPI_CONFIG	KW_REGISTER(0x10604)
+#define KW_REG_SPI_DATA_OUT	KW_REGISTER(0x10608)
+#define KW_REG_SPI_DATA_IN	KW_REGISTER(0x1060c)
+#define KW_REG_SPI_IRQ_CAUSE	KW_REGISTER(0x10610)
+#define KW_REG_SPI_IRQ_MASK	KW_REGISTER(0x10614)
+
+#define KW_SPI_TIMEOUT		10000
+#endif __KW_SPI_H__
include/asm-arm/cache.h new file +49 -0

49 lines not on this page · raw message

include/asm-arm/config.h +4 -0
index 049c44e..5d52f15 100644
@@ -21,4 +21,8 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#if defined (CONFIG_KIRKWOOD)
+#include <asm-arm/arch-kirkwood/kirkwood.h>
+#endif /* CONFIG_KIRKWOOD */
+
 #endif
include/common.h +1 -0
index 30fff7d..9e4b859 100644
@@ -294,6 +294,7 @@ void	pciinfo	      (int, int);
 #endif
 #endif
 
+int	arch_misc_init (void);
 int	misc_init_f   (void);
 int	misc_init_r   (void);
 
lib_arm/board.c +4 -0
index 3dfaec0..7f7c28d 100644
@@ -390,6 +390,10 @@ void start_armboot (void)
 
 	console_init_r ();	/* fully init console as a device */
 
+#if defined(CONFIG_ARCH_MISC_INIT)
+	/* miscellaneous arch dependent initialisations */
+	arch_misc_init ();
+#endif
 #if defined(CONFIG_MISC_INIT_R)
 	/* miscellaneous platform dependent initialisations */
 	misc_init_r ();
Signature · 1 line
1.5.3.3
#51 lore raw

PATCH v4 1/1 Marvell Kirkwood family SOC support

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 12 lines
cpu/arm926ejs/kirkwood/dram.c new file +7 -0
+
+	if ((!enable) || (bank > BANK3))
+		return 0;
+	result = 0xff000000 & readl(KW_REG_CPUCS_WIN_SZ(bank));
+	result += 0x01000000;
+	return result;
+}
cpu/arm926ejs/kirkwood/kwcore.c new file +0 -0
new file mode 100644
index 0000000..9eaaab6

please cpu.c

Quoted 39 lines
cpu/arm926ejs/kirkwood/kwcore.c new file +23 -0
@@ -0,0 +1,284 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
cpu/arm926ejs/start.S +1 -1
index ed4932a..bdbb7e0 100644
@@ -139,7 +139,7 @@ reset:
 	 * we do sys-critical inits only at reboot,
 	 * not when booting from ram!
 	 */
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined (CONFIG_ARCH_LOWLEVEL_INIT)
 	bl	cpu_init_crit
 #endif
 

cpu/arm926ejs/start.S _start_armboot: · line 204

Quoted 5 lines
cpu/arm926ejs/start.S +1 -1
@@ -201,7 +201,7 @@ _start_armboot:
  *
  *************************************************************************
  */
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined (CONFIG_ARCH_LOWLEVEL_INIT)

NACK

if you skip the lowlevel init you also skip the arch lowlevel_init

if it's permannent arch init please use arch_cpu_init

Best regards,
J.

#52 lore raw

PATCH v4 1/1 Marvell Kirkwood family SOC support

Thanks Jean for your review...

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 5 lines
(quoted diff) +0 -0

b/cpu/arm926ejs/kirkwood/kwcore.c new file mode 100644 index 0000000..9eaaab6

cpu/arm926ejs/kirkwood/kwcore.c new file +0 -0

please cpu.c

Okay I will rename it

Quoted 7 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 4 lines

*/

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -1
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined 
+(CONFIG_ARCH_LOWLEVEL_INIT)

NACK

if you skip the lowlevel init you also skip the arch lowlevel_init

I got it already, I have encapsulated similar condition at caller function so that even though only ARCH_LOWLEVEL_INIT is define it will not skip it.

Quoted 2 lines

if it's permannent arch init please use arch_cpu_init

Is it really lowlevel init, needs to be called before stack/dram init, so please let it be arch_lowlevel_init.
I am trying to keep minimal code under arch_lowlevel_init (only few assembly lines) rest I am moving to arch_cpu_init under lib_arm/board.c

Thanks I will send v5 soon

Regards..
Prafulla . .

#53 lore raw

PATCH v4 1/1 Marvell Kirkwood family SOC support

Quoted 16 lines · Prafulla Wadaskar

Thanks Jean for your review...

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 5 lines
(quoted diff) +0 -0

b/cpu/arm926ejs/kirkwood/kwcore.c new file mode 100644 index 0000000..9eaaab6

cpu/arm926ejs/kirkwood/kwcore.c new file +0 -0

please cpu.c

Okay I will rename it

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 4 lines

*/

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -1
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined 
+(CONFIG_ARCH_LOWLEVEL_INIT)

NACK

Quoted 7 lines
Quoted 1 line

if you skip the lowlevel init you also skip the arch lowlevel_init

I got it already, I have encapsulated similar condition at caller function so that even though only ARCH_LOWLEVEL_INIT is define it will not skip it.

Quoted 2 lines

if it's permannent arch init please use arch_cpu_init

Is it really lowlevel init, needs to be called before stack/dram init, so please let it be arch_lowlevel_init.
I am trying to keep minimal code under arch_lowlevel_init (only few assembly lines) rest I am moving to arch_cpu_init under lib_arm/board.c

the arch_cpu_init is the first init in c
and I want the current design clear
If you choice to skip the lowlevel_init you will skip all lowlevel_init with no exception as I've in mind to regroup all start.S

Best Regards,
J.

#54 lore raw

PATCH v4 1/1 Marvell Kirkwood family SOC support

Quoted 35 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Sunday, May 03, 2009 2:02 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v4] Marvell Kirkwood family SOC support

Quoted 10 lines · Prafulla Wadaskar

Thanks Jean for your review...

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 5 lines
(quoted diff) +0 -0

b/cpu/arm926ejs/kirkwood/kwcore.c new file mode 100644 index 0000000..9eaaab6

cpu/arm926ejs/kirkwood/kwcore.c new file +0 -0

please cpu.c

Okay I will rename it

Quoted 8 lines
Quoted 7 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 4 lines

*/

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -1
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined
+(CONFIG_ARCH_LOWLEVEL_INIT)

NACK

if you skip the lowlevel init you also skip the arch lowlevel_init

I got it already, I have encapsulated similar condition at

caller function so that even though only ARCH_LOWLEVEL_INIT is define it will not skip it.

Quoted 4 lines
Quoted 3 lines

if it's permannent arch init please use arch_cpu_init

Is it really lowlevel init, needs to be called before

Quoted 8 lines

stack/dram init, so please let it be arch_lowlevel_init.

Quoted 3 lines

I am trying to keep minimal code under arch_lowlevel_init (only few assembly lines) rest I am moving to arch_cpu_init under lib_arm/board.c

the arch_cpu_init is the first init in c and I want the current design clear If you choice to skip the lowlevel_init you will skip all lowlevel_init with no exception as I've in mind to regroup all start.S

In this case....I think
Let's have arch_cpu_init (c function call) to take care of Soc Specific init and Let's use lowlevel_init instead of arch_lowlevel_init for any configuration before stack init. arch_lowlevel_init should be assembly code similar to lowlevel_init and is invoking should be similar

In case of kirkwood specially in some board version if we use Kirkwood without internal BootROM we need to configure DRAM before setting stack in DRAM, this should be done in lowlevel_init.S i.e. lowlevel_init or arch_lowlevel_init jump

What do you think? Or what is in your mind about regroup start.S?

Regards..
Prafulla . .

Quoted 4 lines

Best Regards,
J.

#55 lore raw

PATCH v4 1/1 Marvell Kirkwood family SOC support

Dear Prafulla Wadaskar,

Quoted 2 lines · In message <[email protected]>…

In case of kirkwood specially in some board version if we use Kirkwood without internal BootROM we need to configure DRAM before setting stack in DRAM, this should be done in lowlevel_init.S i.e. lowlevel_init or arch_lowlevel_init jump

This may be what many ARM systems are currently doing, but actually it is not what I'd like to see.

Normally DRAM should only be initialized right before relocation to RAM, i. e. relatively late in the boot sequence, and definitely by C code (at a time, when you have printf() and friends for debugging).

Also, normally the actual RAM size should be auto-detected using the utilities provided by common/memsize.c, etc. [Also, flash sizes should be auto-detected.]

If you don't have any on-chip memory on your system, or any other SRAM etc. that could be used for initial data or stack, then the standard method is to lock (parts of) D-Cache and use this as RAM.

It would be great if such standard procedures would find their way into U-Boot on ARM, too.

[Note that I wrote "I'd like to see", and "normally", and "should". I did not say "must" - I'm a realist, and I know that ARM still has a long way to go to fully recover from the ARMBoot heritage.]

Thanks in advance.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Deliver yesterday, code today, think tomorrow."
#56 lore raw

PATCH v4 1/1 Marvell Kirkwood family SOC support

In reply to Prafulla Wadaskar
Quoted 43 lines · Prafulla Wadaskar
Quoted 35 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Sunday, May 03, 2009 2:02 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik; Ronen Shitrit
Subject: Re: [U-Boot] [PATCH v4] Marvell Kirkwood family SOC support

Quoted 10 lines · Prafulla Wadaskar

Thanks Jean for your review...

Quoted 6 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 5 lines
(quoted diff) +0 -0

b/cpu/arm926ejs/kirkwood/kwcore.c new file mode 100644 index 0000000..9eaaab6

cpu/arm926ejs/kirkwood/kwcore.c new file +0 -0

please cpu.c

Okay I will rename it

Quoted 8 lines
Quoted 7 lines

cpu/arm926ejs/kirkwood/kwcore.c

Quoted 4 lines

*/

cpu/arm926ejs/kirkwood/kwcore.c new file +2 -1
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#if !defined (CONFIG_SKIP_LOWLEVEL_INIT) || defined
+(CONFIG_ARCH_LOWLEVEL_INIT)

NACK

if you skip the lowlevel init you also skip the arch lowlevel_init

I got it already, I have encapsulated similar condition at

caller function so that even though only ARCH_LOWLEVEL_INIT is define it will not skip it.

Quoted 4 lines
Quoted 3 lines

if it's permannent arch init please use arch_cpu_init

Is it really lowlevel init, needs to be called before

Quoted 8 lines

stack/dram init, so please let it be arch_lowlevel_init.

Quoted 3 lines

I am trying to keep minimal code under arch_lowlevel_init (only few assembly lines) rest I am moving to arch_cpu_init under lib_arm/board.c

the arch_cpu_init is the first init in c and I want the current design clear If you choice to skip the lowlevel_init you will skip all lowlevel_init with no exception as I've in mind to regroup all start.S

Quoted 8 lines

In this case....I think
Let's have arch_cpu_init (c function call) to take care of Soc Specific init and Let's use lowlevel_init instead of arch_lowlevel_init for any configuration before stack init. arch_lowlevel_init should be assembly code similar to lowlevel_init and is invoking should be similar

In case of kirkwood specially in some board version if we use Kirkwood without internal BootROM we need to configure DRAM before setting stack in DRAM, this should be done in lowlevel_init.S i.e. lowlevel_init or arch_lowlevel_init jump

sure but in this case you will have to init everythink as done for ofther ARCH at91 in norflash boot, ixp, pxa etc...

if the dram init is common of the arch the arch_lowlevel_init is the right place, it's board specific lowlevel_init is.

please also note I'm preparing 2 new patch
that will introduce
board_pre_lowlevel_init and
arch_pre_lowlevel_init
with the board that use it (already mainline)

Quoted 2 lines

What do you think? Or what is in your mind about regroup start.S?

For the start.S I'll take care of this
actually nearly all arm share the same start.S
and normaly the lowlevel_init is always the same
wiht just few specific thinks which will be care
by some few callback

Best Regards,
J.

#57 lore raw

PATCH v3 1/1 Marvell MV88F6281GTW_GE Board support

In reply to Prafulla Wadaskar

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash

---
Change log
v2: updated as per first review comments
debug_prints updated to debug

v3: updated as per review comments for v2
added mv88f6281gtw_ge.h file
removed BITxx macros

 MAKEALL                                         |    1 +
 Makefile                                        |    3 +
 board/Marvell/mv88f6281gtw_ge/Makefile          |   51 +++++++
 board/Marvell/mv88f6281gtw_ge/config.mk         |   25 ++++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  102 +++++++++++++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h |   46 ++++++
 board/Marvell/mv88f6281gtw_ge/u-boot.lds        |   53 +++++++
 include/configs/mv88f6281gtw_ge.h               |  175 +++++++++++++++++++++++
 8 files changed, 456 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/mv88f6281gtw_ge/Makefile
 create mode 100644 board/Marvell/mv88f6281gtw_ge/config.mk
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h
 create mode 100644 board/Marvell/mv88f6281gtw_ge/u-boot.lds
 create mode 100644 include/configs/mv88f6281gtw_ge.h
MAKEALL +1 -0
index e4eb42b..1caf81d 100755
@@ -504,6 +504,7 @@ LIST_ARM9="                 \
        cp946es                 \
        cp966                   \
        lpd7a400                \
+       mv88f6281gtw_ge         \
        mx1ads                  \
        mx1fs2                  \
        netstar                 \
Makefile +3 -0
index d2c7c3f..709e4be 100644
@@ -2792,6 +2792,9 @@ lpd7a400_config \
 lpd7a404_config:       unconfig
        @$(MKCONFIG) $(@:_config=) arm lh7a40x lpd7a40x
 
+mv88f6281gtw_ge_config: unconfig
+       @$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 mx1ads_config  :       unconfig
        @$(MKCONFIG) $(@:_config=) arm arm920t mx1ads NULL imx
 
board/Marvell/mv88f6281gtw_ge/Makefile new file +51 -0

51 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/config.mk new file +25 -0
new file mode 100644
index 0000000..fb29a1b
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+TEXT_BASE = 0x00600000
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +102 -0

102 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h new file +46 -0

46 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +53 -0

53 lines not on this page · raw message

include/configs/mv88f6281gtw_ge.h new file +175 -0

175 lines not on this page · raw message

--
1.5.3.4

#58 lore raw

PATCH v3 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 11 lines · Prafulla Wadaskar

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash

Quoted 8 lines

---
Change log
v2: updated as per first review comments
debug_prints updated to debug

v3: updated as per review comments for v2
added mv88f6281gtw_ge.h file
removed BITxx macros

first a general comment
I do not known if it's your mailer but all tab are converted in whitespace please fix it

Quoted 45 lines
 MAKEALL                                         |    1 +
 Makefile                                        |    3 +
 board/Marvell/mv88f6281gtw_ge/Makefile          |   51 +++++++
 board/Marvell/mv88f6281gtw_ge/config.mk         |   25 ++++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  102 +++++++++++++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h |   46 ++++++
 board/Marvell/mv88f6281gtw_ge/u-boot.lds        |   53 +++++++
 include/configs/mv88f6281gtw_ge.h               |  175 +++++++++++++++++++++++
 8 files changed, 456 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/mv88f6281gtw_ge/Makefile
 create mode 100644 board/Marvell/mv88f6281gtw_ge/config.mk
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h
 create mode 100644 board/Marvell/mv88f6281gtw_ge/u-boot.lds
 create mode 100644 include/configs/mv88f6281gtw_ge.h
MAKEALL +17 -0
index e4eb42b..1caf81d 100755
@@ -504,6 +504,7 @@ LIST_ARM9="                 \
        cp946es                 \
        cp966                   \
        lpd7a400                \
+       mv88f6281gtw_ge         \
        mx1ads                  \
        mx1fs2                  \
        netstar                 \
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+

MAKEALL LIST_ARM9=" \

Quoted 10 lines
MAKEALL +10 -0
+#include <common.h>
+#include <../drivers/net/phy/mv88e61xx.h>
+#include <netdev.h>
+#include "mv88f6281gtw_ge.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+       /* Board Parameters initializations */

could explain what you do a few more?

MAKEALL

Quoted 12 lines
MAKEALL +12 -0
+       kw_window_ctrl_reg_init();
+       kw_gpio_init(MV88F6281GTW_GE_OE_VAL_LOW,
+                    MV88F6281GTW_GE_OE_VAL_HIGH,
+                    MV88F6281GTW_GE_OE_LOW, MV88F6281GTW_GE_OE_HIGH);
+
+       kw_mpp_control_init(MV88F6281GTW_GE_MPP0_7,
+                           MV88F6281GTW_GE_MPP8_15,
+                           MV88F6281GTW_GE_MPP16_23,
+                           MV88F6281GTW_GE_MPP24_31,
+                           MV88F6281GTW_GE_MPP32_39,
+                           MV88F6281GTW_GE_MPP40_47, MV88F6281GTW_GE_MPP48_55);
+

from

MAKEALL

Quoted 3 lines
MAKEALL +3 -0
+       /* serial config */
+       gd->baudrate = CONFIG_BAUDRATE;
+       gd->have_console = 1;

no need please remove

MAKEALL

Quoted 7 lines
MAKEALL +7 -0
+       /*
+        * arch number of USED SOC
+        */
+       gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;
+
+       /* adress of boot parameters */
+       gd->bd->bi_boot_params = 0x00000100;

please be more consistant with the other arm boards RAM_BASE + 0x100

Quoted 9 lines
MAKEALL +9 -0
+
+       return 0;
+}
+
+int dram_init(void)
+{
+       int i;
+
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {

MAKEALL

Quoted 10 lines
MAKEALL +10 -0
+               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
+               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+       }
+       return 0;
+}
+
+int last_stage_init(void)
+{
+       return 0;
+}

no need please remove

MAKEALL

Quoted 7 lines
MAKEALL +7 -0
+
+#if defined(CONFIG_MISC_INIT_R)
+/* miscellaneous platform dependent init */
+int misc_init_r(void)
+{
+       return kw_misc_init_r();
+}

if it's really arch late init please create a generic function like arch_late_init or arch_misc_init
and call it from lib_arm/board.c

Quoted 8 lines
MAKEALL +8 -0
+
+void reset_phy(void)
+{
+#ifdef CONFIG_MV88E61XX_SWITCH
+       /* configure and initialize switch */
+       struct mv88e61xx_config swcfg = {
+               .name = "egiga0",
+               .vlancfg = MV88E61XX_VLANCFG_ROUTER,

MAKEALL

Quoted 10 lines
MAKEALL +10 -0
+               .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
+               .portstate = MV88E61XX_PORTSTT_FORWARDING,
+               .cpuport = 5,
+               .ports_enabled = (PORT(0) | PORT(1) | PORT(2)
+                                 | PORT(3) | PORT(4) | PORT(5))
+       };
+
+       mv88e61xx_switch_initialize(&swcfg);
+#endif
+}

please only call reset_phy when the SWITCH is enable. it will reduce the size of u-boot whenyou do not use the switch

Quoted 42 lines
MAKEALL +2 -0
+
+#endif /* CONFIG_MISC_INIT_R */
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h new file +34 -0
new file mode 100644
index 0000000..6e91c25
@@ -0,0 +1,46 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef __MV88F6281GTW_GE_H
+#define __MV88F6281GTW_GE_H
+
+#define MV88F6281GTW_GE_OE_LOW         (~((1<<7) | (1<<20) \
+                                         |(1<<21)))    /*enable GLED,RLED */
+#define MV88F6281GTW_GE_OE_HIGH                (~((1<<4)|(1<<6)|(1<<7)|(1<<12) \
+                                         |(1<<13)|(1<<16)|(1<<17)))
+#define MV88F6281GTW_GE_OE_VAL_LOW     (1<<20) /*make GLED on */
+#define MV88F6281GTW_GE_OE_VAL_HIGH    ((1<<6)|(1<<13)|(1<<16)|(1<<17))
+

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h line 44

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h new file +10 -0
+/*
+ * Default values for MPP registers
+ */
+#define MV88F6281GTW_GE_MPP0_7         0x01112222
+#define MV88F6281GTW_GE_MPP8_15                0x11103311
+#define MV88F6281GTW_GE_MPP16_23       0x00001111
+#define MV88F6281GTW_GE_MPP24_31       0x22222222
+#define MV88F6281GTW_GE_MPP32_39       0x40440222
+#define MV88F6281GTW_GE_MPP40_47       0x00004444
+#define MV88F6281GTW_GE_MPP48_55       0x00000000

could explain a few more these value

Quoted 28 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h new file +2 -0
+
+#endif /* __MV88F6281GTW_GE_H */
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +22 -1
new file mode 100644
index 0000000..9695f3f
--- /dev/null
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_MV88F6281GTW_GE_H
+#define _CONFIG_MV88F6281GTW_GE_H
+
+/*
+ * Version number information
+ */
+#define CONFIG_IDENT_STRING    "\nMarvell-MV88F6281GTW_GE-A0"
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_MARVELL         1
+#define CONFIG_ARM926EJS       1       /* Basic Architecture */
+#define CONFIG_FEROCEON_88FR131        1       /* CPU Core subversion */
+#define CONFIG_KIRKWOOD                1       /* SOC Family Name */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +10 -0
+#define CONFIG_KW88F6281       1       /* SOC Name */
+
+#ifdef CONFIG_KIRKWOOD
+#define CONFIG_MD5     /* get_random_hex on krikwood needs MD5 support */
+#define CONFIG_ARCH_LOWLEVEL_INIT      /* enable arch_lowlevel_init */
+#define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
+#define CONFIG_KIRKWOOD_EGIGA_INIT     /* Enable GbePort0/1 for kernel */
+#define CONFIG_KIRKWOOD_PCIE_INIT      /* Enable PCIE Port0 for kernel */
+#define CONFIG_KIRKWOOD_RGMII_PAD_1V8  /* Set RGMII Pad voltage to 1.8V */
+#endif

why?
this boards is not a KIRWOOD?

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +4 -0
+
+/*
+ * CLKs configurations
+ */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +10 -0
+#define CONFIG_SYS_HZ          1000
+
+/*
+ * Serial Port configuration
+ * The following definitions let you select what serial you want to use
+ * for your console driver.
+ */
+ * Default environment variables
+ */
+#define CONFIG_BOOTCOMMAND             "$(x_bootcmd_kernel); setenv bootargs " \

IIRC please use ${} instead of $()

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +3 -0
+       "$(x_bootargs) $(x_bootargs_root); bootm 0x6400000;"
+#define CONFIG_EXTRA_ENV_SETTINGS      "x_bootargs=console=ttyS0,115200 " \
+       "mtdparts=spi0.0:512k(uboot),512k at 512k(psm),2m at 1m(kernel),13m at 3m(rootfs)\0" \

he could be usefull to use CONFIG_MTDPARTS

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +3 -0
+       "x_bootcmd_kernel=cp.b 0xf8100000 0x6400000 0x200000\0" \
+       "x_bootargs_root=root=/dev/mtdblock3 ro rootfstype=squashfs\0"
+

Best Regards,
J.

#59 lore raw

PATCH v3 1/1 Marvell MV88F6281GTW_GE Board support

Hi Jean
Thanks for your review feedback
Pls see my in lined comments

Quoted 10 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Monday, April 27, 2009 4:06 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Ronen Shitrit; Prabhanjan Sarnaik
Subject: Re: [PATCH v3] Marvell MV88F6281GTW_GE Board support

Quoted 1 line · Prafulla Wadaskar

This is Marvell's 88F6281_A0 based custom board developed

Quoted 8 lines

for wireless

Quoted 2 lines

access point product
v3: updated as per review comments for v2 added

mv88f6281gtw_ge.h file

Quoted 1 line

removed BITxx macros

first a general comment
I do not known if it's your mailer but all tab are converted in whitespace please fix it

This should be mailer problem, I will fix it for all next patch send

Quoted 6 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 34

Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +5 -0
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+       /* Board Parameters initializations */

could explain what you do a few more?

This is explained in detail in Kirkwood support file (i.e. cpu/arm926ejs/kirkwood/kwcore.c) in Kirkwood SOC support patch I will put some explanation here too for each init call

Quoted 15 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +4 -0
+       kw_window_ctrl_reg_init();
+       kw_gpio_init(MV88F6281GTW_GE_OE_VAL_LOW,
+                    MV88F6281GTW_GE_OE_VAL_HIGH,
+                    MV88F6281GTW_GE_OE_LOW, 

MV88F6281GTW_GE_OE_HIGH);

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 46

Quoted 9 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +9 -0
+
+       kw_mpp_control_init(MV88F6281GTW_GE_MPP0_7,
+                           MV88F6281GTW_GE_MPP8_15,
+                           MV88F6281GTW_GE_MPP16_23,
+                           MV88F6281GTW_GE_MPP24_31,
+                           MV88F6281GTW_GE_MPP32_39,
+                           MV88F6281GTW_GE_MPP40_47, 
+ MV88F6281GTW_GE_MPP48_55);
+

from

Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 49

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +3 -0
+       /* serial config */
+       gd->baudrate = CONFIG_BAUDRATE;
+       gd->have_console = 1;

no need please remove

Okay I will remove this

Quoted 8 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 56

Quoted 7 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +7 -0
+       /*
+        * arch number of USED SOC
+        */
+       gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;
+
+       /* adress of boot parameters */
+       gd->bd->bi_boot_params = 0x00000100;

please be more consistant with the other arm boards RAM_BASE + 0x100

Okay..

Quoted 12 lines
Quoted 12 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +12 -0
+
+       return 0;
+}
+
+int dram_init(void)
+{
+       int i;
+
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
+               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+       }
Quoted 8 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 75

Quoted 7 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +7 -0
+       return 0;
+}
+
+int last_stage_init(void)
+{
+       return 0;
+}

no need please remove

Okay

Quoted 20 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 82

Quoted 5 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +5 -0
+
+#if defined(CONFIG_MISC_INIT_R)
+/* miscellaneous platform dependent init */ int misc_init_r(void) {
+       return kw_misc_init_r();
+}

if it's really arch late init please create a generic function like arch_late_init or arch_misc_init and call it from lib_arm/board.c

Quoted 12 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +12 -0
+
+void reset_phy(void)
+{
+#ifdef CONFIG_MV88E61XX_SWITCH
+       /* configure and initialize switch */
+       struct mv88e61xx_config swcfg = {
+               .name = "egiga0",
+               .vlancfg = MV88E61XX_VLANCFG_ROUTER,
+               .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
+               .portstate = MV88E61XX_PORTSTT_FORWARDING,
+               .cpuport = 5,
+               .ports_enabled = (PORT(0) | PORT(1) | PORT(2)
Quoted 8 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 100

Quoted 6 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +6 -0
+                                 | PORT(3) | PORT(4) | PORT(5))
+       };
+
+       mv88e61xx_switch_initialize(&swcfg);
+#endif
+}

please only call reset_phy when the SWITCH is enable. it will reduce the size of u-boot whenyou do not use the switch

Yes... I will do it

Quoted 11 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h line 44

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h new file +10 -0
+/*
+ * Default values for MPP registers
+ */
+#define MV88F6281GTW_GE_MPP0_7         0x01112222
+#define MV88F6281GTW_GE_MPP8_15                0x11103311
+#define MV88F6281GTW_GE_MPP16_23       0x00001111
+#define MV88F6281GTW_GE_MPP24_31       0x22222222
+#define MV88F6281GTW_GE_MPP32_39       0x40440222
+#define MV88F6281GTW_GE_MPP40_47       0x00004444
+#define MV88F6281GTW_GE_MPP48_55       0x00000000

could explain a few more these value

I will put explanation for this

Quoted 7 lines

GbePort0/1 for kernel */

Quoted 1 line

+#define CONFIG_KIRKWOOD_PCIE_INIT /* Enable PCIE

Port0 for kernel */

Quoted 2 lines

+#define CONFIG_KIRKWOOD_RGMII_PAD_1V8 /* Set RGMII Pad voltage to +1.8V */ #endif

why?
this boards is not a KIRWOOD?

No, This board is MV88F6281GTW_GE which uses 88F6281 belongs to kirkwood family of SoCs.
Soc has provision to configure RGMII pad voltages to 1.8 or 3.3 Volts connected to Gbe interface (i.e. switch used on this board). Also kernel switch and Gbe controller driver does not take care of this since they are generic.

Quoted 3 lines
Quoted 1 line

+#define CONFIG_BOOTCOMMAND

"$(x_bootcmd_kernel); setenv bootargs " \
IIRC please use ${} instead of $()

Okay

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       "$(x_bootargs) $(x_bootargs_root); bootm 0x6400000;"
+#define CONFIG_EXTRA_ENV_SETTINGS      

"x_bootargs=console=ttyS0,115200 " \

Quoted 2 lines

+

+"mtdparts=spi0.0:512k(uboot),512k at 512k(psm),2m at 1m(kernel),13m at 3m(root

Quoted 1 line

+fs)\0" \

he could be usefull to use CONFIG_MTDPARTS

I will check this and use it

Regards..
Prafulla . .

#60 lore raw

PATCH v4 1/1 Marvell MV88F6281GTW_GE Board support

From: prafulla_wadaskar <[email protected]>

This is Marvell's 88F6281_A0 based custom board developed for wireless access point product

This patch is tested for-
1. Boot from DRAM/SPI flash/NFS
2. File transfer using tftp and loadb
3. SPI flash read/write/erase
4. Booting Linux kernel and RFS from SPI flash

---
Change log
v2: updated as per first review comments
debug_prints updated to debug

v3: updaed as per review comments for v2
added mv88f6281gtw_ge.h file
removed BITxx macros

v4: updated as per review comments for v3 arch_misc_init support is added and used from kirkwood

 MAKEALL                                         |    1 +
 Makefile                                        |    3 +
 board/Marvell/mv88f6281gtw_ge/Makefile          |   51 +++++++
 board/Marvell/mv88f6281gtw_ge/config.mk         |   25 +++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |   86 +++++++++++
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h |   51 +++++++
 board/Marvell/mv88f6281gtw_ge/u-boot.lds        |   53 +++++++
 include/configs/mv88f6281gtw_ge.h               |  180 +++++++++++++++++++++++
 8 files changed, 450 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/mv88f6281gtw_ge/Makefile
 create mode 100644 board/Marvell/mv88f6281gtw_ge/config.mk
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
 create mode 100644 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h
 create mode 100644 board/Marvell/mv88f6281gtw_ge/u-boot.lds
 create mode 100644 include/configs/mv88f6281gtw_ge.h
MAKEALL +1 -0
index e4eb42b..1caf81d 100755
@@ -504,6 +504,7 @@ LIST_ARM9="			\
 	cp946es			\
 	cp966			\
 	lpd7a400		\
+	mv88f6281gtw_ge		\
 	mx1ads			\
 	mx1fs2			\
 	netstar			\
Makefile +3 -0
index d2c7c3f..709e4be 100644
@@ -2792,6 +2792,9 @@ lpd7a400_config \
 lpd7a404_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm lh7a40x lpd7a40x
 
+mv88f6281gtw_ge_config: unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 mx1ads_config	:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm920t mx1ads NULL imx
 
board/Marvell/mv88f6281gtw_ge/Makefile new file +51 -0

51 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/config.mk new file +25 -0
new file mode 100644
index 0000000..fb29a1b
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+TEXT_BASE = 0x00600000
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +86 -0

86 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.h new file +51 -0

51 lines not on this page · raw message

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +53 -0

53 lines not on this page · raw message

include/configs/mv88f6281gtw_ge.h new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
1.5.3.3
#61 lore raw

PATCH v4 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 4 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +4 -0
+# (C) Copyright 2009
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 26

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +10 -0
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <common.h>
+#include <../drivers/net/phy/mv88e61xx.h>

Ben I not sure it's clean
any better idea?

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 33

Quoted 7 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +7 -0
+#include <netdev.h>
+#include "mv88f6281gtw_ge.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{

please add comment

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 45

Quoted 12 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +12 -0
+	kw_config_gpio(MV88F6281GTW_GE_OE_VAL_LOW,
+		       MV88F6281GTW_GE_OE_VAL_HIGH,
+		       MV88F6281GTW_GE_OE_LOW, MV88F6281GTW_GE_OE_HIGH);
+
+	/* Multi-Purpose Pins Functionality configuration */
+	kw_config_mpp(MV88F6281GTW_GE_MPP0_7,
+		      MV88F6281GTW_GE_MPP8_15,
+		      MV88F6281GTW_GE_MPP16_23,
+		      MV88F6281GTW_GE_MPP24_31,
+		      MV88F6281GTW_GE_MPP32_39,
+		      MV88F6281GTW_GE_MPP40_47, MV88F6281GTW_GE_MPP48_55);
+

From

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 47

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +2 -0
+	/* serial config */
+	gd->baudrate = CONFIG_BAUDRATE;

againt please remove

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 25 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +22 -0
+	/*
+	 * arch number of USED SOC
+	 */
+	gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;
+
+	/* adress of boot parameters */
+	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		gd->bd->bi_dram[i].start = kw_sdram_bar(i);
+		gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+	}
+	return 0;
+}
+

index 0000000..9695f3f

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +0 -0

please move to cpu/arm/kirkwood/

Quoted 51 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +50 -0
@@ -0,0 +1,53 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Prafulla Wadaskar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	. = _start;
+	. = ALIGN(4);
+	.text	:
+	{
+	  cpu/arm926ejs/start.o	(.text)
+	  *(.text)
+	}
+	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata))) }
+	. = ALIGN(4);
+	.data : { *(.data) }
+	. = ALIGN(4);
+	.got : { *(.got) }
+ * MA 02110-1301 USA
+ */
+
+#ifndef _CONFIG_MV88F6281GTW_GE_H
+#define _CONFIG_MV88F6281GTW_GE_H
+
+/*
+ * Version number information
+ */

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 10 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +10 -0
+#define CONFIG_IDENT_STRING	"\nMarvell-MV88F6281GTW_GE-A0"
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_MARVELL		1
+#define CONFIG_ARM926EJS	1	/* Basic Architecture */
+#define CONFIG_FEROCEON_88FR131	1	/* CPU Core subversion */
+#define CONFIG_KIRKWOOD		1	/* SOC Family Name */
+#define CONFIG_KW88F6281	1	/* SOC Name */

please define the CONFIG_MACH

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +2 -0
+
+#ifdef CONFIG_KIRKWOOD

as I guess it will be always KIRKWOOD please remove

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 8 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +8 -0
+#define CONFIG_MD5		/* get_random_hex on krikwood needs MD5 support */
+#define CONFIG_ARCH_LOWLEVEL_INIT	/* enable arch_lowlevel_init */
+#define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+#define CONFIG_KIRKWOOD_EGIGA_INIT	/* Enable GbePort0/1 for kernel */
+#define CONFIG_KIRKWOOD_PCIE_INIT	/* Enable PCIE Port0 for kernel */
+#define CONFIG_KIRKWOOD_RGMII_PAD_1V8	/* Set RGMII Pad voltage to 1.8V */
+#endif
+

otherwise fine

Best Regards,
J.

#62 lore raw

PATCH v4 1/1 Marvell MV88F6281GTW_GE Board support

Thanks Jean...

Quoted 5 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 26

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +3 -0
+
+#include <common.h>
+#include <../drivers/net/phy/mv88e61xx.h>

Ben I not sure it's clean
any better idea?

Quoted 8 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 33

Quoted 7 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +7 -0
+#include <netdev.h>
+#include "mv88f6281gtw_ge.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{

please add comment

Okay

Quoted 12 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c

Quoted 11 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +11 -0
+	kw_config_gpio(MV88F6281GTW_GE_OE_VAL_LOW,
+		       MV88F6281GTW_GE_OE_VAL_HIGH,
+		       MV88F6281GTW_GE_OE_LOW, MV88F6281GTW_GE_OE_HIGH);
+
+	/* Multi-Purpose Pins Functionality configuration */
+	kw_config_mpp(MV88F6281GTW_GE_MPP0_7,
+		      MV88F6281GTW_GE_MPP8_15,
+		      MV88F6281GTW_GE_MPP16_23,
+		      MV88F6281GTW_GE_MPP24_31,
+		      MV88F6281GTW_GE_MPP32_39,
+		      MV88F6281GTW_GE_MPP40_47, 

MV88F6281GTW_GE_MPP48_55);

Quoted 5 lines
Quoted 1 line

+

From

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 47

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +2 -0
+	/* serial config */
+	gd->baudrate = CONFIG_BAUDRATE;

againt please remove

Okay

Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines

index 0000000..9695f3f

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +0 -0

please move to cpu/arm/kirkwood/

I tried it, If we move it to Kirkwood there is build error, how do we invoke it for the build?
currently it provides boot from DRAM since doimage (utility to convert u-boot.bin to flashable bin) is outside. I think this is board specific and each board will have different configuration, for ex. Board with boot from NAND will have different info

Quoted 3 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +2 -0
+#define CONFIG_KIRKWOOD		1	/* SOC Family Name */
+#define CONFIG_KW88F6281	1	/* SOC Name */

please define the CONFIG_MACH

Okay I will check this and do the needful

Quoted 3 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 2 lines
board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +2 -0
+
+#ifdef CONFIG_KIRKWOOD

as I guess it will be always KIRKWOOD please remove

Sounds good, I will remove it

Regards..
Prafulla . .

#63 lore raw

PATCH v4 1/1 Marvell MV88F6281GTW_GE Board support

Quoted 11 lines · Prafulla Wadaskar

Thanks Jean...

Quoted 8 lines

board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c line 26

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +3 -0
+
+#include <common.h>
+#include <../drivers/net/phy/mv88e61xx.h>

Ben I not sure it's clean
any better idea?

Quoted 3 lines
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c new file +3 -0
+#include <netdev.h>
+#include "mv88f6281gtw_ge.h"
+
Quoted 6 lines
Quoted 4 lines

board/Marvell/mv88f6281gtw_ge/u-boot.lds

Quoted 3 lines

index 0000000..9695f3f

board/Marvell/mv88f6281gtw_ge/u-boot.lds new file +0 -0

please move to cpu/arm/kirkwood/

I tried it, If we move it to Kirkwood there is build error, how do we invoke it for the build?
currently it provides boot from DRAM since doimage (utility to convert u-boot.bin to flashable bin) is outside. I think this is board specific and each board will have different configuration, for ex. Board with boot from NAND will have different info

3 thinks

1) to boot from DRAM you normaly do not need to change it for nand maybe but it will be normaly the same for all kirkwood

2) do you update your arch confif.mk
cat cpu/arm926ejs/kirwood/config.mk
LDSCRIPT := $(SRCTREE)/cpu/arm926ejs/kirwood/u-boot.lds

3) I'm in favor as Mike to have the tool to build the final flashable bin in the tree as done for the blackfin with a new target and a new extention as .kwd (or any other)

Best Regards,
J.

#64 lore raw

PATCH v4 1/1 Marvell MV88F6281GTW_GE Board support

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 4 lines · In message <[email protected]> you wrote:

3) I'm in favor as Mike to have the tool to build the final flashable bin in the tree as done for the blackfin with a new target and a new extention as .kwd (or any other)

You know my opinion about this; it has not changed.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Technology is dominated by those who manage what they do  not  under-
stand.
#65 lore raw

PATCH 1/1 Marvell Feroceon-FR131/Sheeva-88SV131 cpu core support

In reply to Prafulla Wadaskar

Dear Prafulla Wadaskar,

Quoted 17 lines · In message <[email protected]> you wrote:

This is ARM v5TE-compliant processor core with
MMU and L1/L2 Cache

Reviewed by: Ronen Shitrit <[email protected]>

---
 cpu/arm926ejs/start.S |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
cpu/arm926ejs/start.S +0 -0
index ed4932a..08ec955 100644
@@ -214,10 +214,15 @@ cpu_init_crit:
 	 * disable MMU stuff and caches
 	 */
 	mrc	p15, 0, r0, c1, c0, 0

cpu/arm926ejs/start.S cpu_init_crit: · line 226

Quoted 10 lines
cpu/arm926ejs/start.S +5 -0
+#if defined (CONFIG_FEROCEON_88FR131) || defined (CONFIG_SHEEVA_88SV131)
+	bic	r0, r0, #0x00000007	/* clear bits 2:0 (CAM) */
+	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
+#else
 	bic	r0, r0, #0x00002300	/* clear bits 13, 9:8 (--V- --RS) */
 	bic	r0, r0, #0x00000087	/* clear bits 7, 2:0 (B--- -CAM) */
 	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
 	orr	r0, r0, #0x00001000	/* set bit 12 (I) I-Cache */
+#endif
 	mcr	p15, 0, r0, c1, c0, 0

Why is this special case needed?

Cannot you enable the IC, too?

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Voodoo Programming: Things programmers do that  they  know  shouldn't
work  but they try anyway, and which sometimes actually work, such as
recompiling everything.                             - Karl Lehenbauer
#66 lore raw

PATCH 1/1 Marvell Feroceon-FR131/Sheeva-88SV131 cpu core support

In reply to Prafulla Wadaskar
Quoted 16 lines · Prafulla Wadaskar

This is ARM v5TE-compliant processor core with
MMU and L1/L2 Cache

Reviewed by: Ronen Shitrit <[email protected]>

---
 cpu/arm926ejs/start.S |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
cpu/arm926ejs/start.S +0 -0
index ed4932a..08ec955 100644
@@ -214,10 +214,15 @@ cpu_init_crit:
 	 * disable MMU stuff and caches
 	 */

cpu/arm926ejs/start.S cpu_init_crit: · line 225

Quoted 10 lines
cpu/arm926ejs/start.S +5 -0
 	mrc	p15, 0, r0, c1, c0, 0
+#if defined (CONFIG_FEROCEON_88FR131) || defined (CONFIG_SHEEVA_88SV131)
+	bic	r0, r0, #0x00000007	/* clear bits 2:0 (CAM) */
+	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
+#else
 	bic	r0, r0, #0x00002300	/* clear bits 13, 9:8 (--V- --RS) */
 	bic	r0, r0, #0x00000087	/* clear bits 7, 2:0 (B--- -CAM) */
 	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
 	orr	r0, r0, #0x00001000	/* set bit 12 (I) I-Cache */
+#endif

I've plan to clean up the asm mmu and cache management as I've done for the C part. The idea is to avoid to duplicated code and #ifdef every where. So please create asm macro to handle this

and please explain a few more why you need it

Best Regards,
J.

#67 lore raw

PATCH 1/1 Marvell Feroceon-FR131/Sheeva-88SV131 cpu core support

Quoted 37 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Saturday, April 04, 2009 9:46 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ronen Shitrit; Nicolas Pitre
Subject: Re: [U-Boot] [PATCH] Marvell Feroceon-FR131/Sheeva-88SV131 cpu core support

Quoted 3 lines · Prafulla Wadaskar

This is ARM v5TE-compliant processor core with MMU and L1/L2 Cache

Reviewed by:

Quoted 10 lines

Ronen Shitrit <[email protected]>

---
 cpu/arm926ejs/start.S |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
cpu/arm926ejs/start.S index renamed from cpu/arm926ejs/start.S +0 -0

ed4932a..08ec955 100644

cpu/arm926ejs/start.S cpu_init_crit: · line 217

Quoted 4 lines
cpu/arm926ejs/start.S +1 -0
@@ -214,10 +214,15 @@ cpu_init_crit:
 	 * disable MMU stuff and caches
 	 */
 	mrc	p15, 0, r0, c1, c0, 0
+#if defined (CONFIG_FEROCEON_88FR131) || defined 

(CONFIG_SHEEVA_88SV131)

cpu/arm926ejs/start.S cpu_init_crit:

Quoted 4 lines
cpu/arm926ejs/start.S +3 -0
+	bic	r0, r0, #0x00000007	/* clear bits 2:0 (CAM) */
+	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
+#else
 	bic	r0, r0, #0x00002300	/* clear bits 13, 9:8 

(--V- --RS) */

cpu/arm926ejs/start.S cpu_init_crit: · line 222

Quoted 1 line
cpu/arm926ejs/start.S +0 -0
 	bic	r0, r0, #0x00000087	/* clear bits 7, 2:0 

(B--- -CAM) */

Quoted 8 lines

cpu/arm926ejs/start.S cpu_init_crit: · line 225

Quoted 3 lines
cpu/arm926ejs/start.S +1 -0
 	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
 	orr	r0, r0, #0x00001000	/* set bit 12 (I) I-Cache */
+#endif

I've plan to clean up the asm mmu and cache management as I've done for the C part. The idea is to avoid to duplicated code and #ifdef every where. So please create asm macro to handle this

and please explain a few more why you need it

The issue was of 'order of operations'.
In our devices we have L2 cache and the L2 must be enabled before the L1. this change was with reference to older u-boot and earlier SOC versions. I have tested the code without this patch and is functional.
We can add code for disabling the L1 before enabling the L2 in SOC specific .

This patch is not needed now, We can skip this patch.

Quoted 4 lines

Best Regards,
J.