68d505868e27450a1e3b63a7a3d3c22cf0a549bf
[coreboot.git] / src / mainboard / via / epia-n / pata_methods.asl
1 /*
2  * Minimalist ACPI DSDT table for EPIA-N / NL
3  * Basic description of some hardware resources to allow
4  * interrupt assignments to be done. This is expected to be included
5  * into the PATA Device definition in ab_physical.asl
6  * (C) Copyright 2009 Jon Harrison <jon.harrison@blueyonder.co.uk>
7  *
8  */
9
10 Name (TIM0, Package (0x07)
11 {
12     Package (0x05)
13     {
14         0x78, 0xB4, 0xF0, 0x017F, 0x0258
15     },
16
17     Package (0x05)
18     {
19         0x20, 0x22, 0x33, 0x47, 0x5D
20     },
21
22     Package (0x05)
23     {
24         0x04, 0x03, 0x02, 0x01, 0x00
25     },
26
27     Package (0x04)
28     {
29         0x02, 0x01, 0x00, 0x00
30     },
31
32     Package (0x07)
33     {
34         0x78, 0x50, 0x3C, 0x2D, 0x1E, 0x14, 0x0F
35     },
36
37     Package (0x0F)
38     {
39         0x06, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02,
40         0x01, 0x01, 0x01, 0x01, 0x01, 0x01,0x00
41     },
42
43     Package (0x07)
44     {
45         0x0E, 0x08, 0x06, 0x04, 0x02, 0x01, 0x00
46     }
47 })
48
49
50 /* This method sets up the PATA Timing Control*/
51 /* Note that a lot of this is done in the     */
52 /* Coreboot VT8237R Init code, but this is    */
53 /* already getting very cluttered with board  */
54 /* specific code. Using ACPI will allow this  */
55 /* to be de-cluttered a bit (so long as we're */
56 /* running a ACPI Capable OS !!!)             */
57
58 Method (PMEX, 0, Serialized)
59 {
60     If (REGF)
61     {
62                 /* Check if these regs are still at defaults */
63                 /* Board specific timing improvement if not  */
64                 /* Already changed                           */
65         If (LEqual (PMPT, 0xA8))
66         {
67             Store (0x5D, PMPT)
68         }
69
70         If (LEqual (PSPT, 0xA8))
71         {
72             Store (0x5D, PSPT)
73         }
74
75         If (LEqual (SMPT, 0xA8))
76         {
77             Store (0x5D, SMPT)
78         }
79
80         If (LEqual (SSPT, 0xA8))
81         {
82             Store (0x5D, SSPT)
83         }
84
85     }
86 }
87
88 /* This Method Provides the method that is used to */
89 /* Reset ATA Drives to POST reset condition        */
90 Method (GTF, 4, Serialized)
91 {
92     Store (Buffer (0x07)
93         {
94             0x03, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xEF
95         }, Local1)
96     Store (Buffer (0x07)
97         {
98             0x03, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xEF
99         }, Local2)
100     CreateByteField (Local1, 0x01, MODE)
101     CreateByteField (Local2, 0x01, UMOD)
102     CreateByteField (Local1, 0x05, PCHA)
103     CreateByteField (Local2, 0x05, UCHA)
104     And (Arg0, 0x03, Local3)
105     If (LEqual (And (Local3, 0x01), 0x01))
106     {
107         Store (0xB0, PCHA)
108         Store (0xB0, UCHA)
109     }
110
111     If (Arg1)
112     {
113         Store (DerefOf (Index (DerefOf (Index (TIM0, 0x05)), Arg2)),
114             UMOD)
115         Or (UMOD, 0x40, UMOD)
116     }
117     Else
118     {
119         Store (Match (DerefOf (Index (TIM0, 0x01)), MEQ, Arg3, MTR,
120             0x00, 0x00), Local0)
121         Or (0x20, DerefOf (Index (DerefOf (Index (TIM0, 0x03)), Local0
122             )), UMOD)
123     }
124
125     Store (Match (DerefOf (Index (TIM0, 0x01)), MEQ, Arg3, MTR,
126         0x00, 0x00), Local0)
127     Or (0x08, DerefOf (Index (DerefOf (Index (TIM0, 0x02)), Local0
128         )), MODE)
129     Concatenate (Local1, Local2, Local6)
130     Return (Local6)
131 }
132