This is a set of patches removing the board file code
for Versatile flash handling and instead moving it over to the device tree and a special add-on file. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJXAifOAAoJEEEQszewGV1zKZ4P/0w2YgBN6B2ZM3TDVBRwI1RM R7f0/cvjC5d4evUvVngZwu7Y7pmMiafcUTBdWnYdA5TZJamdPYDXak7mVyCeBqOv JrWWSQI6xsdWS/+P74p17c9U/rrBqW0xX8bEPGa2JN4gijjEws9rO1EWCVu+DW+h AU9y6LFrrFFoWHNucp03+PBwdzP//jtzGT2MNKgfwQ0EB4W38zZBvAj8+ELYiiQV YYNtZKAfAqWOVP02t2MnztINccPJn8nWJJIAOxFjI8cMkRNWXlulM9g0doTkXaoV sa8+GNpSaQnIlxz6eTZOUR2K+xN7qwp2zR17CHq6FnJQiyAs54Ye/czdDudpZoQk 0lOBHNTiWTnnw67wB2nCV9harcUODcKEWxdyR93SM30lu3I9IyCSjl8oveZEfRJe 0STZvt6qBo3NqzrSGhtzKHHIdBnJm+qbZmbzzGe0ezPrxyr7a+as9rZcI8vCXG0Z wtvEKCaMp+5XLuAoftHfZc456tT1Xul5w/tdzsR2QDeGinmaf0KxZxFLLMyc/wc0 7MOKfpEVRl2fpHEx174EgiBD8L7ZaEjCa8fz3FdBZeTPlrJUtPjJW366i7pkA0he rjoN5Mlbg52yiWdBOPFnGZ9ww8taaRk4wV2N41ERUy+gXL9dWe3LB32HAGwancvZ hzpP+ZOgHju8zQwjkj8d =9Fgt -----END PGP SIGNATURE----- Merge tag 'versatile-flash-for-arm-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator into next/drivers Merge "move Versatile flash protection to the device tree" from Linus Walleij: This is a set of patches removing the board file code for Versatile flash handling and instead moving it over to the device tree and a special add-on file. * tag 'versatile-flash-for-arm-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator: ARM: integrator: move flash registration to device tree ARM: versatile: move flash registration to the device tree mtd: augment the "arm,versatile-flash" bindings mtd: physmap_of: add a hook for Versatile write protection Acked-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:
commit
26a8eb59e0
|
@ -1,8 +1,26 @@
|
|||
Flash device on ARM Versatile board
|
||||
|
||||
These flash chips are found in the ARM reference designs like Integrator,
|
||||
Versatile, RealView, Versatile Express etc.
|
||||
|
||||
They are regular CFI compatible (Intel or AMD extended) flash chips with
|
||||
some special write protect/VPP bits that can be controlled by the machine's
|
||||
system controller.
|
||||
|
||||
Required properties:
|
||||
- compatible : must be "arm,versatile-flash";
|
||||
- compatible : must be "arm,versatile-flash", "cfi-flash";
|
||||
- reg : memory address for the flash chip
|
||||
- bank-width : width in bytes of flash interface.
|
||||
|
||||
For the rest of the properties, see mtd-physmap.txt.
|
||||
|
||||
The device tree may optionally contain sub-nodes describing partitions of the
|
||||
address space. See partition.txt for more detail.
|
||||
|
||||
Example:
|
||||
|
||||
flash@34000000 {
|
||||
compatible = "arm,versatile-flash", "cfi-flash";
|
||||
reg = <0x34000000 0x4000000>;
|
||||
bank-width = <4>;
|
||||
};
|
||||
|
|
|
@ -52,8 +52,9 @@
|
|||
};
|
||||
|
||||
flash@24000000 {
|
||||
compatible = "cfi-flash";
|
||||
compatible = "arm,versatile-flash", "cfi-flash";
|
||||
reg = <0x24000000 0x02000000>;
|
||||
bank-width = <4>;
|
||||
};
|
||||
|
||||
fpga {
|
||||
|
|
|
@ -119,8 +119,9 @@
|
|||
};
|
||||
|
||||
flash@34000000 {
|
||||
compatible = "arm,versatile-flash";
|
||||
reg = <0x34000000 0x4000000>;
|
||||
/* 64 MiB NOR flash in non-interleaved chips */
|
||||
compatible = "arm,versatile-flash", "cfi-flash";
|
||||
reg = <0x34000000 0x04000000>;
|
||||
bank-width = <4>;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <linux/amba/kmi.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/irqchip.h>
|
||||
#include <linux/mtd/physmap.h>
|
||||
#include <linux/platform_data/clk-integrator.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/of_address.h>
|
||||
|
@ -146,65 +145,6 @@ static int __init irq_syscore_init(void)
|
|||
|
||||
device_initcall(irq_syscore_init);
|
||||
|
||||
/*
|
||||
* Flash handling.
|
||||
*/
|
||||
static int ap_flash_init(struct platform_device *dev)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP,
|
||||
ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
|
||||
|
||||
tmp = readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET) |
|
||||
INTEGRATOR_EBI_WRITE_ENABLE;
|
||||
writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET);
|
||||
|
||||
if (!(readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET)
|
||||
& INTEGRATOR_EBI_WRITE_ENABLE)) {
|
||||
writel(0xa05f, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET);
|
||||
writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET);
|
||||
writel(0, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ap_flash_exit(struct platform_device *dev)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP,
|
||||
ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
|
||||
|
||||
tmp = readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET) &
|
||||
~INTEGRATOR_EBI_WRITE_ENABLE;
|
||||
writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET);
|
||||
|
||||
if (readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET) &
|
||||
INTEGRATOR_EBI_WRITE_ENABLE) {
|
||||
writel(0xa05f, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET);
|
||||
writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET);
|
||||
writel(0, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
static void ap_flash_set_vpp(struct platform_device *pdev, int on)
|
||||
{
|
||||
if (on)
|
||||
writel(INTEGRATOR_SC_CTRL_nFLVPPEN,
|
||||
ap_syscon_base + INTEGRATOR_SC_CTRLS_OFFSET);
|
||||
else
|
||||
writel(INTEGRATOR_SC_CTRL_nFLVPPEN,
|
||||
ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
|
||||
}
|
||||
|
||||
static struct physmap_flash_data ap_flash_data = {
|
||||
.width = 4,
|
||||
.init = ap_flash_init,
|
||||
.exit = ap_flash_exit,
|
||||
.set_vpp = ap_flash_set_vpp,
|
||||
};
|
||||
|
||||
/*
|
||||
* For the PL010 found in the Integrator/AP some of the UART control is
|
||||
* implemented in the system controller and accessed using a callback
|
||||
|
@ -266,8 +206,6 @@ static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = {
|
|||
"kmi0", NULL),
|
||||
OF_DEV_AUXDATA("arm,primecell", KMI1_BASE,
|
||||
"kmi1", NULL),
|
||||
OF_DEV_AUXDATA("cfi-flash", INTEGRATOR_FLASH_BASE,
|
||||
"physmap-flash", &ap_flash_data),
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <linux/io.h>
|
||||
#include <linux/irqchip.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/mtd/physmap.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_platform.h>
|
||||
|
@ -43,14 +42,8 @@
|
|||
/* Base address to the CP controller */
|
||||
static void __iomem *intcp_con_base;
|
||||
|
||||
#define INTCP_PA_FLASH_BASE 0x24000000
|
||||
|
||||
#define INTCP_PA_CLCD_BASE 0xc0000000
|
||||
|
||||
#define INTCP_FLASHPROG 0x04
|
||||
#define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0)
|
||||
#define CINTEGRATOR_FLASHPROG_FLWREN (1 << 1)
|
||||
|
||||
/*
|
||||
* Logical Physical
|
||||
* f1000000 10000000 Core module registers
|
||||
|
@ -107,48 +100,6 @@ static void __init intcp_map_io(void)
|
|||
iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc));
|
||||
}
|
||||
|
||||
/*
|
||||
* Flash handling.
|
||||
*/
|
||||
static int intcp_flash_init(struct platform_device *dev)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = readl(intcp_con_base + INTCP_FLASHPROG);
|
||||
val |= CINTEGRATOR_FLASHPROG_FLWREN;
|
||||
writel(val, intcp_con_base + INTCP_FLASHPROG);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void intcp_flash_exit(struct platform_device *dev)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = readl(intcp_con_base + INTCP_FLASHPROG);
|
||||
val &= ~(CINTEGRATOR_FLASHPROG_FLVPPEN|CINTEGRATOR_FLASHPROG_FLWREN);
|
||||
writel(val, intcp_con_base + INTCP_FLASHPROG);
|
||||
}
|
||||
|
||||
static void intcp_flash_set_vpp(struct platform_device *pdev, int on)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = readl(intcp_con_base + INTCP_FLASHPROG);
|
||||
if (on)
|
||||
val |= CINTEGRATOR_FLASHPROG_FLVPPEN;
|
||||
else
|
||||
val &= ~CINTEGRATOR_FLASHPROG_FLVPPEN;
|
||||
writel(val, intcp_con_base + INTCP_FLASHPROG);
|
||||
}
|
||||
|
||||
static struct physmap_flash_data intcp_flash_data = {
|
||||
.width = 4,
|
||||
.init = intcp_flash_init,
|
||||
.exit = intcp_flash_exit,
|
||||
.set_vpp = intcp_flash_set_vpp,
|
||||
};
|
||||
|
||||
/*
|
||||
* It seems that the card insertion interrupt remains active after
|
||||
* we've acknowledged it. We therefore ignore the interrupt, and
|
||||
|
@ -260,8 +211,6 @@ static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = {
|
|||
"aaci", &mmc_data),
|
||||
OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE,
|
||||
"clcd", &clcd_data),
|
||||
OF_DEV_AUXDATA("cfi-flash", INTCP_PA_FLASH_BASE,
|
||||
"physmap-flash", &intcp_flash_data),
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <linux/amba/clcd.h>
|
||||
#include <linux/platform_data/video-clcd-versatile.h>
|
||||
#include <linux/amba/mmci.h>
|
||||
#include <linux/mtd/physmap.h>
|
||||
#include <asm/mach-types.h>
|
||||
#include <asm/mach/arch.h>
|
||||
#include <asm/mach/map.h>
|
||||
|
@ -41,12 +40,6 @@
|
|||
#define IO_ADDRESS(x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
|
||||
#define __io_address(n) ((void __iomem __force *)IO_ADDRESS(n))
|
||||
|
||||
/*
|
||||
* Memory definitions
|
||||
*/
|
||||
#define VERSATILE_FLASH_BASE 0x34000000
|
||||
#define VERSATILE_FLASH_SIZE SZ_64M
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------------------
|
||||
* Versatile Registers
|
||||
|
@ -54,14 +47,8 @@
|
|||
*/
|
||||
#define VERSATILE_SYS_PCICTL_OFFSET 0x44
|
||||
#define VERSATILE_SYS_MCI_OFFSET 0x48
|
||||
#define VERSATILE_SYS_FLASH_OFFSET 0x4C
|
||||
#define VERSATILE_SYS_CLCD_OFFSET 0x50
|
||||
|
||||
/*
|
||||
* VERSATILE_SYS_FLASH
|
||||
*/
|
||||
#define VERSATILE_FLASHPROG_FLVPPEN (1 << 0) /* Enable writing to flash */
|
||||
|
||||
/*
|
||||
* VERSATILE peripheral addresses
|
||||
*/
|
||||
|
@ -86,39 +73,6 @@
|
|||
static void __iomem *versatile_sys_base;
|
||||
static void __iomem *versatile_ib2_ctrl;
|
||||
|
||||
static void versatile_flash_set_vpp(struct platform_device *pdev, int on)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = readl(versatile_sys_base + VERSATILE_SYS_FLASH_OFFSET);
|
||||
if (on)
|
||||
val |= VERSATILE_FLASHPROG_FLVPPEN;
|
||||
else
|
||||
val &= ~VERSATILE_FLASHPROG_FLVPPEN;
|
||||
writel(val, versatile_sys_base + VERSATILE_SYS_FLASH_OFFSET);
|
||||
}
|
||||
|
||||
static struct physmap_flash_data versatile_flash_data = {
|
||||
.width = 4,
|
||||
.set_vpp = versatile_flash_set_vpp,
|
||||
};
|
||||
|
||||
static struct resource versatile_flash_resource = {
|
||||
.start = VERSATILE_FLASH_BASE,
|
||||
.end = VERSATILE_FLASH_BASE + VERSATILE_FLASH_SIZE - 1,
|
||||
.flags = IORESOURCE_MEM,
|
||||
};
|
||||
|
||||
struct platform_device versatile_flash_device = {
|
||||
.name = "physmap-flash",
|
||||
.id = 0,
|
||||
.dev = {
|
||||
.platform_data = &versatile_flash_data,
|
||||
},
|
||||
.num_resources = 1,
|
||||
.resource = &versatile_flash_resource,
|
||||
};
|
||||
|
||||
unsigned int mmc_status(struct device *dev)
|
||||
{
|
||||
struct amba_device *adev = container_of(dev, struct amba_device, dev);
|
||||
|
@ -390,7 +344,6 @@ static void __init versatile_dt_init(void)
|
|||
|
||||
versatile_dt_pci_init();
|
||||
|
||||
platform_device_register(&versatile_flash_device);
|
||||
of_platform_populate(NULL, of_default_bus_match_table,
|
||||
versatile_auxdata_lookup, NULL);
|
||||
}
|
||||
|
|
|
@ -74,6 +74,16 @@ config MTD_PHYSMAP_OF
|
|||
physically into the CPU's memory. The mapping description here is
|
||||
taken from OF device tree.
|
||||
|
||||
config MTD_PHYSMAP_OF_VERSATILE
|
||||
bool "Support ARM Versatile physmap OF"
|
||||
depends on MTD_PHYSMAP_OF
|
||||
depends on MFD_SYSCON
|
||||
default y if (ARCH_INTEGRATOR || ARCH_VERSATILE || REALVIEW_DT)
|
||||
help
|
||||
This provides some extra DT physmap parsing for the ARM Versatile
|
||||
platforms, basically to add a VPP (write protection) callback so
|
||||
the flash can be taken out of write protection.
|
||||
|
||||
config MTD_PMC_MSP_EVM
|
||||
tristate "CFI Flash device mapped on PMC-Sierra MSP"
|
||||
depends on PMC_MSP && MTD_CFI
|
||||
|
|
|
@ -18,6 +18,7 @@ obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o
|
|||
obj-$(CONFIG_MTD_PXA2XX) += pxa2xx-flash.o
|
||||
obj-$(CONFIG_MTD_PHYSMAP) += physmap.o
|
||||
obj-$(CONFIG_MTD_PHYSMAP_OF) += physmap_of.o
|
||||
obj-$(CONFIG_MTD_PHYSMAP_OF_VERSATILE) += physmap_of_versatile.o
|
||||
obj-$(CONFIG_MTD_PISMO) += pismo.o
|
||||
obj-$(CONFIG_MTD_PMC_MSP_EVM) += pmcmsp-flash.o
|
||||
obj-$(CONFIG_MTD_PCMCIA) += pcmciamtd.o
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <linux/of_address.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/slab.h>
|
||||
#include "physmap_of_versatile.h"
|
||||
|
||||
struct of_flash_list {
|
||||
struct mtd_info *mtd;
|
||||
|
@ -240,6 +241,11 @@ static int of_flash_probe(struct platform_device *dev)
|
|||
info->list[i].map.size = res_size;
|
||||
info->list[i].map.bankwidth = be32_to_cpup(width);
|
||||
info->list[i].map.device_node = dp;
|
||||
err = of_flash_probe_versatile(dev, dp, &info->list[i].map);
|
||||
if (err) {
|
||||
dev_err(&dev->dev, "Can't probe Versatile VPP\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = -ENOMEM;
|
||||
info->list[i].map.virt = ioremap(info->list[i].map.phys,
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* Versatile OF physmap driver add-on
|
||||
*
|
||||
* Copyright (c) 2016, Linaro Limited
|
||||
* Author: Linus Walleij <linus.walleij@linaro.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
#include <linux/io.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/mtd/map.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/bitops.h>
|
||||
#include "physmap_of_versatile.h"
|
||||
|
||||
static struct regmap *syscon_regmap;
|
||||
|
||||
enum versatile_flashprot {
|
||||
INTEGRATOR_AP_FLASHPROT,
|
||||
INTEGRATOR_CP_FLASHPROT,
|
||||
VERSATILE_FLASHPROT,
|
||||
REALVIEW_FLASHPROT,
|
||||
};
|
||||
|
||||
static const struct of_device_id syscon_match[] = {
|
||||
{
|
||||
.compatible = "arm,integrator-ap-syscon",
|
||||
.data = (void *)INTEGRATOR_AP_FLASHPROT,
|
||||
},
|
||||
{
|
||||
.compatible = "arm,integrator-cp-syscon",
|
||||
.data = (void *)INTEGRATOR_CP_FLASHPROT,
|
||||
},
|
||||
{
|
||||
.compatible = "arm,core-module-versatile",
|
||||
.data = (void *)VERSATILE_FLASHPROT,
|
||||
},
|
||||
{
|
||||
.compatible = "arm,realview-eb-syscon",
|
||||
.data = (void *)REALVIEW_FLASHPROT,
|
||||
},
|
||||
{
|
||||
.compatible = "arm,realview-pb1176-syscon",
|
||||
.data = (void *)REALVIEW_FLASHPROT,
|
||||
},
|
||||
{
|
||||
.compatible = "arm,realview-pb11mp-syscon",
|
||||
.data = (void *)REALVIEW_FLASHPROT,
|
||||
},
|
||||
{
|
||||
.compatible = "arm,realview-pba8-syscon",
|
||||
.data = (void *)REALVIEW_FLASHPROT,
|
||||
},
|
||||
{
|
||||
.compatible = "arm,realview-pbx-syscon",
|
||||
.data = (void *)REALVIEW_FLASHPROT,
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
/*
|
||||
* Flash protection handling for the Integrator/AP
|
||||
*/
|
||||
#define INTEGRATOR_SC_CTRLS_OFFSET 0x08
|
||||
#define INTEGRATOR_SC_CTRLC_OFFSET 0x0C
|
||||
#define INTEGRATOR_SC_CTRL_FLVPPEN BIT(1)
|
||||
#define INTEGRATOR_SC_CTRL_FLWP BIT(2)
|
||||
|
||||
#define INTEGRATOR_EBI_CSR1_OFFSET 0x04
|
||||
/* The manual says bit 2, the code says bit 3, trust the code */
|
||||
#define INTEGRATOR_EBI_WRITE_ENABLE BIT(3)
|
||||
#define INTEGRATOR_EBI_LOCK_OFFSET 0x20
|
||||
#define INTEGRATOR_EBI_LOCK_VAL 0xA05F
|
||||
|
||||
static const struct of_device_id ebi_match[] = {
|
||||
{ .compatible = "arm,external-bus-interface"},
|
||||
{ },
|
||||
};
|
||||
|
||||
static int ap_flash_init(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *ebi;
|
||||
static void __iomem *ebi_base;
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
/* Look up the EBI */
|
||||
ebi = of_find_matching_node(NULL, ebi_match);
|
||||
if (!ebi) {
|
||||
return -ENODEV;
|
||||
}
|
||||
ebi_base = of_iomap(ebi, 0);
|
||||
if (!ebi_base)
|
||||
return -ENODEV;
|
||||
|
||||
/* Clear VPP and write protection bits */
|
||||
ret = regmap_write(syscon_regmap,
|
||||
INTEGRATOR_SC_CTRLC_OFFSET,
|
||||
INTEGRATOR_SC_CTRL_FLVPPEN | INTEGRATOR_SC_CTRL_FLWP);
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "error clearing Integrator VPP/WP\n");
|
||||
|
||||
/* Unlock the EBI */
|
||||
writel(INTEGRATOR_EBI_LOCK_VAL, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET);
|
||||
|
||||
/* Enable write cycles on the EBI, CSR1 (flash) */
|
||||
val = readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET);
|
||||
val |= INTEGRATOR_EBI_WRITE_ENABLE;
|
||||
writel(val, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET);
|
||||
|
||||
/* Lock the EBI again */
|
||||
writel(0, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET);
|
||||
iounmap(ebi_base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ap_flash_set_vpp(struct map_info *map, int on)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (on) {
|
||||
ret = regmap_write(syscon_regmap,
|
||||
INTEGRATOR_SC_CTRLS_OFFSET,
|
||||
INTEGRATOR_SC_CTRL_FLVPPEN | INTEGRATOR_SC_CTRL_FLWP);
|
||||
if (ret)
|
||||
pr_err("error enabling AP VPP\n");
|
||||
} else {
|
||||
ret = regmap_write(syscon_regmap,
|
||||
INTEGRATOR_SC_CTRLC_OFFSET,
|
||||
INTEGRATOR_SC_CTRL_FLVPPEN | INTEGRATOR_SC_CTRL_FLWP);
|
||||
if (ret)
|
||||
pr_err("error disabling AP VPP\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Flash protection handling for the Integrator/CP
|
||||
*/
|
||||
|
||||
#define INTCP_FLASHPROG_OFFSET 0x04
|
||||
#define CINTEGRATOR_FLVPPEN BIT(0)
|
||||
#define CINTEGRATOR_FLWREN BIT(1)
|
||||
#define CINTEGRATOR_FLMASK BIT(0)|BIT(1)
|
||||
|
||||
static void cp_flash_set_vpp(struct map_info *map, int on)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (on) {
|
||||
ret = regmap_update_bits(syscon_regmap,
|
||||
INTCP_FLASHPROG_OFFSET,
|
||||
CINTEGRATOR_FLMASK,
|
||||
CINTEGRATOR_FLVPPEN | CINTEGRATOR_FLWREN);
|
||||
if (ret)
|
||||
pr_err("error setting CP VPP\n");
|
||||
} else {
|
||||
ret = regmap_update_bits(syscon_regmap,
|
||||
INTCP_FLASHPROG_OFFSET,
|
||||
CINTEGRATOR_FLMASK,
|
||||
0);
|
||||
if (ret)
|
||||
pr_err("error setting CP VPP\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Flash protection handling for the Versatiles and RealViews
|
||||
*/
|
||||
|
||||
#define VERSATILE_SYS_FLASH_OFFSET 0x4C
|
||||
|
||||
static void versatile_flash_set_vpp(struct map_info *map, int on)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = regmap_update_bits(syscon_regmap, VERSATILE_SYS_FLASH_OFFSET,
|
||||
0x01, !!on);
|
||||
if (ret)
|
||||
pr_err("error setting Versatile VPP\n");
|
||||
}
|
||||
|
||||
int of_flash_probe_versatile(struct platform_device *pdev,
|
||||
struct device_node *np,
|
||||
struct map_info *map)
|
||||
{
|
||||
struct device_node *sysnp;
|
||||
const struct of_device_id *devid;
|
||||
struct regmap *rmap;
|
||||
static enum versatile_flashprot versatile_flashprot;
|
||||
int ret;
|
||||
|
||||
/* Not all flash chips use this protection line */
|
||||
if (!of_device_is_compatible(np, "arm,versatile-flash"))
|
||||
return 0;
|
||||
|
||||
/* For first chip probed, look up the syscon regmap */
|
||||
if (!syscon_regmap) {
|
||||
sysnp = of_find_matching_node_and_match(NULL,
|
||||
syscon_match,
|
||||
&devid);
|
||||
if (!sysnp)
|
||||
return -ENODEV;
|
||||
|
||||
versatile_flashprot = (enum versatile_flashprot)devid->data;
|
||||
rmap = syscon_node_to_regmap(sysnp);
|
||||
if (IS_ERR(rmap))
|
||||
return PTR_ERR(rmap);
|
||||
|
||||
syscon_regmap = rmap;
|
||||
}
|
||||
|
||||
switch (versatile_flashprot) {
|
||||
case INTEGRATOR_AP_FLASHPROT:
|
||||
ret = ap_flash_init(pdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
map->set_vpp = ap_flash_set_vpp;
|
||||
dev_info(&pdev->dev, "Integrator/AP flash protection\n");
|
||||
break;
|
||||
case INTEGRATOR_CP_FLASHPROT:
|
||||
map->set_vpp = cp_flash_set_vpp;
|
||||
dev_info(&pdev->dev, "Integrator/CP flash protection\n");
|
||||
break;
|
||||
case VERSATILE_FLASHPROT:
|
||||
case REALVIEW_FLASHPROT:
|
||||
map->set_vpp = versatile_flash_set_vpp;
|
||||
dev_info(&pdev->dev, "versatile/realview flash protection\n");
|
||||
break;
|
||||
default:
|
||||
dev_info(&pdev->dev, "device marked as Versatile flash "
|
||||
"but no system controller was found\n");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#include <linux/of.h>
|
||||
#include <linux/mtd/map.h>
|
||||
|
||||
#ifdef CONFIG_MTD_PHYSMAP_OF_VERSATILE
|
||||
int of_flash_probe_versatile(struct platform_device *pdev,
|
||||
struct device_node *np,
|
||||
struct map_info *map);
|
||||
#else
|
||||
static inline
|
||||
int of_flash_probe_versatile(struct platform_device *pdev,
|
||||
struct device_node *np,
|
||||
struct map_info *map)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue