Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/tty.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/console.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/rtc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/vt_kern.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/bootinfo-apollo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/apollohw.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/machdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) u_long sio01_physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) u_long sio23_physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) u_long rtc_physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) u_long pica_physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) u_long picb_physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) u_long cpuctrl_physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) u_long timer_physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) u_long apollo_model;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) extern void dn_sched_init(irq_handler_t handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) extern void dn_init_IRQ(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) extern int dn_dummy_hwclk(int, struct rtc_time *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) extern void dn_dummy_reset(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #ifdef CONFIG_HEARTBEAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static void dn_heartbeat(int on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static irqreturn_t dn_timer_int(int irq,void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) static void dn_get_model(char *model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static const char *apollo_models[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	[APOLLO_DN3000-APOLLO_DN3000] = "DN3000 (Otter)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	[APOLLO_DN3010-APOLLO_DN3000] = "DN3010 (Otter)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	[APOLLO_DN3500-APOLLO_DN3000] = "DN3500 (Cougar II)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	[APOLLO_DN4000-APOLLO_DN3000] = "DN4000 (Mink)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	[APOLLO_DN4500-APOLLO_DN3000] = "DN4500 (Roadrunner)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) int __init apollo_parse_bootinfo(const struct bi_record *record)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	int unknown = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	const void *data = record->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	switch (be16_to_cpu(record->tag)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	case BI_APOLLO_MODEL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		apollo_model = be32_to_cpup(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		 unknown=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	return unknown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static void __init dn_setup_model(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	pr_info("Apollo hardware found: [%s]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		apollo_models[apollo_model - APOLLO_DN3000]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	switch(apollo_model) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		case APOLLO_UNKNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			panic("Unknown apollo model");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		case APOLLO_DN3000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		case APOLLO_DN3010:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			sio01_physaddr=SAU8_SIO01_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			rtc_physaddr=SAU8_RTC_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			pica_physaddr=SAU8_PICA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			picb_physaddr=SAU8_PICB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			cpuctrl_physaddr=SAU8_CPUCTRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			timer_physaddr=SAU8_TIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		case APOLLO_DN4000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			sio01_physaddr=SAU7_SIO01_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			sio23_physaddr=SAU7_SIO23_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			rtc_physaddr=SAU7_RTC_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			pica_physaddr=SAU7_PICA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			picb_physaddr=SAU7_PICB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			cpuctrl_physaddr=SAU7_CPUCTRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			timer_physaddr=SAU7_TIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		case APOLLO_DN4500:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			panic("Apollo model not yet supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		case APOLLO_DN3500:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			sio01_physaddr=SAU7_SIO01_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			sio23_physaddr=SAU7_SIO23_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			rtc_physaddr=SAU7_RTC_PHYSADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			pica_physaddr=SAU7_PICA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			picb_physaddr=SAU7_PICB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			cpuctrl_physaddr=SAU7_CPUCTRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			timer_physaddr=SAU7_TIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			panic("Undefined apollo model");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int dn_serial_console_wait_key(struct console *co) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	while(!(sio01.srb_csrb & 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	return sio01.rhrb_thrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) void dn_serial_console_write (struct console *co, const char *str,unsigned int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)    while(count--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	if (*str == '\n') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	sio01.rhrb_thrb = (unsigned char)'\r';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	while (!(sio01.srb_csrb & 0x4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)                 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)     sio01.rhrb_thrb = (unsigned char)*str++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)     while (!(sio01.srb_csrb & 0x4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)             ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) void dn_serial_print (const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)     while (*str) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)         if (*str == '\n') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)             sio01.rhrb_thrb = (unsigned char)'\r';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)             while (!(sio01.srb_csrb & 0x4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)                 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)         sio01.rhrb_thrb = (unsigned char)*str++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)         while (!(sio01.srb_csrb & 0x4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)             ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) void __init config_apollo(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	dn_setup_model();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	mach_sched_init=dn_sched_init; /* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	mach_init_IRQ=dn_init_IRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	mach_max_dma_address = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	mach_hwclk           = dn_dummy_hwclk; /* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	mach_reset	     = dn_dummy_reset;  /* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #ifdef CONFIG_HEARTBEAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	mach_heartbeat = dn_heartbeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	mach_get_model       = dn_get_model;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	cpuctrl=0xaa00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	/* clear DMA translation table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	for(i=0;i<0x400;i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		addr_xlat_map[i]=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) irqreturn_t dn_timer_int(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	irq_handler_t timer_handler = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	volatile unsigned char x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	timer_handler(irq, dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	x = *(volatile unsigned char *)(apollo_timer + 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	x = *(volatile unsigned char *)(apollo_timer + 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) void dn_sched_init(irq_handler_t timer_routine)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	/* program timer 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	*(volatile unsigned char *)(apollo_timer + 3) = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	*(volatile unsigned char *)(apollo_timer + 1) = 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	*(volatile unsigned char *)(apollo_timer + 5) = 0x09;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	*(volatile unsigned char *)(apollo_timer + 7) = 0xc4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	/* enable IRQ of PIC B */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	*(volatile unsigned char *)(pica+1)&=(~8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	pr_info("*(0x10803) %02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		*(volatile unsigned char *)(apollo_timer + 0x3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	pr_info("*(0x10803) %02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		*(volatile unsigned char *)(apollo_timer + 0x3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (request_irq(IRQ_APOLLO, dn_timer_int, 0, "time", timer_routine))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		pr_err("Couldn't register timer interrupt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int dn_dummy_hwclk(int op, struct rtc_time *t) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)   if(!op) { /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)     t->tm_sec=rtc->second;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)     t->tm_min=rtc->minute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)     t->tm_hour=rtc->hours;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)     t->tm_mday=rtc->day_of_month;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)     t->tm_wday=rtc->day_of_week;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)     t->tm_mon = rtc->month - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)     t->tm_year=rtc->year;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)     if (t->tm_year < 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	t->tm_year += 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)   } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)     rtc->second=t->tm_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)     rtc->minute=t->tm_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)     rtc->hours=t->tm_hour;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)     rtc->day_of_month=t->tm_mday;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)     if(t->tm_wday!=-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)       rtc->day_of_week=t->tm_wday;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)     rtc->month = t->tm_mon + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)     rtc->year = t->tm_year % 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)   return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void dn_dummy_reset(void) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)   dn_serial_print("The end !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)   for(;;);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) void dn_dummy_waitbut(void) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)   dn_serial_print("waitbut\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static void dn_get_model(char *model)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)     strcpy(model, "Apollo ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)     if (apollo_model >= APOLLO_DN3000 && apollo_model <= APOLLO_DN4500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)         strcat(model, apollo_models[apollo_model - APOLLO_DN3000]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) #ifdef CONFIG_HEARTBEAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static int dn_cpuctrl=0xff00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) static void dn_heartbeat(int on) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	if(on) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		dn_cpuctrl&=~0x100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		cpuctrl=dn_cpuctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		dn_cpuctrl&=~0x100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		dn_cpuctrl|=0x100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		cpuctrl=dn_cpuctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)