i2c-eg20t: change timeout value 50msec to 1000msec
[zen-stable.git] / drivers / gpu / drm / nouveau / nouveau_hwsq.h
blob697687593a81e944b27571c52fe9e6a89d1a802e
1 /*
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.
22 * Authors: Ben Skeggs
25 #ifndef __NOUVEAU_HWSQ_H__
26 #define __NOUVEAU_HWSQ_H__
28 struct hwsq_ucode {
29 u8 data[0x200];
30 union {
31 u8 *u08;
32 u16 *u16;
33 u32 *u32;
34 } ptr;
35 u16 len;
37 u32 reg;
38 u32 val;
41 static inline void
42 hwsq_init(struct hwsq_ucode *hwsq)
44 hwsq->ptr.u08 = hwsq->data;
45 hwsq->reg = 0xffffffff;
46 hwsq->val = 0xffffffff;
49 static inline void
50 hwsq_fini(struct hwsq_ucode *hwsq)
52 do {
53 *hwsq->ptr.u08++ = 0x7f;
54 hwsq->len = hwsq->ptr.u08 - hwsq->data;
55 } while (hwsq->len & 3);
56 hwsq->ptr.u08 = hwsq->data;
59 static inline void
60 hwsq_usec(struct hwsq_ucode *hwsq, u8 usec)
62 u32 shift = 0;
63 while (usec & ~3) {
64 usec >>= 2;
65 shift++;
68 *hwsq->ptr.u08++ = (shift << 2) | usec;
71 static inline void
72 hwsq_setf(struct hwsq_ucode *hwsq, u8 flag, int val)
74 flag += 0x80;
75 if (val >= 0)
76 flag += 0x20;
77 if (val >= 1)
78 flag += 0x20;
79 *hwsq->ptr.u08++ = flag;
82 static inline void
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;
90 static inline void
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);
97 } else {
98 *hwsq->ptr.u08++ = 0xe2;
99 *hwsq->ptr.u32++ = val;
102 hwsq->val = val;
105 if ((reg & 0xffff0000) == (hwsq->reg & 0xffff0000)) {
106 *hwsq->ptr.u08++ = 0x40;
107 *hwsq->ptr.u16++ = (reg & 0x0000ffff);
108 } else {
109 *hwsq->ptr.u08++ = 0xe0;
110 *hwsq->ptr.u32++ = reg;
112 hwsq->reg = reg;
115 #endif