18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * linux/drivers/video/bt455.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright 2003 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> 58c2ecf20Sopenharmony_ci * Copyright 2016 Maciej W. Rozycki <macro@linux-mips.org> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General 88c2ecf20Sopenharmony_ci * Public License. See the file COPYING in the main directory of this 98c2ecf20Sopenharmony_ci * archive for more details. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Bt455 byte-wide registers, 32-bit aligned. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_cistruct bt455_regs { 178c2ecf20Sopenharmony_ci volatile u8 addr_cmap; 188c2ecf20Sopenharmony_ci u8 pad0[3]; 198c2ecf20Sopenharmony_ci volatile u8 addr_cmap_data; 208c2ecf20Sopenharmony_ci u8 pad1[3]; 218c2ecf20Sopenharmony_ci volatile u8 addr_clr; 228c2ecf20Sopenharmony_ci u8 pad2[3]; 238c2ecf20Sopenharmony_ci volatile u8 addr_ovly; 248c2ecf20Sopenharmony_ci u8 pad3[3]; 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic inline void bt455_select_reg(struct bt455_regs *regs, int ir) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci mb(); 308c2ecf20Sopenharmony_ci regs->addr_cmap = ir & 0x0f; 318c2ecf20Sopenharmony_ci} 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistatic inline void bt455_reset_reg(struct bt455_regs *regs) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci mb(); 368c2ecf20Sopenharmony_ci regs->addr_clr = 0; 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* 408c2ecf20Sopenharmony_ci * Read/write to a Bt455 color map register. 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_cistatic inline void bt455_read_cmap_next(struct bt455_regs *regs, u8 *grey) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci mb(); 458c2ecf20Sopenharmony_ci regs->addr_cmap_data; 468c2ecf20Sopenharmony_ci rmb(); 478c2ecf20Sopenharmony_ci *grey = regs->addr_cmap_data & 0xf; 488c2ecf20Sopenharmony_ci rmb(); 498c2ecf20Sopenharmony_ci regs->addr_cmap_data; 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic inline void bt455_write_cmap_next(struct bt455_regs *regs, u8 grey) 538c2ecf20Sopenharmony_ci{ 548c2ecf20Sopenharmony_ci wmb(); 558c2ecf20Sopenharmony_ci regs->addr_cmap_data = 0x0; 568c2ecf20Sopenharmony_ci wmb(); 578c2ecf20Sopenharmony_ci regs->addr_cmap_data = grey & 0xf; 588c2ecf20Sopenharmony_ci wmb(); 598c2ecf20Sopenharmony_ci regs->addr_cmap_data = 0x0; 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistatic inline void bt455_write_ovly_next(struct bt455_regs *regs, u8 grey) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci wmb(); 658c2ecf20Sopenharmony_ci regs->addr_ovly = 0x0; 668c2ecf20Sopenharmony_ci wmb(); 678c2ecf20Sopenharmony_ci regs->addr_ovly = grey & 0xf; 688c2ecf20Sopenharmony_ci wmb(); 698c2ecf20Sopenharmony_ci regs->addr_ovly = 0x0; 708c2ecf20Sopenharmony_ci} 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistatic inline void bt455_read_cmap_entry(struct bt455_regs *regs, 738c2ecf20Sopenharmony_ci int cr, u8 *grey) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci bt455_select_reg(regs, cr); 768c2ecf20Sopenharmony_ci bt455_read_cmap_next(regs, grey); 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistatic inline void bt455_write_cmap_entry(struct bt455_regs *regs, 808c2ecf20Sopenharmony_ci int cr, u8 grey) 818c2ecf20Sopenharmony_ci{ 828c2ecf20Sopenharmony_ci bt455_select_reg(regs, cr); 838c2ecf20Sopenharmony_ci bt455_write_cmap_next(regs, grey); 848c2ecf20Sopenharmony_ci} 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic inline void bt455_write_ovly_entry(struct bt455_regs *regs, u8 grey) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci bt455_reset_reg(regs); 898c2ecf20Sopenharmony_ci bt455_write_ovly_next(regs, grey); 908c2ecf20Sopenharmony_ci} 91