~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/SLOF/board-js2x/slof/attu.fs

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\ *****************************************************************************
 
2
\ * Copyright (c) 2004, 2008 IBM Corporation
 
3
\ * All rights reserved.
 
4
\ * This program and the accompanying materials
 
5
\ * are made available under the terms of the BSD License
 
6
\ * which accompanies this distribution, and is available at
 
7
\ * http://www.opensource.org/licenses/bsd-license.php
 
8
\ *
 
9
\ * Contributors:
 
10
\ *     IBM Corporation - initial implementation
 
11
\ ****************************************************************************/
 
12
 
 
13
\ U4 "Attu" PCIe root complex.
 
14
 
 
15
\ See the PCI OF binding document.
 
16
 
 
17
new-device
 
18
 
 
19
s" pciex" device-name s" pci" device-type
 
20
s" U4-pcie" compatible
 
21
s" U4" encode-string s" model" property
 
22
 
 
23
\ spare out 0xc0000000-0xefffffff for pcie
 
24
f8070200 rl@ fffffff0 and f8070200 rl!
 
25
\ enable io memory for pcie @ c0000000-efffffff
 
26
70000003 f80903f0 rl!-le
 
27
 
 
28
3 encode-int s" #address-cells" property
 
29
2 encode-int s" #size-cells" property
 
30
 
 
31
s" /mpic" find-node encode-int s" interrupt-parent" property
 
32
\ XXX should have interrupt map, etc.  this works for now though.
 
33
 
 
34
: decode-unit  2 hex-decode-unit  3 #join  8 lshift  0 0 rot F00000 + ;
 
35
: encode-unit  nip nip  ff00 and 8 rshift  3 #split
 
36
               over IF 2 ELSE nip 1 THEN hex-encode-unit ;
 
37
 
 
38
f1000000 CONSTANT my-puid
 
39
\ Configuration space accesses.
 
40
: >config  f1000000 + ;
 
41
: config-l!  >config rl!-le ;
 
42
: config-l@  >config rl@-le ;
 
43
: config-w!  >config rw!-le ;
 
44
: config-w@  >config rw@-le ;
 
45
: config-b!  >config rb! ;
 
46
: config-b@  >config rb@ ;
 
47
 
 
48
: config-dump ( addr size -- )  ['] config-l@ 4 (dump) ;
 
49
 
 
50
\ 16MB of configuration space
 
51
f1000000 encode-64 1000000 encode-64+ s" reg" property
 
52
 
 
53
\ 4MB of I/O space.
 
54
01000000 encode-int  00000000 encode-int+ 00000000 encode-int+ 
 
55
00000000 encode-int+ f0000000 encode-int+ 
 
56
00000000 encode-int+ 00400000 encode-int+
 
57
 
 
58
\ 1.75GB of memory space @ c0000000.
 
59
02000000 encode-int+ c0000000 encode-64+
 
60
c0000000 encode-64+  30000000 encode-64+ s" ranges" property
 
61
 
 
62
\ Host bridge, so full bus range.
 
63
f0 encode-int ff encode-int+ s" bus-range" property
 
64
 
 
65
: open  true ;
 
66
: close ;
 
67
 
 
68
\ : probe-pci-host-bridge ( bus-max bus-min mmio-max mmio-base mem-max mem-base io-max io-base my-puid -- )
 
69
s" /mpic" find-node my-puid pci-irq-init drop
 
70
 
 
71
00fff1f0 18 config-l!
 
72
 
 
73
ff F0 f0000000 e8000000 e8000000 c0000000 100000000 f000
 
74
my-puid probe-pci-host-bridge
 
75
 
 
76
\ \ PCIe debug / fixup
 
77
: find-pcie-cap  ( devfn -- offset | 0 )
 
78
   >r 34  BEGIN  r@ + config-b@ dup ff <> over and  WHILE
 
79
       dup r@ + config-b@ 10 =  IF
 
80
          r> drop EXIT
 
81
       THEN 1+
 
82
   REPEAT r> 2drop 0
 
83
;
 
84
 
 
85
 : (set-ps) ( ps addr -- )
 
86
   8 + >r 5 lshift r@ config-w@ ff1f and or r> config-w! ;
 
87
 : set-ps ( ps -- )
 
88
   log2 7 -
 
89
   10000 0 DO i 8 lshift dup find-pcie-cap ?dup IF
 
90
   + 2dup (set-ps) THEN drop LOOP drop ;
 
91
 
 
92
 : (set-rr) ( rr addr -- )
 
93
   8 + >r c lshift r@ config-w@ 8fff and or r> config-w! ;
 
94
 : set-rr ( rr -- )
 
95
   log2 7 -
 
96
   10000 0 DO i 8 lshift dup find-pcie-cap ?dup IF
 
97
   + 2dup (set-rr) THEN drop LOOP drop ;
 
98
 
 
99
80 set-ps  80 set-rr  
 
100
 
 
101
finish-device