1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * GPR board platform device registration (Au1550)
8 #include <linux/delay.h>
9 #include <linux/init.h>
10 #include <linux/interrupt.h>
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/leds.h>
17 #include <linux/gpio.h>
18 #include <linux/i2c.h>
19 #include <linux/platform_data/i2c-gpio.h>
20 #include <linux/gpio/machine.h>
21 #include <asm/bootinfo.h>
23 #include <asm/reboot.h>
24 #include <asm/setup.h>
25 #include <asm/mach-au1x00/au1000.h>
26 #include <asm/mach-au1x00/gpio-au1000.h>
29 const char *get_system_type(void)
34 void __init prom_init(void)
36 unsigned char *memsize_str;
37 unsigned long memsize;
40 prom_argv = (char **)fw_arg1;
41 prom_envp = (char **)fw_arg2;
45 memsize_str = prom_getenv("memsize");
46 if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
48 add_memory_region(0, memsize, BOOT_MEM_RAM);
51 void prom_putchar(char c)
53 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
56 static void gpr_reset(char *c)
58 /* switch System-LED to orange (red# and green# on) */
59 alchemy_gpio_direction_output(4, 0);
60 alchemy_gpio_direction_output(5, 0);
62 /* trigger watchdog to reset board in 200ms */
63 printk(KERN_EMERG "Triggering watchdog soft reset...\n");
64 raw_local_irq_disable();
65 alchemy_gpio_direction_output(1, 0);
67 alchemy_gpio_set_value(1, 1);
72 static void gpr_power_off(void)
78 void __init board_setup(void)
80 printk(KERN_INFO "Trapeze ITS GPR board\n");
82 pm_power_off = gpr_power_off;
83 _machine_halt = gpr_power_off;
84 _machine_restart = gpr_reset;
87 alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
88 alchemy_uart_enable(AU1000_UART1_PHYS_ADDR);
90 /* Take away Reset of UMTS-card */
91 alchemy_gpio_direction_output(215, 1);
97 static struct resource gpr_wdt_resource[] = {
101 .name = "gpr-adm6320-wdt",
102 .flags = IORESOURCE_IRQ,
106 static struct platform_device gpr_wdt_device = {
107 .name = "adm6320-wdt",
109 .num_resources = ARRAY_SIZE(gpr_wdt_resource),
110 .resource = gpr_wdt_resource,
116 * 0x00000000-0x00200000 : "kernel"
117 * 0x00200000-0x00a00000 : "rootfs"
118 * 0x01d00000-0x01f00000 : "config"
119 * 0x01c00000-0x01d00000 : "yamon"
120 * 0x01d00000-0x01d40000 : "yamon env vars"
121 * 0x00000000-0x00a00000 : "kernel+rootfs"
123 static struct mtd_partition gpr_mtd_partitions[] = {
132 .offset = MTDPART_OFS_APPEND,
133 .mask_flags = MTD_WRITEABLE,
138 .offset = 0x01d00000,
143 .offset = 0x01c00000,
146 .name = "yamon env vars",
148 .offset = MTDPART_OFS_APPEND,
151 .name = "kernel+rootfs",
157 static struct physmap_flash_data gpr_flash_data = {
159 .nr_parts = ARRAY_SIZE(gpr_mtd_partitions),
160 .parts = gpr_mtd_partitions,
163 static struct resource gpr_mtd_resource = {
166 .flags = IORESOURCE_MEM,
169 static struct platform_device gpr_mtd_device = {
170 .name = "physmap-flash",
172 .platform_data = &gpr_flash_data,
175 .resource = &gpr_mtd_resource,
181 static const struct gpio_led gpr_gpio_leds[] = {
194 static struct gpio_led_platform_data gpr_led_data = {
195 .num_leds = ARRAY_SIZE(gpr_gpio_leds),
196 .leds = gpr_gpio_leds,
199 static struct platform_device gpr_led_devices = {
203 .platform_data = &gpr_led_data,
210 static struct gpiod_lookup_table gpr_i2c_gpiod_table = {
211 .dev_id = "i2c-gpio",
214 * This should be on "GPIO2" which has base at 200 so
215 * the global numbers 209 and 210 should correspond to
216 * local offsets 9 and 10.
218 GPIO_LOOKUP_IDX("alchemy-gpio2", 9, NULL, 0,
220 GPIO_LOOKUP_IDX("alchemy-gpio2", 10, NULL, 1,
225 static struct i2c_gpio_platform_data gpr_i2c_data = {
227 * The open drain mode is hardwired somewhere or an electrical
228 * property of the alchemy GPIO controller.
230 .sda_is_open_drain = 1,
231 .scl_is_open_drain = 1,
232 .udelay = 2, /* ~100 kHz */
236 static struct platform_device gpr_i2c_device = {
239 .dev.platform_data = &gpr_i2c_data,
242 static struct i2c_board_info gpr_i2c_info[] __initdata = {
244 I2C_BOARD_INFO("lm83", 0x18),
250 static struct resource alchemy_pci_host_res[] = {
252 .start = AU1500_PCI_PHYS_ADDR,
253 .end = AU1500_PCI_PHYS_ADDR + 0xfff,
254 .flags = IORESOURCE_MEM,
258 static int gpr_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
260 if ((slot == 0) && (pin == 1))
261 return AU1550_PCI_INTA;
262 else if ((slot == 0) && (pin == 2))
263 return AU1550_PCI_INTB;
268 static struct alchemy_pci_platdata gpr_pci_pd = {
269 .board_map_irq = gpr_map_pci_irq,
270 .pci_cfg_set = PCI_CONFIG_AEN | PCI_CONFIG_R2H | PCI_CONFIG_R1H |
272 #if defined(__MIPSEB__)
273 PCI_CONFIG_SIC_HWA_DAT | PCI_CONFIG_SM,
279 static struct platform_device gpr_pci_host_dev = {
280 .dev.platform_data = &gpr_pci_pd,
281 .name = "alchemy-pci",
283 .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
284 .resource = alchemy_pci_host_res,
287 static struct platform_device *gpr_devices[] __initdata = {
294 static int __init gpr_pci_init(void)
296 return platform_device_register(&gpr_pci_host_dev);
298 /* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */
299 arch_initcall(gpr_pci_init);
302 static int __init gpr_dev_init(void)
304 gpiod_add_lookup_table(&gpr_i2c_gpiod_table);
305 i2c_register_board_info(0, gpr_i2c_info, ARRAY_SIZE(gpr_i2c_info));
307 return platform_add_devices(gpr_devices, ARRAY_SIZE(gpr_devices));
309 device_initcall(gpr_dev_init);