Skip to content

Commit 02bf6cc

Browse files
committed
sh: Preliminary SDK7786 board support.
This stubs in some preliminary board support for the RTE SDK7786. This is quite stunted at the moment, and primarily builds on top of the system FPGA. FPGA IRQs are handled via CPU IRL masking for simplicity, with initial peripheral support restricted to the debug ethernet. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent e44d6c4 commit 02bf6cc

6 files changed

Lines changed: 1670 additions & 0 deletions

File tree

‎arch/sh/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ defaultimage-$(CONFIG_SH_AP325RXA) := uImage
8383
defaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage
8484
defaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux
8585
defaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux
86+
defaultimage-$(CONFIG_SH_SDK7786) := vmlinux.bin
8687

8788
# Set some sensible Kbuild defaults
8889
KBUILD_IMAGE := $(defaultimage-y)
@@ -143,6 +144,7 @@ machdir-$(CONFIG_SH_AP325RXA) += mach-ap325rxa
143144
machdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09
144145
machdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24
145146
machdir-$(CONFIG_SH_SDK7780) += mach-sdk7780
147+
machdir-$(CONFIG_SH_SDK7786) += mach-sdk7786
146148
machdir-$(CONFIG_SH_X3PROTO) += mach-x3proto
147149
machdir-$(CONFIG_SH_SH7763RDP) += mach-sh7763rdp
148150
machdir-$(CONFIG_SH_SH4202_MICRODEV) += mach-microdev

‎arch/sh/boards/Kconfig‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ config SH_SDK7780
150150
Select SDK7780 if configuring for a Renesas SH7780 SDK7780R3
151151
evaluation board.
152152

