1 /* 2 * Ben NanoNote screen details and panel-specific functions. 3 * 4 * Copyright (C) Xiangfu Liu <xiangfu@sharism.cc> 5 * Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA 21 */ 22 23 #include "board.h" 24 #include "jzlcd.h" 25 #include "nanonote.h" 26 #include "gpio.h" 27 28 struct jzfb_info jzfb = { 29 .cfg=MODE_8BIT_SERIAL_TFT | PCLK_N | HSYNC_N | VSYNC_N, 30 .w=320, .h=240, /* dimensions */ 31 .bpp=32, /* bits per pixel */ 32 .fclk=70, /* frame clock rate */ 33 .hsw=1, .vsw=1, /* sync widths */ 34 .elw=273, .blw=140, /* line limits */ 35 .efw=1, .bfw=20 /* frame limits */ 36 }; 37 38 vidinfo_t panel_info = { 39 .jz_fb=&jzfb, // this will need correcting for user mode usage 40 .lcd=0, // base address for registers 41 }; 42 43 /* Display configuration functions. */ 44 45 static void spi_write_reg1(uint8_t reg, uint8_t val) 46 { 47 uint8_t no; 48 uint16_t value; 49 void *gpio_port_base = jz4740_gpio_get_port((void *) GPIO_BASE, GPIO_PORT_LCD); 50 51 jz4740_gpio_set_pin(gpio_port_base, SPEN); 52 jz4740_gpio_set_pin(gpio_port_base, SPCK); 53 jz4740_gpio_clear_pin(gpio_port_base, SPDA); 54 jz4740_gpio_clear_pin(gpio_port_base, SPEN); 55 56 value = ((reg << 8) | (val & 0xFF)); 57 58 for (no = 0; no < 16; no++) 59 { 60 jz4740_gpio_clear_pin(gpio_port_base, SPCK); 61 jz4740_gpio_set_value(gpio_port_base, SPDA, value & 0x8000 ? 1 : 0); 62 jz4740_gpio_set_pin(gpio_port_base, SPCK); 63 value = (value << 1); 64 } 65 66 jz4740_gpio_set_pin(gpio_port_base, SPEN); 67 } 68 69 void lcd_display_pin_init() 70 { 71 void *gpio_port_base = jz4740_gpio_get_port((void *) GPIO_BASE, GPIO_PORT_LCD); 72 73 jz4740_gpio_as_output(gpio_port_base, SPEN); 74 jz4740_gpio_as_output(gpio_port_base, SPCK); 75 jz4740_gpio_as_output(gpio_port_base, SPDA); 76 } 77 78 void lcd_display_on() 79 { 80 spi_write_reg1(0x05, 0x1e); 81 spi_write_reg1(0x05, 0x5e); 82 spi_write_reg1(0x07, 0x8d); 83 spi_write_reg1(0x13, 0x01); 84 spi_write_reg1(0x05, 0x5f); 85 } 86 87 void lcd_display_off() 88 { 89 spi_write_reg1(0x05, 0x5e); 90 }