2 * RouterBoard 500 Platform devices
4 * Copyright (C) 2006 Felix Fietkau <nbd@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.
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/module.h>
21 #include <linux/ctype.h>
22 #include <linux/string.h>
23 #include <linux/platform_device.h>
24 #include <asm/unaligned.h>
27 #include <asm/rc32434/rc32434.h>
28 #include <asm/rc32434/dma.h>
29 #include <asm/rc32434/dma_v.h>
30 #include <asm/rc32434/eth.h>
31 #include <asm/rc32434/rb.h>
33 #define ETH0_DMA_RX_IRQ GROUP1_IRQ_BASE + 0
34 #define ETH0_DMA_TX_IRQ GROUP1_IRQ_BASE + 1
35 #define ETH0_RX_OVR_IRQ GROUP3_IRQ_BASE + 9
36 #define ETH0_TX_UND_IRQ GROUP3_IRQ_BASE + 10
38 #define ETH0_RX_DMA_ADDR (DMA0_PhysicalAddress + 0*DMA_CHAN_OFFSET)
39 #define ETH0_TX_DMA_ADDR (DMA0_PhysicalAddress + 1*DMA_CHAN_OFFSET)
41 static struct resource korina_dev0_res
[] = {
43 .name
= "korina_regs",
44 .start
= ETH0_PhysicalAddress
,
45 .end
= ETH0_PhysicalAddress
+ sizeof(ETH_t
),
46 .flags
= IORESOURCE_MEM
,
50 .start
= ETH0_DMA_RX_IRQ
,
51 .end
= ETH0_DMA_RX_IRQ
,
52 .flags
= IORESOURCE_IRQ
56 .start
= ETH0_DMA_TX_IRQ
,
57 .end
= ETH0_DMA_TX_IRQ
,
58 .flags
= IORESOURCE_IRQ
62 .start
= ETH0_RX_OVR_IRQ
,
63 .end
= ETH0_RX_OVR_IRQ
,
64 .flags
= IORESOURCE_IRQ
68 .start
= ETH0_TX_UND_IRQ
,
69 .end
= ETH0_TX_UND_IRQ
,
70 .flags
= IORESOURCE_IRQ
73 .name
= "korina_dma_rx",
74 .start
= ETH0_RX_DMA_ADDR
,
75 .end
= ETH0_RX_DMA_ADDR
+ DMA_CHAN_OFFSET
- 1,
76 .flags
= IORESOURCE_MEM
,
79 .name
= "korina_dma_tx",
80 .start
= ETH0_TX_DMA_ADDR
,
81 .end
= ETH0_TX_DMA_ADDR
+ DMA_CHAN_OFFSET
- 1,
82 .flags
= IORESOURCE_MEM
,
86 static struct korina_device korina_dev0_data
= {
88 .mac
= { 0xde, 0xca, 0xff, 0xc0, 0xff, 0xee }
91 static struct platform_device korina_dev0
= {
94 .dev
.platform_data
= &korina_dev0_data
,
95 .resource
= korina_dev0_res
,
96 .num_resources
= ARRAY_SIZE(korina_dev0_res
),
100 #define CF_GPIO_NUM 13
102 static struct resource cf_slot0_res
[] = {
104 .name
= "cf_membase",
105 .flags
= IORESOURCE_MEM
109 .start
= (8 + 4 * 32 + CF_GPIO_NUM
), /* 149 */
110 .end
= (8 + 4 * 32 + CF_GPIO_NUM
),
111 .flags
= IORESOURCE_IRQ
115 static struct cf_device cf_slot0_data
= {
119 static struct platform_device cf_slot0
= {
122 .dev
.platform_data
= &cf_slot0_data
,
123 .resource
= cf_slot0_res
,
124 .num_resources
= ARRAY_SIZE(cf_slot0_res
),
127 /* Resources and device for NAND. There is no data needed and no irqs, so just define the memory used. */
128 static struct resource nand_slot0_res
[] = {
130 .name
= "nand_membase",
132 .end
= (0x18a20000+0x1000)-1,
133 .flags
= IORESOURCE_MEM
137 static struct platform_device nand_slot0
= {
139 .name
= "rb500-nand",
140 .resource
= nand_slot0_res
,
141 .num_resources
= ARRAY_SIZE(nand_slot0_res
),
144 static struct platform_device rb500led
= {
150 static struct platform_device
*rb500_devs
[] = {
157 static void __init
parse_mac_addr(char* macstr
)
160 unsigned char result
, value
;
162 for (i
=0; i
<6; i
++) {
164 if (i
!= 5 && *(macstr
+2) != ':') {
167 for (j
=0; j
<2; j
++) {
168 if (isxdigit(*macstr
) && (value
= isdigit(*macstr
) ? *macstr
-'0' :
169 toupper(*macstr
)-'A'+10) < 16) {
170 result
= result
*16 + value
;
177 korina_dev0_data
.mac
[i
] = result
;
182 /* DEVICE CONTROLLER 1 */
183 #define CFG_DC_DEV1 (void*)0xb8010010
184 #define CFG_DC_DEV2 (void*)0xb8010020
185 #define CFG_DC_DEVBASE 0x0
186 #define CFG_DC_DEVMASK 0x4
187 #define CFG_DC_DEVC 0x8
188 #define CFG_DC_DEVTC 0xC
191 static int __init
plat_setup_devices(void)
193 /* Look for the CF card reader */
194 if (!readl(CFG_DC_DEV1
+ CFG_DC_DEVMASK
))
195 rb500_devs
[1] = NULL
;
197 cf_slot0_res
[0].start
= readl(CFG_DC_DEV1
+ CFG_DC_DEVBASE
);
198 cf_slot0_res
[0].end
= cf_slot0_res
[0].start
+ 0x1000;
201 /* There is always a NAND device */
202 nand_slot0_res
[0].start
= readl( CFG_DC_DEV2
+ CFG_DC_DEVBASE
);
203 nand_slot0_res
[0].end
= nand_slot0_res
[0].start
+ 0x1000;
205 return platform_add_devices(rb500_devs
, ARRAY_SIZE(rb500_devs
));
208 static int __init
setup_kmac(char *s
)
210 printk("korina mac = %s\n",s
);
215 __setup("kmac=", setup_kmac
);
216 arch_initcall(plat_setup_devices
);