Skip to content

Commit 6d01f51

Browse files
committed
sh: Add SH7203 CPU support.
This adds support for the SH7203 (SH-2A) CPU. Signed-off-by: Kieran Bingham <kbingham@mpc-data.co.uk> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent ff1b750 commit 6d01f51

12 files changed

Lines changed: 399 additions & 15 deletions

File tree

‎arch/sh/Kconfig‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ config CPU_SUBTYPE_SH7619
158158

159159
# SH-2A Processor Support
160160

161+
config CPU_SUBTYPE_SH7203
162+
bool "Support SH7203 processor"
163+
select CPU_SH2A
164+
161165
config CPU_SUBTYPE_SH7206
162166
bool "Support SH7206 processor"
163167
select CPU_SH2A
@@ -556,7 +560,7 @@ config SH_PCLK_FREQ
556560
default "32000000" if CPU_SUBTYPE_SH7722
557561
default "33333333" if CPU_SUBTYPE_SH7770 || \
558562
CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7705 || \
559-
CPU_SUBTYPE_SH7206
563+
CPU_SUBTYPE_SH7203 || CPU_SUBTYPE_SH7206
560564
default "60000000" if CPU_SUBTYPE_SH7751 || CPU_SUBTYPE_SH7751R
561565
default "66000000" if CPU_SUBTYPE_SH4_202
562566
default "50000000"
@@ -567,7 +571,7 @@ config SH_PCLK_FREQ
567571

568572
config SH_CLK_MD
569573
int "CPU Mode Pin Setting"
570-
depends on CPU_SUBTYPE_SH7619 || CPU_SUBTYPE_SH7206
574+
depends on CPU_SH2
571575
default 6 if CPU_SUBTYPE_SH7206
572576
default 5 if CPU_SUBTYPE_SH7619
573577
default 0

‎arch/sh/Kconfig.debug‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ config EARLY_SCIF_CONSOLE_PORT
3232
depends on EARLY_SCIF_CONSOLE
3333
default "0xffe00000" if CPU_SUBTYPE_SH7780
3434
default "0xffea0000" if CPU_SUBTYPE_SH7785
35+
default "0xfffe8000" if CPU_SUBTYPE_SH7203
3536
default "0xfffe9800" if CPU_SUBTYPE_SH7206
3637
default "0xf8420000" if CPU_SUBTYPE_SH7619
3738
default "0xa4400000" if CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7705

‎arch/sh/kernel/cpu/sh2a/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ obj-y := common.o probe.o opcode_helper.o
77
common-y += $(addprefix ../sh2/, ex.o entry.o)
88

