Subversion Repositories HelenOS

Rev

Rev 1946 | Rev 2071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1946 Rev 1984
Line 49... Line 49...
49
#define PCI_SABRE_REGS_REG  0
49
#define PCI_SABRE_REGS_REG  0
50
 
50
 
51
#define PCI_SABRE_IMAP_BASE 0x200
51
#define PCI_SABRE_IMAP_BASE 0x200
52
#define PCI_SABRE_ICLR_BASE 0x300
52
#define PCI_SABRE_ICLR_BASE 0x300
53
 
53
 
-
 
54
#define PCI_PSYCHO_REGS_REG 2   
-
 
55
 
-
 
56
#define PCI_PSYCHO_IMAP_BASE    0x200
-
 
57
#define PCI_PSYCHO_ICLR_BASE    0x300   
-
 
58
 
54
static pci_t *pci_sabre_init(ofw_tree_node_t *node);
59
static pci_t *pci_sabre_init(ofw_tree_node_t *node);
55
static void pci_sabre_enable_interrupt(pci_t *pci, int inr);
60
static void pci_sabre_enable_interrupt(pci_t *pci, int inr);
56
static void pci_sabre_clear_interrupt(pci_t *pci, int inr);
61
static void pci_sabre_clear_interrupt(pci_t *pci, int inr);
57
 
62
 
-
 
63
static pci_t *pci_psycho_init(ofw_tree_node_t *node);
-
 
64
static void pci_psycho_enable_interrupt(pci_t *pci, int inr);
-
 
65
static void pci_psycho_clear_interrupt(pci_t *pci, int inr);
-
 
66
 
58
/** PCI operations for Sabre model. */
67
/** PCI operations for Sabre model. */
59
static pci_operations_t pci_sabre_ops = {
68
static pci_operations_t pci_sabre_ops = {
60
    .enable_interrupt = pci_sabre_enable_interrupt,
69
    .enable_interrupt = pci_sabre_enable_interrupt,
61
    .clear_interrupt = pci_sabre_clear_interrupt
70
    .clear_interrupt = pci_sabre_clear_interrupt
62
};
71
};
-
 
72
/** PCI operations for Psycho model. */
-
 
73
static pci_operations_t pci_psycho_ops = {
-
 
74
    .enable_interrupt = pci_psycho_enable_interrupt,
-
 
75
    .clear_interrupt = pci_psycho_clear_interrupt
-
 
76
};
63
 
77
 
64
/** Initialize PCI controller (model Sabre). */
78
/** Initialize PCI controller (model Sabre).
-
 
79
 *
-
 
80
 * @param node OpenFirmware device tree node of the Sabre.
-
 
81
 *
-
 
82
 * @return Address of the initialized PCI structure.
-
 
83
 */
65
pci_t *pci_sabre_init(ofw_tree_node_t *node)
84
pci_t *pci_sabre_init(ofw_tree_node_t *node)
66
{
85
{
67
    pci_t *pci;
86
    pci_t *pci;
68
    ofw_tree_property_t *prop;
87
    ofw_tree_property_t *prop;
69
 
88
 
Line 93... Line 112...
93
    pci->reg = (uint64_t *) hw_map(paddr, reg[PCI_SABRE_REGS_REG].size);
112
    pci->reg = (uint64_t *) hw_map(paddr, reg[PCI_SABRE_REGS_REG].size);
94
 
113
 
95
    return pci;
114
    return pci;
96
}
115
}
97
 
116
 
-
 
117
 
-
 
118
/** Initialize the Psycho PCI controller.
-
 
119
 *
-
 
120
 * @param node OpenFirmware device tree node of the Psycho.
-
 
121
 *
-
 
122
 * @return Address of the initialized PCI structure.
-
 
123
 */
-
 
124
pci_t *pci_psycho_init(ofw_tree_node_t *node)
-
 
