Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 123807
b: refs/heads/master
c: 74b265d
h: refs/heads/master
i:
  123805: ecb9760
  123803: 6a8f261
  123799: d4cbbfe
  123791: f116619
  123775: 5d9459e
v: v3
  • Loading branch information
Ben Dooks committed Dec 15, 2008
1 parent ed7b343 commit f338592
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 156 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2cd493fc10a5ad628dce8471ae72cf0882506735
refs/heads/master: 74b265d4e0555b9fc9cc75eb8876140ecf8c6b8a
5 changes: 1 addition & 4 deletions trunk/arch/arm/mach-s3c2410/s3c2410.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,9 @@ void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
* machine specific initialisation.
*/

void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size)
void __init s3c2410_map_io(void)
{
/* register our io-tables */

iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
iotable_init(mach_desc, mach_size);
}

void __init s3c2410_init_clocks(int xtal)
Expand Down
3 changes: 1 addition & 2 deletions trunk/arch/arm/mach-s3c2412/s3c2412.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void s3c2412_hard_reset(void)
* machine specific initialisation.
*/

void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size)
void __init s3c2412_map_io(void)
{
/* move base of IO */

Expand All @@ -153,7 +153,6 @@ void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size)
/* register our io-tables */

iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
iotable_init(mach_desc, mach_size);
}

void __init s3c2412_init_clocks(int xtal)
Expand Down
3 changes: 1 addition & 2 deletions trunk/arch/arm/mach-s3c2443/s3c2443.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ void __init s3c2443_init_uarts(struct s3c2410_uartcfg *cfg, int no)
* machine specific initialisation.
*/

void __init s3c2443_map_io(struct map_desc *mach_desc, int mach_size)
void __init s3c2443_map_io(void)
{
iotable_init(s3c2443_iodesc, ARRAY_SIZE(s3c2443_iodesc));
iotable_init(mach_desc, mach_size);
}

/* need to register class before we actually register the device, and
Expand Down
15 changes: 13 additions & 2 deletions trunk/arch/arm/plat-s3c/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# dummy makefile, currently just including asm/arm/plat-s3c/include/plat
# arch/arm/plat-s3c/Makefile
#
# Copyright 2008 Simtec Electronics
#
# Licensed under GPLv2

obj-n := dummy.o
obj-y :=
obj-m :=
obj-n :=
obj- :=

# Core support for all Samsung SoCs

obj-y += init.o
161 changes: 161 additions & 0 deletions trunk/arch/arm/plat-s3c/init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/* linux/arch/arm/plat-s3c/init.c
*
* Copyright (c) 2008 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
* http://armlinux.simtec.co.uk/
*
* S3C series CPU initialisation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/serial_core.h>
#include <linux/platform_device.h>
#include <linux/delay.h>

#include <mach/hardware.h>

#include <asm/mach/arch.h>
#include <asm/mach/map.h>

#include <plat/cpu.h>
#include <plat/devs.h>
#include <plat/clock.h>

#include <plat/regs-serial.h>

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++) {
if ((idcode & tab->idmask) == tab->idcode)
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);

if (cpu->map_io == NULL || cpu->init == NULL) {
printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
panic("Unsupported Samsung CPU");
}

cpu->map_io();
}

/* s3c24xx_init_clocks
*
* Initialise the clock subsystem and associated information from the
* given master crystal value.
*
* xtal = 0 -> use default PLL crystal value (normally 12MHz)
* != 0 -> PLL crystal value in Hz
*/

void __init s3c24xx_init_clocks(int xtal)
{
if (xtal == 0)
xtal = 12*1000*1000;

if (cpu == NULL)
panic("s3c24xx_init_clocks: no cpu setup?\n");

if (cpu->init_clocks == NULL)
panic("s3c24xx_init_clocks: cpu has no clock init\n");
else
(cpu->init_clocks)(xtal);
}

/* uart management */

static int nr_uarts __initdata = 0;

static struct s3c2410_uartcfg uart_cfgs[3];

/* 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)
{
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;
}

void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
{
if (cpu == NULL)
return;

if (cpu->init_uarts == NULL) {
printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
} else
(cpu->init_uarts)(cfg, no);
}

static int __init s3c_arch_init(void)
{
int ret;

// do the correct init for cpu

if (cpu == NULL)
panic("s3c_arch_init: NULL cpu\n");

ret = (cpu->init)();
if (ret != 0)
return ret;

ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
return ret;
}

arch_initcall(s3c_arch_init);
141 changes: 3 additions & 138 deletions trunk/arch/arm/plat-s3c24xx/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@
#include <plat/s3c2442.h>
#include <plat/s3c2443.h>

struct cpu_table {
unsigned long idcode;
unsigned long idmask;
void (*map_io)(struct map_desc *mach_desc, int size);
void (*init_uarts)(struct s3c2410_uartcfg *cfg, int no);
void (*init_clocks)(int xtal);
int (*init)(void);
const char *name;
};

/* table of supported CPUs */

static const char name_s3c2400[] = "S3C2400";
Expand Down Expand Up @@ -169,23 +159,7 @@ static struct map_desc s3c_iodesc[] __initdata = {
IODESC_ENT(UART)
};

static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode)
{
struct cpu_table *tab;
int count;

tab = cpu_ids;
for (count = 0; count < ARRAY_SIZE(cpu_ids); count++, tab++) {
if ((idcode & tab->idmask) == tab->idcode)
return tab;
}

return NULL;
}

/* cpu information */

static struct cpu_table *cpu;
/* read cpu identificaiton code */

static unsigned long s3c24xx_read_idcode_v5(void)
{
Expand Down Expand Up @@ -231,6 +205,7 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
unsigned long idcode = 0x0;

/* initialise the io descriptors we need for initialisation */
iotable_init(mach_desc, size);
iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));

if (cpu_architecture() >= CPU_ARCH_ARMv5) {
Expand All @@ -239,117 +214,7 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
idcode = s3c24xx_read_idcode_v4();
}

cpu = s3c_lookup_cpu(idcode);

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);

if (cpu->map_io == NULL || cpu->init == NULL) {
printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
panic("Unsupported S3C24XX CPU");
}

arm_pm_restart = s3c24xx_pm_restart;

(cpu->map_io)(mach_desc, size);
}

/* s3c24xx_init_clocks
*
* Initialise the clock subsystem and associated information from the
* given master crystal value.
*
* xtal = 0 -> use default PLL crystal value (normally 12MHz)
* != 0 -> PLL crystal value in Hz
*/

void __init s3c24xx_init_clocks(int xtal)
{
if (xtal == 0)
xtal = 12*1000*1000;

if (cpu == NULL)
panic("s3c24xx_init_clocks: no cpu setup?\n");

if (cpu->init_clocks == NULL)
panic("s3c24xx_init_clocks: cpu has no clock init\n");
else
(cpu->init_clocks)(xtal);
}

/* uart management */

static int nr_uarts __initdata = 0;

static struct s3c2410_uartcfg uart_cfgs[3];

/* 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)
{
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;
s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids));
}

void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
{
if (cpu == NULL)
return;

if (cpu->init_uarts == NULL) {
printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
} else
(cpu->init_uarts)(cfg, no);
}

static int __init s3c_arch_init(void)
{
int ret;

// do the correct init for cpu

if (cpu == NULL)
panic("s3c_arch_init: NULL cpu\n");

ret = (cpu->init)();
if (ret != 0)
return ret;

ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
return ret;
}

arch_initcall(s3c_arch_init);
Loading

0 comments on commit f338592

Please sign in to comment.