Sansa Fuze+: initial commit (bootloader only, LCD basically working)
[kugel-rb.git] / firmware / target / arm / imx233 / lcdif-imx233.h
blob970b8661e5ec818fadd33ca65ca854e66390950d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2011 by Amaury Pouly
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef __LCDIF_IMX233_H__
22 #define __LCDIF_IMX233_H__
24 #include <string.h>
25 #include "cpu.h"
26 #include "system.h"
27 #include "system-target.h"
29 #define HW_LCDIF_BASE 0x80030000
31 #define HW_LCDIF_CTRL (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x0))
32 #define HW_LCDIF_CTRL__WORD_LENGTH_16_BIT (0 << 8)
33 #define HW_LCDIF_CTRL__WORD_LENGTH_8_BIT (1 << 8)
34 #define HW_LCDIF_CTRL__WORD_LENGTH_18_BIT (2 << 8)
35 #define HW_LCDIF_CTRL__WORD_LENGTH_24_BIT (3 << 8)
36 #define HW_LCDIF_CTRL__WORD_LENGTH_BM (3 << 8)
37 #define HW_LCDIF_CTRL__LCD_DATABUS_WIDTH_18_BIT (2 << 10)
38 #define HW_LCDIF_CTRL__LCD_DATABUS_WIDTH_BM (3 << 10)
39 #define HW_LCDIF_CTRL__LCDIF_MASTER (1 << 5)
40 #define HW_LCDIF_CTRL__DATA_FORMAT_16_BIT (1 << 3)
41 #define HW_LCDIF_CTRL__DATA_FORMAT_18_BIT (1 << 2)
42 #define HW_LCDIF_CTRL__DATA_FORMAT_24_BIT (1 << 1)
43 #define HW_LCDIF_CTRL__RUN 0x1
44 #define HW_LCDIF_CTRL__DATA_SELECT (1 << 16)
46 #define HW_LCDIF_CTRL1 (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x10))
47 #define HW_LCDIF_CTRL1__RESET 1
48 #define HW_LCDIF_CTRL1__BUSY_ENABLE (1 << 2)
49 #define HW_LCDIF_CTRL1__MODE86 (1 << 1)
50 #define HW_LCDIF_CTRL1__IRQ_EN_BP 12
51 #define HW_LCDIF_CTRL1__IRQ_EN_BM (0xf << 12)
52 #define HW_LCDIF_CTRL1__IRQ_BP 8
53 #define HW_LCDIF_CTRL1__BYTE_PACKING_FORMAT_BM (0xf << 16)
54 #define HW_LCDIF_CTRL1__BYTE_PACKING_FORMAT_BP 16
56 #define HW_LCDIF__VSYNC_EDGE_IRQ 1
57 #define HW_LCDIF__CUR_FRAME_DONE_IRQ 2
58 #define HW_LCDIF__UNDERFLOW_IRQ 4
59 #define HW_LCDIF__OVERFLOW_IRQ 8
61 #define HW_LCDIF_TRANSFER_COUNT (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x20))
62 #define HW_LCDIF_CUR_BUF (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x30))
63 #define HW_LCDIF_NEXT_BUF (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x40))
64 #define HW_LCDIF_TIMING (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x60))
65 #define HW_LCDIF_TIMING__DATA_SETUP_BP 0
66 #define HW_LCDIF_TIMING__DATA_HOLD_BP 8
67 #define HW_LCDIF_TIMING__CMD_SETUP_BP 16
68 #define HW_LCDIF_TIMING__CMD_HOLD_BP 24
70 #define HW_LCDIF_CSC_COEFF0 (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x110))
71 #define HW_LCDIF_CSC_COEFF1 (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x120))
72 #define HW_LCDIF_CSC_COEFF2 (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x130))
73 #define HW_LCDIF_CSC_COEFF3 (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x140))
74 #define HW_LCDIF_CSC_COEFF4 (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x150))
75 #define HW_LCDIF_CSC_OFFSET (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x160))
76 #define HW_LCDIF_CSC_LIMIT (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x170))
77 #define HW_LCDIF_DATA (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x1b0))
79 #define HW_LCDIF_STAT (*(volatile uint32_t *)(HW_LCDIF_BASE + 0x1d0))
80 #define HW_LCDIF_STAT__LFIFO_FULL (1 << 29)
81 #define HW_LCDIF_STAT__LFIFO_EMPTY (1 << 28)
82 #define HW_LCDIF_STAT__TXFIFO_FULL (1 << 27)
83 #define HW_LCDIF_STAT__TXFIFO_EMPTY (1 << 26)
84 #define HW_LCDIF_STAT__BUSY (1 << 25)
86 void imx233_lcdif_enable_bus_master(bool enable);
87 void imx233_lcdif_enable(bool enable);
88 void imx233_lcdif_reset(void);
89 void imx233_lcdif_set_timings(unsigned data_setup, unsigned data_hold,
90 unsigned cmd_setup, unsigned cmd_hold);
91 void imx233_lcdif_set_lcd_databus_width(unsigned width);
92 void imx233_lcdif_set_word_length(unsigned word_length);
93 void imx233_lcdif_set_byte_packing_format(unsigned byte_packing);
94 void imx233_lcdif_set_data_format(bool data_fmt_16, bool data_fmt_18, bool data_fmt_24);
95 unsigned imx233_lcdif_enable_irqs(unsigned irq_bm); /* return old mask */
96 void imx233_lcdif_wait_ready(void);
97 void imx233_lcdif_pio_send(bool data_mode, unsigned len, uint32_t *buf);
98 void imx233_lcdif_dma_send(void *buf, unsigned width, unsigned height);
100 #endif /* __LCDIF_IMX233_H__ */