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> 21fd13f811SArnd Bergmann #include <linux/soc/pxa/smemc.h> 22*3c816d95SArnd Bergmann #include <linux/clk/pxa.h> 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds #include <asm/mach/map.h> 256769717dSEric Miao #include <asm/mach-types.h> 261da177e4SLinus Torvalds 27225b5d37SArnd Bergmann #include "addr-map.h" 28a38b1f60SRobert Jarzmik #include <mach/irqs.h> 29afd2fc02SRussell King #include <mach/reset.h> 30ad68bb9fSMarek Vasut #include <mach/smemc.h> 31a4553358SHaojian Zhuang #include <mach/pxa3xx-regs.h> 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds #include "generic.h" 34a38b1f60SRobert Jarzmik #include <clocksource/pxa.h> 351da177e4SLinus Torvalds 3604fef228SEric Miao void clear_reset_status(unsigned int mask) 3704fef228SEric Miao { 3804fef228SEric Miao if (cpu_is_pxa2xx()) 3904fef228SEric Miao pxa2xx_clear_reset_status(mask); 40a4553358SHaojian Zhuang else { 41a4553358SHaojian Zhuang /* RESET_STATUS_* has a 1:1 mapping with ARSR */ 42a4553358SHaojian Zhuang ARSR = mask; 43a4553358SHaojian Zhuang } 4404fef228SEric Miao } 4504fef228SEric Miao 461da177e4SLinus Torvalds /* 47a38b1f60SRobert Jarzmik * For non device-tree builds, keep legacy timer init 48a38b1f60SRobert Jarzmik */ 493d3c6a5fSArnd Bergmann void __init pxa_timer_init(void) 50a38b1f60SRobert Jarzmik { 515e1d0128SRobert Jarzmik if (cpu_is_pxa25x()) 52*3c816d95SArnd Bergmann pxa25x_clocks_init(io_p2v(0x41300000)); 535e1d0128SRobert Jarzmik if (cpu_is_pxa27x()) 54*3c816d95SArnd Bergmann pxa27x_clocks_init(io_p2v(0x41300000)); 55a1c0a6adSRobert Jarzmik if (cpu_is_pxa3xx()) 56*3c816d95SArnd Bergmann pxa3xx_clocks_init(io_p2v(0x41340000), io_p2v(0x41350000)); 57f4e14edfSRobert Jarzmik pxa_timer_nodt_init(IRQ_OST0, io_p2v(0x40a00000)); 58a38b1f60SRobert Jarzmik } 59a38b1f60SRobert Jarzmik 606a946f1bSArnd Bergmann void pxa_smemc_set_pcmcia_timing(int sock, u32 mcmem, u32 mcatt, u32 mcio) 616a946f1bSArnd Bergmann { 626a946f1bSArnd Bergmann __raw_writel(mcmem, MCMEM(sock)); 636a946f1bSArnd Bergmann __raw_writel(mcatt, MCATT(sock)); 646a946f1bSArnd Bergmann __raw_writel(mcio, MCIO(sock)); 656a946f1bSArnd Bergmann } 666a946f1bSArnd Bergmann EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_timing); 676a946f1bSArnd Bergmann 686a946f1bSArnd Bergmann void pxa_smemc_set_pcmcia_socket(int nr) 696a946f1bSArnd Bergmann { 706a946f1bSArnd Bergmann switch (nr) { 716a946f1bSArnd Bergmann case 0: 726a946f1bSArnd Bergmann __raw_writel(0, MECR); 736a946f1bSArnd Bergmann break; 746a946f1bSArnd Bergmann case 1: 756a946f1bSArnd Bergmann /* 766a946f1bSArnd Bergmann * We have at least one socket, so set MECR:CIT 776a946f1bSArnd Bergmann * (Card Is There) 786a946f1bSArnd Bergmann */ 796a946f1bSArnd Bergmann __raw_writel(MECR_CIT, MECR); 806a946f1bSArnd Bergmann break; 816a946f1bSArnd Bergmann case 2: 826a946f1bSArnd Bergmann /* Set CIT and MECR:NOS (Number Of Sockets) */ 836a946f1bSArnd Bergmann __raw_writel(MECR_CIT | MECR_NOS, MECR); 846a946f1bSArnd Bergmann break; 856a946f1bSArnd Bergmann } 866a946f1bSArnd Bergmann } 876a946f1bSArnd Bergmann EXPORT_SYMBOL_GPL(pxa_smemc_set_pcmcia_socket); 886a946f1bSArnd Bergmann 89fd13f811SArnd Bergmann void __iomem *pxa_smemc_get_mdrefr(void) 90fd13f811SArnd Bergmann { 91fd13f811SArnd Bergmann return MDREFR; 92fd13f811SArnd Bergmann } 93fd13f811SArnd Bergmann 9415a40333SRussell King /* 951da177e4SLinus Torvalds * Intel PXA2xx internal register mapping. 961da177e4SLinus Torvalds * 97851982c1SMarek Vasut * Note: virtual 0xfffe0000-0xffffffff is reserved for the vector table 981da177e4SLinus Torvalds * and cache flush area. 991da177e4SLinus Torvalds */ 100851982c1SMarek Vasut static struct map_desc common_io_desc[] __initdata = { 1016f9182ebSDeepak Saxena { /* Devs */ 1020e32986cSLaurent Pinchart .virtual = (unsigned long)PERIPH_VIRT, 1030e32986cSLaurent Pinchart .pfn = __phys_to_pfn(PERIPH_PHYS), 1040e32986cSLaurent Pinchart .length = PERIPH_SIZE, 1056f9182ebSDeepak Saxena .type = MT_DEVICE 1066f9182ebSDeepak Saxena } 1071da177e4SLinus Torvalds }; 1081da177e4SLinus Torvalds 1091da177e4SLinus Torvalds void __init pxa_map_io(void) 1101da177e4SLinus Torvalds { 1112111667bSAndrew Ruder debug_ll_io_init(); 112851982c1SMarek Vasut iotable_init(ARRAY_AND_SIZE(common_io_desc)); 1131da177e4SLinus Torvalds } 114