~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/ppc/platforms/prpmc800_setup.c

Version: ~ [ linux-5.10-rc1 ] ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *
  3  * Author: Dale Farnsworth <dale.farnsworth@mvista.com>
  4  *
  5  * 2001 (c) MontaVista, Software, Inc.  This file is licensed under
  6  * the terms of the GNU General Public License version 2.  This program
  7  * is licensed "as is" without any warranty of any kind, whether express
  8  * or implied.
  9  */
 10 
 11 #include <linux/config.h>
 12 #include <linux/stddef.h>
 13 #include <linux/kernel.h>
 14 #include <linux/init.h>
 15 #include <linux/errno.h>
 16 #include <linux/reboot.h>
 17 #include <linux/pci.h>
 18 #include <linux/kdev_t.h>
 19 #include <linux/types.h>
 20 #include <linux/major.h>
 21 #include <linux/initrd.h>
 22 #include <linux/console.h>
 23 #include <linux/delay.h>
 24 #include <linux/irq.h>
 25 #include <linux/seq_file.h>
 26 #include <linux/ide.h>
 27 #include <linux/root_dev.h>
 28 
 29 #include <asm/system.h>
 30 #include <asm/pgtable.h>
 31 #include <asm/page.h>
 32 #include <asm/dma.h>
 33 #include <asm/io.h>
 34 #include <asm/machdep.h>
 35 #include <asm/time.h>
 36 #include <platforms/prpmc800.h>
 37 #include <asm/open_pic.h>
 38 #include <asm/bootinfo.h>
 39 #include <asm/harrier.h>
 40 
 41 #define HARRIER_REVI_REG        (PRPMC800_HARRIER_XCSR_BASE+HARRIER_REVI_OFF)
 42 #define HARRIER_UCTL_REG        (PRPMC800_HARRIER_XCSR_BASE+HARRIER_UCTL_OFF)
 43 #define HARRIER_MISC_CSR_REG  (PRPMC800_HARRIER_XCSR_BASE+HARRIER_MISC_CSR_OFF)
 44 #define HARRIER_IFEVP_REG   (PRPMC800_HARRIER_MPIC_BASE+HARRIER_MPIC_IFEVP_OFF)
 45 #define HARRIER_IFEDE_REG   (PRPMC800_HARRIER_MPIC_BASE+HARRIER_MPIC_IFEDE_OFF)
 46 #define HARRIER_FEEN_REG        (PRPMC800_HARRIER_XCSR_BASE+HARRIER_FEEN_OFF)
 47 #define HARRIER_FEMA_REG        (PRPMC800_HARRIER_XCSR_BASE+HARRIER_FEMA_OFF)
 48 
 49 extern void prpmc800_find_bridges(void);
 50 extern int mpic_init(void);
 51 extern unsigned long loops_per_jiffy;
 52 
 53 static u_char prpmc800_openpic_initsenses[] __initdata =
 54 {
 55     1,  /* PRPMC800_INT_HOSTINT0 */
 56     1,  /* PRPMC800_INT_UNUSED */
 57     1,  /* PRPMC800_INT_DEBUGINT */
 58     1,  /* PRPMC800_INT_HARRIER_WDT */
 59     1,  /* PRPMC800_INT_UNUSED */
 60     1,  /* PRPMC800_INT_UNUSED */
 61     1,  /* PRPMC800_INT_HOSTINT1 */
 62     1,  /* PRPMC800_INT_HOSTINT2 */
 63     1,  /* PRPMC800_INT_HOSTINT3 */
 64     1,  /* PRPMC800_INT_PMC_INTA */
 65     1,  /* PRPMC800_INT_PMC_INTB */
 66     1,  /* PRPMC800_INT_PMC_INTC */
 67     1,  /* PRPMC800_INT_PMC_INTD */
 68     1,  /* PRPMC800_INT_UNUSED */
 69     1,  /* PRPMC800_INT_UNUSED */
 70     1,  /* PRPMC800_INT_UNUSED */
 71     1,  /* PRPMC800_INT_HARRIER_INT (UARTS, ABORT, DMA) */
 72 };
 73 
 74 static int
 75 prpmc800_show_cpuinfo(struct seq_file *m)
 76 {
 77         seq_printf(m, "machine\t\t: PrPMC800\n");
 78 
 79         return 0;
 80 }
 81 
 82 static void __init
 83 prpmc800_setup_arch(void)
 84 {
 85 
 86         /* init to some ~sane value until calibrate_delay() runs */
 87         loops_per_jiffy = 50000000/HZ;
 88 
 89         /* Lookup PCI host bridges */
 90         prpmc800_find_bridges();
 91 
 92 #ifdef CONFIG_BLK_DEV_INITRD
 93         if (initrd_start)
 94                 ROOT_DEV = Root_RAM0;
 95         else
 96 #endif
 97 #ifdef CONFIG_ROOT_NFS
 98                 ROOT_DEV = Root_NFS;
 99 #else
100                 ROOT_DEV = Root_SDA2;
101 #endif
102 
103 #ifdef CONFIG_DUMMY_CONSOLE
104         conswitchp = &dummy_con;
105 #endif
106 
107         OpenPIC_InitSenses = prpmc800_openpic_initsenses;
108         OpenPIC_NumInitSenses = sizeof(prpmc800_openpic_initsenses);
109 
110         printk("PrPMC800 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
111 }
112 
113 /*
114  * Compute the PrPMC800's tbl frequency using the baud clock as a reference.
115  */
116 
117 static void __init
118 prpmc800_calibrate_decr(void)
119 {
120         unsigned long tbl_start, tbl_end;
121         unsigned long current_state, old_state, tb_ticks_per_second;
122         unsigned int count;
123         unsigned int harrier_revision;
124 
125         harrier_revision = readb(HARRIER_REVI_REG);
126         if (harrier_revision < 2) {
127                 /* XTAL64 was broken in harrier revision 1 */
128                 printk("time_init: Harrier revision %d, assuming 100 Mhz bus\n",
129                         harrier_revision);
130                 tb_ticks_per_second = 100000000/4;
131                 tb_ticks_per_jiffy = tb_ticks_per_second / HZ;
132                 tb_to_us = mulhwu_scale_factor(tb_ticks_per_second, 1000000);
133                 return;
134         }
135 
136         /*
137          * The XTAL64 bit oscillates at the 1/64 the base baud clock
138          * Set count to XTAL64 cycles per second.  Since we'll count
139          * half-cycles, we'll reach the count in half a second.
140          */
141         count = PRPMC800_BASE_BAUD / 64;
142 
143         /* Find the first edge of the baud clock */
144         old_state = readb(HARRIER_UCTL_REG) & HARRIER_XTAL64_MASK;
145         do {
146                 current_state = readb(HARRIER_UCTL_REG) &
147                         HARRIER_XTAL64_MASK;
148         } while(old_state == current_state);
149 
150         old_state = current_state;
151 
152         /* Get the starting time base value */
153         tbl_start = get_tbl();
154 
155         /*
156          * Loop until we have found a number of edges (half-cycles)
157          * equal to the count (half a second)
158          */
159         do {
160                 do {
161                         current_state = readb(HARRIER_UCTL_REG) &
162                                 HARRIER_XTAL64_MASK;
163                 } while(old_state == current_state);
164                 old_state = current_state;
165         } while (--count);
166 
167         /* Get the ending time base value */
168         tbl_end = get_tbl();
169 
170         /* We only counted for half a second, so double to get ticks/second */
171         tb_ticks_per_second = (tbl_end - tbl_start) * 2;
172         tb_ticks_per_jiffy = tb_ticks_per_second / HZ;
173         tb_to_us = mulhwu_scale_factor(tb_ticks_per_second, 1000000);
174 }
175 
176 static void
177 prpmc800_restart(char *cmd)
178 {
179         local_irq_disable();
180         writeb(HARRIER_RSTOUT_MASK, HARRIER_MISC_CSR_REG);
181         while(1);
182 }
183 
184 static void
185 prpmc800_halt(void)
186 {
187         local_irq_disable();
188         while (1);
189 }
190 
191 static void
192 prpmc800_power_off(void)
193 {
194         prpmc800_halt();
195 }
196 
197 static void __init
198 prpmc800_init_IRQ(void)
199 {
200         openpic_init(1, 0, 0, -1);
201 
202 #define PRIORITY        15
203 #define VECTOR          16
204 #define PROCESSOR       0
205         /* initialize the harrier's internal interrupt priority 15, irq 1 */
206         out_be32((u32 *)HARRIER_IFEVP_REG, (PRIORITY<<16) | VECTOR);
207         out_be32((u32 *)HARRIER_IFEDE_REG, (1<<PROCESSOR));
208 
209         /* enable functional exceptions for uarts and abort */
210         out_8((u8 *)HARRIER_FEEN_REG, (HARRIER_FE_UA0|HARRIER_FE_UA1));
211         out_8((u8 *)HARRIER_FEMA_REG, ~(HARRIER_FE_UA0|HARRIER_FE_UA1));
212 }
213 
214 /*
215  * Set BAT 3 to map 0xf0000000 to end of physical memory space.
216  */
217 static __inline__ void
218 prpmc800_set_bat(void)
219 {
220         unsigned long   bat3u, bat3l;
221         static int      mapping_set = 0;
222 
223         if (!mapping_set)
224         {
225                 __asm__ __volatile__(
226                                 " lis %0,0xf000\n \
227                                 ori %1,%0,0x002a\n \
228                                 ori %0,%0,0x1ffe\n \
229                                 mtspr 0x21e,%0\n \
230                                 mtspr 0x21f,%1\n \
231                                 isync\n \
232                                 sync "
233                                 : "=r" (bat3u), "=r" (bat3l));
234 
235                 mapping_set = 1;
236         }
237         return;
238 }
239 
240 #ifdef  CONFIG_SERIAL_TEXT_DEBUG
241 #include <linux/serial.h>
242 #include <linux/serialP.h>
243 #include <linux/serial_reg.h>
244 #include <asm/serial.h>
245 
246 static struct serial_state rs_table[RS_TABLE_SIZE] = {
247         SERIAL_PORT_DFNS        /* Defined in <asm/serial.h> */
248 };
249 
250 void
251 prpmc800_progress(char *s, unsigned short hex)
252 {
253         volatile char c;
254         volatile unsigned char *com_port;
255         volatile unsigned char *com_port_lsr;
256 
257         com_port = (volatile unsigned char *) rs_table[0].port;
258         com_port_lsr = com_port + UART_LSR;
259 
260         while ((c = *s++) != 0) {
261                 while ((*com_port_lsr & UART_LSR_THRE) == 0)
262                                 ;
263                 *com_port = c;
264 
265                 if (c == '\n') {
266                         while ((*com_port_lsr & UART_LSR_THRE) == 0)
267                                         ;
268                         *com_port = '\r';
269                 }
270         }
271 }
272 #endif  /* CONFIG_SERIAL_TEXT_DEBUG */
273 
274 /*
275  * We need to read the Harrier memory controller
276  * to properly determine this value
277  */
278 static unsigned long __init
279 prpmc800_find_end_of_memory(void)
280 {
281         /* Cover the harrier registers with a BAT */
282         prpmc800_set_bat();
283 
284         /* Read the memory size from the Harrier XCSR */
285         return harrier_get_mem_size(PRPMC800_HARRIER_XCSR_BASE);
286 }
287 
288 static void __init
289 prpmc800_map_io(void)
290 {
291         io_block_mapping(0x80000000, 0x80000000, 0x10000000, _PAGE_IO);
292         io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
293 }
294 
295 void __init
296 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
297           unsigned long r6, unsigned long r7)
298 {
299         parse_bootinfo(find_bootinfo());
300 
301         prpmc800_set_bat();
302 
303         isa_io_base = PRPMC800_ISA_IO_BASE;
304         isa_mem_base = PRPMC800_ISA_MEM_BASE;
305         pci_dram_offset = PRPMC800_PCI_DRAM_OFFSET;
306 
307         ppc_md.setup_arch       = prpmc800_setup_arch;
308         ppc_md.show_cpuinfo     = prpmc800_show_cpuinfo;
309         ppc_md.init_IRQ         = prpmc800_init_IRQ;
310         ppc_md.get_irq          = openpic_get_irq;
311 
312         ppc_md.find_end_of_memory = prpmc800_find_end_of_memory;
313         ppc_md.setup_io_mappings = prpmc800_map_io;
314 
315         ppc_md.restart          = prpmc800_restart;
316         ppc_md.power_off        = prpmc800_power_off;
317         ppc_md.halt             = prpmc800_halt;
318 
319         /* PrPMC800 has no timekeeper part */
320         ppc_md.time_init        = NULL;
321         ppc_md.get_rtc_time     = NULL;
322         ppc_md.set_rtc_time     = NULL;
323         ppc_md.calibrate_decr   = prpmc800_calibrate_decr;
324 #ifdef  CONFIG_SERIAL_TEXT_DEBUG
325         ppc_md.progress = prpmc800_progress;
326 #else   /* !CONFIG_SERIAL_TEXT_DEBUG */
327         ppc_md.progress = NULL;
328 #endif  /* CONFIG_SERIAL_TEXT_DEBUG */
329 }
330 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp