sd-as3525v1: set up bank selection data outside of the loop
[kugel-rb.git] / firmware / target / arm / as3525 / sansa-fuzev2 / lcd-fuzev2.c
blobfd6bcb45fc338c2451d4e38bc2a6b00bb196035a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Dave Chapman
11 * Copyright (C) 2010 by Thomas Martitz
13 * LCD driver for the Sansa Fuze - controller unknown
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
24 #include "config.h"
26 #include "cpu.h"
27 #include "lcd.h"
28 #include "system.h"
29 #include "clock-target.h"
30 #include "dbop-as3525.h"
31 #include "lcd-fuze.h"
33 void lcd_write_cmd(int16_t cmd)
35 unsigned short data = swap16(cmd);
36 DBOP_TIMPOL_23 = 0xA12F0036;
37 dbop_write_data(&data, 1);
39 int delay = 32;
40 do {
41 nop;
42 } while(delay--);
44 DBOP_TIMPOL_23 = 0xA12FE037;
47 void lcd_write_reg(int reg, int value)
49 int16_t data = swap16(value);
50 lcd_write_cmd(reg);
51 dbop_write_data(&data, 1);
55 static void as3525_dbop_init(void)
57 CCU_IO |= 1<<12;
58 CGU_DBOP |= (1<<4) | (1<<3) | AS3525_DBOP_DIV;
59 DBOP_TIMPOL_01 = 0xE12FE12F;
60 DBOP_TIMPOL_23 = 0xE12F0036;
61 DBOP_CTRL = 0x41004;
62 DBOP_TIMPOL_23 = 0x60036;
63 DBOP_CTRL = 0x51004;
64 DBOP_TIMPOL_01 = 0x60036;
65 DBOP_TIMPOL_23 = 0xA12FE037;
69 void lcd_init_device(void)
71 as3525_dbop_init();
73 GPIOA_DIR |= (0x20|0x1);
74 GPIOA_DIR &= ~(1<<3);
75 GPIOA_PIN(3) = 0;
76 GPIOA_PIN(0) = 1;
77 GPIOA_PIN(4) = 0;
79 GPIOB_DIR |= (1<<0)|(1<<2)|(1<<3);
80 GPIOB_PIN(0) = 1<<0;
81 GPIOB_PIN(2) = 1<<2;
82 GPIOB_PIN(3) = 1<<3;
84 GPIOA_PIN(4) = 1<<4;
85 GPIOA_PIN(5) = 1<<5;
87 fuze_display_on();