2 * Infineon/ADMTek 8668 (WildPass) platform devices support
4 * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
5 * Copyright (C) 2012 Florian Fainelli <florian@openwrt.org>
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
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/platform_device.h>
15 #include <linux/platform_data/tulip.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/pci.h>
19 #include <linux/slab.h>
20 #include <linux/ioport.h>
21 #include <linux/amba/bus.h>
22 #include <linux/amba/serial.h>
24 #include <asm/reboot.h>
26 #include <asm/addrspace.h>
27 #include <asm/bootinfo.h>
31 #define ADM8868_UBOOT_ENV 0x20000
32 #define ADM8868_UBOOT_WAN_MAC 0x5ac
33 #define ADM8868_UBOOT_LAN_MAC 0x404
35 static void adm8668_uart_set_mctrl(struct amba_device
*dev
,
41 static struct amba_pl010_data adm8668_uart0_data
= {
42 .set_mctrl
= adm8668_uart_set_mctrl
,
45 static struct amba_device adm8668_uart0_device
= {
47 .init_name
= "apb:uart0",
48 .platform_data
= &adm8668_uart0_data
,
51 .start
= ADM8668_UART0_BASE
,
52 .end
= ADM8668_UART0_BASE
+ 0xF,
53 .flags
= IORESOURCE_MEM
,
59 .periphid
= 0x0041010,
62 static struct resource eth0_resources
[] = {
64 .start
= ADM8668_LAN_BASE
,
65 .end
= ADM8668_LAN_BASE
+ 256,
66 .flags
= IORESOURCE_MEM
,
70 .flags
= IORESOURCE_IRQ
,
74 static struct tulip_platform_data eth0_pdata
= {
78 static struct platform_device adm8668_eth0_device
= {
81 .resource
= eth0_resources
,
82 .num_resources
= ARRAY_SIZE(eth0_resources
),
83 .dev
.platform_data
= ð0_pdata
,
86 static struct resource eth1_resources
[] = {
88 .start
= ADM8668_WAN_BASE
,
89 .end
= ADM8668_WAN_BASE
+ 256,
90 .flags
= IORESOURCE_MEM
,
94 .flags
= IORESOURCE_IRQ
,
98 static struct tulip_platform_data eth1_pdata
= {
102 static struct platform_device adm8668_eth1_device
= {
105 .resource
= eth1_resources
,
106 .num_resources
= ARRAY_SIZE(eth1_resources
),
107 .dev
.platform_data
= ð1_pdata
,
110 static const char *nor_probe_types
[] = { "adm8668part", NULL
};
112 static struct physmap_flash_data nor_flash_data
= {
114 .part_probe_types
= nor_probe_types
,
117 static struct resource nor_resources
[] = {
119 .start
= ADM8668_SMEM1_BASE
,
120 .end
= ADM8668_SMEM1_BASE
+ 0x800000 - 1,
121 .flags
= IORESOURCE_MEM
,
125 static struct platform_device adm8668_nor_device
= {
126 .name
= "physmap-flash",
128 .resource
= nor_resources
,
129 .num_resources
= ARRAY_SIZE(nor_resources
),
130 .dev
.platform_data
= &nor_flash_data
,
133 static struct platform_device
*adm8668_devs
[] = {
134 &adm8668_eth0_device
,
135 &adm8668_eth1_device
,
139 static void adm8668_fetch_mac(int unit
)
143 struct tulip_platform_data
*pdata
;
148 offset
= ADM8868_UBOOT_LAN_MAC
;
152 offset
= ADM8868_UBOOT_WAN_MAC
;
156 pr_err("unsupported ethernet unit: %d\n", unit
);
160 mac
= (u8
*)(KSEG1ADDR(ADM8668_SMEM1_BASE
) + ADM8868_UBOOT_ENV
+ offset
);
162 memcpy(pdata
->mac
, mac
, sizeof(pdata
->mac
));
166 int __devinit
adm8668_devs_register(void)
170 ret
= amba_device_register(&adm8668_uart0_device
, &iomem_resource
);
172 panic("failed to register AMBA UART");
174 adm8668_fetch_mac(0);
175 adm8668_fetch_mac(1);
177 return platform_add_devices(adm8668_devs
, ARRAY_SIZE(adm8668_devs
));
179 arch_initcall(adm8668_devs_register
);