2017-12-25 19:54:35 +00:00
// SPDX-License-Identifier: GPL-2.0
//
// Copyright (c) 2008 Simtec Electronics
// Ben Dooks <ben@simtec.co.uk>
// http://armlinux.simtec.co.uk/
//
// S3C series CPU initialisation
2008-10-21 13:06:31 +00:00
2013-08-25 17:37:34 +00:00
/*
* NOTE : Code in this file is not used on S3C64xx when booting with
* Device Tree support .
*/
2008-10-21 13:06:31 +00:00
# include <linux/init.h>
# include <linux/module.h>
# include <linux/interrupt.h>
# include <linux/ioport.h>
# include <linux/serial_core.h>
2014-02-14 01:32:45 +00:00
# include <linux/serial_s3c.h>
2008-10-21 13:06:31 +00:00
# include <linux/platform_device.h>
2013-08-25 17:37:34 +00:00
# include <linux/of.h>
2008-10-21 13:06:31 +00:00
# include <asm/mach/arch.h>
# include <asm/mach/map.h>
2019-09-02 16:37:30 +00:00
# include "cpu.h"
# include "devs.h"
2008-10-21 13:06:31 +00:00
static struct cpu_table * cpu ;
static struct cpu_table * __init s3c_lookup_cpu ( unsigned long idcode ,
struct cpu_table * tab ,
unsigned int count )
{
for ( ; count ! = 0 ; count - - , tab + + ) {
2011-03-23 05:45:29 +00:00
if ( ( idcode & tab - > idmask ) = = ( tab - > idcode & tab - > idmask ) )
2008-10-21 13:06:31 +00:00
return tab ;
}
return NULL ;
}
void __init s3c_init_cpu ( unsigned long idcode ,
struct cpu_table * cputab , unsigned int cputab_size )
{
cpu = s3c_lookup_cpu ( idcode , cputab , cputab_size ) ;
if ( cpu = = NULL ) {
printk ( KERN_ERR " Unknown CPU type 0x%08lx \n " , idcode ) ;
panic ( " Unknown S3C24XX CPU " ) ;
}
printk ( " CPU %s (id 0x%08lx) \n " , cpu - > name , idcode ) ;
2013-07-30 02:32:40 +00:00
if ( cpu - > init = = NULL ) {
2008-10-21 13:06:31 +00:00
printk ( KERN_ERR " CPU %s support not enabled \n " , cpu - > name ) ;
panic ( " Unsupported Samsung CPU " ) ;
}
2013-07-30 02:32:40 +00:00
if ( cpu - > map_io )
cpu - > map_io ( ) ;
2022-04-20 07:03:42 +00:00
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 " ) ;
2008-10-21 13:06:31 +00:00
}
/* uart management */
2013-06-15 00:03:49 +00:00
# if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
2008-10-21 13:06:31 +00:00
static int nr_uarts __initdata = 0 ;
2014-02-26 16:55:35 +00:00
# ifdef CONFIG_SERIAL_SAMSUNG_UARTS
2008-11-03 19:51:42 +00:00
static struct s3c2410_uartcfg uart_cfgs [ CONFIG_SERIAL_SAMSUNG_UARTS ] ;
2014-02-26 16:55:35 +00:00
# endif
2008-10-21 13:06:31 +00:00
/* s3c24xx_init_uartdevs
*
* copy the specified platform data and configuration into our central
* set of devices , before the data is thrown away after the init process .
*
* This also fills in the array passed to the serial driver for the
* early initialisation of the console .
*/
void __init s3c24xx_init_uartdevs ( char * name ,
struct s3c24xx_uart_resources * res ,
struct s3c2410_uartcfg * cfg , int no )
{
2014-02-26 16:55:35 +00:00
# ifdef CONFIG_SERIAL_SAMSUNG_UARTS
2008-10-21 13:06:31 +00:00
struct platform_device * platdev ;
struct s3c2410_uartcfg * cfgptr = uart_cfgs ;
struct s3c24xx_uart_resources * resp ;
int uart ;
memcpy ( cfgptr , cfg , sizeof ( struct s3c2410_uartcfg ) * no ) ;
for ( uart = 0 ; uart < no ; uart + + , cfg + + , cfgptr + + ) {
platdev = s3c24xx_uart_src [ cfgptr - > hwport ] ;
resp = res + cfgptr - > hwport ;
s3c24xx_uart_devs [ uart ] = platdev ;
platdev - > name = name ;
platdev - > resource = resp - > resources ;
platdev - > num_resources = resp - > nr_resources ;
platdev - > dev . platform_data = cfgptr ;
}
nr_uarts = no ;
2014-02-26 16:55:35 +00:00
# endif
2008-10-21 13:06:31 +00:00
}
void __init s3c24xx_init_uarts ( struct s3c2410_uartcfg * cfg , int no )
{
if ( cpu = = NULL )
return ;
2013-06-15 00:03:49 +00:00
if ( cpu - > init_uarts = = NULL & & IS_ENABLED ( CONFIG_SAMSUNG_ATAGS ) ) {
2008-10-21 13:06:31 +00:00
printk ( KERN_ERR " s3c24xx_init_uarts: cpu has no uart init \n " ) ;
} else
( cpu - > init_uarts ) ( cfg , no ) ;
}
2013-06-15 00:03:49 +00:00
# endif
2008-10-21 13:06:31 +00:00
static int __init s3c_arch_init ( void )
{
int ret ;
2015-02-27 19:31:51 +00:00
/* init is only needed for ATAGS based platforms */
2022-09-29 14:18:41 +00:00
if ( ! IS_ENABLED ( CONFIG_ATAGS ) )
2015-02-27 19:31:51 +00:00
return 0 ;
2008-10-21 13:06:31 +00:00
// do the correct init for cpu
2013-08-25 17:37:34 +00:00
if ( cpu = = NULL ) {
/* Not needed when booting with device tree. */
if ( of_have_populated_dt ( ) )
return 0 ;
2008-10-21 13:06:31 +00:00
panic ( " s3c_arch_init: NULL cpu \n " ) ;
2013-08-25 17:37:34 +00:00
}
2008-10-21 13:06:31 +00:00
ret = ( cpu - > init ) ( ) ;
if ( ret ! = 0 )
return ret ;
2013-06-15 00:03:49 +00:00
# if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
2008-10-21 13:06:31 +00:00
ret = platform_add_devices ( s3c24xx_uart_devs , nr_uarts ) ;
2013-06-15 00:03:49 +00:00
# endif
2008-10-21 13:06:31 +00:00
return ret ;
}
arch_initcall ( s3c_arch_init ) ;