xref: /haiku/src/add-ons/kernel/busses/usb/xhci.h (revision b46615c55ad2c8fe6de54412055a0713da3d610a)
1 /*
2  * Copyright 2006-2011, Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Lotz <mmlr@mlotz.ch>
7  *		Jian Chiang <j.jian.chiang@gmail.com>
8  */
9 #ifndef XHCI_H
10 #define XHCI_H
11 
12 
13 #include "usb_private.h"
14 #include "xhci_hardware.h"
15 
16 
17 struct pci_info;
18 struct pci_module_info;
19 
20 
21 class XHCI : public BusManager {
22 public:
23 								XHCI(pci_info *info, Stack *stack);
24 								~XHCI();
25 
26 			status_t			Start();
27 	virtual	status_t			SubmitTransfer(Transfer *transfer);
28 	virtual	status_t			CancelQueuedTransfers(Pipe *pipe, bool force);
29 
30 	virtual	status_t			NotifyPipeChange(Pipe *pipe,
31 									usb_change change);
32 
33 	static	status_t			AddTo(Stack *stack);
34 
35 		// Port operations for root hub
36 			uint8				PortCount() { return fPortCount; };
37 			status_t			GetPortStatus(uint8 index, usb_port_status *status);
38 			status_t			SetPortFeature(uint8 index, uint16 feature);
39 			status_t			ClearPortFeature(uint8 index, uint16 feature);
40 
41 			status_t			ResetPort(uint8 index);
42 			status_t			SuspendPort(uint8 index);
43 
44 	virtual	const char *		TypeName() const { return "xhci"; };
45 
46 private:
47 		// Controller resets
48 			status_t			ControllerReset();
49 			status_t			ControllerHalt();
50 			status_t			LightReset();
51 
52 		// Interrupt functions
53 	static	int32				InterruptHandler(void *data);
54 			int32				Interrupt();
55 
56 
57 		// Operational register functions
58 	inline	void				WriteOpReg(uint32 reg, uint32 value);
59 	inline	uint32				ReadOpReg(uint32 reg);
60 
61 		// Capability register functions
62 	inline	uint8				ReadCapReg8(uint32 reg);
63 	inline	uint16				ReadCapReg16(uint32 reg);
64 	inline	uint32				ReadCapReg32(uint32 reg);
65 	inline	void				WriteCapReg32(uint32 reg, uint32 value);
66 
67 	static	pci_module_info *	sPCIModule;
68 
69 			uint8 *				fCapabilityRegisters;
70 			uint8 *				fOperationalRegisters;
71 			uint8 *				fRuntimeRegisters;
72 			area_id				fRegisterArea;
73 			pci_info *			fPCIInfo;
74 			Stack *				fStack;
75 
76 		// Root Hub
77 
78 		// Port management
79 			uint8				fPortCount;
80 };
81 
82 
83 #endif // !XHCI_H
84