xref: /linux-6.15/drivers/video/fbdev/bt455.h (revision 01ac59c3)
1 /*
2  *	linux/drivers/video/bt455.h
3  *
4  *	Copyright 2003  Thiemo Seufer <[email protected]>
5  *	Copyright 2016  Maciej W. Rozycki <[email protected]>
6  *
7  *	This file is subject to the terms and conditions of the GNU General
8  *	Public License. See the file COPYING in the main directory of this
9  *	archive for more details.
10  */
11 #include <linux/types.h>
12 
13 /*
14  * Bt455 byte-wide registers, 32-bit aligned.
15  */
16 struct bt455_regs {
17 	volatile u8 addr_cmap;
18 	u8 pad0[3];
19 	volatile u8 addr_cmap_data;
20 	u8 pad1[3];
21 	volatile u8 addr_clr;
22 	u8 pad2[3];
23 	volatile u8 addr_ovly;
24 	u8 pad3[3];
25 };
26 
27 static inline void bt455_select_reg(struct bt455_regs *regs, int ir)
28 {
29 	mb();
30 	regs->addr_cmap = ir & 0x0f;
31 }
32 
33 /*
34  * Read/write to a Bt455 color map register.
35  */
36 static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
37 					 int cr, u8 *grey)
38 {
39 	bt455_select_reg(regs, cr);
40 	mb();
41 	regs->addr_cmap_data;
42 	rmb();
43 	*grey = regs->addr_cmap_data & 0xf;
44 	rmb();
45 	regs->addr_cmap_data;
46 }
47 
48 static inline void bt455_write_cmap_entry(struct bt455_regs *regs,
49 					  int cr, u8 grey)
50 {
51 	bt455_select_reg(regs, cr);
52 	wmb();
53 	regs->addr_cmap_data = 0x0;
54 	wmb();
55 	regs->addr_cmap_data = grey & 0xf;
56 	wmb();
57 	regs->addr_cmap_data = 0x0;
58 }
59 
60 static inline void bt455_write_ovly_entry(struct bt455_regs *regs,
61 					  int cr, u8 grey)
62 {
63 	bt455_select_reg(regs, cr);
64 	wmb();
65 	regs->addr_ovly = 0x0;
66 	wmb();
67 	regs->addr_ovly = grey & 0xf;
68 	wmb();
69 	regs->addr_ovly = 0x0;
70 }
71