aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/mach-sdk7786/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/mach-sdk7786/setup.c')
-rw-r--r--arch/sh/boards/mach-sdk7786/setup.c219
1 files changed, 219 insertions, 0 deletions
diff --git a/arch/sh/boards/mach-sdk7786/setup.c b/arch/sh/boards/mach-sdk7786/setup.c
new file mode 100644
index 000000000000..b460dcc785c1
--- /dev/null
+++ b/arch/sh/boards/mach-sdk7786/setup.c
@@ -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
20static 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
35static 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
42static 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
52static struct resource smbus_fpga_resource = {
53 .start = 0x07fff9e0,
54 .end = 0x07fff9e0 + SZ_32 - 1,
55 .flags = IORESOURCE_MEM,
56};
57
58static struct platform_device smbus_fpga_device = {
59 .name = "i2c-sdk7786",
60 .id = 0,
61 .num_resources = 1,
62 .resource = &smbus_fpga_resource,
63};
64
65static struct resource smbus_pcie_resource = {
66 .start = 0x07fffc30,
67 .end = 0x07fffc30 + SZ_32 - 1,
68 .flags = IORESOURCE_MEM,
69};
70
71static struct platform_device smbus_pcie_device = {
72 .name = "i2c-sdk7786",
73 .id = 1,
74 .num_resources = 1,
75 .resource = &smbus_pcie_resource,
76};
77
78static struct i2c_board_info __initdata sdk7786_i2c_devices[] = {
79 {
80 I2C_BOARD_INFO("max6900", 0x68),
81 },
82};
83
84static 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
95static 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
116static 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
153static void __iomem *fpga_regs;
154
155static u16 fpga_read_reg(unsigned int reg)
156{
157 return __raw_readw(fpga_regs + reg);
158}
159
160static void fpga_write_reg(u16 val, unsigned int reg)
161{
162 __raw_writew(val, fpga_regs + reg);
163}
164
165enum {
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
180static 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 */
207static 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 */
215static struct sh_machine_vector mv_sdk7786 __initmv = {
216 .mv_name = "SDK7786",
217 .mv_setup = sdk7786_setup,
218 .mv_init_irq = init_sdk7786_IRQ,
219};