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>
24 static struct resource rt288x_flash0_resources[] = {
26 .flags = IORESOURCE_MEM,
27 .start = KSEG1ADDR(RT2880_FLASH0_BASE),
28 .end = KSEG1ADDR(RT2880_FLASH0_BASE) +
29 RT2880_FLASH0_SIZE - 1,
33 static struct platform_device rt288x_flash0_device = {
34 .name = "physmap-flash",
35 .resource = rt288x_flash0_resources,
36 .num_resources = ARRAY_SIZE(rt288x_flash0_resources),
39 static struct resource rt288x_flash1_resources[] = {
41 .flags = IORESOURCE_MEM,
42 .start = KSEG1ADDR(RT2880_FLASH1_BASE),
43 .end = KSEG1ADDR(RT2880_FLASH1_BASE) +
44 RT2880_FLASH1_SIZE - 1,
48 static struct platform_device rt288x_flash1_device = {
49 .name = "physmap-flash",
50 .resource = rt288x_flash1_resources,
51 .num_resources = ARRAY_SIZE(rt288x_flash1_resources),
54 static int rt288x_flash_instance __initdata;
55 void __init rt288x_register_flash(unsigned int id,
56 struct physmap_flash_data *pdata)
58 struct platform_device *pdev;
64 pdev = &rt288x_flash0_device;
65 reg = MEMC_REG_FLASH_CFG0;
68 pdev = &rt288x_flash1_device;
69 reg = MEMC_REG_FLASH_CFG1;
75 t = rt288x_memc_rr(reg);
76 t = (t >> FLASH_CFG_WIDTH_SHIFT) & FLASH_CFG_WIDTH_MASK;
79 case FLASH_CFG_WIDTH_8BIT:
82 case FLASH_CFG_WIDTH_16BIT:
85 case FLASH_CFG_WIDTH_32BIT:
89 printk(KERN_ERR "RT288x: flash bank%u witdh is invalid\n", id);
93 pdev->dev.platform_data = pdata;
94 pdev->id = rt288x_flash_instance;
96 platform_device_register(pdev);
97 rt288x_flash_instance++;