usb-core: adding generic dev-hci.fs
* Generic forth device file for [OEX]HCI controller. * Routines to setup hcd structure Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com> [ implmented generic hc-suspend for [oe]hci ] Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Acked-by: Thomas Huth <thuth@linux.vnet.ibm.com>
This commit is contained in:
parent
c4ddc59f67
commit
7ef8498799
|
@ -45,7 +45,8 @@ FPPINCLUDES = -I. -I$(SLOFCMNDIR)/fs -I$(SLOFCMNDIR)
|
|||
|
||||
USB_FFS_FILES = \
|
||||
$(SLOFCMNDIR)/fs/devices/pci-class_02.fs \
|
||||
$(SLOFCMNDIR)/fs/devices/pci-class_0c.fs
|
||||
$(SLOFCMNDIR)/fs/devices/pci-class_0c.fs \
|
||||
$(SLOFCMNDIR)/fs/usb/dev-hci.fs
|
||||
|
||||
VIO_FFS_FILES = \
|
||||
$(SLOFBRDDIR)/pci-device_1af4_1000.fs \
|
||||
|
|
|
@ -124,6 +124,10 @@ d# 512000000 VALUE tb-frequency \ default value - needed for "ms" to work
|
|||
|
||||
3f0 cp
|
||||
|
||||
#include "usb.fs"
|
||||
|
||||
400 cp
|
||||
|
||||
#include "tree.fs"
|
||||
|
||||
800 cp
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
\ *****************************************************************************
|
||||
\ * Copyright (c) 2006, 2012, 2013 IBM Corporation
|
||||
\ * All rights reserved.
|
||||
\ * This program and the accompanying materials
|
||||
\ * are made available under the terms of the BSD License
|
||||
\ * which accompanies this distribution, and is available at
|
||||
\ * http://www.opensource.org/licenses/bsd-license.php
|
||||
\ *
|
||||
\ * Contributors:
|
||||
\ * IBM Corporation - initial implementation
|
||||
\ ****************************************************************************/
|
||||
\ *
|
||||
\ * [OEX]HCI functions
|
||||
\ *
|
||||
\ ****************************************************************************
|
||||
|
||||
STRUCT
|
||||
/n FIELD hcd>base
|
||||
/n FIELD hcd>type
|
||||
/n FIELD hcd>num
|
||||
CONSTANT /hci-dev
|
||||
|
||||
: usb-setup-hcidev ( num hci-dev -- )
|
||||
>r
|
||||
s" 10 config-l@ translate-my-address 3 not AND" evaluate
|
||||
( io-base ) r@ hcd>base !
|
||||
s" 08 config-l@ 8 rshift 0000000F0 AND 4 rshift " evaluate
|
||||
( usb-type ) r@ hcd>type !
|
||||
( usb-num ) r@ hcd>num !
|
||||
r> drop
|
||||
;
|
|
@ -0,0 +1,100 @@
|
|||
\ *****************************************************************************
|
||||
\ * Copyright (c) 2006, 2012, 2013 IBM Corporation
|
||||
\ * All rights reserved.
|
||||
\ * This program and the accompanying materials
|
||||
\ * are made available under the terms of the BSD License
|
||||
\ * which accompanies this distribution, and is available at
|
||||
\ * http://www.opensource.org/licenses/bsd-license.php
|
||||
\ *
|
||||
\ * Contributors:
|
||||
\ * IBM Corporation - initial implementation
|
||||
\ ****************************************************************************/
|
||||
\ *
|
||||
\ * [OEX]HCI functions
|
||||
\ *
|
||||
\ ****************************************************************************
|
||||
|
||||
\ ( num $name type )
|
||||
|
||||
VALUE usb_type \ USB type
|
||||
|
||||
\ Open Firmware Properties
|
||||
2dup device-name
|
||||
s" usb" device-type
|
||||
|
||||
rot
|
||||
VALUE usb_num \ controller number
|
||||
usb_num $cathex strdup \ create alias name
|
||||
2dup find-alias 0= IF
|
||||
get-node node>path set-alias
|
||||
ELSE 3drop THEN
|
||||
|
||||
/hci-dev BUFFER: hcidev
|
||||
usb_num hcidev usb-setup-hcidev
|
||||
|
||||
false VALUE dev-hci-debug?
|
||||
|
||||
: get-base-address ( -- baseaddr )
|
||||
hcidev hcd>base @
|
||||
;
|
||||
|
||||
get-base-address CONSTANT baseaddrs
|
||||
|
||||
1 encode-int s" #address-cells" property
|
||||
0 encode-int s" #size-cells" property
|
||||
|
||||
\ converts physical address to text unit string
|
||||
: encode-unit ( port -- unit-str unit-len ) 1 hex-encode-unit ;
|
||||
|
||||
\ Converts text unit string to phyical address
|
||||
: decode-unit ( addr len -- port ) 1 hex-decode-unit ;
|
||||
|
||||
: get-hci-dev ( -- hcidev )
|
||||
hcidev
|
||||
;
|
||||
|
||||
|
||||
0 VALUE open-count
|
||||
|
||||
: USB-HCI-INIT drop 1 ;
|
||||
: USB-HCI-EXIT drop 1 ;
|
||||
|
||||
: open ( -- true | false )
|
||||
dev-hci-debug? IF ." DEV-HCI: Opening (count is " open-count . ." )" cr THEN
|
||||
open-count 0= IF
|
||||
hcidev USB-HCI-INIT 0= IF
|
||||
." HCI Device setup failed " pwd cr
|
||||
false EXIT
|
||||
THEN
|
||||
THEN
|
||||
open-count 1 + to open-count
|
||||
true
|
||||
;
|
||||
|
||||
: close
|
||||
dev-hci-debug? IF ." DEV-HCI: Closing (count is " open-count . ." )" cr THEN
|
||||
open-count 0> IF
|
||||
open-count 1 - dup to open-count
|
||||
0= IF
|
||||
hcidev USB-HCI-EXIT drop
|
||||
THEN
|
||||
THEN
|
||||
;
|
||||
|
||||
\ set HCI into suspend mode
|
||||
\ this disables all activities to shared RAM
|
||||
\ called when linux starts (quiesce)
|
||||
: hc-suspend ( -- )
|
||||
hcidev hcd>type @ dup 1 = IF
|
||||
00C3 baseaddrs 4 + rl!-le \ Suspend OHCI controller
|
||||
THEN
|
||||
2 = IF
|
||||
baseaddrs dup c@ + rl@-le FFFFFFFE and
|
||||
baseaddrs dup c@ + rl!-le \ Stop EHCI controller
|
||||
ELSE
|
||||
drop
|
||||
THEN
|
||||
;
|
||||
|
||||
\ create a new entry to suspend HCI
|
||||
' hc-suspend add-quiesce-xt
|
|
@ -10,11 +10,9 @@
|
|||
\ * IBM Corporation - initial implementation
|
||||
\ ****************************************************************************/
|
||||
|
||||
\ register device alias
|
||||
: do-alias-setting ( num name-str name-len )
|
||||
rot $cathex strdup \ create alias name
|
||||
get-node node>path \ get path string
|
||||
set-alias \ and set the alias
|
||||
\ Load dev hci
|
||||
: load-dev-hci ( num name-str name-len )
|
||||
s" dev-hci.fs" INCLUDED
|
||||
;
|
||||
|
||||
0 VALUE ohci-alias-num
|
||||
|
@ -24,24 +22,50 @@
|
|||
\ create a new ohci device alias for the current node
|
||||
: set-ohci-alias ( -- )
|
||||
ohci-alias-num dup 1+ TO ohci-alias-num ( num )
|
||||
s" ohci" do-alias-setting
|
||||
s" ohci" 1 load-dev-hci
|
||||
;
|
||||
|
||||
\ create a new ehci device alias for the current node
|
||||
: set-ehci-alias ( -- )
|
||||
ehci-alias-num dup 1+ TO ehci-alias-num ( num )
|
||||
s" ehci" do-alias-setting
|
||||
s" ehci" 2 load-dev-hci
|
||||
;
|
||||
|
||||
\ create a new xhci device alias for the current node
|
||||
: set-xhci-alias ( -- )
|
||||
xhci-alias-num dup 1+ TO xhci-alias-num ( num )
|
||||
s" xhci" do-alias-setting
|
||||
s" xhci" 3 load-dev-hci
|
||||
;
|
||||
|
||||
: usb-enumerate ( hcidev -- )
|
||||
drop
|
||||
;
|
||||
|
||||
: usb-scan ( -- )
|
||||
." Scanning USB " cr
|
||||
ohci-alias-num 1 >= IF
|
||||
USB-OHCI-REGISTER
|
||||
then
|
||||
;
|
||||
THEN
|
||||
|
||||
ohci-alias-num 0 ?DO
|
||||
" ohci" i $cathex find-device
|
||||
" get-hci-dev" get-node find-method
|
||||
IF
|
||||
execute usb-enumerate
|
||||
ELSE
|
||||
." get-base-address method not found for ohci" i . cr
|
||||
THEN
|
||||
LOOP
|
||||
|
||||
ehci-alias-num 0 ?DO
|
||||
" ehci" i $cathex find-device
|
||||
" get-hci-dev" get-node find-method
|
||||
IF
|
||||
execute usb-enumerate
|
||||
ELSE
|
||||
." get-base-address method not found for ehci" i . cr
|
||||
THEN
|
||||
LOOP
|
||||
|
||||
0 set-node \ FIXME Setting it back
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue