2 * Ralink RT288x SoC platform device registration
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/physmap.h>
17 #include <asm/addrspace.h>
19 #include <asm/mach-ralink/rt288x.h>
20 #include <asm/mach-ralink/rt288x_regs.h>
21 #include <asm/mach-ralink/platform.h>
23 static struct resource rt288x_flash0_resources[] = {
25 .flags = IORESOURCE_MEM,
26 .start = KSEG1ADDR(RT2880_FLASH0_BASE),
27 .end = KSEG1ADDR(RT2880_FLASH0_BASE) +
28 RT2880_FLASH0_SIZE - 1,
32 static struct platform_device rt288x_flash0_device = {
33 .name = "physmap-flash",
34 .resource = rt288x_flash0_resources,
35 .num_resources = ARRAY_SIZE(rt288x_flash0_resources),
38 static struct resource rt288x_flash1_resources[] = {
40 .flags = IORESOURCE_MEM,
41 .start = KSEG1ADDR(RT2880_FLASH1_BASE),
42 .end = KSEG1ADDR(RT2880_FLASH1_BASE) +
43 RT2880_FLASH1_SIZE - 1,
47 static struct platform_device rt288x_flash1_device = {
48 .name = "physmap-flash",
49 .resource = rt288x_flash1_resources,
50 .num_resources = ARRAY_SIZE(rt288x_flash1_resources),
53 static int rt288x_flash_instance __initdata;
54 void __init rt288x_register_flash(unsigned int id,
55 struct physmap_flash_data *pdata)
57 struct platform_device *pdev;
63 pdev = &rt288x_flash0_device;
64 reg = MEMC_REG_FLASH_CFG0;
67 pdev = &rt288x_flash1_device;
68 reg = MEMC_REG_FLASH_CFG1;
74 t = rt288x_memc_rr(reg);
75 t = (t >> FLASH_CFG_WIDTH_SHIFT) & FLASH_CFG_WIDTH_MASK;
78 case FLASH_CFG_WIDTH_8BIT:
81 case FLASH_CFG_WIDTH_16BIT:
84 case FLASH_CFG_WIDTH_32BIT:
88 printk(KERN_ERR "RT288x: flash bank%u witdh is invalid\n", id);
92 pdev->dev.platform_data = pdata;
93 pdev->id = rt288x_flash_instance;
95 platform_device_register(pdev);
96 rt288x_flash_instance++;