# arm: samsung

---

# Samsung SoC

_Peios Kernel / Hardware and drivers / Processor architectures / arm: samsung_

> Reference for Samsung SoC.

<a id="rst-samsung-soc"></a>

<!-- SPDX-License-Identifier: GPL-2.0 -->

- [Samsung GPIO implementation](</kernel/hardware/arch/arm-samsung/gpio.md>)
- [Interface between kernel and boot loaders on Exynos boards](</kernel/hardware/arch/arm-samsung/bootloader-interface.md>)
- [Samsung ARM Linux Overview](</kernel/hardware/arch/arm-samsung/overview.md>)

---

# Interface between kernel and boot loaders on Exynos boards

_Peios Kernel / Hardware and drivers / Processor architectures / arm: samsung_

> Author: Krzysztof Kozlowski

<a id="rst-interface-between-kernel-and-boot-loaders-on-exynos-boards"></a>

Author: Krzysztof Kozlowski

Date  : 6 June 2015

The document tries to describe currently used interface between Linux kernel and boot loaders on Samsung Exynos based boards. This is not a definition of interface but rather a description of existing state, a reference for information purpose only.

In the document "boot loader" means any of following: U-boot, proprietary SBOOT or any other firmware for ARMv7 and ARMv8 initializing the board before executing kernel.

1. Non-Secure mode

Address:      sysram_ns_base_addr


<table>
<thead>
<tr>
<th>


Offset

</th>
<th>


Value

</th>
<th>


Purpose

</th>
</tr>
</thead>
<tbody>
<tr>
<td>


0x08

</td>
<td>


exynos_cpu_resume_ns, mcpm_entry_point

</td>
<td>


System suspend

</td>
</tr>
<tr>
<td>


0x0c

</td>
<td>


0x00000bad (Magic cookie)

</td>
<td>


System suspend

</td>
</tr>
<tr>
<td>


0x1c

</td>
<td>


exynos4_secondary_startup

</td>
<td>


Secondary CPU boot

</td>
</tr>
<tr>
<td>


0x1c + 4\*cpu

</td>
<td>


exynos4_secondary_startup (Exynos4412)

</td>
<td>


Secondary CPU boot

</td>
</tr>
<tr>
<td>


0x20

</td>
<td>


0xfcba0d10 (Magic cookie)

</td>
<td>


AFTR

</td>
</tr>
<tr>
<td>


0x24

</td>
<td>


exynos_cpu_resume_ns

</td>
<td>


AFTR

</td>
</tr>
<tr>
<td>


0x28 + 4\*cpu

</td>
<td>


0x8 (Magic cookie, Exynos3250)

</td>
<td>


AFTR

</td>
</tr>
<tr>
<td>


0x28

</td>
<td>


0x0 or last value during resume (Exynos542x)

</td>
<td>


System suspend

</td>
</tr>
</tbody>
</table>

2. Secure mode

Address:      sysram_base_addr


<table>
<thead>
<tr>
<th>


Offset

</th>
<th>


Value

</th>
<th>


Purpose

</th>
</tr>
</thead>
<tbody>
<tr>
<td>


0x00

</td>
<td>


exynos4_secondary_startup

</td>
<td>


Secondary CPU boot

</td>
</tr>
<tr>
<td>


0x04

</td>
<td>


exynos4_secondary_startup (Exynos542x)

</td>
<td>


Secondary CPU boot

</td>
</tr>
<tr>
<td>


4\*cpu

</td>
<td>


exynos4_secondary_startup (Exynos4412)

</td>
<td>


Secondary CPU boot

</td>
</tr>
<tr>
<td>


0x20

</td>
<td>


exynos_cpu_resume (Exynos4210 r1.0)

</td>
<td>


AFTR

</td>
</tr>
<tr>
<td>


0x24

</td>
<td>


0xfcba0d10 (Magic cookie, Exynos4210 r1.0)

</td>
<td>


AFTR

</td>
</tr>
</tbody>
</table>

Address:      pmu_base_addr


<table>
<thead>
<tr>
<th>


Offset

</th>
<th>


Value

</th>
<th>


Purpose

</th>
</tr>
</thead>
<tbody>
<tr>
<td>


0x0800

</td>
<td>


exynos_cpu_resume

</td>
<td>


AFTR, suspend

</td>
</tr>
<tr>
<td>


0x0800

</td>
<td>


mcpm_entry_point (Exynos542x with MCPM)

</td>
<td>


AFTR, suspend

</td>
</tr>
<tr>
<td>


0x0804

</td>
<td>


0xfcba0d10 (Magic cookie)

</td>
<td>


AFTR

</td>
</tr>
<tr>
<td>


0x0804

</td>
<td>


0x00000bad (Magic cookie)

</td>
<td>


