aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/cavium-octeon
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2015-03-05 09:31:31 -0500
committerRalf Baechle <ralf@linux-mips.org>2015-04-01 11:21:43 -0400
commit7f481716bc90442bb19e77b53b28c59a41499300 (patch)
tree2c2382389f092ccd290ee2e965201d649e567679 /arch/mips/cavium-octeon
parent8c1e6b14e27d78fcea4aa6ba09e56c41f528f1cc (diff)
MIPS: OCTEON: Use device tree to probe for flash chips.
Don't assume they are there, the device tree will tell us. Signed-off-by: David Daney <david.daney@cavium.com> Signed-off-by: Aleksey Makarov <aleksey.makarov@auriga.com> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/9461/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/cavium-octeon')
-rw-r--r--arch/mips/cavium-octeon/flash_setup.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/arch/mips/cavium-octeon/flash_setup.c b/arch/mips/cavium-octeon/flash_setup.c
index 39e26dfe7d8d..a3d609da4510 100644
--- a/arch/mips/cavium-octeon/flash_setup.c
+++ b/arch/mips/cavium-octeon/flash_setup.c
@@ -8,10 +8,11 @@
8 * Copyright (C) 2007, 2008 Cavium Networks 8 * Copyright (C) 2007, 2008 Cavium Networks
9 */ 9 */
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/export.h> 11#include <linux/module.h>
12#include <linux/semaphore.h> 12#include <linux/semaphore.h>
13#include <linux/mtd/mtd.h> 13#include <linux/mtd/mtd.h>
14#include <linux/mtd/map.h> 14#include <linux/mtd/map.h>
15#include <linux/of_platform.h>
15#include <linux/mtd/partitions.h> 16#include <linux/mtd/partitions.h>
16 17
17#include <asm/octeon/octeon.h> 18#include <asm/octeon/octeon.h>
@@ -66,14 +67,22 @@ static void octeon_flash_map_copy_to(struct map_info *map, unsigned long to,
66 * 67 *
67 * Returns Zero on success 68 * Returns Zero on success
68 */ 69 */
69static int __init flash_init(void) 70static int octeon_flash_probe(struct platform_device *pdev)
70{ 71{
72 union cvmx_mio_boot_reg_cfgx region_cfg;
73 u32 cs;
74 int r;
75 struct device_node *np = pdev->dev.of_node;
76
77 r = of_property_read_u32(np, "reg", &cs);
78 if (r)
79 return r;
80
71 /* 81 /*
72 * Read the bootbus region 0 setup to determine the base 82 * Read the bootbus region 0 setup to determine the base
73 * address of the flash. 83 * address of the flash.
74 */ 84 */
75 union cvmx_mio_boot_reg_cfgx region_cfg; 85 region_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
76 region_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(0));
77 if (region_cfg.s.en) { 86 if (region_cfg.s.en) {
78 /* 87 /*
79 * The bootloader always takes the flash and sets its 88 * The bootloader always takes the flash and sets its
@@ -109,4 +118,27 @@ static int __init flash_init(void)
109 return 0; 118 return 0;
110} 119}
111 120
112late_initcall(flash_init); 121static const struct of_device_id of_flash_match[] = {
122 {
123 .compatible = "cfi-flash",
124 },
125 { },
126};
127MODULE_DEVICE_TABLE(of, of_flash_match);
128
129static struct platform_driver of_flash_driver = {
130 .driver = {
131 .name = "octeon-of-flash",
132 .owner = THIS_MODULE,
133 .of_match_table = of_flash_match,
134 },
135 .probe = octeon_flash_probe,
136};
137
138static int octeon_flash_init(void)
139{
140 return platform_driver_register(&of_flash_driver);
141}
142late_initcall(octeon_flash_init);
143
144MODULE_LICENSE("GPL");