Linux Audio

Check our new training course

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