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

« back to all changes in this revision

Viewing changes to roms/SLOF/slof/fs/devices/pci-class_0c.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, 2011 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
s" serial bus [ " type my-space pci-class-name type s"  ]" type cr
 
14
 
 
15
my-space pci-device-generic-setup
 
16
 
 
17
STRUCT
 
18
    /n FIELD hcd>base
 
19
    /n FIELD hcd>type
 
20
    /n FIELD hcd>num
 
21
    /n FIELD hcd>ops
 
22
    /n FIELD hcd>priv
 
23
    /n FIELD hcd>nextaddr
 
24
CONSTANT /hci-dev
 
25
 
 
26
: usb-setup-hcidev ( num hci-dev -- )
 
27
    >r
 
28
    10 config-l@ F AND case
 
29
        0 OF 10 config-l@ translate-my-address ENDOF       \ 32-bit memory space
 
30
        4 OF                                               \ 64-bit memory space
 
31
            14 config-l@ 20 lshift                         \ Read two bars
 
32
            10 config-l@ OR translate-my-address
 
33
        ENDOF
 
34
    ENDCASE
 
35
    F not AND
 
36
    ( io-base ) r@ hcd>base !
 
37
    08 config-l@ 8 rshift  0000000F0 AND 4 rshift
 
38
    ( usb-type ) r@ hcd>type !
 
39
    ( usb-num )  r@ hcd>num !
 
40
    r> drop
 
41
;
 
42
 
 
43
\ Handle USB OHCI controllers:
 
44
: handle-usb-class  ( -- )
 
45
   \ set Memory Write and Invalidate Enable, SERR# Enable
 
46
   \ (see PCI 3.0 Spec Chapter 6.2.2 device control):
 
47
   4 config-w@ 110 or 4 config-w!
 
48
   pci-master-enable               \ set PCI Bus master bit and
 
49
   pci-mem-enable                  \ memory space enable for USB scan
 
50
;
 
51
 
 
52
\ Check PCI sub-class and interface type of Serial Bus Controller
 
53
\ to include the appropriate driver:
 
54
: handle-sbc-subclass  ( -- )
 
55
    my-space pci-class@ ffff and CASE         \ get PCI sub-class and interface
 
56
        0310 OF                      \ OHCI controller
 
57
            handle-usb-class
 
58
            set-ohci-alias
 
59
        ENDOF
 
60
        0320 OF                      \ EHCI controller
 
61
            handle-usb-class
 
62
            set-ehci-alias
 
63
        ENDOF
 
64
        0330 OF                      \ XHCI controller
 
65
            handle-usb-class
 
66
            set-xhci-alias
 
67
        ENDOF
 
68
   ENDCASE
 
69
;
 
70
 
 
71
handle-sbc-subclass