2 * Ralink RT288x SoC specific setup
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * Parts of this file are based on Ralink's 2.6.21 BSP
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/gpio.h>
19 #include <asm/mach-ralink/common.h>
20 #include <asm/mach-ralink/rt288x.h>
21 #include <asm/mach-ralink/rt288x_regs.h>
23 void __iomem
* rt288x_sysc_base
;
24 void __iomem
* rt288x_memc_base
;
26 void __init
rt288x_detect_sys_type(void)
32 n0
= rt288x_sysc_rr(SYSC_REG_CHIP_NAME0
);
33 n1
= rt288x_sysc_rr(SYSC_REG_CHIP_NAME1
);
34 id
= rt288x_sysc_rr(SYSC_REG_CHIP_ID
);
36 snprintf(ramips_sys_type
, RAMIPS_SYS_TYPE_LEN
,
37 "Ralink %c%c%c%c%c%c%c%c id:%u rev:%u",
38 (char) (n0
& 0xff), (char) ((n0
>> 8) & 0xff),
39 (char) ((n0
>> 16) & 0xff), (char) ((n0
>> 24) & 0xff),
40 (char) (n1
& 0xff), (char) ((n1
>> 8) & 0xff),
41 (char) ((n1
>> 16) & 0xff), (char) ((n1
>> 24) & 0xff),
42 (id
>> CHIP_ID_ID_SHIFT
) & CHIP_ID_ID_MASK
,
43 (id
& CHIP_ID_REV_MASK
));
46 static void rt288x_gpio_reserve(int first
, int last
)
48 for (; first
<= last
; first
++)
49 gpio_request(first
, "reserved");
52 void __init
rt288x_gpio_init(u32 mode
)
54 rt288x_sysc_wr(mode
, SYSC_REG_GPIO_MODE
);
57 if ((mode
& RT2880_GPIO_MODE_I2C
) == 0)
58 rt288x_gpio_reserve(1, 2);
60 if ((mode
& RT2880_GPIO_MODE_SPI
) == 0)
61 rt288x_gpio_reserve(3, 6);
63 if ((mode
& RT2880_GPIO_MODE_UART0
) == 0)
64 rt288x_gpio_reserve(7, 14);
66 if ((mode
& RT2880_GPIO_MODE_JTAG
) == 0)
67 rt288x_gpio_reserve(17, 21);
69 if ((mode
& RT2880_GPIO_MODE_MDIO
) == 0)
70 rt288x_gpio_reserve(22, 23);
72 if ((mode
& RT2880_GPIO_MODE_SDRAM
) == 0)
73 rt288x_gpio_reserve(24, 39);
75 if ((mode
& RT2880_GPIO_MODE_PCI
) == 0)
76 rt288x_gpio_reserve(40, 71);
This page took 0.045822 seconds and 5 git commands to generate.