125
{
-
 
126
    pci_t *pci;
-
 
127
    ofw_tree_property_t *prop;
-
 
128
 
-
 
129
    /*
-
 
130
     * Get registers.
-
 
131
     */
-
 
132
    prop = ofw_tree_getprop(node, "reg");
-
 
133
    if (!prop || !prop->value)
-
 
134
        return NULL;
-
 
135
 
-
 
136
    ofw_upa_reg_t *reg = prop->value;
-
 
137
    count_t regs = prop->size / sizeof(ofw_upa_reg_t);
-
 
138
 
-
 
139
    if (regs < PCI_PSYCHO_REGS_REG + 1)
-
 
140
        return NULL;
-
 
141
 
-
 
142
    uintptr_t paddr;
-
 
143
    if (!ofw_upa_apply_ranges(node->parent, &reg[PCI_PSYCHO_REGS_REG], &paddr))
-
 
144
        return NULL;
-
 
145
 
-
 
146
    pci = (pci_t *) malloc(sizeof(pci_t), FRAME_ATOMIC);
-
 
147
    if (!pci)
-
 
148
        return NULL;
-
 
149
 
-
 
150
    pci->model = PCI_PSYCHO;
-
 
151
    pci->op = &pci_psycho_ops;
-
 
152
    pci->reg = (uint64_t *) hw_map(paddr, reg[PCI_PSYCHO_REGS_REG].size);
-
 
153
 
-
 
154
    return pci;
-
 
155
}
-
 
156
 
98
void pci_sabre_enable_interrupt(pci_t *pci, int inr)
157
void pci_sabre_enable_interrupt(pci_t *pci, int inr)
99
{
158
{
100
    pci->reg[PCI_SABRE_IMAP_BASE + (inr & INO_MASK)] |= IMAP_V_MASK;
159
    pci->reg[PCI_SABRE_IMAP_BASE + (inr & INO_MASK)] |= IMAP_V_MASK;
101
}
160
}
102
 
161
 
103
void pci_sabre_clear_interrupt(pci_t *pci, int inr)
162
void pci_sabre_clear_interrupt(pci_t *pci, int inr)
104
{
163
{
105
    pci->reg[PCI_SABRE_ICLR_BASE + (inr & INO_MASK)] = 0;
164
    pci->reg[PCI_SABRE_ICLR_BASE + (inr & INO_MASK)] = 0;
106
}
165
}
107
 
166
 
-
 
167
void pci_psycho_enable_interrupt(pci_t *pci, int inr)
-
 
168
{
-
 
169
    pci->reg[PCI_PSYCHO_IMAP_BASE + (inr & INO_MASK)] |= IMAP_V_MASK;
-
 
170
}
-
 
171
 
-
 
172
void pci_psycho_clear_interrupt(pci_t *pci, int inr)
-
 
173
{
-
 
174
    pci->reg[PCI_PSYCHO_ICLR_BASE + (inr & INO_MASK)] = 0;
-
 
175
}
-
 
176
 
108
/** Initialize PCI controller. */
177
/** Initialize PCI controller. */
109
pci_t *pci_init(ofw_tree_node_t *node)
178
pci_t *pci_init(ofw_tree_node_t *node)
110
{
179
{
111
    ofw_tree_property_t *prop;
180
    ofw_tree_property_t *prop;
112
 
181
 
Line 126... Line 195...
126
        /*
195
        /*
127
         * PCI controller Sabre.
196
         * PCI controller Sabre.
128
         * This model is found on UltraSPARC IIi based machines.
197
         * This model is found on UltraSPARC IIi based machines.
129
         */
198
         */
130
        return pci_sabre_init(node);
199
        return pci_sabre_init(node);
-
 
200
    } else if (strcmp(prop->value, "SUNW,psycho") == 0) {
-
 
201
        /*
-
 
202
         * PCI controller Psycho.
-
 
203
         * Used on UltraSPARC II based processors, for instance,
-
 
204
         * on Ultra 60.
-
 
205
         */
-
 
206
        return pci_psycho_init(node);
131
    } else {
207
    } else {
132
        /*
208
        /*
133
         * Unsupported model.
209
         * Unsupported model.
134
         */
210
         */
135
        printf("Unsupported PCI controller model (%s).\n", prop->value);
211
        printf("Unsupported PCI controller model (%s).\n", prop->value);