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> 21*fd13f811SArnd Bergmann #include <linux/soc/pxa/smemc.h> 221da177e4SLinus Torvalds 231da177e4SLinus Torvalds #include <asm/mach/map.h> 246769717dSEric Miao #include <asm/mach-types.h> 251da177e4SLinus Torvalds 26225b5d37SArnd Bergmann #include "addr-map.h" 27a38b1f60SRobert Jarzmik #include <mach/irqs.h> 28afd2fc02SRussell King #include <mach/reset.h> 29ad68bb9fSMarek Vasut #include <mach/smemc.h> 30a4553358SHaojian Zhuang #include <mach/pxa3xx-regs.h> 311da177e4SLinus Torvalds 321da177e4SLinus Torvalds #include "generic.h" 33a38b1f60SRobert Jarzmik #include <clocksource/pxa.h> 341da177e4SLinus Torvalds 3504fef228SEric Miao void clear_reset_status(unsigned int mask) 3604fef228SEric Miao { 3704fef228SEric Miao if (cpu_is_pxa2xx()) 3804fef228SEric Miao pxa2xx_clear_reset_status(mask); 39a4553358SHaojian Zhuang else { 40a4553358SHaojian Zhuang /* RESET_STATUS_* has a 1:1 mapping with ARSR */ 41a4553358SHaojian Zhuang ARSR = mask; 42a4553358SHaojian Zhuang } 4304fef228SEric Miao } 4404fef228SEric Miao 451da177e4SLinus Torvalds /* 46a38b1f60SRobert Jarzmik * For non device-tree builds, keep legacy timer init 47a38b1f60SRobert Jarzmik */ 483d3c6a5fSArnd Bergmann void __init pxa_timer_init(void) 49a38b1f60SRobert Jarzmik { 505e1d0128SRobert Jarzmik if (cpu_is_pxa25x()) 515e1d0128SRobert Jarzmik pxa25x_clocks_init(); 525e1d0128SRobert Jarzmik if (cpu_is_pxa27x()) 535e1d0128SRobert Jarzmik pxa27x_clocks_init(); 54a1c0a6adSRobert Jarzmik if (cpu_is_pxa3xx()) 55a1c0a6adSRobert Jarzmik pxa3xx_clocks_init(); 56f4e14edfSRobert Jarzmik pxa_timer_nodt_init(IRQ_OST0, io_p2v(0x40a00000)); 57a38b1f60SRobert Jarzmik } 58a38b1f60SRobert Jarzmik 596a946f1bSArnd Bergmann void pxa_smemc_set_pcmcia_timing(int sock, u32 mcmem, u32 mcatt, u32 mcio) 606a946f1bSArnd Bergmann { 616a946f1bSArnd Bergmann __raw_writel(mcmem, MCMEM(sock)); 626a946f1bSArnd Bergmann __raw_writel(mcatt, MCATT(sock)); 636a946f1bSArnd Bergmann __raw_writel(mcio, MCIO(sock)); 646a946f1bSArnd Bergmann } 656a946f1bSArnd Bergmann EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_timing); 666a946f1bSArnd Bergmann 676a946f1bSArnd Bergmann void pxa_smemc_set_pcmcia_socket(int nr) 686a946f1bSArnd Bergmann { 696a946f1bSArnd Bergmann switch (nr) { 706a946f1bSArnd Bergmann case 0: 716a946f1bSArnd Bergmann __raw_writel(0, MECR); 726a946f1bSArnd Bergmann break; 736a946f1bSArnd Bergmann case 1: 746a946f1bSArnd Bergmann /* 756a946f1bSArnd Bergmann * We have at least one socket, so set MECR:CIT 766a946f1bSArnd Bergmann * (Card Is There) 776a946f1bSArnd Bergmann */ 786a946f1bSArnd Bergmann __raw_writel(MECR_CIT, MECR); 796a946f1bSArnd Bergmann break; 806a946f1bSArnd Bergmann case 2: 816a946f1bSArnd Bergmann /* Set CIT and MECR:NOS (Number Of Sockets) */ 826a946f1bSArnd Bergmann __raw_writel(MECR_CIT | MECR_NOS, MECR); 836a946f1bSArnd Bergmann break; 846a946f1bSArnd Bergmann } 856a946f1bSArnd Bergmann } 866a946f1bSArnd Bergmann EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_socket); 876a946f1bSArnd Bergmann 88*fd13f811SArnd Bergmann void __iomem *pxa_smemc_get_mdrefr(void) 89*fd13f811SArnd Bergmann { 90*fd13f811SArnd Bergmann return MDREFR; 91*fd13f811SArnd Bergmann } 92*fd13f811SArnd Bergmann 9315a40333SRussell King /* 941da177e4SLinus Torvalds * Intel PXA2xx internal register mapping. 951da177e4SLinus Torvalds * 96851982c1SMarek Vasut * Note: virtual 0xfffe0000-0xffffffff is reserved for the vector table 971da177e4SLinus Torvalds * and cache flush area. 981da177e4SLinus Torvalds */ 99851982c1SMarek Vasut static struct map_desc common_io_desc[] __initdata = { 1006f9182ebSDeepak Saxena { /* Devs */ 1010e32986cSLaurent Pinchart .virtual = (unsigned long)PERIPH_VIRT, 1020e32986cSLaurent Pinchart .pfn = __phys_to_pfn(PERIPH_PHYS), 1030e32986cSLaurent Pinchart .length = PERIPH_SIZE, 1046f9182ebSDeepak Saxena .type = MT_DEVICE 1056f9182ebSDeepak Saxena } 1061da177e4SLinus Torvalds }; 1071da177e4SLinus Torvalds 1081da177e4SLinus Torvalds void __init pxa_map_io(void) 1091da177e4SLinus Torvalds { 1102111667bSAndrew Ruder debug_ll_io_init(); 111851982c1SMarek Vasut iotable_init(ARRAY_AND_SIZE(common_io_desc)); 1121da177e4SLinus Torvalds } 113