2 * Copyright 2010 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef __NOUVEAU_HWSQ_H__
26 #define __NOUVEAU_HWSQ_H__
42 hwsq_init(struct hwsq_ucode *hwsq)
44 hwsq->ptr.u08 = hwsq->data;
45 hwsq->reg = 0xffffffff;
46 hwsq->val = 0xffffffff;
50 hwsq_fini(struct hwsq_ucode *hwsq)
53 *hwsq->ptr.u08++ = 0x7f;
54 hwsq->len = hwsq->ptr.u08 - hwsq->data;
55 } while (hwsq->len & 3);
56 hwsq->ptr.u08 = hwsq->data;
60 hwsq_usec(struct hwsq_ucode *hwsq, u8 usec)
68 *hwsq->ptr.u08++ = (shift << 2) | usec;
72 hwsq_setf(struct hwsq_ucode *hwsq, u8 flag, int val)
79 *hwsq->ptr.u08++ = flag;
83 hwsq_op5f(struct hwsq_ucode *hwsq, u8 v0, u8 v1)
85 *hwsq->ptr.u08++ = 0x5f;
86 *hwsq->ptr.u08++ = v0;
87 *hwsq->ptr.u08++ = v1;
91 hwsq_wr32(struct hwsq_ucode *hwsq, u32 reg, u32 val)
93 if (val != hwsq->val) {
94 if ((val & 0xffff0000) == (hwsq->val & 0xffff0000)) {
95 *hwsq->ptr.u08++ = 0x42;
96 *hwsq->ptr.u16++ = (val & 0x0000ffff);
98 *hwsq->ptr.u08++ = 0xe2;
99 *hwsq->ptr.u32++ = val;
105 if ((reg & 0xffff0000) == (hwsq->reg & 0xffff0000)) {
106 *hwsq->ptr.u08++ = 0x40;
107 *hwsq->ptr.u16++ = (reg & 0x0000ffff);
109 *hwsq->ptr.u08++ = 0xe0;
110 *hwsq->ptr.u32++ = reg;