xref: /linux/arch/arm/mach-pxa/generic.c (revision 6a946f1bd5cc966c9dd377b14efa4cec388101ce)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  *  linux/arch/arm/mach-pxa/generic.c
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  *  Author:	Nicolas Pitre
61da177e4SLinus Torvalds  *  Created:	Jun 15, 2001
71da177e4SLinus Torvalds  *  Copyright:	MontaVista Software Inc.
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  * Code common to all PXA machines.
101da177e4SLinus Torvalds  *
111da177e4SLinus Torvalds  * Since this file should be linked before any other machine specific file,
121da177e4SLinus Torvalds  * the __initcall() here will be executed first.  This serves as default
131da177e4SLinus Torvalds  * initialization stuff for PXA machines which can be overridden later if
141da177e4SLinus Torvalds  * need be.
151da177e4SLinus Torvalds  */
162f8163baSRussell King #include <linux/gpio.h>
171da177e4SLinus Torvalds #include <linux/module.h>
181da177e4SLinus Torvalds #include <linux/kernel.h>
191da177e4SLinus Torvalds #include <linux/init.h>
2008d3df8cSArnd Bergmann #include <linux/soc/pxa/cpu.h>
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds #include <asm/mach/map.h>
236769717dSEric Miao #include <asm/mach-types.h>
241da177e4SLinus Torvalds 
25225b5d37SArnd Bergmann #include "addr-map.h"
26a38b1f60SRobert Jarzmik #include <mach/irqs.h>
27afd2fc02SRussell King #include <mach/reset.h>
28ad68bb9fSMarek Vasut #include <mach/smemc.h>
29a4553358SHaojian Zhuang #include <mach/pxa3xx-regs.h>
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds #include "generic.h"
32a38b1f60SRobert Jarzmik #include <clocksource/pxa.h>
331da177e4SLinus Torvalds 
3404fef228SEric Miao void clear_reset_status(unsigned int mask)
3504fef228SEric Miao {
3604fef228SEric Miao 	if (cpu_is_pxa2xx())
3704fef228SEric Miao 		pxa2xx_clear_reset_status(mask);
38a4553358SHaojian Zhuang 	else {
39a4553358SHaojian Zhuang 		/* RESET_STATUS_* has a 1:1 mapping with ARSR */
40a4553358SHaojian Zhuang 		ARSR = mask;
41a4553358SHaojian Zhuang 	}
4204fef228SEric Miao }
4304fef228SEric Miao 
441da177e4SLinus Torvalds /*
45a38b1f60SRobert Jarzmik  * For non device-tree builds, keep legacy timer init
46a38b1f60SRobert Jarzmik  */
473d3c6a5fSArnd Bergmann void __init pxa_timer_init(void)
48a38b1f60SRobert Jarzmik {
495e1d0128SRobert Jarzmik 	if (cpu_is_pxa25x())
505e1d0128SRobert Jarzmik 		pxa25x_clocks_init();
515e1d0128SRobert Jarzmik 	if (cpu_is_pxa27x())
525e1d0128SRobert Jarzmik 		pxa27x_clocks_init();
53a1c0a6adSRobert Jarzmik 	if (cpu_is_pxa3xx())
54a1c0a6adSRobert Jarzmik 		pxa3xx_clocks_init();
55f4e14edfSRobert Jarzmik 	pxa_timer_nodt_init(IRQ_OST0, io_p2v(0x40a00000));
56a38b1f60SRobert Jarzmik }
57a38b1f60SRobert Jarzmik 
58a38b1f60SRobert Jarzmik /*
5915a40333SRussell King  * Get the clock frequency as reflected by CCCR and the turbo flag.
6015a40333SRussell King  * We assume these values have been applied via a fcs.
6115a40333SRussell King  * If info is not 0 we also display the current settings.
6215a40333SRussell King  */
6315a40333SRussell King unsigned int get_clk_frequency_khz(int info)
6415a40333SRussell King {
650ffcbfd5SEric Miao 	if (cpu_is_pxa25x())
6615a40333SRussell King 		return pxa25x_get_clk_frequency_khz(info);
672c8086a5Seric miao 	else if (cpu_is_pxa27x())
6815a40333SRussell King 		return pxa27x_get_clk_frequency_khz(info);
69ecf89b8aSHaojian Zhuang 	return 0;
7015a40333SRussell King }
7115a40333SRussell King EXPORT_SYMBOL(get_clk_frequency_khz);
7215a40333SRussell King 
73*6a946f1bSArnd Bergmann void pxa_smemc_set_pcmcia_timing(int sock, u32 mcmem, u32 mcatt, u32 mcio)
74*6a946f1bSArnd Bergmann {
75*6a946f1bSArnd Bergmann 	__raw_writel(mcmem, MCMEM(sock));
76*6a946f1bSArnd Bergmann 	__raw_writel(mcatt, MCATT(sock));
77*6a946f1bSArnd Bergmann 	__raw_writel(mcio, MCIO(sock));
78*6a946f1bSArnd Bergmann }
79*6a946f1bSArnd Bergmann EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_timing);
80*6a946f1bSArnd Bergmann 
81*6a946f1bSArnd Bergmann void pxa_smemc_set_pcmcia_socket(int nr)
82*6a946f1bSArnd Bergmann {
83*6a946f1bSArnd Bergmann 	switch (nr) {
84*6a946f1bSArnd Bergmann 	case 0:
85*6a946f1bSArnd Bergmann 		__raw_writel(0, MECR);
86*6a946f1bSArnd Bergmann 		break;
87*6a946f1bSArnd Bergmann 	case 1:
88*6a946f1bSArnd Bergmann 		/*
89*6a946f1bSArnd Bergmann 		 * We have at least one socket, so set MECR:CIT
90*6a946f1bSArnd Bergmann 		 * (Card Is There)
91*6a946f1bSArnd Bergmann 		 */
92*6a946f1bSArnd Bergmann 		__raw_writel(MECR_CIT, MECR);
93*6a946f1bSArnd Bergmann 		break;
94*6a946f1bSArnd Bergmann 	case 2:
95*6a946f1bSArnd Bergmann 		/* Set CIT and MECR:NOS (Number Of Sockets) */
96*6a946f1bSArnd Bergmann 		__raw_writel(MECR_CIT | MECR_NOS, MECR);
97*6a946f1bSArnd Bergmann 		break;
98*6a946f1bSArnd Bergmann 	}
99*6a946f1bSArnd Bergmann }
100*6a946f1bSArnd Bergmann EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_socket);
101*6a946f1bSArnd Bergmann 
10215a40333SRussell King /*
1031da177e4SLinus Torvalds  * Intel PXA2xx internal register mapping.
1041da177e4SLinus Torvalds  *
105851982c1SMarek Vasut  * Note: virtual 0xfffe0000-0xffffffff is reserved for the vector table
1061da177e4SLinus Torvalds  *       and cache flush area.
1071da177e4SLinus Torvalds  */
108851982c1SMarek Vasut static struct map_desc common_io_desc[] __initdata = {
1096f9182ebSDeepak Saxena   	{	/* Devs */
1100e32986cSLaurent Pinchart 		.virtual	= (unsigned long)PERIPH_VIRT,
1110e32986cSLaurent Pinchart 		.pfn		= __phys_to_pfn(PERIPH_PHYS),
1120e32986cSLaurent Pinchart 		.length		= PERIPH_SIZE,
1136f9182ebSDeepak Saxena 		.type		= MT_DEVICE
1146f9182ebSDeepak Saxena 	}
1151da177e4SLinus Torvalds };
1161da177e4SLinus Torvalds 
1171da177e4SLinus Torvalds void __init pxa_map_io(void)
1181da177e4SLinus Torvalds {
1192111667bSAndrew Ruder 	debug_ll_io_init();
120851982c1SMarek Vasut 	iotable_init(ARRAY_AND_SIZE(common_io_desc));
1211da177e4SLinus Torvalds }
122