99
obj-$(CONFIG_CPU_SUBTYPE_SH7206) += setup-sh7206.o clock-sh7206.o
10+
obj-$(CONFIG_CPU_SUBTYPE_SH7203) += setup-sh7203.o clock-sh7203.o
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* arch/sh/kernel/cpu/sh2a/clock-sh7203.c
3+
*
4+
* SH7203 support for the clock framework
5+
*
6+
* Copyright (C) 2007 Kieran Bingham (MPC-Data Ltd)
7+
*
8+
* Based on clock-sh7263.c
9+
* Copyright (C) 2006 Yoshinori Sato
10+
*
11+
* Based on clock-sh4.c
12+
* Copyright (C) 2005 Paul Mundt
13+
*
14+
* This file is subject to the terms and conditions of the GNU General Public
15+
* License. See the file "COPYING" in the main directory of this archive
16+
* for more details.
17+
*/
18+
#include <linux/init.h>
19+
#include <linux/kernel.h>
20+
#include <asm/clock.h>
21+
#include <asm/freq.h>
22+
#include <asm/io.h>
23+
24+
const static int pll1rate[]={8,12,16,0};
25+
const static int pfc_divisors[]={1,2,3,4,6,8,12};
26+
#define ifc_divisors pfc_divisors
27+
28+
#if (CONFIG_SH_CLK_MD == 0)
29+
#define PLL2 (1)
30+
#elif (CONFIG_SH_CLK_MD == 1)
31+
#define PLL2 (2)
32+
#elif (CONFIG_SH_CLK_MD == 2)
33+
#define PLL2 (4)
34+
#elif (CONFIG_SH_CLK_MD == 3)
35+
#define PLL2 (4)
36+
#else
37+
#error "Illegal Clock Mode!"
38+
#endif
39+
40+
static void master_clk_init(struct clk *clk)
41+
{
42+
clk->rate *= pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0003] * PLL2 ;
43+
}
44+
45+
static struct clk_ops sh7203_master_clk_ops = {
46+
.init = master_clk_init,
47+
};
48+
49+
static void module_clk_recalc(struct clk *clk)
50+
{
51+
int idx = (ctrl_inw(FREQCR) & 0x0007);
52+
clk->rate = clk->parent->rate / pfc_divisors[idx];
53+
}
54+
55+
static struct clk_ops sh7203_module_clk_ops = {
56+
.recalc = module_clk_recalc,
57+
};
58+
59+
static void bus_clk_recalc(struct clk *clk)
60+
{
61+
int idx = (ctrl_inw(FREQCR) & 0x0007);
62+
clk->rate = clk->parent->rate / pfc_divisors[idx-2];
63+
}
64+
65+
static struct clk_ops sh7203_bus_clk_ops = {
66+
.recalc = bus_clk_recalc,
67+
};
68+
69+
static void cpu_clk_recalc(struct clk *clk)
70+
{
71+
clk->rate = clk->parent->rate;
72+
}
73+
74+
static struct clk_ops sh7203_cpu_clk_ops = {
75+
.recalc = cpu_clk_recalc,
76+
};
77+
78+
static struct clk_ops *sh7203_clk_ops[] = {
79+
&sh7203_master_clk_ops,
80+
&sh7203_module_clk_ops,
81+
&sh7203_bus_clk_ops,
82+
&sh7203_cpu_clk_ops,
83+
};
84+
85+
void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
86+
{
87+
if (idx < ARRAY_SIZE(sh7203_clk_ops))
88+
*ops = sh7203_clk_ops[idx];
89+
}

‎arch/sh/kernel/cpu/sh2a/probe.c‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@
33
*
44
* CPU Subtype Probing for SH-2A.
55
*
6-
* Copyright (C) 2004, 2005 Paul Mundt
6+
* Copyright (C) 2004 - 2007 Paul Mundt
77
*
88
* This file is subject to the terms and conditions of the GNU General Public
99
* License. See the file "COPYING" in the main directory of this archive
1010
* for more details.
1111
*/
12-
1312
#include <linux/init.h>
1413
#include <asm/processor.h>
1514
#include <asm/cache.h>
1615

1716
int __init detect_cpu_and_cache_system(void)
1817
{
19-
/* Just SH7206 for now .. */
20-
boot_cpu_data.type = CPU_SH7206;
18+
/* All SH-2A CPUs have support for 16 and 32-bit opcodes.. */
2119
boot_cpu_data.flags |= CPU_HAS_OP32;
2220

21+
#if defined(CONFIG_CPU_SUBTYPE_SH7203)
22+
boot_cpu_data.type = CPU_SH7203;
23+
/* SH7203 has an FPU.. */
24+
boot_cpu_data.flags |= CPU_HAS_FPU;
25+
#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
26+
boot_cpu_data.type = CPU_SH7206;
27+
/* While SH7206 has a DSP.. */
28+
boot_cpu_data.flags |= CPU_HAS_DSP;
29+
#endif
30+
2331
boot_cpu_data.dcache.ways = 4;
24-
boot_cpu_data.dcache.way_incr = (1 << 11);
32+
boot_cpu_data.dcache.way_incr = (1 << 11);
2533
boot_cpu_data.dcache.sets = 128;
2634
boot_cpu_data.dcache.entry_shift = 4;
2735
boot_cpu_data.dcache.linesz = L1_CACHE_BYTES;
@@ -37,4 +45,3 @@ int __init detect_cpu_and_cache_system(void)
3745

3846
return 0;
3947
}
40-

0 commit comments

Comments
 (0)