Subversion Repositories freemyipod

Rev

Rev 892 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
892 theseven 1
#include "global.h"
2
#include "synopsysotg.h"
3
#include "interrupt.h"
4
#include "clockgates.h"
5
#include "power.h"
6
#include "timer.h"
7
 
8
#ifdef TARGET_ipodnano2g
9
#include "target/ipodnano2g/s5l8701.h"
10
#endif
11
#if defined(TARGET_ipodnano3g) || defined(TARGET_ipodclassic)
12
#include "target/ipodnano3g/s5l8702.h"
13
#endif
14
#if defined(TARGET_ipodnano4g) || defined(TARGET_ipodtouch2g)
15
#include "target/ipodnano4g/s5l8720.h"
16
#endif
17
 
18
 
19
static const struct usb_instance* synopsysotg_instance;
20
 
21
void synopsysotg_target_enable_clocks(const struct usb_instance* instance)
22
{
23
    const struct synopsysotg_config* data = (const struct synopsysotg_config*)instance->driver_config;
24
    clockgate_enable(CLOCKGATE_USB_1, true);
25
    clockgate_enable(CLOCKGATE_USB_2, true);
26
    data->core->pcgcctl.d32 = 0;
27
    *((volatile uint32_t*)(PHYBASE + 0x00)) = 0;  /* PHY: Power up */
28
    udelay(10);
29
    *((volatile uint32_t*)(PHYBASE + 0x1c)) = 1;
30
    *((volatile uint32_t*)(PHYBASE + 0x44)) = 0xe3f;
31
    *((volatile uint32_t*)(PHYBASE + 0x08)) = 1;  /* PHY: Assert Software Reset */
32
    udelay(10);
33
    *((volatile uint32_t*)(PHYBASE + 0x08)) = 0;  /* PHY: Deassert Software Reset */
34
    udelay(10);
35
    *((volatile uint32_t*)(PHYBASE + 0x18)) = 0x600;
36
    *((volatile uint32_t*)(PHYBASE + 0x04)) = SYNOPSYSOTG_CLOCK;
37
    udelay(400);
38
}
39
 
40
void synopsysotg_target_disable_clocks(const struct usb_instance* instance)
41
{
42
    *((volatile uint32_t*)(PHYBASE + 0x00)) = 0xf;  /* PHY: Power down */
43
    udelay(10);
44
    *((volatile uint32_t*)(PHYBASE + 0x08)) = 7;  /* PHY: Assert Software Reset */
45
    udelay(10);
46
    const struct synopsysotg_config* data = (const struct synopsysotg_config*)instance->driver_config;
47
    data->core->pcgcctl.d32 = 0;
48
    clockgate_enable(CLOCKGATE_USB_1, false);
49
    clockgate_enable(CLOCKGATE_USB_2, false);
50
}
51
 
52
void synopsysotg_target_enable_irq(const struct usb_instance* instance)
53
{
54
    synopsysotg_instance = instance;
55
    interrupt_enable(IRQ_USB_FUNC, true);
56
}
57
 
58
void synopsysotg_target_disable_irq(const struct usb_instance* instance)
59
{
60
    interrupt_enable(IRQ_USB_FUNC, false);
61
}
62
 
63
void synopsysotg_target_clear_irq(const struct usb_instance* instance)
64
{
65
}
66
 
67
void INT_USB_FUNC()
68
{
69
    synopsysotg_irq(synopsysotg_instance);
70
}
71