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