blob: dd1404b40611db952e5a8ba013a688a6887087ee [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/drivers/video/bt455.h
3 *
4 * Copyright 2003 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +00005 * Copyright 2016 Maciej W. Rozycki <macro@linux-mips.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13/*
14 * Bt455 byte-wide registers, 32-bit aligned.
15 */
16struct 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
27static inline void bt455_select_reg(struct bt455_regs *regs, int ir)
28{
29 mb();
30 regs->addr_cmap = ir & 0x0f;
31}
32
Maciej W. Rozycki58327062016-02-22 01:55:27 +000033static inline void bt455_reset_reg(struct bt455_regs *regs)
34{
35 mb();
36 regs->addr_clr = 0;
37}
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039/*
40 * Read/write to a Bt455 color map register.
41 */
Maciej W. Rozycki58327062016-02-22 01:55:27 +000042static inline void bt455_read_cmap_next(struct bt455_regs *regs, u8 *grey)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 mb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000045 regs->addr_cmap_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 rmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000047 *grey = regs->addr_cmap_data & 0xf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 rmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000049 regs->addr_cmap_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
Maciej W. Rozycki58327062016-02-22 01:55:27 +000052static inline void bt455_write_cmap_next(struct bt455_regs *regs, u8 grey)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 wmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000055 regs->addr_cmap_data = 0x0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 wmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000057 regs->addr_cmap_data = grey & 0xf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 wmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000059 regs->addr_cmap_data = 0x0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060}
61
Maciej W. Rozycki58327062016-02-22 01:55:27 +000062static inline void bt455_write_ovly_next(struct bt455_regs *regs, u8 grey)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 wmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000065 regs->addr_ovly = 0x0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 wmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000067 regs->addr_ovly = grey & 0xf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 wmb();
Maciej W. Rozycki01ac59c2016-02-22 01:55:21 +000069 regs->addr_ovly = 0x0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
Maciej W. Rozycki58327062016-02-22 01:55:27 +000071
72static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
73 int cr, u8 *grey)
74{
75 bt455_select_reg(regs, cr);
76 bt455_read_cmap_next(regs, grey);
77}
78
79static inline void bt455_write_cmap_entry(struct bt455_regs *regs,
80 int cr, u8 grey)
81{
82 bt455_select_reg(regs, cr);
83 bt455_write_cmap_next(regs, grey);
84}
85
86static inline void bt455_write_ovly_entry(struct bt455_regs *regs, u8 grey)
87{
88 bt455_reset_reg(regs);
89 bt455_write_ovly_next(regs, grey);
90}