2 * MTX-1 platform devices registration (Au1500)
4 * Copyright (C) 2007-2009, Florian Fainelli <florian@openwrt.org>
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/init.h>
22 #include <linux/interrupt.h>
23 #include <linux/kernel.h>
24 #include <linux/platform_device.h>
25 #include <linux/leds.h>
26 #include <linux/gpio.h>
27 #include <linux/gpio_keys.h>
28 #include <linux/input.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/physmap.h>
31 #include <mtd/mtd-abi.h>
32 #include <asm/bootinfo.h>
33 #include <asm/reboot.h>
34 #include <asm/mach-au1x00/au1000.h>
35 #include <asm/mach-au1x00/au1xxx_eth.h>
38 const char *get_system_type(void)
43 void __init
prom_init(void)
45 unsigned char *memsize_str
;
46 unsigned long memsize
;
49 prom_argv
= (char **)fw_arg1
;
50 prom_envp
= (char **)fw_arg2
;
54 memsize_str
= prom_getenv("memsize");
58 strict_strtoul(memsize_str
, 0, &memsize
);
59 add_memory_region(0, memsize
, BOOT_MEM_RAM
);
62 void prom_putchar(unsigned char c
)
64 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR
, c
);
67 static void mtx1_reset(char *c
)
69 /* Jump to the reset vector */
70 __asm__
__volatile__("jr\t%0" : : "r"(0xbfc00000));
73 static void mtx1_power_off(void)
82 void __init
board_setup(void)
84 #if IS_ENABLED(CONFIG_USB_OHCI_HCD)
85 /* Enable USB power switch */
86 alchemy_gpio_direction_output(204, 0);
87 #endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
89 /* Initialize sys_pinfunc */
90 au_writel(SYS_PF_NI2
, SYS_PINFUNC
);
93 au_writel(~0, KSEG1ADDR(AU1000_SYS_PHYS_ADDR
) + SYS_TRIOUTCLR
);
94 alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */
95 alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */
96 alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */
97 alchemy_gpio_direction_output(5, 0); /* Disable eth PHY TX_ER */
99 /* Enable LED and set it to green */
100 alchemy_gpio_direction_output(211, 1); /* green on */
101 alchemy_gpio_direction_output(212, 0); /* red off */
103 pm_power_off
= mtx1_power_off
;
104 _machine_halt
= mtx1_power_off
;
105 _machine_restart
= mtx1_reset
;
107 printk(KERN_INFO
"4G Systems MTX-1 Board\n");
110 /******************************************************************************/
112 static struct gpio_keys_button mtx1_gpio_button
[] = {
116 .desc
= "System button",
120 static struct gpio_keys_platform_data mtx1_buttons_data
= {
121 .buttons
= mtx1_gpio_button
,
122 .nbuttons
= ARRAY_SIZE(mtx1_gpio_button
),
125 static struct platform_device mtx1_button
= {
129 .platform_data
= &mtx1_buttons_data
,
133 static struct resource mtx1_wdt_res
[] = {
137 .name
= "mtx1-wdt-gpio",
138 .flags
= IORESOURCE_IRQ
,
142 static struct platform_device mtx1_wdt
= {
145 .num_resources
= ARRAY_SIZE(mtx1_wdt_res
),
146 .resource
= mtx1_wdt_res
,
149 static struct gpio_led default_leds
[] = {
151 .name
= "mtx1:green",
159 static struct gpio_led_platform_data mtx1_led_data
= {
160 .num_leds
= ARRAY_SIZE(default_leds
),
161 .leds
= default_leds
,
164 static struct platform_device mtx1_gpio_leds
= {
168 .platform_data
= &mtx1_led_data
,
172 static struct mtd_partition mtx1_mtd_partitions
[] = {
174 .name
= "filesystem",
181 .offset
= MTDPART_OFS_APPEND
,
182 .mask_flags
= MTD_WRITEABLE
,
187 .offset
= MTDPART_OFS_APPEND
,
192 .offset
= MTDPART_OFS_APPEND
,
196 static struct physmap_flash_data mtx1_flash_data
= {
199 .parts
= mtx1_mtd_partitions
,
202 static struct resource mtx1_mtd_resource
= {
205 .flags
= IORESOURCE_MEM
,
208 static struct platform_device mtx1_mtd
= {
209 .name
= "physmap-flash",
211 .platform_data
= &mtx1_flash_data
,
214 .resource
= &mtx1_mtd_resource
,
217 static struct resource alchemy_pci_host_res
[] = {
219 .start
= AU1500_PCI_PHYS_ADDR
,
220 .end
= AU1500_PCI_PHYS_ADDR
+ 0xfff,
221 .flags
= IORESOURCE_MEM
,
225 static int mtx1_pci_idsel(unsigned int devsel
, int assert)
227 /* This function is only necessary to support a proprietary Cardbus
228 * adapter on the mtx-1 "singleboard" variant. It triggers a custom
229 * logic chip connected to EXT_IO3 (GPIO1) to suppress IDSEL signals.
231 if (assert && devsel
!= 0)
232 /* Suppress signal to Cardbus */
233 alchemy_gpio_set_value(1, 0); /* set EXT_IO3 OFF */
235 alchemy_gpio_set_value(1, 1); /* set EXT_IO3 ON */
241 static const char mtx1_irqtab
[][5] = {
242 [0] = { -1, AU1500_PCI_INTA
, AU1500_PCI_INTA
, 0xff, 0xff }, /* IDSEL 00 - AdapterA-Slot0 (top) */
243 [1] = { -1, AU1500_PCI_INTB
, AU1500_PCI_INTA
, 0xff, 0xff }, /* IDSEL 01 - AdapterA-Slot1 (bottom) */
244 [2] = { -1, AU1500_PCI_INTC
, AU1500_PCI_INTD
, 0xff, 0xff }, /* IDSEL 02 - AdapterB-Slot0 (top) */
245 [3] = { -1, AU1500_PCI_INTD
, AU1500_PCI_INTC
, 0xff, 0xff }, /* IDSEL 03 - AdapterB-Slot1 (bottom) */
246 [4] = { -1, AU1500_PCI_INTA
, AU1500_PCI_INTB
, 0xff, 0xff }, /* IDSEL 04 - AdapterC-Slot0 (top) */
247 [5] = { -1, AU1500_PCI_INTB
, AU1500_PCI_INTA
, 0xff, 0xff }, /* IDSEL 05 - AdapterC-Slot1 (bottom) */
248 [6] = { -1, AU1500_PCI_INTC
, AU1500_PCI_INTD
, 0xff, 0xff }, /* IDSEL 06 - AdapterD-Slot0 (top) */
249 [7] = { -1, AU1500_PCI_INTD
, AU1500_PCI_INTC
, 0xff, 0xff }, /* IDSEL 07 - AdapterD-Slot1 (bottom) */
252 static int mtx1_map_pci_irq(const struct pci_dev
*d
, u8 slot
, u8 pin
)
254 return mtx1_irqtab
[slot
][pin
];
257 static struct alchemy_pci_platdata mtx1_pci_pd
= {
258 .board_map_irq
= mtx1_map_pci_irq
,
259 .board_pci_idsel
= mtx1_pci_idsel
,
260 .pci_cfg_set
= PCI_CONFIG_AEN
| PCI_CONFIG_R2H
| PCI_CONFIG_R1H
|
262 #if defined(__MIPSEB__)
263 PCI_CONFIG_SIC_HWA_DAT
| PCI_CONFIG_SM
,
269 static struct platform_device mtx1_pci_host
= {
270 .dev
.platform_data
= &mtx1_pci_pd
,
271 .name
= "alchemy-pci",
273 .num_resources
= ARRAY_SIZE(alchemy_pci_host_res
),
274 .resource
= alchemy_pci_host_res
,
277 static struct __initdata platform_device
* mtx1_devs
[] = {
285 static struct au1000_eth_platform_data mtx1_au1000_eth0_pdata
= {
286 .phy_search_highest_addr
= 1,
287 .phy1_search_mac0
= 1,
290 static int __init
mtx1_register_devices(void)
294 irq_set_irq_type(AU1500_GPIO204_INT
, IRQ_TYPE_LEVEL_HIGH
);
295 irq_set_irq_type(AU1500_GPIO201_INT
, IRQ_TYPE_LEVEL_LOW
);
296 irq_set_irq_type(AU1500_GPIO202_INT
, IRQ_TYPE_LEVEL_LOW
);
297 irq_set_irq_type(AU1500_GPIO203_INT
, IRQ_TYPE_LEVEL_LOW
);
298 irq_set_irq_type(AU1500_GPIO205_INT
, IRQ_TYPE_LEVEL_LOW
);
300 au1xxx_override_eth_cfg(0, &mtx1_au1000_eth0_pdata
);
302 rc
= gpio_request(mtx1_gpio_button
[0].gpio
,
303 mtx1_gpio_button
[0].desc
);
305 printk(KERN_INFO
"mtx1: failed to request %d\n",
306 mtx1_gpio_button
[0].gpio
);
309 gpio_direction_input(mtx1_gpio_button
[0].gpio
);
311 return platform_add_devices(mtx1_devs
, ARRAY_SIZE(mtx1_devs
));
313 arch_initcall(mtx1_register_devices
);