System suspend

</td>
</tr>
<tr>
<td>


0x0814

</td>
<td>


exynos4_secondary_startup (Exynos4210 r1.1)

</td>
<td>


Secondary CPU boot

</td>
</tr>
<tr>
<td>


0x0818

</td>
<td>


0xfcba0d10 (Magic cookie, Exynos4210 r1.1)

</td>
<td>


AFTR

</td>
</tr>
<tr>
<td>


0x081C

</td>
<td>


exynos_cpu_resume (Exynos4210 r1.1)

</td>
<td>


AFTR

</td>
</tr>
</tbody>
</table>

3. Other (regardless of secure/non-secure mode)

Address:      pmu_base_addr


<table>
<thead>
<tr>
<th>


Offset

</th>
<th>


Value

</th>
<th>


Purpose

</th>
</tr>
</thead>
<tbody>
<tr>
<td>


0x0908

</td>
<td>


Non-zero

</td>
<td>


Secondary CPU boot up indicator on Exynos3250 and Exynos542x

</td>
</tr>
</tbody>
</table>

4. Glossary

AFTR - ARM Off Top Running, a low power mode, Cortex cores and many other modules are power gated, except the TOP modules MCPM - Multi-Cluster Power Management

---

# Samsung GPIO implementation

_Peios Kernel / Hardware and drivers / Processor architectures / arm: samsung_

> This outlines the Samsung GPIO implementation and the architecture specific calls provided alongside the drivers/gpio core.

<a id="rst-samsung-gpio-implementation"></a>

<a id="rst-introduction"></a>

## Introduction

This outlines the Samsung GPIO implementation and the architecture specific calls provided alongside the drivers/gpio core.

<a id="rst-gpiolib-integration"></a>

## GPIOLIB integration

The gpio implementation uses gpiolib as much as possible, only providing specific calls for the items that require Samsung specific handling, such as pin special-function or pull resistor control.

GPIO numbering is synchronised between the Samsung and gpiolib system.

<a id="rst-pin-configuration"></a>

## PIN configuration

Pin configuration is specific to the Samsung architecture, with each SoC registering the necessary information for the core gpio configuration implementation to configure pins as necessary.

The s3c_gpio_cfgpin() and s3c_gpio_setpull() provide the means for a driver or machine to change gpio configuration.

See arch/arm/mach-s3c/gpio-cfg.h for more information on these functions.

---

# Samsung ARM Linux Overview

_Peios Kernel / Hardware and drivers / Processor architectures / arm: samsung_

> The Samsung range of ARM SoCs spans many similar devices, from the initial ARM9 through to the newest ARM cores. This document shows an overview of the current kernel support, how to use it and where to find the code that supports this.

<a id="rst-samsung-arm-linux-overview"></a>

<a id="rst-introduction"></a>

## Introduction

> The Samsung range of ARM SoCs spans many similar devices, from the initial ARM9 through to the newest ARM cores. This document shows an overview of the current kernel support, how to use it and where to find the code that supports this.
>
> The currently supported SoCs are:
>
> - S3C64XX: S3C6400 and S3C6410
>
> - S5PC110 / S5PV210

<a id="rst-configuration"></a>

## Configuration

> A number of configurations are supplied, as there is no current way of unifying all the SoCs into one kernel.
>
> - **s5pc110_defconfig**
>
>   - S5PC110 specific default configuration
>
> - **s5pv210_defconfig**
>
>   - S5PV210 specific default configuration

<a id="rst-layout"></a>

## Layout

> The directory layout is currently being restructured, and consists of several platform directories and then the machine specific directories of the CPUs being built for.
>
> plat-samsung provides the base for all the implementations, and is the last in the line of include directories that are processed for the build specific information. It contains the base clock, GPIO and device definitions to get the system running.
>
> plat-s5p is for s5p specific builds, and contains common support for the S5P specific systems. Not all S5Ps use all the features in this directory due to differences in the hardware.

<a id="rst-layout-changes"></a>

## Layout changes

> The old plat-s3c and plat-s5pc1xx directories have been removed, with support moved to either plat-samsung or plat-s5p as necessary. These moves where to simplify the include and dependency issues involved with having so many different platform directories.

<a id="rst-port-contributors"></a>

## Port Contributors

> Ben Dooks (BJD) Vincent Sanders Herbert Potzl Arnaud Patard (RTP) Roc Wu Klaus Fetscher Dimitry Andric Shannon Holland Guillaume Gourat (NexVision) Christer Weinigel (wingel) (Acer N30) Lucas Correia Villa Real (S3C2400 port)

<a id="rst-document-author"></a>

## Document Author

Copyright 2009-2010 Ben Dooks &lt;[ben-linux@fluff.org](<mailto:ben-linux@fluff.org>)&gt;

