1 /* 2 * Interrupt handling. 3 * 4 * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifdef CONFIG_CPU_JZ4730_MINIPC 21 #include "minipc.h" 22 #else 23 #include "nanonote.h" 24 #endif 25 26 #include "board-specific.h" 27 #include "board.h" 28 #include "lcd.h" 29 #include "jzlcd.h" 30 #include "cpu.h" 31 32 extern vidinfo_t panel_info; 33 static unsigned short pixel_type; 34 static unsigned short x, y; 35 extern unsigned long lastdec; 36 37 void next_pixel() 38 { 39 x++; 40 if (x >= panel_info.vl_col) { 41 x = 0; 42 y++; 43 if (y >= panel_info.vl_row) 44 y = 0; 45 } 46 } 47 48 /* Tasks. */ 49 50 void plot_pattern() 51 { 52 while (1) { 53 if (pixel_type) 54 test_pixel(x, y); 55 else 56 clear_pixel(x, y); 57 next_pixel(); 58 udelay(100); 59 } 60 } 61 62 /* Initialisation and handling. */ 63 64 void irq_init() 65 { 66 timer_init_irq(); 67 gpio_init_irq(); 68 x = 0; y = 0; pixel_type = 1; 69 handle_error_level(); 70 init_interrupts(); 71 enable_interrupts(); 72 } 73 74 void irq_handle() 75 { 76 unsigned short i; 77 78 /* Check interrupt identity. */ 79 80 /* Timer interrupt. */ 81 82 if (REG_INTC_IPR & (1 << TIMER_CHAN_IRQ)) { 83 84 /* Update the pixel type. */ 85 86 pixel_type = 1 - pixel_type; 87 88 /* Clear interrupt status. */ 89 90 __tcu_clear_full_match_flag(TIMER_CHAN); 91 __intc_ack_irq(TIMER_CHAN_IRQ); 92 } 93 94 /* GPIO interrupts. */ 95 96 if (REG_INTC_IPR & (1 << GPIO_IRQ)) { 97 98 /* Check for the power button. */ 99 100 if (REG_GPIO_PXFLG(GPIO_POWER / 32) & (1 << (GPIO_POWER % 32))) { 101 102 /* Clear interrupt status. */ 103 104 __gpio_ack_irq(GPIO_POWER); 105 __intc_ack_irq(GPIO_IRQ); 106 } 107 } 108 109 /* Handle other interrupts, anyway. */ 110 111 for (i = 0; i < 32; i++) { 112 if (REG_INTC_IPR & (1 << i)) 113 __intc_ack_irq(i); 114 } 115 } 116 117 void start_task() 118 { 119 plot_pattern(); 120 }