2 * GPR board platform device registration (Au1550)
4 * Copyright (C) 2010 Wolfgang Grandegger <wg@denx.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <linux/delay.h>
22 #include <linux/init.h>
23 #include <linux/interrupt.h>
24 #include <linux/kernel.h>
25 #include <linux/platform_device.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/leds.h>
30 #include <linux/gpio.h>
31 #include <linux/i2c.h>
32 #include <linux/i2c-gpio.h>
33 #include <linux/gpio/machine.h>
34 #include <asm/bootinfo.h>
36 #include <asm/reboot.h>
37 #include <asm/mach-au1x00/au1000.h>
38 #include <asm/mach-au1x00/gpio-au1000.h>
41 const char *get_system_type(void)
46 void __init
prom_init(void)
48 unsigned char *memsize_str
;
49 unsigned long memsize
;
52 prom_argv
= (char **)fw_arg1
;
53 prom_envp
= (char **)fw_arg2
;
57 memsize_str
= prom_getenv("memsize");
58 if (!memsize_str
|| kstrtoul(memsize_str
, 0, &memsize
))
60 add_memory_region(0, memsize
, BOOT_MEM_RAM
);
63 void prom_putchar(unsigned char c
)
65 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR
, c
);
68 static void gpr_reset(char *c
)
70 /* switch System-LED to orange (red# and green# on) */
71 alchemy_gpio_direction_output(4, 0);
72 alchemy_gpio_direction_output(5, 0);
74 /* trigger watchdog to reset board in 200ms */
75 printk(KERN_EMERG
"Triggering watchdog soft reset...\n");
76 raw_local_irq_disable();
77 alchemy_gpio_direction_output(1, 0);
79 alchemy_gpio_set_value(1, 1);
84 static void gpr_power_off(void)
90 void __init
board_setup(void)
92 printk(KERN_INFO
"Trapeze ITS GPR board\n");
94 pm_power_off
= gpr_power_off
;
95 _machine_halt
= gpr_power_off
;
96 _machine_restart
= gpr_reset
;
99 alchemy_uart_enable(AU1000_UART3_PHYS_ADDR
);
100 alchemy_uart_enable(AU1000_UART1_PHYS_ADDR
);
102 /* Take away Reset of UMTS-card */
103 alchemy_gpio_direction_output(215, 1);
109 static struct resource gpr_wdt_resource
[] = {
113 .name
= "gpr-adm6320-wdt",
114 .flags
= IORESOURCE_IRQ
,
118 static struct platform_device gpr_wdt_device
= {
119 .name
= "adm6320-wdt",
121 .num_resources
= ARRAY_SIZE(gpr_wdt_resource
),
122 .resource
= gpr_wdt_resource
,
128 * 0x00000000-0x00200000 : "kernel"
129 * 0x00200000-0x00a00000 : "rootfs"
130 * 0x01d00000-0x01f00000 : "config"
131 * 0x01c00000-0x01d00000 : "yamon"
132 * 0x01d00000-0x01d40000 : "yamon env vars"
133 * 0x00000000-0x00a00000 : "kernel+rootfs"
135 static struct mtd_partition gpr_mtd_partitions
[] = {
144 .offset
= MTDPART_OFS_APPEND
,
145 .mask_flags
= MTD_WRITEABLE
,
150 .offset
= 0x01d00000,
155 .offset
= 0x01c00000,
158 .name
= "yamon env vars",
160 .offset
= MTDPART_OFS_APPEND
,
163 .name
= "kernel+rootfs",
169 static struct physmap_flash_data gpr_flash_data
= {
171 .nr_parts
= ARRAY_SIZE(gpr_mtd_partitions
),
172 .parts
= gpr_mtd_partitions
,
175 static struct resource gpr_mtd_resource
= {
178 .flags
= IORESOURCE_MEM
,
181 static struct platform_device gpr_mtd_device
= {
182 .name
= "physmap-flash",
184 .platform_data
= &gpr_flash_data
,
187 .resource
= &gpr_mtd_resource
,
193 static struct gpio_led gpr_gpio_leds
[] = {
206 static struct gpio_led_platform_data gpr_led_data
= {
207 .num_leds
= ARRAY_SIZE(gpr_gpio_leds
),
208 .leds
= gpr_gpio_leds
,
211 static struct platform_device gpr_led_devices
= {
215 .platform_data
= &gpr_led_data
,
222 static struct gpiod_lookup_table gpr_i2c_gpiod_table
= {
223 .dev_id
= "i2c-gpio",
226 * This should be on "GPIO2" which has base at 200 so
227 * the global numbers 209 and 210 should correspond to
228 * local offsets 9 and 10.
230 GPIO_LOOKUP_IDX("alchemy-gpio2", 9, NULL
, 0,
232 GPIO_LOOKUP_IDX("alchemy-gpio2", 10, NULL
, 1,
237 static struct i2c_gpio_platform_data gpr_i2c_data
= {
239 * The open drain mode is hardwired somewhere or an electrical
240 * property of the alchemy GPIO controller.
242 .sda_is_open_drain
= 1,
243 .scl_is_open_drain
= 1,
244 .udelay
= 2, /* ~100 kHz */
248 static struct platform_device gpr_i2c_device
= {
251 .dev
.platform_data
= &gpr_i2c_data
,
254 static struct i2c_board_info gpr_i2c_info
[] __initdata
= {
256 I2C_BOARD_INFO("lm83", 0x18),
262 static struct resource alchemy_pci_host_res
[] = {
264 .start
= AU1500_PCI_PHYS_ADDR
,
265 .end
= AU1500_PCI_PHYS_ADDR
+ 0xfff,
266 .flags
= IORESOURCE_MEM
,
270 static int gpr_map_pci_irq(const struct pci_dev
*d
, u8 slot
, u8 pin
)
272 if ((slot
== 0) && (pin
== 1))
273 return AU1550_PCI_INTA
;
274 else if ((slot
== 0) && (pin
== 2))
275 return AU1550_PCI_INTB
;
280 static struct alchemy_pci_platdata gpr_pci_pd
= {
281 .board_map_irq
= gpr_map_pci_irq
,
282 .pci_cfg_set
= PCI_CONFIG_AEN
| PCI_CONFIG_R2H
| PCI_CONFIG_R1H
|
284 #if defined(__MIPSEB__)
285 PCI_CONFIG_SIC_HWA_DAT
| PCI_CONFIG_SM
,
291 static struct platform_device gpr_pci_host_dev
= {
292 .dev
.platform_data
= &gpr_pci_pd
,
293 .name
= "alchemy-pci",
295 .num_resources
= ARRAY_SIZE(alchemy_pci_host_res
),
296 .resource
= alchemy_pci_host_res
,
299 static struct platform_device
*gpr_devices
[] __initdata
= {
306 static int __init
gpr_pci_init(void)
308 return platform_device_register(&gpr_pci_host_dev
);
310 /* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */
311 arch_initcall(gpr_pci_init
);
314 static int __init
gpr_dev_init(void)
316 gpiod_add_lookup_table(&gpr_i2c_gpiod_table
);
317 i2c_register_board_info(0, gpr_i2c_info
, ARRAY_SIZE(gpr_i2c_info
));
319 return platform_add_devices(gpr_devices
, ARRAY_SIZE(gpr_devices
));
321 device_initcall(gpr_dev_init
);