153+
config SH_SDK7786
154+
bool "SDK7786"
155+
depends on CPU_SUBTYPE_SH7786
156+
help
157+
Select SDK7786 if configuring for a Renesas Technology Europe
158+
SH7786-65nm board.
159+
153160
config SH_HIGHLANDER
154161
bool "Highlander"
155162
depends on CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7785
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-y := setup.o
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
/*
2+
* Renesas Technology Europe SDK7786 Support.
3+
*
4+
* Copyright (C) 2010 Matt Fleming
5+
* Copyright (C) 2010 Paul Mundt
6+
*
7+
* This file is subject to the terms and conditions of the GNU General Public
8+
* License. See the file "COPYING" in the main directory of this archive
9+
* for more details.
10+
*/
11+
#include <linux/init.h>
12+
#include <linux/platform_device.h>
13+
#include <linux/io.h>
14+
#include <linux/smsc911x.h>
15+
#include <linux/i2c.h>
16+
#include <linux/irq.h>
17+
#include <asm/machvec.h>
18+
#include <asm/sizes.h>
19+
20+
static struct resource smsc911x_resources[] = {
21+
[0] = {
22+
.name = "smsc911x-memory",
23+
.start = 0x07ffff00,
24+
.end = 0x07ffff00 + SZ_256 - 1,
25+
.flags = IORESOURCE_MEM,
26+
},
27+
[1] = {
28+
.name = "smsc911x-irq",
29+
.start = evt2irq(0x2c0),
30+
.end = evt2irq(0x2c0),
31+
.flags = IORESOURCE_IRQ,
32+
},
33+
};
34+
35+
static struct smsc911x_platform_config smsc911x_config = {
36+
.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
37+
.irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
38+
.flags = SMSC911X_USE_32BIT,
39+
.phy_interface = PHY_INTERFACE_MODE_MII,
40+
};
41+
42+
static struct platform_device smsc911x_device = {
43+
.name = "smsc911x",
44+
.id = -1,
45+
.num_resources = ARRAY_SIZE(smsc911x_resources),
46+
.resource = smsc911x_resources,
47+
.dev = {
48+
.platform_data = &smsc911x_config,
49+
},
50+
};
51+
52+
static struct resource smbus_fpga_resource = {
53+
.start = 0x07fff9e0,
54+
.end = 0x07fff9e0 + SZ_32 - 1,
55+
.flags = IORESOURCE_MEM,
56+
};
57+
58+
static struct platform_device smbus_fpga_device = {
59+
.name = "i2c-sdk7786",
60+
.id = 0,
61+
.num_resources = 1,
62+
.resource = &smbus_fpga_resource,
63+
};
64+
65+
static struct resource smbus_pcie_resource = {
66+
.start = 0x07fffc30,
67+
.end = 0x07fffc30 + SZ_32 - 1,
68+
.flags = IORESOURCE_MEM,
69+
};
70+
71+
static struct platform_device smbus_pcie_device = {
72+
.name = "i2c-sdk7786",
73+
.id = 1,
74+
.num_resources = 1,
75+
.resource = &smbus_pcie_resource,
76+
};
77+
78+
static struct i2c_board_info __initdata sdk7786_i2c_devices[] = {
79+
{
80+
I2C_BOARD_INFO("max6900", 0x68),
81+
},
82+
};
83+
84+
static struct platform_device *sh7786_devices[] __initdata = {
85+
&smsc911x_device,
86+
&smbus_fpga_device,
87+
&smbus_pcie_device,
88+
};
89+
90+
#define SBCR_REGS_BASE 0x07fff990
91+
92+
#define SCBR_I2CMEN (1 << 0) /* FPGA I2C master enable */
93+
#define SCBR_I2CCEN (1 << 1) /* CPU I2C master enable */
94+
95+
static int sdk7786_i2c_setup(void)
96+
{
97+
void __iomem *sbcr;
98+
unsigned int tmp;
99+
100+
sbcr = ioremap_nocache(SBCR_REGS_BASE, SZ_16);
101+
102+
/*
103+
* Hand over I2C control to the FPGA.
104+
*/
105+
tmp = ioread16(sbcr);
106+
tmp &= ~SCBR_I2CCEN;
107+
tmp |= SCBR_I2CMEN;
108+
iowrite16(tmp, sbcr);
109+
110+
iounmap(sbcr);
111+
112+
return i2c_register_board_info(0, sdk7786_i2c_devices,
113+
ARRAY_SIZE(sdk7786_i2c_devices));
114+
}
115+
116+
static int __init sdk7786_devices_setup(void)
117+
{
118+
int ret;
119+
120+
ret = platform_add_devices(sh7786_devices, ARRAY_SIZE(sh7786_devices));
121+
if (unlikely(ret != 0))
122+
return ret;
123+
124+
return sdk7786_i2c_setup();
125+
}
126+
__initcall(sdk7786_devices_setup);
127+
128+
#define FPGA_REGS_BASE 0x07fff800
129+
#define FPGA_REGS_SIZE 1152
130+
131+
#define INTASR 0x010
132+
#define INTAMR 0x020
133+
#define INTBSR 0x090
134+
#define INTBMR 0x0a0
135+
#define INTMSR 0x130
136+
137+
#define IASELR1 0x210
138+
#define IASELR2 0x220
139+
#define IASELR3 0x230
140+
#define IASELR4 0x240
141+
#define IASELR5 0x250
142+
#define IASELR6 0x260
143+
#define IASELR7 0x270
144+
#define IASELR8 0x280
145+
#define IASELR9 0x290
146+
#define IASELR10 0x2a0
147+
#define IASELR11 0x2b0
148+
#define IASELR12 0x2c0
149+
#define IASELR13 0x2d0
150+
#define IASELR14 0x2e0
151+
#define IASELR15 0x2f0
152+
153+
static void __iomem *fpga_regs;
154+
155+
static u16 fpga_read_reg(unsigned int reg)
156+
{
157+
return __raw_readw(fpga_regs + reg);
158+
}
159+
160+
static void fpga_write_reg(u16 val, unsigned int reg)
161+
{
162+
__raw_writew(val, fpga_regs + reg);
163+
}
164+
165+
enum {
166+
ATA_IRQ_BIT = 1,
167+
SPI_BUSY_BIT = 2,
168+
LIRQ5_BIT = 3,
169+
LIRQ6_BIT = 4,
170+
LIRQ7_BIT = 5,
171+
LIRQ8_BIT = 6,
172+
KEY_IRQ_BIT = 7,
173+
PEN_IRQ_BIT = 8,
174+
ETH_IRQ_BIT = 9,
175+
RTC_ALARM_BIT = 10,
176+
CRYSTAL_FAIL_BIT = 12,
177+
ETH_PME_BIT = 14,
178+
};
179+
180+
static void __init init_sdk7786_IRQ(void)
181+
{
182+
unsigned int tmp;
183+
184+
fpga_regs = ioremap_nocache(FPGA_REGS_BASE, FPGA_REGS_SIZE);
185+
if (!fpga_regs) {
186+
printk(KERN_ERR "Couldn't map FPGA registers\n");
187+
return;
188+
}
189+
190+
/* Enable priority encoding for all IRLs */
191+
fpga_write_reg(fpga_read_reg(INTMSR) | 0x0303, INTMSR);
192+
193+
/* Clear FPGA interrupt status registers */
194+
fpga_write_reg(0x0000, INTASR);
195+
fpga_write_reg(0x0000, INTBSR);
196+
197+
/* Unmask FPGA interrupts */
198+
tmp = fpga_read_reg(INTAMR);
199+
tmp &= ~(1 << ETH_IRQ_BIT);
200+
fpga_write_reg(tmp, INTAMR);
201+
202+
plat_irq_setup_pins(IRQ_MODE_IRL7654_MASK);
203+
plat_irq_setup_pins(IRQ_MODE_IRL3210_MASK);
204+
}
205+
206+
/* Initialize the board */
207+
static void __init sdk7786_setup(char **cmdline_p)
208+
{
209+
printk(KERN_INFO "Renesas Technology Corp. SDK7786 support.\n");
210+
}
211+
212+
/*
213+
* The Machine Vector
214+
*/
215+
static struct sh_machine_vector mv_sdk7786 __initmv = {
216+
.mv_name = "SDK7786",
217+
.mv_setup = sdk7786_setup,
218+
.mv_init_irq = init_sdk7786_IRQ,
219+
};

0 commit comments

Comments
 (0)