paul@0 | 1 | /* |
paul@0 | 2 | * LCD peripheral support for the JZ4740 and related SoCs. |
paul@0 | 3 | * |
paul@31 | 4 | * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 5 | * |
paul@0 | 6 | * This program is free software; you can redistribute it and/or |
paul@0 | 7 | * modify it under the terms of the GNU General Public License as |
paul@0 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@0 | 9 | * the License, or (at your option) any later version. |
paul@0 | 10 | * |
paul@0 | 11 | * This program is distributed in the hope that it will be useful, |
paul@0 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@0 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@0 | 14 | * GNU General Public License for more details. |
paul@0 | 15 | * |
paul@0 | 16 | * You should have received a copy of the GNU General Public License |
paul@0 | 17 | * along with this program; if not, write to the Free Software |
paul@0 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@0 | 19 | * Boston, MA 02110-1301, USA |
paul@0 | 20 | */ |
paul@0 | 21 | |
paul@0 | 22 | #pragma once |
paul@0 | 23 | |
paul@0 | 24 | #include "lcd.h" |
paul@0 | 25 | #include "lcd-jz4740-panel.h" |
paul@0 | 26 | |
paul@0 | 27 | #include <l4/sys/types.h> |
paul@0 | 28 | |
paul@0 | 29 | #include <stdint.h> |
paul@0 | 30 | |
paul@0 | 31 | /* Descriptor referenced by the DMA mechanism. */ |
paul@0 | 32 | |
paul@0 | 33 | struct Jz4740_lcd_descriptor |
paul@0 | 34 | { |
paul@0 | 35 | struct Jz4740_lcd_descriptor *next; /* FDADR: frame descriptor address */ |
paul@0 | 36 | uint32_t source; /* FSADR: frame source address */ |
paul@0 | 37 | uint32_t identifier; /* FIDR: frame identifier */ |
paul@0 | 38 | uint32_t command; /* CMD: command */ |
paul@0 | 39 | }; |
paul@0 | 40 | |
paul@0 | 41 | |
paul@0 | 42 | |
paul@0 | 43 | /* C++ language interface. */ |
paul@0 | 44 | |
paul@0 | 45 | #ifdef __cplusplus |
paul@0 | 46 | |
paul@0 | 47 | #include <l4/devices/hw_mmio_register_block.h> |
paul@0 | 48 | |
paul@0 | 49 | /* General JZ4740 LCD controller support. */ |
paul@0 | 50 | |
paul@0 | 51 | class Lcd_jz4740_chip : public Lcd_chip |
paul@0 | 52 | { |
paul@0 | 53 | private: |
paul@0 | 54 | Hw::Register_block<32> _regs; |
paul@0 | 55 | Jz4740_lcd_panel *_panel; |
paul@0 | 56 | int _burst_size; |
paul@0 | 57 | |
paul@0 | 58 | /* Control register value calculation. */ |
paul@0 | 59 | |
paul@0 | 60 | uint32_t _control_bpp(); |
paul@0 | 61 | uint32_t _control_panel(); |
paul@0 | 62 | uint32_t _control_stn_frc(); |
paul@0 | 63 | uint32_t _control_transfer(); |
paul@0 | 64 | |
paul@0 | 65 | /* Panel mode access. */ |
paul@0 | 66 | |
paul@0 | 67 | uint32_t _mode(); |
paul@0 | 68 | |
paul@0 | 69 | /* Panel initialisation. */ |
paul@0 | 70 | |
paul@0 | 71 | void _init_stn(); |
paul@0 | 72 | void _init_tft(); |
paul@0 | 73 | void _init_panel(); |
paul@0 | 74 | |
paul@0 | 75 | /* Descriptor initialisation. */ |
paul@0 | 76 | |
paul@0 | 77 | void _set_descriptor(struct Jz4740_lcd_descriptor &desc, l4_addr_t source, |
paul@0 | 78 | l4_size_t size, struct Jz4740_lcd_descriptor *next, |
paul@0 | 79 | uint32_t flags = 0); |
paul@0 | 80 | |
paul@0 | 81 | public: |
paul@0 | 82 | Lcd_jz4740_chip(l4_addr_t addr, Jz4740_lcd_panel *panel); |
paul@0 | 83 | |
paul@0 | 84 | struct Jz4740_lcd_panel *get_panel(); |
paul@0 | 85 | |
paul@0 | 86 | /* Peripheral control. */ |
paul@0 | 87 | |
paul@0 | 88 | void disable(); |
paul@0 | 89 | void disable_quick(); |
paul@0 | 90 | void enable(); |
paul@0 | 91 | |
paul@0 | 92 | /* Peripheral properties. */ |
paul@0 | 93 | |
paul@0 | 94 | int get_pixel_clock(); |
paul@0 | 95 | |
paul@0 | 96 | /* Panel properties. */ |
paul@0 | 97 | |
paul@0 | 98 | int get_panels(); |
paul@0 | 99 | int have_stn_panel(); |
paul@0 | 100 | int have_colour_stn(); |
paul@0 | 101 | int have_serial_tft(); |
paul@0 | 102 | |
paul@0 | 103 | /* Memory properties. */ |
paul@0 | 104 | |
paul@0 | 105 | l4_size_t get_line_size(); |
paul@0 | 106 | l4_size_t get_screen_size(); |
paul@0 | 107 | l4_size_t get_aligned_size(); |
paul@0 | 108 | l4_size_t get_palette_size(); |
paul@0 | 109 | l4_size_t get_aligned_palette_size(); |
paul@0 | 110 | |
paul@0 | 111 | /* Memory properties for allocation purposes. */ |
paul@0 | 112 | |
paul@0 | 113 | l4_size_t get_total_size(); |
paul@0 | 114 | l4_size_t get_descriptors_size(); |
paul@0 | 115 | |
paul@0 | 116 | /* Memory region access. */ |
paul@0 | 117 | |
paul@0 | 118 | l4_addr_t get_palette(l4_addr_t screen); |
paul@0 | 119 | l4_addr_t get_framebuffer(int panel, l4_addr_t screen); |
paul@0 | 120 | |
paul@0 | 121 | /* Convenience methods. */ |
paul@0 | 122 | |
paul@0 | 123 | void init_palette(l4_addr_t palette); |
paul@0 | 124 | |
paul@0 | 125 | /* Configuration. */ |
paul@0 | 126 | |
paul@0 | 127 | void config(struct Jz4740_lcd_descriptor *desc_vaddr, |
paul@0 | 128 | struct Jz4740_lcd_descriptor *desc_paddr, |
paul@0 | 129 | l4_addr_t fb_paddr); |
paul@0 | 130 | }; |
paul@0 | 131 | |
paul@0 | 132 | #endif |
paul@0 | 133 | |
paul@0 | 134 | |
paul@0 | 135 | |
paul@0 | 136 | /* C language interface. */ |
paul@0 | 137 | |
paul@0 | 138 | EXTERN_C_BEGIN |
paul@0 | 139 | |
paul@0 | 140 | void *jz4740_lcd_init(l4_addr_t lcd_base, struct Jz4740_lcd_panel *panel); |
paul@0 | 141 | |
paul@0 | 142 | void jz4740_lcd_config(void *lcd, struct Jz4740_lcd_descriptor *desc_vaddr, |
paul@0 | 143 | struct Jz4740_lcd_descriptor *desc_paddr, |
paul@0 | 144 | l4_addr_t fb_paddr); |
paul@0 | 145 | |
paul@0 | 146 | void jz4740_lcd_disable(void *lcd); |
paul@0 | 147 | void jz4740_lcd_disable_quick(void *lcd); |
paul@0 | 148 | void jz4740_lcd_enable(void *lcd); |
paul@0 | 149 | |
paul@0 | 150 | l4_addr_t jz4740_lcd_get_palette(void *lcd, l4_addr_t base); |
paul@0 | 151 | int jz4740_lcd_get_pixel_clock(void *lcd); |
paul@0 | 152 | |
paul@0 | 153 | void jz4740_lcd_init_palette(void *lcd, l4_addr_t palette); |
paul@0 | 154 | |
paul@0 | 155 | EXTERN_C_END |