cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

init.c (4205B)


      1// SPDX-License-Identifier: GPL-2.0
      2//
      3// Copyright (c) 2008 Simtec Electronics
      4//	Ben Dooks <ben@simtec.co.uk>
      5//	http://armlinux.simtec.co.uk/
      6//
      7// S3C series CPU initialisation
      8
      9/*
     10 * NOTE: Code in this file is not used on S3C64xx when booting with
     11 * Device Tree support.
     12 */
     13
     14#include <linux/init.h>
     15#include <linux/module.h>
     16#include <linux/interrupt.h>
     17#include <linux/ioport.h>
     18#include <linux/serial_core.h>
     19#include <linux/serial_s3c.h>
     20#include <linux/platform_device.h>
     21#include <linux/of.h>
     22
     23#include <asm/mach/arch.h>
     24#include <asm/mach/map.h>
     25
     26#include "cpu.h"
     27#include "devs.h"
     28
     29static struct cpu_table *cpu;
     30
     31static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode,
     32						struct cpu_table *tab,
     33						unsigned int count)
     34{
     35	for (; count != 0; count--, tab++) {
     36		if ((idcode & tab->idmask) == (tab->idcode & tab->idmask))
     37			return tab;
     38	}
     39
     40	return NULL;
     41}
     42
     43void __init s3c_init_cpu(unsigned long idcode,
     44			 struct cpu_table *cputab, unsigned int cputab_size)
     45{
     46	cpu = s3c_lookup_cpu(idcode, cputab, cputab_size);
     47
     48	if (cpu == NULL) {
     49		printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
     50		panic("Unknown S3C24XX CPU");
     51	}
     52
     53	printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
     54
     55	if (cpu->init == NULL) {
     56		printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
     57		panic("Unsupported Samsung CPU");
     58	}
     59
     60	if (cpu->map_io)
     61		cpu->map_io();
     62
     63	pr_err("The platform is deprecated and scheduled for removal. Please reach to the maintainers of the platform and linux-samsung-soc@vger.kernel.org if you still use it.  Without such feedback, the platform will be removed after 2022.\n");
     64}
     65
     66/* s3c24xx_init_clocks
     67 *
     68 * Initialise the clock subsystem and associated information from the
     69 * given master crystal value.
     70 *
     71 * xtal  = 0 -> use default PLL crystal value (normally 12MHz)
     72 *      != 0 -> PLL crystal value in Hz
     73*/
     74
     75void __init s3c24xx_init_clocks(int xtal)
     76{
     77	if (xtal == 0)
     78		xtal = 12*1000*1000;
     79
     80	if (cpu == NULL)
     81		panic("s3c24xx_init_clocks: no cpu setup?\n");
     82
     83	if (cpu->init_clocks == NULL)
     84		panic("s3c24xx_init_clocks: cpu has no clock init\n");
     85	else
     86		(cpu->init_clocks)(xtal);
     87}
     88
     89/* uart management */
     90#if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
     91static int nr_uarts __initdata = 0;
     92
     93#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
     94static struct s3c2410_uartcfg uart_cfgs[CONFIG_SERIAL_SAMSUNG_UARTS];
     95#endif
     96
     97/* s3c24xx_init_uartdevs
     98 *
     99 * copy the specified platform data and configuration into our central
    100 * set of devices, before the data is thrown away after the init process.
    101 *
    102 * This also fills in the array passed to the serial driver for the
    103 * early initialisation of the console.
    104*/
    105
    106void __init s3c24xx_init_uartdevs(char *name,
    107				  struct s3c24xx_uart_resources *res,
    108				  struct s3c2410_uartcfg *cfg, int no)
    109{
    110#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
    111	struct platform_device *platdev;
    112	struct s3c2410_uartcfg *cfgptr = uart_cfgs;
    113	struct s3c24xx_uart_resources *resp;
    114	int uart;
    115
    116	memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
    117
    118	for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
    119		platdev = s3c24xx_uart_src[cfgptr->hwport];
    120
    121		resp = res + cfgptr->hwport;
    122
    123		s3c24xx_uart_devs[uart] = platdev;
    124
    125		platdev->name = name;
    126		platdev->resource = resp->resources;
    127		platdev->num_resources = resp->nr_resources;
    128
    129		platdev->dev.platform_data = cfgptr;
    130	}
    131
    132	nr_uarts = no;
    133#endif
    134}
    135
    136void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
    137{
    138	if (cpu == NULL)
    139		return;
    140
    141	if (cpu->init_uarts == NULL && IS_ENABLED(CONFIG_SAMSUNG_ATAGS)) {
    142		printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
    143	} else
    144		(cpu->init_uarts)(cfg, no);
    145}
    146#endif
    147
    148static int __init s3c_arch_init(void)
    149{
    150	int ret;
    151
    152	/* init is only needed for ATAGS based platforms */
    153	if (!IS_ENABLED(CONFIG_ATAGS) ||
    154	    (!soc_is_s3c24xx() && !soc_is_s3c64xx()))
    155		return 0;
    156
    157	// do the correct init for cpu
    158
    159	if (cpu == NULL) {
    160		/* Not needed when booting with device tree. */
    161		if (of_have_populated_dt())
    162			return 0;
    163		panic("s3c_arch_init: NULL cpu\n");
    164	}
    165
    166	ret = (cpu->init)();
    167	if (ret != 0)
    168		return ret;
    169#if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
    170	ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
    171#endif
    172	return ret;
    173}
    174
    175arch_initcall(s3c_arch_init);