Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/video/bt455.h |
| 3 | * |
| 4 | * Copyright 2003 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 5 | * Copyright 2016 Maciej W. Rozycki <macro@linux-mips.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Maciej W. Rozycki | 5832706 | 2016-02-22 01:55:27 +0000 | [diff] [blame] | 33 | static inline void bt455_reset_reg(struct bt455_regs *regs) |
| 34 | { |
| 35 | mb(); |
| 36 | regs->addr_clr = 0; |
| 37 | } |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | /* |
| 40 | * Read/write to a Bt455 color map register. |
| 41 | */ |
Maciej W. Rozycki | 5832706 | 2016-02-22 01:55:27 +0000 | [diff] [blame] | 42 | static inline void bt455_read_cmap_next(struct bt455_regs *regs, u8 *grey) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | mb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 45 | regs->addr_cmap_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | rmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 47 | *grey = regs->addr_cmap_data & 0xf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | rmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 49 | regs->addr_cmap_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Maciej W. Rozycki | 5832706 | 2016-02-22 01:55:27 +0000 | [diff] [blame] | 52 | static inline void bt455_write_cmap_next(struct bt455_regs *regs, u8 grey) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | wmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 55 | regs->addr_cmap_data = 0x0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | wmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 57 | regs->addr_cmap_data = grey & 0xf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | wmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 59 | regs->addr_cmap_data = 0x0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Maciej W. Rozycki | 5832706 | 2016-02-22 01:55:27 +0000 | [diff] [blame] | 62 | static inline void bt455_write_ovly_next(struct bt455_regs *regs, u8 grey) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | wmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 65 | regs->addr_ovly = 0x0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | wmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 67 | regs->addr_ovly = grey & 0xf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | wmb(); |
Maciej W. Rozycki | 01ac59c | 2016-02-22 01:55:21 +0000 | [diff] [blame] | 69 | regs->addr_ovly = 0x0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
Maciej W. Rozycki | 5832706 | 2016-02-22 01:55:27 +0000 | [diff] [blame] | 71 | |
| 72 | static 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 | |
| 79 | static 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 | |
| 86 | static 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 | } |