Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: ath25: register AR5312 flash controller

AR5312 SoC flash controller maps the flash content to memory and
translates the memory access operations to the flash access operations.
Such controller is fully supported by the physmap-flash driver.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>R5312 SoC flash
Cc: Linux MIPS <linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/8245/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Sergey Ryazanov and committed by
Ralf Baechle
d58eaa7f 1654861f

+36 -2
+36 -2
arch/mips/ath25/ar5312.c
··· 19 19 #include <linux/bitops.h> 20 20 #include <linux/irqdomain.h> 21 21 #include <linux/interrupt.h> 22 + #include <linux/platform_device.h> 23 + #include <linux/mtd/physmap.h> 22 24 #include <linux/reboot.h> 23 25 #include <asm/bootinfo.h> 24 26 #include <asm/reboot.h> ··· 162 160 ar5312_misc_irq_domain = domain; 163 161 } 164 162 163 + static struct physmap_flash_data ar5312_flash_data = { 164 + .width = 2, 165 + }; 166 + 167 + static struct resource ar5312_flash_resource = { 168 + .start = AR5312_FLASH_BASE, 169 + .end = AR5312_FLASH_BASE + AR5312_FLASH_SIZE - 1, 170 + .flags = IORESOURCE_MEM, 171 + }; 172 + 173 + static struct platform_device ar5312_physmap_flash = { 174 + .name = "physmap-flash", 175 + .id = 0, 176 + .dev.platform_data = &ar5312_flash_data, 177 + .resource = &ar5312_flash_resource, 178 + .num_resources = 1, 179 + }; 180 + 165 181 static void __init ar5312_flash_init(void) 166 182 { 167 183 void __iomem *flashctl_base; ··· 188 168 flashctl_base = ioremap_nocache(AR5312_FLASHCTL_BASE, 189 169 AR5312_FLASHCTL_SIZE); 190 170 171 + ctl = __raw_readl(flashctl_base + AR5312_FLASHCTL0); 172 + ctl &= AR5312_FLASHCTL_MW; 173 + 174 + /* fixup flash width */ 175 + switch (ctl) { 176 + case AR5312_FLASHCTL_MW16: 177 + ar5312_flash_data.width = 2; 178 + break; 179 + case AR5312_FLASHCTL_MW8: 180 + default: 181 + ar5312_flash_data.width = 1; 182 + break; 183 + } 184 + 191 185 /* 192 186 * Configure flash bank 0. 193 187 * Assume 8M window size. Flash will be aliased if it's smaller 194 188 */ 195 - ctl = __raw_readl(flashctl_base + AR5312_FLASHCTL0); 196 - ctl &= AR5312_FLASHCTL_MW; 197 189 ctl |= AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC_8M | AR5312_FLASHCTL_RBLE; 198 190 ctl |= 0x01 << AR5312_FLASHCTL_IDCY_S; 199 191 ctl |= 0x07 << AR5312_FLASHCTL_WST1_S; ··· 244 212 /* Everything else is probably AR5312 or compatible */ 245 213 else 246 214 ath25_soc = ATH25_SOC_AR5312; 215 + 216 + platform_device_register(&ar5312_physmap_flash); 247 217 } 248 218 249 219 static void ar5312_restart(char *command)