Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Header file for AT91/AT32 LCD Controller |
| 3 | * |
| 4 | * Data structure and register user interface |
| 5 | * |
| 6 | * Copyright (C) 2007 Atmel Corporation |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | #ifndef __ATMEL_LCDC_H__ |
| 23 | #define __ATMEL_LCDC_H__ |
| 24 | |
Adrian Bunk | 44ccac1 | 2008-07-25 19:44:38 -0700 | [diff] [blame] | 25 | #include <linux/workqueue.h> |
Nicolas Ferre | fd08580 | 2008-04-28 02:15:21 -0700 | [diff] [blame] | 26 | |
| 27 | /* Way LCD wires are connected to the chip: |
| 28 | * Some Atmel chips use BGR color mode (instead of standard RGB) |
| 29 | * A swapped wiring onboard can bring to RGB mode. |
| 30 | */ |
| 31 | #define ATMEL_LCDC_WIRING_BGR 0 |
| 32 | #define ATMEL_LCDC_WIRING_RGB 1 |
| 33 | |
Johan Hovold | bbd44f6b | 2013-02-07 16:31:58 +0100 | [diff] [blame] | 34 | struct atmel_lcdfb_config; |
Nicolas Ferre | fd08580 | 2008-04-28 02:15:21 -0700 | [diff] [blame] | 35 | |
David Brownell | a9a84c3 | 2008-02-06 01:39:26 -0800 | [diff] [blame] | 36 | /* LCD Controller info data structure, stored in device platform_data */ |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 37 | struct atmel_lcdfb_info { |
| 38 | spinlock_t lock; |
| 39 | struct fb_info *info; |
| 40 | void __iomem *mmio; |
Nicolas Ferre | 722facc | 2008-11-12 13:24:59 -0800 | [diff] [blame] | 41 | int irq_base; |
Nicolas Ferre | d22579b | 2008-07-23 21:31:20 -0700 | [diff] [blame] | 42 | struct work_struct task; |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 43 | |
| 44 | unsigned int guard_time; |
Haavard Skinnemoen | ea757ac | 2008-08-12 15:08:57 -0700 | [diff] [blame] | 45 | unsigned int smem_len; |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 46 | struct platform_device *pdev; |
| 47 | struct clk *bus_clk; |
| 48 | struct clk *lcdc_clk; |
David Brownell | a9a84c3 | 2008-02-06 01:39:26 -0800 | [diff] [blame] | 49 | |
| 50 | #ifdef CONFIG_BACKLIGHT_ATMEL_LCDC |
| 51 | struct backlight_device *backlight; |
| 52 | u8 bl_power; |
| 53 | #endif |
| 54 | bool lcdcon_is_backlight; |
Andreas Bießmann | 7cdcdb6 | 2011-02-11 15:19:43 +0000 | [diff] [blame] | 55 | bool lcdcon_pol_negative; |
David Brownell | cf19a37 | 2008-04-28 02:15:20 -0700 | [diff] [blame] | 56 | u8 saved_lcdcon; |
David Brownell | a9a84c3 | 2008-02-06 01:39:26 -0800 | [diff] [blame] | 57 | |
| 58 | u8 default_bpp; |
Nicolas Ferre | fd08580 | 2008-04-28 02:15:21 -0700 | [diff] [blame] | 59 | u8 lcd_wiring_mode; |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 60 | unsigned int default_lcdcon2; |
| 61 | unsigned int default_dmacon; |
| 62 | void (*atmel_lcdfb_power_control)(int on); |
| 63 | struct fb_monspecs *default_monspecs; |
| 64 | u32 pseudo_palette[16]; |
Johan Hovold | bbd44f6b | 2013-02-07 16:31:58 +0100 | [diff] [blame] | 65 | |
| 66 | struct atmel_lcdfb_config *config; |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | #define ATMEL_LCDC_DMABADDR1 0x00 |
| 70 | #define ATMEL_LCDC_DMABADDR2 0x04 |
| 71 | #define ATMEL_LCDC_DMAFRMPT1 0x08 |
| 72 | #define ATMEL_LCDC_DMAFRMPT2 0x0c |
| 73 | #define ATMEL_LCDC_DMAFRMADD1 0x10 |
| 74 | #define ATMEL_LCDC_DMAFRMADD2 0x14 |
| 75 | |
| 76 | #define ATMEL_LCDC_DMAFRMCFG 0x18 |
| 77 | #define ATMEL_LCDC_FRSIZE (0x7fffff << 0) |
| 78 | #define ATMEL_LCDC_BLENGTH_OFFSET 24 |
| 79 | #define ATMEL_LCDC_BLENGTH (0x7f << ATMEL_LCDC_BLENGTH_OFFSET) |
| 80 | |
| 81 | #define ATMEL_LCDC_DMACON 0x1c |
| 82 | #define ATMEL_LCDC_DMAEN (0x1 << 0) |
| 83 | #define ATMEL_LCDC_DMARST (0x1 << 1) |
| 84 | #define ATMEL_LCDC_DMABUSY (0x1 << 2) |
| 85 | #define ATMEL_LCDC_DMAUPDT (0x1 << 3) |
| 86 | #define ATMEL_LCDC_DMA2DEN (0x1 << 4) |
| 87 | |
| 88 | #define ATMEL_LCDC_DMA2DCFG 0x20 |
| 89 | #define ATMEL_LCDC_ADDRINC_OFFSET 0 |
| 90 | #define ATMEL_LCDC_ADDRINC (0xffff) |
| 91 | #define ATMEL_LCDC_PIXELOFF_OFFSET 24 |
| 92 | #define ATMEL_LCDC_PIXELOFF (0x1f << 24) |
| 93 | |
| 94 | #define ATMEL_LCDC_LCDCON1 0x0800 |
| 95 | #define ATMEL_LCDC_BYPASS (1 << 0) |
| 96 | #define ATMEL_LCDC_CLKVAL_OFFSET 12 |
| 97 | #define ATMEL_LCDC_CLKVAL (0x1ff << ATMEL_LCDC_CLKVAL_OFFSET) |
| 98 | #define ATMEL_LCDC_LINCNT (0x7ff << 21) |
| 99 | |
| 100 | #define ATMEL_LCDC_LCDCON2 0x0804 |
| 101 | #define ATMEL_LCDC_DISTYPE (3 << 0) |
| 102 | #define ATMEL_LCDC_DISTYPE_STNMONO (0 << 0) |
| 103 | #define ATMEL_LCDC_DISTYPE_STNCOLOR (1 << 0) |
| 104 | #define ATMEL_LCDC_DISTYPE_TFT (2 << 0) |
| 105 | #define ATMEL_LCDC_SCANMOD (1 << 2) |
| 106 | #define ATMEL_LCDC_SCANMOD_SINGLE (0 << 2) |
| 107 | #define ATMEL_LCDC_SCANMOD_DUAL (1 << 2) |
| 108 | #define ATMEL_LCDC_IFWIDTH (3 << 3) |
| 109 | #define ATMEL_LCDC_IFWIDTH_4 (0 << 3) |
| 110 | #define ATMEL_LCDC_IFWIDTH_8 (1 << 3) |
| 111 | #define ATMEL_LCDC_IFWIDTH_16 (2 << 3) |
| 112 | #define ATMEL_LCDC_PIXELSIZE (7 << 5) |
| 113 | #define ATMEL_LCDC_PIXELSIZE_1 (0 << 5) |
| 114 | #define ATMEL_LCDC_PIXELSIZE_2 (1 << 5) |
| 115 | #define ATMEL_LCDC_PIXELSIZE_4 (2 << 5) |
| 116 | #define ATMEL_LCDC_PIXELSIZE_8 (3 << 5) |
| 117 | #define ATMEL_LCDC_PIXELSIZE_16 (4 << 5) |
| 118 | #define ATMEL_LCDC_PIXELSIZE_24 (5 << 5) |
| 119 | #define ATMEL_LCDC_PIXELSIZE_32 (6 << 5) |
| 120 | #define ATMEL_LCDC_INVVD (1 << 8) |
| 121 | #define ATMEL_LCDC_INVVD_NORMAL (0 << 8) |
| 122 | #define ATMEL_LCDC_INVVD_INVERTED (1 << 8) |
| 123 | #define ATMEL_LCDC_INVFRAME (1 << 9 ) |
| 124 | #define ATMEL_LCDC_INVFRAME_NORMAL (0 << 9) |
| 125 | #define ATMEL_LCDC_INVFRAME_INVERTED (1 << 9) |
| 126 | #define ATMEL_LCDC_INVLINE (1 << 10) |
| 127 | #define ATMEL_LCDC_INVLINE_NORMAL (0 << 10) |
| 128 | #define ATMEL_LCDC_INVLINE_INVERTED (1 << 10) |
| 129 | #define ATMEL_LCDC_INVCLK (1 << 11) |
| 130 | #define ATMEL_LCDC_INVCLK_NORMAL (0 << 11) |
| 131 | #define ATMEL_LCDC_INVCLK_INVERTED (1 << 11) |
| 132 | #define ATMEL_LCDC_INVDVAL (1 << 12) |
| 133 | #define ATMEL_LCDC_INVDVAL_NORMAL (0 << 12) |
| 134 | #define ATMEL_LCDC_INVDVAL_INVERTED (1 << 12) |
| 135 | #define ATMEL_LCDC_CLKMOD (1 << 15) |
| 136 | #define ATMEL_LCDC_CLKMOD_ACTIVEDISPLAY (0 << 15) |
| 137 | #define ATMEL_LCDC_CLKMOD_ALWAYSACTIVE (1 << 15) |
| 138 | #define ATMEL_LCDC_MEMOR (1 << 31) |
| 139 | #define ATMEL_LCDC_MEMOR_BIG (0 << 31) |
| 140 | #define ATMEL_LCDC_MEMOR_LITTLE (1 << 31) |
| 141 | |
| 142 | #define ATMEL_LCDC_TIM1 0x0808 |
Haavard Skinnemoen | 162b3a0 | 2008-02-06 01:39:11 -0800 | [diff] [blame] | 143 | #define ATMEL_LCDC_VFP (0xffU << 0) |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 144 | #define ATMEL_LCDC_VBP_OFFSET 8 |
Haavard Skinnemoen | 162b3a0 | 2008-02-06 01:39:11 -0800 | [diff] [blame] | 145 | #define ATMEL_LCDC_VBP (0xffU << ATMEL_LCDC_VBP_OFFSET) |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 146 | #define ATMEL_LCDC_VPW_OFFSET 16 |
Haavard Skinnemoen | 162b3a0 | 2008-02-06 01:39:11 -0800 | [diff] [blame] | 147 | #define ATMEL_LCDC_VPW (0x3fU << ATMEL_LCDC_VPW_OFFSET) |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 148 | #define ATMEL_LCDC_VHDLY_OFFSET 24 |
Haavard Skinnemoen | 162b3a0 | 2008-02-06 01:39:11 -0800 | [diff] [blame] | 149 | #define ATMEL_LCDC_VHDLY (0xfU << ATMEL_LCDC_VHDLY_OFFSET) |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 150 | |
| 151 | #define ATMEL_LCDC_TIM2 0x080c |
Haavard Skinnemoen | 162b3a0 | 2008-02-06 01:39:11 -0800 | [diff] [blame] | 152 | #define ATMEL_LCDC_HBP (0xffU << 0) |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 153 | #define ATMEL_LCDC_HPW_OFFSET 8 |
Haavard Skinnemoen | 162b3a0 | 2008-02-06 01:39:11 -0800 | [diff] [blame] | 154 | #define ATMEL_LCDC_HPW (0x3fU << ATMEL_LCDC_HPW_OFFSET) |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 155 | #define ATMEL_LCDC_HFP_OFFSET 21 |
Haavard Skinnemoen | 162b3a0 | 2008-02-06 01:39:11 -0800 | [diff] [blame] | 156 | #define ATMEL_LCDC_HFP (0x7ffU << ATMEL_LCDC_HFP_OFFSET) |
Nicolas Ferre | 1434058 | 2007-05-10 22:23:26 -0700 | [diff] [blame] | 157 | |
| 158 | #define ATMEL_LCDC_LCDFRMCFG 0x0810 |
| 159 | #define ATMEL_LCDC_LINEVAL (0x7ff << 0) |
| 160 | #define ATMEL_LCDC_HOZVAL_OFFSET 21 |
| 161 | #define ATMEL_LCDC_HOZVAL (0x7ff << ATMEL_LCDC_HOZVAL_OFFSET) |
| 162 | |
| 163 | #define ATMEL_LCDC_FIFO 0x0814 |
| 164 | #define ATMEL_LCDC_FIFOTH (0xffff) |
| 165 | |
| 166 | #define ATMEL_LCDC_MVAL 0x0818 |
| 167 | |
| 168 | #define ATMEL_LCDC_DP1_2 0x081c |
| 169 | #define ATMEL_LCDC_DP4_7 0x0820 |
| 170 | #define ATMEL_LCDC_DP3_5 0x0824 |
| 171 | #define ATMEL_LCDC_DP2_3 0x0828 |
| 172 | #define ATMEL_LCDC_DP5_7 0x082c |
| 173 | #define ATMEL_LCDC_DP3_4 0x0830 |
| 174 | #define ATMEL_LCDC_DP4_5 0x0834 |
| 175 | #define ATMEL_LCDC_DP6_7 0x0838 |
| 176 | #define ATMEL_LCDC_DP1_2_VAL (0xff) |
| 177 | #define ATMEL_LCDC_DP4_7_VAL (0xfffffff) |
| 178 | #define ATMEL_LCDC_DP3_5_VAL (0xfffff) |
| 179 | #define ATMEL_LCDC_DP2_3_VAL (0xfff) |
| 180 | #define ATMEL_LCDC_DP5_7_VAL (0xfffffff) |
| 181 | #define ATMEL_LCDC_DP3_4_VAL (0xffff) |
| 182 | #define ATMEL_LCDC_DP4_5_VAL (0xfffff) |
| 183 | #define ATMEL_LCDC_DP6_7_VAL (0xfffffff) |
| 184 | |
| 185 | #define ATMEL_LCDC_PWRCON 0x083c |
| 186 | #define ATMEL_LCDC_PWR (1 << 0) |
| 187 | #define ATMEL_LCDC_GUARDT_OFFSET 1 |
| 188 | #define ATMEL_LCDC_GUARDT (0x7f << ATMEL_LCDC_GUARDT_OFFSET) |
| 189 | #define ATMEL_LCDC_BUSY (1 << 31) |
| 190 | |
| 191 | #define ATMEL_LCDC_CONTRAST_CTR 0x0840 |
| 192 | #define ATMEL_LCDC_PS (3 << 0) |
| 193 | #define ATMEL_LCDC_PS_DIV1 (0 << 0) |
| 194 | #define ATMEL_LCDC_PS_DIV2 (1 << 0) |
| 195 | #define ATMEL_LCDC_PS_DIV4 (2 << 0) |
| 196 | #define ATMEL_LCDC_PS_DIV8 (3 << 0) |
| 197 | #define ATMEL_LCDC_POL (1 << 2) |
| 198 | #define ATMEL_LCDC_POL_NEGATIVE (0 << 2) |
| 199 | #define ATMEL_LCDC_POL_POSITIVE (1 << 2) |
| 200 | #define ATMEL_LCDC_ENA (1 << 3) |
| 201 | #define ATMEL_LCDC_ENA_PWMDISABLE (0 << 3) |
| 202 | #define ATMEL_LCDC_ENA_PWMENABLE (1 << 3) |
| 203 | |
| 204 | #define ATMEL_LCDC_CONTRAST_VAL 0x0844 |
| 205 | #define ATMEL_LCDC_CVAL (0xff) |
| 206 | |
| 207 | #define ATMEL_LCDC_IER 0x0848 |
| 208 | #define ATMEL_LCDC_IDR 0x084c |
| 209 | #define ATMEL_LCDC_IMR 0x0850 |
| 210 | #define ATMEL_LCDC_ISR 0x0854 |
| 211 | #define ATMEL_LCDC_ICR 0x0858 |
| 212 | #define ATMEL_LCDC_LNI (1 << 0) |
| 213 | #define ATMEL_LCDC_LSTLNI (1 << 1) |
| 214 | #define ATMEL_LCDC_EOFI (1 << 2) |
| 215 | #define ATMEL_LCDC_UFLWI (1 << 4) |
| 216 | #define ATMEL_LCDC_OWRI (1 << 5) |
| 217 | #define ATMEL_LCDC_MERI (1 << 6) |
| 218 | |
| 219 | #define ATMEL_LCDC_LUT(n) (0x0c00 + ((n)*4)) |
| 220 | |
| 221 | #endif /* __ATMEL_LCDC_H__ */ |