LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
tinyehci.c
Go to the documentation of this file.
1/*
2 Custom IOS Module (EHCI)
3
4 Copyright (C) 2008 neimod.
5 Copyright (C) 2009 kwiirk.
6 Copyright (C) 2009 Hermes.
7 Copyright (C) 2009 Waninkoko.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22*/
23
24#include <stdlib.h>
25#include <string.h>
26#include <setjmp.h>
27#include <byteswap.h>
28#include <pci/io.h>
29#include <ppc/timebase.h>
30#include <ppc/cache.h>
31#include <xetypes.h>
32#include <debug.h>
33
34#include "ehci_types.h"
35#include "ehci.h"
36
37//#define DEBUG
38//#define MEM_PRINT
39
40/* Macros */
41#ifdef DEBUG
42 #define debug_printf(a...) printf(a)
43#else
44 #define debug_printf(a...)
45#endif
46
47#define print_hex_dump_bytes(a, b, c, d)
48
49#define ehci_dbg(a...) debug_printf(a)
50#define printk(a...) debug_printf(a)
51#define BUG() while(1)
52#define BUG_ON(a) while(1)
53#define cpu_to_le32(a) bswap_32(a)
54#define le32_to_cpu(a) bswap_32(a)
55#define cpu_to_le16(a) bswap_16(a)
56#define le16_to_cpu(a) bswap_16(a)
57#define cpu_to_be32(a) (a)
58#define be32_to_cpu(a) (a)
59#define ehci_readl(a) read32((u32)a)
60#define ehci_writel(v,a) write32((u32)a,v)
61#define get_timer() (mftb()/(PPC_TIMEBASE_FREQ/1000000LL))
62
63#define EHCI_HCD_COUNT 2
64
65/* EHCI structure */
67
68#include "ehci.c"
69
70static s32 EHCI_do_one(u32 idx,u32 addr)
71{
72 s32 ret;
73 struct ehci_hcd *ehci=&ehci_hcds[idx];
74
75 /* EHCI addresses */
76 ehci->caps = (void *)addr;
77 ehci->regs = (void *)(addr + HC_LENGTH(ehci_readl(&ehci->caps->hc_capbase)));
78
79 printf("Initialising EHCI bus %d at %p\n",idx,addr);
80
81 /* Setup EHCI */
83
84 ehci_dbg("ehci->hcs_params %x\n",ehci->hcs_params);
85
87 ehci->bus_id = idx;
88
89 /* Initialize EHCI */
90 ret = ehci_init(ehci,1);
91 if (ret)
92 return ret;
93
95
96 return 0;
97}
98
99
101{
102 s32 ret;
103
104 ret=EHCI_do_one(0,0xea003000);
105 if (ret)
106 return ret;
107
108 ret=EHCI_do_one(1,0xea005000);
109 return ret;
110}
int ehci_discover(struct ehci_hcd *ehci)
Definition: ehci.c:984
struct ehci_hcd * ehci
Definition: ehci.h:23
#define HC_LENGTH(p)
Definition: ehci_defs.h:4
#define HCS_N_PORTS(p)
Definition: ehci_defs.h:13
u32 hcs_params
Definition: ehci_defs.h:32
u32 hc_capbase
Definition: ehci_defs.h:29
Definition: ehci.h:75
struct ehci_caps __iomem * caps
Definition: ehci.h:78
int bus_id
Definition: ehci.h:102
__u32 hcs_params
Definition: ehci.h:82
struct ehci_regs __iomem * regs
Definition: ehci.h:79
u8 num_port
Definition: ehci.h:98
struct ehci_hcd ehci_hcds[EHCI_HCD_COUNT]
Definition: tinyehci.c:66
#define ehci_dbg(a...)
Definition: tinyehci.c:49
#define EHCI_HCD_COUNT
Definition: tinyehci.c:63
#define ehci_readl(a)
Definition: tinyehci.c:59
s32 EHCI_Init(void)
Definition: tinyehci.c:100
int32_t s32
32bit signed integer
Definition: xetypes.h:19
uint32_t u32
32bit unsigned integer
Definition: xetypes.h:14