[ramips] use common get_system_type function
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / devices.c
1 /*
2 * Ralink RT305x SoC platform device registration
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/physmap.h>
15
16 #include <asm/addrspace.h>
17
18 #include <asm/mach-ralink/rt305x.h>
19 #include <asm/mach-ralink/rt305x_regs.h>
20 #include "devices.h"
21
22 static struct resource rt305x_flash0_resources[] = {
23 {
24 .flags = IORESOURCE_MEM,
25 .start = KSEG1ADDR(RT305X_FLASH0_BASE),
26 .end = KSEG1ADDR(RT305X_FLASH0_BASE) +
27 RT305X_FLASH0_SIZE - 1,
28 },
29 };
30
31 static struct platform_device rt305x_flash0_device = {
32 .name = "physmap-flash",
33 .resource = rt305x_flash0_resources,
34 .num_resources = ARRAY_SIZE(rt305x_flash0_resources),
35 };
36
37 static struct resource rt305x_flash1_resources[] = {
38 {
39 .flags = IORESOURCE_MEM,
40 .start = KSEG1ADDR(RT305X_FLASH1_BASE),
41 .end = KSEG1ADDR(RT305X_FLASH1_BASE) +
42 RT305X_FLASH1_SIZE - 1,
43 },
44 };
45
46 static struct platform_device rt305x_flash1_device = {
47 .name = "physmap-flash",
48 .resource = rt305x_flash1_resources,
49 .num_resources = ARRAY_SIZE(rt305x_flash1_resources),
50 };
51
52 static int rt305x_flash_instance __initdata;
53 void __init rt305x_register_flash(unsigned int id,
54 struct physmap_flash_data *pdata)
55 {
56 struct platform_device *pdev;
57 u32 t;
58 int reg;
59
60 switch (id) {
61 case 0:
62 pdev = &rt305x_flash0_device;
63 reg = MEMC_REG_FLASH_CFG0;
64 break;
65 case 1:
66 pdev = &rt305x_flash1_device;
67 reg = MEMC_REG_FLASH_CFG1;
68 break;
69 default:
70 return;
71 }
72
73 t = rt305x_memc_rr(reg);
74 t = (t >> FLASH_CFG_WIDTH_SHIFT) & FLASH_CFG_WIDTH_MASK;
75
76 switch (t) {
77 case FLASH_CFG_WIDTH_8BIT:
78 pdata->width = 1;
79 break;
80 case FLASH_CFG_WIDTH_16BIT:
81 pdata->width = 2;
82 break;
83 case FLASH_CFG_WIDTH_32BIT:
84 pdata->width = 4;
85 break;
86 default:
87 printk(KERN_ERR "RT305x: flash bank%u witdh is invalid\n", id);
88 return;
89 }
90
91 pdev->dev.platform_data = pdata;
92 pdev->id = rt305x_flash_instance;
93
94 platform_device_register(pdev);
95 rt305x_flash_instance++;
96 }
This page took 0.055183 seconds and 5 git commands to generate.