---

# Samsung clock register conversion script

_Peios Kernel / Hardware and drivers / Processor architectures / arm: samsung_

> Retained AWK helper for converting Samsung clock-source register definitions; the source includes its original invocation.

Retained AWK helper for converting Samsung clock-source register definitions; the source includes its original invocation.


```awk
#!/usr/bin/awk -f
#
# Copyright 2010 Ben Dooks <ben-linux@fluff.org>
#
# Released under GPLv2

# example usage
# ./clksrc-change-registers.awk arch/arm/plat-s5pc1xx/include/plat/regs-clock.h < src > dst

function extract_value(s)
{
    eqat = index(s, "=")
    comat = index(s, ",")
    return substr(s, eqat+2, (comat-eqat)-2)
}

function remove_brackets(b)
{
    return substr(b, 2, length(b)-2)
}

function splitdefine(l, p)
{
    r = split(l, tp)

    p[0] = tp[2]
    p[1] = remove_brackets(tp[3])
}

function find_length(f)
{
    if (0)
	printf "find_length " f "\n" > "/dev/stderr"

    if (f ~ /0x1/)
	return 1
    else if (f ~ /0x3/)
	return 2
    else if (f ~ /0x7/)
	return 3
    else if (f ~ /0xf/)
	return 4

    printf "unknown length " f "\n" > "/dev/stderr"
    exit
}

function find_shift(s)
{
    id = index(s, "<")
    if (id <= 0) {
	printf "cannot find shift " s "\n" > "/dev/stderr"
	exit
    }

    return substr(s, id+2)
}


BEGIN {
    if (ARGC < 2) {
	print "too few arguments" > "/dev/stderr"
	exit
    }

# read the header file and find the mask values that we will need
# to replace and create an associative array of values

    while (getline line < ARGV[1] > 0) {
	if (line ~ /\#define.*_MASK/ &&
	    !(line ~ /USB_SIG_MASK/)) {
	    splitdefine(line, fields)
	    name = fields[0]
	    if (0)
		printf "MASK " line "\n" > "/dev/stderr"
	    dmask[name,0] = find_length(fields[1])
	    dmask[name,1] = find_shift(fields[1])
	    if (0)
		printf "=> '" name "' LENGTH=" dmask[name,0] " SHIFT=" dmask[name,1] "\n" > "/dev/stderr"
	} else {
	}
    }

    delete ARGV[1]
}

/clksrc_clk.*=.*{/ {
    shift=""
    mask=""
    divshift=""
    reg_div=""
    reg_src=""
    indent=1

    print $0

    for(; indent >= 1;) {
	if ((getline line) <= 0) {
	    printf "unexpected end of file" > "/dev/stderr"
	    exit 1;
	}

	if (line ~ /\.shift/) {
	    shift = extract_value(line)
	} else if (line ~ /\.mask/) {
	    mask = extract_value(line)
	} else if (line ~ /\.reg_divider/) {
	    reg_div = extract_value(line)
	} else if (line ~ /\.reg_source/) {
	    reg_src = extract_value(line)
	} else if (line ~ /\.divider_shift/) {
	    divshift = extract_value(line)
	} else if (line ~ /{/) {
		indent++
		print line
	    } else if (line ~ /}/) {
	    indent--

	    if (indent == 0) {
		if (0) {
		    printf "shift '" shift   "' ='" dmask[shift,0] "'\n" > "/dev/stderr"
		    printf "mask  '" mask    "'\n" > "/dev/stderr"
		    printf "dshft '" divshift "'\n" > "/dev/stderr"
		    printf "rdiv  '" reg_div "'\n" > "/dev/stderr"
		    printf "rsrc  '" reg_src "'\n" > "/dev/stderr"
		}

		generated = mask
		sub(reg_src, reg_div, generated)

		if (0) {
		    printf "/* rsrc " reg_src " */\n"
		    printf "/* rdiv " reg_div " */\n"
		    printf "/* shift " shift " */\n"
		    printf "/* mask " mask " */\n"
		    printf "/* generated " generated " */\n"
		}

		if (reg_div != "") {
		    printf "\t.reg_div = { "
		    printf ".reg = " reg_div ", "
		    printf ".shift = " dmask[generated,1] ", "
		    printf ".size = " dmask[generated,0] ", "
		    printf "},\n"
		}

		printf "\t.reg_src = { "
		printf ".reg = " reg_src ", "
		printf ".shift = " dmask[mask,1] ", "
		printf ".size = " dmask[mask,0] ", "

		printf "},\n"

	    }

	    print line
	} else {
	    print line
	}

	if (0)
	    printf indent ":" line "\n" > "/dev/stderr"
    }
}

// && ! /clksrc_clk.*=.*{/ { print $0 }

```
