diff options
author | danh-arm <dan.handley@arm.com> | 2014-05-06 17:54:03 +0100 |
---|---|---|
committer | danh-arm <dan.handley@arm.com> | 2014-05-06 17:54:03 +0100 |
commit | 408c37682a0233c8c4fa88700b603f0b09d6361f (patch) | |
tree | 18133148dea88d9a2313113111b24b56e8130505 /drivers | |
parent | b495bdef190acf166c713e138b61c5bb25402fc0 (diff) | |
parent | 97043ac98e13a726dbf8b3b41654dca759e3da2c (diff) |
Merge pull request #48 from danh-arm/dh/major-refactoring
dh/major refactoring
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/arm/cci400/cci400.c (renamed from drivers/arm/interconnect/cci-400/cci400.c) | 10 | ||||
-rw-r--r-- | drivers/arm/gic/aarch64/gic_v3_sysregs.S (renamed from drivers/console/console.h) | 62 | ||||
-rw-r--r-- | drivers/arm/gic/gic_v2.c | 298 | ||||
-rw-r--r-- | drivers/arm/gic/gic_v3.c (renamed from drivers/io/io_memmap.h) | 52 | ||||
-rw-r--r-- | drivers/arm/interconnect/cci-400/cci400.h | 72 | ||||
-rw-r--r-- | drivers/arm/interconnect/tzc-400/tzc400.h | 211 | ||||
-rw-r--r-- | drivers/arm/peripherals/pl011/pl011.h | 161 | ||||
-rw-r--r-- | drivers/arm/pl011/pl011.c (renamed from drivers/arm/peripherals/pl011/pl011.c) | 2 | ||||
-rw-r--r-- | drivers/arm/pl011/pl011_console.c (renamed from drivers/arm/peripherals/pl011/pl011_console.c) | 2 | ||||
-rw-r--r-- | drivers/arm/tzc400/tzc400.c (renamed from drivers/arm/interconnect/tzc-400/tzc400.c) | 22 | ||||
-rw-r--r-- | drivers/io/io_driver.h | 93 | ||||
-rw-r--r-- | drivers/io/io_fip.c | 78 | ||||
-rw-r--r-- | drivers/io/io_fip.h | 36 | ||||
-rw-r--r-- | drivers/io/io_memmap.c | 58 | ||||
-rw-r--r-- | drivers/io/io_semihosting.c | 44 | ||||
-rw-r--r-- | drivers/io/io_semihosting.h | 36 | ||||
-rw-r--r-- | drivers/power/fvp_pwrc.c | 111 | ||||
-rw-r--r-- | drivers/power/fvp_pwrc.h | 77 |
18 files changed, 511 insertions, 914 deletions
diff --git a/drivers/arm/interconnect/cci-400/cci400.c b/drivers/arm/cci400/cci400.c index cd5446fa..02f7f955 100644 --- a/drivers/arm/interconnect/cci-400/cci400.c +++ b/drivers/arm/cci400/cci400.c @@ -28,9 +28,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <assert.h> -#include <platform.h> #include <cci400.h> +#include <mmio.h> +#include <platform.h> static inline unsigned long get_slave_iface_base(unsigned long mpidr) { @@ -44,7 +44,8 @@ void cci_enable_coherency(unsigned long mpidr) DVM_EN_BIT | SNOOP_EN_BIT); /* Wait for the dust to settle down */ - while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT); + while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT) + ; } void cci_disable_coherency(unsigned long mpidr) @@ -54,6 +55,7 @@ void cci_disable_coherency(unsigned long mpidr) ~(DVM_EN_BIT | SNOOP_EN_BIT)); /* Wait for the dust to settle down */ - while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT); + while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT) + ; } diff --git a/drivers/console/console.h b/drivers/arm/gic/aarch64/gic_v3_sysregs.S index e2859092..2a96da76 100644 --- a/drivers/console/console.h +++ b/drivers/arm/gic/aarch64/gic_v3_sysregs.S @@ -28,12 +28,62 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __CONSOLE_H__ -#define __CONSOLE_H__ +#include <asm_macros.S> -void console_init(unsigned long base_addr); -int console_putc(int c); -int console_getc(void); + .globl read_icc_sre_el1 + .globl read_icc_sre_el2 + .globl read_icc_sre_el3 + .globl write_icc_sre_el1 + .globl write_icc_sre_el2 + .globl write_icc_sre_el3 + .globl write_icc_pmr_el1 -#endif /* __CONSOLE_H__ */ +/* + * Register definitions used by GCC for GICv3 access. + * These are defined by ARMCC, so keep them in the GCC specific code for now. + */ +#define ICC_SRE_EL1 S3_0_C12_C12_5 +#define ICC_SRE_EL2 S3_4_C12_C9_5 +#define ICC_SRE_EL3 S3_6_C12_C12_5 +#define ICC_CTLR_EL1 S3_0_C12_C12_4 +#define ICC_CTLR_EL3 S3_6_C12_C12_4 +#define ICC_PMR_EL1 S3_0_C4_C6_0 + +func read_icc_sre_el1 + mrs x0, ICC_SRE_EL1 + ret + + +func read_icc_sre_el2 + mrs x0, ICC_SRE_EL2 + ret + + +func read_icc_sre_el3 + mrs x0, ICC_SRE_EL3 + ret + + +func write_icc_sre_el1 + msr ICC_SRE_EL1, x0 + isb + ret + + +func write_icc_sre_el2 + msr ICC_SRE_EL2, x0 + isb + ret + + +func write_icc_sre_el3 + msr ICC_SRE_EL3, x0 + isb + ret + + +func write_icc_pmr_el1 + msr ICC_PMR_EL1, x0 + isb + ret diff --git a/drivers/arm/gic/gic_v2.c b/drivers/arm/gic/gic_v2.c new file mode 100644 index 00000000..b0119002 --- /dev/null +++ b/drivers/arm/gic/gic_v2.c @@ -0,0 +1,298 @@ +/* + * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of ARM nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <assert.h> +#include <gic_v2.h> +#include <mmio.h> + +/******************************************************************************* + * GIC Distributor interface accessors for reading entire registers + ******************************************************************************/ + +unsigned int gicd_read_igroupr(unsigned int base, unsigned int id) +{ + unsigned n = id >> IGROUPR_SHIFT; + return mmio_read_32(base + GICD_IGROUPR + (n << 2)); +} + +unsigned int gicd_read_isenabler(unsigned int base, unsigned int id) +{ + unsigned n = id >> ISENABLER_SHIFT; + return mmio_read_32(base + GICD_ISENABLER + (n << 2)); +} + +unsigned int gicd_read_icenabler(unsigned int base, unsigned int id) +{ + unsigned n = id >> ICENABLER_SHIFT; + return mmio_read_32(base + GICD_ICENABLER + (n << 2)); +} + +unsigned int gicd_read_ispendr(unsigned int base, unsigned int id) +{ + unsigned n = id >> ISPENDR_SHIFT; + return mmio_read_32(base + GICD_ISPENDR + (n << 2)); +} + +unsigned int gicd_read_icpendr(unsigned int base, unsigned int id) +{ + unsigned n = id >> ICPENDR_SHIFT; + return mmio_read_32(base + GICD_ICPENDR + (n << 2)); +} + +unsigned int gicd_read_isactiver(unsigned int base, unsigned int id) +{ + unsigned n = id >> ISACTIVER_SHIFT; + return mmio_read_32(base + GICD_ISACTIVER + (n << 2)); +} + +unsigned int gicd_read_icactiver(unsigned int base, unsigned int id) +{ + unsigned n = id >> ICACTIVER_SHIFT; + return mmio_read_32(base + GICD_ICACTIVER + (n << 2)); +} + +unsigned int gicd_read_ipriorityr(unsigned int base, unsigned int id) +{ + unsigned n = id >> IPRIORITYR_SHIFT; + return mmio_read_32(base + GICD_IPRIORITYR + (n << 2)); +} + +unsigned int gicd_read_itargetsr(unsigned int base, unsigned int id) +{ + unsigned n = id >> ITARGETSR_SHIFT; + return mmio_read_32(base + GICD_ITARGETSR + (n << 2)); +} + +unsigned int gicd_read_icfgr(unsigned int base, unsigned int id) +{ + unsigned n = id >> ICFGR_SHIFT; + return mmio_read_32(base + GICD_ICFGR + (n << 2)); +} + +unsigned int gicd_read_cpendsgir(unsigned int base, unsigned int id) +{ + unsigned n = id >> CPENDSGIR_SHIFT; + return mmio_read_32(base + GICD_CPENDSGIR + (n << 2)); +} + +unsigned int gicd_read_spendsgir(unsigned int base, unsigned int id) +{ + unsigned n = id >> SPENDSGIR_SHIFT; + return mmio_read_32(base + GICD_SPENDSGIR + (n << 2)); +} + +/******************************************************************************* + * GIC Distributor interface accessors for writing entire registers + ******************************************************************************/ + +void gicd_write_igroupr(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> IGROUPR_SHIFT; + mmio_write_32(base + GICD_IGROUPR + (n << 2), val); +} + +void gicd_write_isenabler(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ISENABLER_SHIFT; + mmio_write_32(base + GICD_ISENABLER + (n << 2), val); +} + +void gicd_write_icenabler(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ICENABLER_SHIFT; + mmio_write_32(base + GICD_ICENABLER + (n << 2), val); +} + +void gicd_write_ispendr(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ISPENDR_SHIFT; + mmio_write_32(base + GICD_ISPENDR + (n << 2), val); +} + +void gicd_write_icpendr(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ICPENDR_SHIFT; + mmio_write_32(base + GICD_ICPENDR + (n << 2), val); +} + +void gicd_write_isactiver(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ISACTIVER_SHIFT; + mmio_write_32(base + GICD_ISACTIVER + (n << 2), val); +} + +void gicd_write_icactiver(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ICACTIVER_SHIFT; + mmio_write_32(base + GICD_ICACTIVER + (n << 2), val); +} + +void gicd_write_ipriorityr(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> IPRIORITYR_SHIFT; + mmio_write_32(base + GICD_IPRIORITYR + (n << 2), val); +} + +void gicd_write_itargetsr(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ITARGETSR_SHIFT; + mmio_write_32(base + GICD_ITARGETSR + (n << 2), val); +} + +void gicd_write_icfgr(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> ICFGR_SHIFT; + mmio_write_32(base + GICD_ICFGR + (n << 2), val); +} + +void gicd_write_cpendsgir(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> CPENDSGIR_SHIFT; + mmio_write_32(base + GICD_CPENDSGIR + (n << 2), val); +} + +void gicd_write_spendsgir(unsigned int base, unsigned int id, unsigned int val) +{ + unsigned n = id >> SPENDSGIR_SHIFT; + mmio_write_32(base + GICD_SPENDSGIR + (n << 2), val); +} + +/******************************************************************************* + * GIC Distributor interface accessors for individual interrupt manipulation + ******************************************************************************/ +unsigned int gicd_get_igroupr(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << IGROUPR_SHIFT) - 1); + unsigned int reg_val = gicd_read_igroupr(base, id); + + return (reg_val >> bit_num) & 0x1; +} + +void gicd_set_igroupr(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << IGROUPR_SHIFT) - 1); + unsigned int reg_val = gicd_read_igroupr(base, id); + + gicd_write_igroupr(base, id, reg_val | (1 << bit_num)); +} + +void gicd_clr_igroupr(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << IGROUPR_SHIFT) - 1); + unsigned int reg_val = gicd_read_igroupr(base, id); + + gicd_write_igroupr(base, id, reg_val & ~(1 << bit_num)); +} + +void gicd_set_isenabler(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << ISENABLER_SHIFT) - 1); + unsigned int reg_val = gicd_read_isenabler(base, id); + + gicd_write_isenabler(base, id, reg_val | (1 << bit_num)); +} + +void gicd_set_icenabler(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << ICENABLER_SHIFT) - 1); + unsigned int reg_val = gicd_read_icenabler(base, id); + + gicd_write_icenabler(base, id, reg_val & ~(1 << bit_num)); +} + +void gicd_set_ispendr(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << ISPENDR_SHIFT) - 1); + unsigned int reg_val = gicd_read_ispendr(base, id); + + gicd_write_ispendr(base, id, reg_val | (1 << bit_num)); +} + +void gicd_set_icpendr(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << ICPENDR_SHIFT) - 1); + unsigned int reg_val = gicd_read_icpendr(base, id); + + gicd_write_icpendr(base, id, reg_val & ~(1 << bit_num)); +} + +void gicd_set_isactiver(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << ISACTIVER_SHIFT) - 1); + unsigned int reg_val = gicd_read_isactiver(base, id); + + gicd_write_isactiver(base, id, reg_val | (1 << bit_num)); +} + +void gicd_set_icactiver(unsigned int base, unsigned int id) +{ + unsigned bit_num = id & ((1 << ICACTIVER_SHIFT) - 1); + unsigned int reg_val = gicd_read_icactiver(base, id); + + gicd_write_icactiver(base, id, reg_val & ~(1 << bit_num)); +} + +/* + * Make sure that the interrupt's group is set before expecting + * this function to do its job correctly. + */ +void gicd_set_ipriorityr(unsigned int base, unsigned int id, unsigned int pri) +{ + unsigned int reg = base + GICD_IPRIORITYR + (id & ~3); + unsigned int shift = (id & 3) << 3; + unsigned int reg_val = mmio_read_32(reg); + + /* + * Enforce ARM recommendation to manage priority values such + * that group1 interrupts always have a lower priority than + * group0 interrupts. + * Note, lower numerical values are higher priorities so the comparison + * checks below are reversed from what might be expected. + */ + assert(gicd_get_igroupr(base, id) == GRP1 ? + pri >= GIC_HIGHEST_NS_PRIORITY && + pri <= GIC_LOWEST_NS_PRIORITY : + pri >= GIC_HIGHEST_SEC_PRIORITY && + pri <= GIC_LOWEST_SEC_PRIORITY); + + reg_val &= ~(GIC_PRI_MASK << shift); + reg_val |= (pri & GIC_PRI_MASK) << shift; + mmio_write_32(reg, reg_val); +} + +void gicd_set_itargetsr(unsigned int base, unsigned int id, unsigned int iface) +{ + unsigned byte_off = id & ((1 << ITARGETSR_SHIFT) - 1); + unsigned int reg_val = gicd_read_itargetsr(base, id); + + gicd_write_itargetsr(base, id, reg_val | + (1 << iface) << (byte_off << 3)); +} + diff --git a/drivers/io/io_memmap.h b/drivers/arm/gic/gic_v3.c index 5fa7bc98..f4296629 100644 --- a/drivers/io/io_memmap.h +++ b/drivers/arm/gic/gic_v3.c @@ -28,9 +28,53 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __IO_MEMMAP_H__ -#define __IO_MEMMAP_H__ +#include <arch.h> +#include <debug.h> +#include <gic_v3.h> -int register_io_dev_memmap(struct io_dev_connector **dev_con); +uintptr_t gicv3_get_rdist(uintptr_t gicr_base, uint64_t mpidr) +{ + uint32_t cpu_aff, gicr_aff; + uint64_t gicr_typer; + uintptr_t addr; -#endif /* __IO_MEMMAP_H__ */ + /* Construct the affinity as used by GICv3. MPIDR and GIC affinity level + * mask is the same. + */ + cpu_aff = ((mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK) << + GICV3_AFF0_SHIFT; + cpu_aff |= ((mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK) << + GICV3_AFF1_SHIFT; + cpu_aff |= ((mpidr >> MPIDR_AFF2_SHIFT) & MPIDR_AFFLVL_MASK) << + GICV3_AFF2_SHIFT; + cpu_aff |= ((mpidr >> MPIDR_AFF3_SHIFT) & MPIDR_AFFLVL_MASK) << + GICV3_AFF3_SHIFT; + + addr = gicr_base; + do { + gicr_typer = gicr_read_typer(addr); + + gicr_aff = (gicr_typer >> GICR_TYPER_AFF_SHIFT) & + GICR_TYPER_AFF_MASK; + if (cpu_aff == gicr_aff) { + /* Disable this print for now as it appears every time + * when using PSCI CPU_SUSPEND. + * TODO: Print this only the first time for each CPU. + * INFO("GICv3 - Found RDIST for MPIDR(0x%lx) at 0x%lx\n", + * mpidr, addr); + */ + return addr; + } + + /* TODO: + * For GICv4 we need to adjust the Base address based on + * GICR_TYPER.VLPIS + */ + addr += (1 << GICR_PCPUBASE_SHIFT); + + } while (!(gicr_typer & GICR_TYPER_LAST)); + + /* If we get here we did not find a match. */ + ERROR("GICv3 - Did not find RDIST for CPU with MPIDR 0x%lx\n", mpidr); + return (uintptr_t)NULL; +} diff --git a/drivers/arm/interconnect/cci-400/cci400.h b/drivers/arm/interconnect/cci-400/cci400.h deleted file mode 100644 index 3921675f..00000000 --- a/drivers/arm/interconnect/cci-400/cci400.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __CCI_400_H__ -#define __CCI_400_H__ - -/* Slave interface offsets from PERIPHBASE */ -#define SLAVE_IFACE4_OFFSET 0x5000 -#define SLAVE_IFACE3_OFFSET 0x4000 -#define SLAVE_IFACE2_OFFSET 0x3000 -#define SLAVE_IFACE1_OFFSET 0x2000 -#define SLAVE_IFACE0_OFFSET 0x1000 -#define SLAVE_IFACE_OFFSET(index) SLAVE_IFACE0_OFFSET + (0x1000 * index) - -/* Control and ID register offsets */ -#define CTRL_OVERRIDE_REG 0x0 -#define SPEC_CTRL_REG 0x4 -#define SECURE_ACCESS_REG 0x8 -#define STATUS_REG 0xc -#define IMPRECISE_ERR_REG 0x10 -#define PERFMON_CTRL_REG 0x100 - -/* Slave interface register offsets */ -#define SNOOP_CTRL_REG 0x0 -#define SH_OVERRIDE_REG 0x4 -#define READ_CHNL_QOS_VAL_OVERRIDE_REG 0x100 -#define WRITE_CHNL_QOS_VAL_OVERRIDE_REG 0x104 -#define QOS_CTRL_REG 0x10c -#define MAX_OT_REG 0x110 -#define TARGET_LATENCY_REG 0x130 -#define LATENCY_REGULATION_REG 0x134 -#define QOS_RANGE_REG 0x138 - -/* Snoop Control register bit definitions */ -#define DVM_EN_BIT (1 << 1) -#define SNOOP_EN_BIT (1 << 0) - -/* Status register bit definitions */ -#define CHANGE_PENDING_BIT (1 << 0) - -/* Function declarations */ -extern void cci_enable_coherency(unsigned long mpidr); -extern void cci_disable_coherency(unsigned long mpidr); - -#endif /* __CCI_400_H__ */ diff --git a/drivers/arm/interconnect/tzc-400/tzc400.h b/drivers/arm/interconnect/tzc-400/tzc400.h deleted file mode 100644 index 7eaafd2e..00000000 --- a/drivers/arm/interconnect/tzc-400/tzc400.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __TZC400_H__ -#define __TZC400_H__ - -#include <stdint.h> - -#define BUILD_CONFIG_OFF 0x000 -#define ACTION_OFF 0x004 -#define GATE_KEEPER_OFF 0x008 -#define SPECULATION_CTRL_OFF 0x00c -#define INT_STATUS 0x010 -#define INT_CLEAR 0x014 - -#define FAIL_ADDRESS_LOW_OFF 0x020 -#define FAIL_ADDRESS_HIGH_OFF 0x024 -#define FAIL_CONTROL_OFF 0x028 -#define FAIL_ID 0x02c - -#define REGION_BASE_LOW_OFF 0x100 -#define REGION_BASE_HIGH_OFF 0x104 -#define REGION_TOP_LOW_OFF 0x108 -#define REGION_TOP_HIGH_OFF 0x10c -#define REGION_ATTRIBUTES_OFF 0x110 -#define REGION_ID_ACCESS_OFF 0x114 -#define REGION_NUM_OFF(region) (0x20 * region) - -/* ID Registers */ -#define PID0_OFF 0xfe0 -#define PID1_OFF 0xfe4 -#define PID2_OFF 0xfe8 -#define PID3_OFF 0xfec -#define PID4_OFF 0xfd0 -#define PID5_OFF 0xfd4 -#define PID6_OFF 0xfd8 -#define PID7_OFF 0xfdc -#define CID0_OFF 0xff0 -#define CID1_OFF 0xff4 -#define CID2_OFF 0xff8 -#define CID3_OFF 0xffc - -#define BUILD_CONFIG_NF_SHIFT 24 -#define BUILD_CONFIG_NF_MASK 0x3 -#define BUILD_CONFIG_AW_SHIFT 8 -#define BUILD_CONFIG_AW_MASK 0x3f -#define BUILD_CONFIG_NR_SHIFT 0 -#define BUILD_CONFIG_NR_MASK 0x1f - -/* Not describing the case where regions 1 to 8 overlap */ -#define ACTION_RV_SHIFT 0 -#define ACTION_RV_MASK 0x3 -#define ACTION_RV_LOWOK 0x0 -#define ACTION_RV_LOWERR 0x1 -#define ACTION_RV_HIGHOK 0x2 -#define ACTION_RV_HIGHERR 0x3 - -/* - * Number of gate keepers is implementation defined. But we know the max for - * this device is 4. Get implementation details from BUILD_CONFIG. - */ -#define GATE_KEEPER_OS_SHIFT 16 -#define GATE_KEEPER_OS_MASK 0xf -#define GATE_KEEPER_OR_SHIFT 0 -#define GATE_KEEPER_OR_MASK 0xf - -/* Speculation is enabled by default. */ -#define SPECULATION_CTRL_WRITE_DISABLE (1 << 1) -#define SPECULATION_CTRL_READ_DISABLE (1 << 0) - -/* Max number of filters allowed is 4. */ -#define INT_STATUS_OVERLAP_SHIFT 16 -#define INT_STATUS_OVERLAP_MASK 0xf -#define INT_STATUS_OVERRUN_SHIFT 8 -#define INT_STATUS_OVERRUN_MASK 0xf -#define INT_STATUS_STATUS_SHIFT 0 -#define INT_STATUS_STATUS_MASK 0xf - -#define INT_CLEAR_CLEAR_SHIFT 0 -#define INT_CLEAR_CLEAR_MASK 0xf - -#define FAIL_CONTROL_DIR_SHIFT (1 << 24) -#define FAIL_CONTROL_DIR_READ 0x0 -#define FAIL_CONTROL_DIR_WRITE 0x1 -#define FAIL_CONTROL_NS_SHIFT (1 << 21) -#define FAIL_CONTROL_NS_SECURE 0x0 -#define FAIL_CONTROL_NS_NONSECURE 0x1 -#define FAIL_CONTROL_PRIV_SHIFT (1 << 20) -#define FAIL_CONTROL_PRIV_PRIV 0x0 -#define FAIL_CONTROL_PRIV_UNPRIV 0x1 - -/* - * FAIL_ID_ID_MASK depends on AID_WIDTH which is platform specific. - * Platform should provide the value on initialisation. - */ -#define FAIL_ID_VNET_SHIFT 24 -#define FAIL_ID_VNET_MASK 0xf -#define FAIL_ID_ID_SHIFT 0 - -/* Used along with 'tzc_region_attributes_t' below */ -#define REGION_ATTRIBUTES_SEC_SHIFT 30 -#define REGION_ATTRIBUTES_F_EN_SHIFT 0 -#define REGION_ATTRIBUTES_F_EN_MASK 0xf - -#define REGION_ID_ACCESS_NSAID_WR_EN_SHIFT 16 -#define REGION_ID_ACCESS_NSAID_RD_EN_SHIFT 0 -#define REGION_ID_ACCESS_NSAID_ID_MASK 0xf - - -/* Macros for setting Region ID access permissions based on NSAID */ -#define TZC_REGION_ACCESS_RD(id) \ - ((1 << (id & REGION_ID_ACCESS_NSAID_ID_MASK)) << \ - REGION_ID_ACCESS_NSAID_RD_EN_SHIFT) -#define TZC_REGION_ACCESS_WR(id) \ - ((1 << (id & REGION_ID_ACCESS_NSAID_ID_MASK)) << \ - REGION_ID_ACCESS_NSAID_WR_EN_SHIFT) -#define TZC_REGION_ACCESS_RDWR(id) \ - (TZC_REGION_ACCESS_RD(id) | TZC_REGION_ACCESS_WR(id)) - -/* Filters are bit mapped 0 to 3. */ -#define TZC400_COMPONENT_ID 0xb105f00d - -#ifndef __ASSEMBLY__ - -/******************************************************************************* - * Function & variable prototypes - ******************************************************************************/ - -/* - * What type of action is expected when an access violation occurs. - * The memory requested is zeroed. But we can also raise and event to - * let the system know it happened. - * We can raise an interrupt(INT) and/or cause an exception(ERR). - * TZC_ACTION_NONE - No interrupt, no Exception - * TZC_ACTION_ERR - No interrupt, raise exception -> sync external - * data abort - * TZC_ACTION_INT - Raise interrupt, no exception - * TZC_ACTION_ERR_INT - Raise interrupt, raise exception -> sync - * external data abort - */ -enum tzc_action { - TZC_ACTION_NONE = 0, - TZC_ACTION_ERR = 1, - TZC_ACTION_INT = 2, - TZC_ACTION_ERR_INT = (TZC_ACTION_ERR | TZC_ACTION_INT) -}; - -/* - * Controls secure access to a region. If not enabled secure access is not - * allowed to region. - */ -enum tzc_region_attributes { - TZC_REGION_S_NONE = 0, - TZC_REGION_S_RD = 1, - TZC_REGION_S_WR = 2, - TZC_REGION_S_RDWR = (TZC_REGION_S_RD | TZC_REGION_S_WR) -}; - -/* - * Implementation defined values used to validate inputs later. - * Filters : max of 4 ; 0 to 3 - * Regions : max of 9 ; 0 to 8 - * Address width : Values between 32 to 64 - */ -struct tzc_instance { - uint64_t base; - uint32_t aid_width; - uint8_t addr_width; - uint8_t num_filters; - uint8_t num_regions; -}; - -void tzc_init(struct tzc_instance *controller); -void tzc_configure_region(const struct tzc_instance *controller, uint32_t filters, - uint8_t region, uint64_t region_base, uint64_t region_top, - enum tzc_region_attributes sec_attr, uint32_t ns_device_access); -void tzc_enable_filters(const struct tzc_instance *controller); -void tzc_disable_filters(const struct tzc_instance *controller); -void tzc_set_action(const struct tzc_instance *controller, - enum tzc_action action); - -#endif /*__ASSEMBLY__*/ - -#endif /* __TZC400__ */ diff --git a/drivers/arm/peripherals/pl011/pl011.h b/drivers/arm/peripherals/pl011/pl011.h deleted file mode 100644 index 5ad2fc7d..00000000 --- a/drivers/arm/peripherals/pl011/pl011.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PL011_H__ -#define __PL011_H__ - -/* PL011 Registers */ -#define UARTDR 0x000 -#define UARTRSR 0x004 -#define UARTECR 0x004 -#define UARTFR 0x018 -#define UARTILPR 0x020 -#define UARTIBRD 0x024 -#define UARTFBRD 0x028 -#define UARTLCR_H 0x02C -#define UARTCR 0x030 -#define UARTIFLS 0x034 -#define UARTIMSC 0x038 -#define UARTRIS 0x03C -#define UARTMIS 0x040 -#define UARTICR 0x044 -#define UARTDMACR 0x048 - -/* Data status bits */ -#define UART_DATA_ERROR_MASK 0x0F00 - -/* Status reg bits */ -#define UART_STATUS_ERROR_MASK 0x0F - -/* Flag reg bits */ -#define PL011_UARTFR_RI (1 << 8) /* Ring indicator */ -#define PL011_UARTFR_TXFE (1 << 7) /* Transmit FIFO empty */ -#define PL011_UARTFR_RXFF (1 << 6) /* Receive FIFO full */ -#define PL011_UARTFR_TXFF (1 << 5) /* Transmit FIFO full */ -#define PL011_UARTFR_RXFE (1 << 4) /* Receive FIFO empty */ -#define PL011_UARTFR_BUSY (1 << 3) /* UART busy */ -#define PL011_UARTFR_DCD (1 << 2) /* Data carrier detect */ -#define PL011_UARTFR_DSR (1 << 1) /* Data set ready */ -#define PL011_UARTFR_CTS (1 << 0) /* Clear to send */ - -/* Control reg bits */ -#define PL011_UARTCR_CTSEN (1 << 15) /* CTS hardware flow control enable */ -#define PL011_UARTCR_RTSEN (1 << 14) /* RTS hardware flow control enable */ -#define PL011_UARTCR_RTS (1 << 11) /* Request to send */ -#define PL011_UARTCR_DTR (1 << 10) /* Data transmit ready. */ -#define PL011_UARTCR_RXE (1 << 9) /* Receive enable */ -#define PL011_UARTCR_TXE (1 << 8) /* Transmit enable */ -#define PL011_UARTCR_LBE (1 << 7) /* Loopback enable */ -#define PL011_UARTCR_UARTEN (1 << 0) /* UART Enable */ - -#if !defined(PL011_BASE) -#error "The PL011_BASE macro must be defined." -#endif - -#if !defined(PL011_BAUDRATE) -#define PL011_BAUDRATE 115200 -#endif - -#if !defined(PL011_CLK_IN_HZ) -#define PL011_CLK_IN_HZ 24000000 -#endif - -#if !defined(PL011_LINE_CONTROL) -/* FIFO Enabled / No Parity / 8 Data bit / One Stop Bit */ -#define PL011_LINE_CONTROL (PL011_UARTLCR_H_FEN | PL011_UARTLCR_H_WLEN_8) -#endif - -/* Line Control Register Bits */ -#define PL011_UARTLCR_H_SPS (1 << 7) /* Stick parity select */ -#define PL011_UARTLCR_H_WLEN_8 (3 << 5) -#define PL011_UARTLCR_H_WLEN_7 (2 << 5) -#define PL011_UARTLCR_H_WLEN_6 (1 << 5) -#define PL011_UARTLCR_H_WLEN_5 (0 << 5) -#define PL011_UARTLCR_H_FEN (1 << 4) /* FIFOs Enable */ -#define PL011_UARTLCR_H_STP2 (1 << 3) /* Two stop bits select */ -#define PL011_UARTLCR_H_EPS (1 << 2) /* Even parity select */ -#define PL011_UARTLCR_H_PEN (1 << 1) /* Parity Enable */ -#define PL011_UARTLCR_H_BRK (1 << 0) /* Send break */ - -/******************************************************************************* - * Pl011 CPU interface accessors for writing registers - ******************************************************************************/ - -static inline void pl011_write_ibrd(unsigned int base, unsigned int val) -{ - mmio_write_32(base + UARTIBRD, val); -} - -static inline void pl011_write_fbrd(unsigned int base, unsigned int val) -{ - mmio_write_32(base + UARTFBRD, val); -} - -static inline void pl011_write_lcr_h(unsigned int base, unsigned int val) -{ - mmio_write_32(base + UARTLCR_H, val); -} - -static inline void pl011_write_ecr(unsigned int base, unsigned int val) -{ - mmio_write_32(base + UARTECR, val); -} - -static inline void pl011_write_cr(unsigned int base, unsigned int val) -{ - mmio_write_32(base + UARTCR, val); -} - -static inline void pl011_write_dr(unsigned int base, unsigned int val) -{ - mmio_write_32(base + UARTDR, val); -} - -/******************************************************************************* - * Pl011 CPU interface accessors for reading registers - ******************************************************************************/ - -static inline unsigned int pl011_read_fr(unsigned int base) -{ - return mmio_read_32(base + UARTFR); -} - -static inline unsigned int pl011_read_dr(unsigned int base) -{ - return mmio_read_32(base + UARTDR); -} - -/******************************************************************************* - * Function prototypes - ******************************************************************************/ - -void pl011_setbaudrate(unsigned long base_addr, unsigned int baudrate); - -#endif /* __PL011_H__ */ diff --git a/drivers/arm/peripherals/pl011/pl011.c b/drivers/arm/pl011/pl011.c index 8288cd81..f12bd23d 100644 --- a/drivers/arm/peripherals/pl011/pl011.c +++ b/drivers/arm/pl011/pl011.c @@ -28,9 +28,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <assert.h> #include <platform.h> #include <pl011.h> -#include <assert.h> void pl011_setbaudrate(unsigned long base_addr, unsigned int baudrate) { diff --git a/drivers/arm/peripherals/pl011/pl011_console.c b/drivers/arm/pl011/pl011_console.c index 1a684ff6..3b0e237f 100644 --- a/drivers/arm/peripherals/pl011/pl011_console.c +++ b/drivers/arm/pl011/pl011_console.c @@ -28,10 +28,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <assert.h> #include <console.h> #include <platform.h> #include <pl011.h> -#include <assert.h> static unsigned long uart_base; diff --git a/drivers/arm/interconnect/tzc-400/tzc400.c b/drivers/arm/tzc400/tzc400.c index b88e34a9..c1716db4 100644 --- a/drivers/arm/interconnect/tzc-400/tzc400.c +++ b/drivers/arm/tzc400/tzc400.c @@ -29,10 +29,10 @@ */ #include <assert.h> -#include "arch_helpers.h" -#include "tzc400.h" -#include "mmio.h" -#include "debug.h" +#include <debug.h> +#include <mmio.h> +#include <stddef.h> +#include <tzc400.h> static uint32_t tzc_read_build_config(uint64_t base) { @@ -49,7 +49,7 @@ static void tzc_write_gate_keeper(uint64_t base, uint32_t val) mmio_write_32(base + GATE_KEEPER_OFF, val); } -static void tzc_write_action(uint64_t base, enum tzc_action action) +static void tzc_write_action(uint64_t base, tzc_action_t action) { mmio_write_32(base + ACTION_OFF, action); } @@ -130,7 +130,7 @@ static void tzc_set_gate_keeper(uint64_t base, uint8_t filter, uint32_t val) } -void tzc_init(struct tzc_instance *controller) +void tzc_init(tzc_instance_t *controller) { uint32_t tzc_id, tzc_build; @@ -166,12 +166,12 @@ void tzc_init(struct tzc_instance *controller) * this cannot be changed. It is, however, possible to change some region 0 * permissions. */ -void tzc_configure_region(const struct tzc_instance *controller, +void tzc_configure_region(const tzc_instance_t *controller, uint32_t filters, uint8_t region, uint64_t region_base, uint64_t region_top, - enum tzc_region_attributes sec_attr, + tzc_region_attributes_t sec_attr, uint32_t ns_device_access) { uint64_t max_addr; @@ -218,7 +218,7 @@ void tzc_configure_region(const struct tzc_instance *controller, } -void tzc_set_action(const struct tzc_instance *controller, enum tzc_action action) +void tzc_set_action(const tzc_instance_t *controller, tzc_action_t action) { assert(controller != NULL); @@ -231,7 +231,7 @@ void tzc_set_action(const struct tzc_instance *controller, enum tzc_action actio } -void tzc_enable_filters(const struct tzc_instance *controller) +void tzc_enable_filters(const tzc_instance_t *controller) { uint32_t state; uint32_t filter; @@ -250,7 +250,7 @@ void tzc_enable_filters(const struct tzc_instance *controller) } -void tzc_disable_filters(const struct tzc_instance *controller) +void tzc_disable_filters(const tzc_instance_t *controller) { uint32_t filter; diff --git a/drivers/io/io_driver.h b/drivers/io/io_driver.h deleted file mode 100644 index 82dbbf12..00000000 --- a/drivers/io/io_driver.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __IO_DRIVER_H__ -#define __IO_DRIVER_H__ - -#include "platform.h" /* For MAX_IO_DEVICES */ - - -/* Generic IO entity structure,representing an accessible IO construct on the - * device, such as a file */ -struct io_entity { - io_dev_handle dev_handle; - uintptr_t info; -}; - - -/* Device info structure, providing device-specific functions and a means of - * adding driver-specific state */ -struct io_dev_info { - struct io_dev_funcs *funcs; - uintptr_t info; -}; - - -/* Structure used to create a connection to a type of device */ -struct io_dev_connector { - /* dev_open opens a connection to a particular device driver */ - int (*dev_open)(void *spec, struct io_dev_info **dev_info); -}; - - -/* Structure to hold device driver function pointers */ -struct io_dev_funcs { - io_type (*type)(void); - int (*open)(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); - int (*seek)(struct io_entity *entity, int mode, ssize_t offset); - int (*size)(struct io_entity *entity, size_t *length); - int (*read)(struct io_entity *entity, void *buffer, size_t length, - size_t *length_read); - int (*write)(struct io_entity *entity, const void *buffer, - size_t length, size_t *length_written); - int (*close)(struct io_entity *entity); - int (*dev_init)(struct io_dev_info *dev_info, const void *init_params); - int (*dev_close)(struct io_dev_info *dev_info); -}; - - -/* IO platform data - used to track devices registered for a specific - * platform */ -struct io_plat_data { - struct io_dev_info *devices[MAX_IO_DEVICES]; - unsigned int dev_count; -}; - - -/* Operations intended to be performed during platform initialisation */ - -/* Initialise the IO layer */ -void io_init(struct io_plat_data *data); - -/* Register a device driver */ -int io_register_device(struct io_dev_info *dev_info); - -#endif /* __IO_DRIVER_H__ */ diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c index 1eb76faa..b2dcfccf 100644 --- a/drivers/io/io_fip.c +++ b/drivers/io/io_fip.c @@ -28,17 +28,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <stdint.h> -#include <uuid.h> +#include <assert.h> +#include <debug.h> #include <errno.h> +#include <firmware_image_package.h> +#include <io_driver.h> +#include <io_fip.h> +#include <io_storage.h> +#include <platform.h> +#include <stdint.h> #include <string.h> -#include <assert.h> -#include "platform.h" -#include "firmware_image_package.h" -#include "io_storage.h" -#include "io_driver.h" -#include "io_fip.h" -#include "debug.h" +#include <uuid.h> /* Useful for printing UUIDs when debugging.*/ #define PRINT_UUID2(x) \ @@ -51,7 +51,7 @@ typedef struct { const char *name; const uuid_t uuid; -} plat_fip_name_uuid; +} plat_fip_name_uuid_t; typedef struct { /* Put file_pos above the struct to allow {0} on static init. @@ -59,10 +59,10 @@ typedef struct { * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 */ unsigned int file_pos; - fip_toc_entry entry; -} file_state; + fip_toc_entry_t entry; +} file_state_t; -static plat_fip_name_uuid name_uuid[] = { +static plat_fip_name_uuid_t name_uuid[] = { {BL2_IMAGE_NAME, UUID_TRUSTED_BOOT_FIRMWARE_BL2}, {BL31_IMAGE_NAME, UUID_EL3_RUNTIME_FIRMWARE_BL31}, {BL32_IMAGE_NAME, UUID_SECURE_PAYLOAD_BL32}, @@ -70,21 +70,21 @@ static plat_fip_name_uuid name_uuid[] = { }; static const uuid_t uuid_null = {0}; -static file_state current_file = {0}; +static file_state_t current_file = {0}; static io_dev_handle backend_dev_handle; static void *backend_image_spec; /* Firmware Image Package driver functions */ -static int fip_dev_open(void *spec, struct io_dev_info **dev_info); -static int fip_file_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); -static int fip_file_len(struct io_entity *entity, size_t *length); -static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, +static int fip_dev_open(void *spec, io_dev_info_t **dev_info); +static int fip_file_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity); +static int fip_file_len(io_entity_t *entity, size_t *length); +static int fip_file_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read); -static int fip_file_close(struct io_entity *entity); -static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params); -static int fip_dev_close(struct io_dev_info *dev_info); +static int fip_file_close(io_entity_t *entity); +static int fip_dev_init(io_dev_info_t *dev_info, const void *init_params); +static int fip_dev_close(io_dev_info_t *dev_info); static inline int copy_uuid(uuid_t *dst, const uuid_t *src) @@ -102,7 +102,7 @@ static inline int compare_uuids(const uuid_t *uuid1, const uuid_t *uuid2) /* TODO: We could check version numbers or do a package checksum? */ -static inline int is_valid_header(fip_toc_header *header) +static inline int is_valid_header(fip_toc_header_t *header) { if ((header->name == TOC_HEADER_NAME) && (header->serial_number != 0)) { return 1; @@ -129,7 +129,7 @@ static int file_to_uuid(const char *filename, uuid_t *uuid) /* Identify the device type as a virtual driver */ -io_type device_type_fip(void) +io_type_t device_type_fip(void) { return IO_TYPE_FIRMWARE_IMAGE_PACKAGE; } @@ -161,7 +161,7 @@ static struct io_dev_info fip_dev_info = { /* Open a connection to the FIP device */ static int fip_dev_open(void *spec __attribute__((unused)), - struct io_dev_info **dev_info) + io_dev_info_t **dev_info) { assert(dev_info != NULL); *dev_info = &fip_dev_info; @@ -171,12 +171,12 @@ static int fip_dev_open(void *spec __attribute__((unused)), /* Do some basic package checks. */ -static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params) +static int fip_dev_init(io_dev_info_t *dev_info, const void *init_params) { int result = IO_FAIL; char *image_name = (char *)init_params; io_handle backend_handle; - fip_toc_header header; + fip_toc_header_t header; size_t bytes_read; /* Obtain a reference to the image by querying the platform layer */ @@ -215,7 +215,7 @@ static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params) } /* Close a connection to the FIP device */ -static int fip_dev_close(struct io_dev_info *dev_info) +static int fip_dev_close(io_dev_info_t *dev_info) { /* TODO: Consider tracking open files and cleaning them up here */ @@ -228,13 +228,13 @@ static int fip_dev_close(struct io_dev_info *dev_info) /* Open a file for access from package. */ -static int fip_file_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity) +static int fip_file_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity) { int result = IO_FAIL; io_handle backend_handle; uuid_t file_uuid; - const io_file_spec *file_spec = (io_file_spec *)spec; + const io_file_spec_t *file_spec = (io_file_spec_t *)spec; size_t bytes_read; int found_file = 0; @@ -262,7 +262,7 @@ static int fip_file_open(struct io_dev_info *dev_info, const void *spec, } /* Seek past the FIP header into the Table of Contents */ - result = io_seek(backend_handle, IO_SEEK_SET, sizeof(fip_toc_header)); + result = io_seek(backend_handle, IO_SEEK_SET, sizeof(fip_toc_header_t)); if (result != IO_SUCCESS) { WARN("fip_file_open: failed to seek\n"); result = IO_FAIL; @@ -310,23 +310,23 @@ static int fip_file_open(struct io_dev_info *dev_info, const void *spec, /* Return the size of a file in package */ -static int fip_file_len(struct io_entity *entity, size_t *length) +static int fip_file_len(io_entity_t *entity, size_t *length) { assert(entity != NULL); assert(length != NULL); - *length = ((file_state *)entity->info)->entry.size; + *length = ((file_state_t *)entity->info)->entry.size; return IO_SUCCESS; } /* Read data from a file in package */ -static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, +static int fip_file_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read) { int result = IO_FAIL; - file_state *fp; + file_state_t *fp; size_t file_offset; size_t bytes_read; io_handle backend_handle; @@ -345,7 +345,7 @@ static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, goto fip_file_read_exit; } - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; /* Seek to the position in the FIP where the payload lives */ file_offset = fp->entry.offset_address + fp->file_pos; @@ -378,7 +378,7 @@ static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, /* Close a file in package */ -static int fip_file_close(struct io_entity *entity) +static int fip_file_close(io_entity_t *entity) { /* Clear our current file pointer. * If we had malloc() we would free() here. @@ -396,7 +396,7 @@ static int fip_file_close(struct io_entity *entity) /* Exported functions */ /* Register the Firmware Image Package driver with the IO abstraction */ -int register_io_dev_fip(struct io_dev_connector **dev_con) +int register_io_dev_fip(io_dev_connector_t **dev_con) { int result = IO_FAIL; assert(dev_con != NULL); diff --git a/drivers/io/io_fip.h b/drivers/io/io_fip.h deleted file mode 100644 index 56dd1e0f..00000000 --- a/drivers/io/io_fip.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014 ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __IO_FIP_H__ -#define __IO_FIP_H__ - -int register_io_dev_fip(struct io_dev_connector **dev_con); - -#endif /* __IO_FIP_H__ */ diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c index 40b8e9ab..a40e6120 100644 --- a/drivers/io/io_memmap.c +++ b/drivers/io/io_memmap.c @@ -29,10 +29,10 @@ */ #include <assert.h> +#include <debug.h> +#include <io_driver.h> +#include <io_storage.h> #include <string.h> -#include "io_storage.h" -#include "io_driver.h" -#include "debug.h" /* As we need to be able to keep state for seek, only one file can be open * at a time. Make this a structure and point to the entity->info. When we @@ -45,28 +45,28 @@ typedef struct { int in_use; size_t base; size_t file_pos; -} file_state; +} file_state_t; -static file_state current_file = {0}; +static file_state_t current_file = {0}; /* Identify the device type as memmap */ -io_type device_type_memmap(void) +io_type_t device_type_memmap(void) { return IO_TYPE_MEMMAP; } /* Memmap device functions */ -static int memmap_dev_open(void *spec, struct io_dev_info **dev_info); -static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); -static int memmap_block_seek(struct io_entity *entity, int mode, +static int memmap_dev_open(void *spec, io_dev_info_t **dev_info); +static int memmap_block_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity); +static int memmap_block_seek(io_entity_t *entity, int mode, ssize_t offset); -static int memmap_block_read(struct io_entity *entity, void *buffer, +static int memmap_block_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read); -static int memmap_block_write(struct io_entity *entity, const void *buffer, +static int memmap_block_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written); -static int memmap_block_close(struct io_entity *entity); -static int memmap_dev_close(struct io_dev_info *dev_info); +static int memmap_block_close(io_entity_t *entity); +static int memmap_dev_close(io_dev_info_t *dev_info); static struct io_dev_connector memmap_dev_connector = { @@ -95,7 +95,7 @@ static struct io_dev_info memmap_dev_info = { /* Open a connection to the memmap device */ static int memmap_dev_open(void *spec __attribute__((unused)), - struct io_dev_info **dev_info) + io_dev_info_t **dev_info) { assert(dev_info != NULL); *dev_info = &memmap_dev_info; @@ -106,7 +106,7 @@ static int memmap_dev_open(void *spec __attribute__((unused)), /* Close a connection to the memmap device */ -static int memmap_dev_close(struct io_dev_info *dev_info) +static int memmap_dev_close(io_dev_info_t *dev_info) { /* NOP */ /* TODO: Consider tracking open files and cleaning them up here */ @@ -116,11 +116,11 @@ static int memmap_dev_close(struct io_dev_info *dev_info) /* Open a file on the memmap device */ /* TODO: Can we do any sensible limit checks on requested memory */ -static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity) +static int memmap_block_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity) { int result = IO_FAIL; - const io_block_spec *block_spec = (io_block_spec *)spec; + const io_block_spec_t *block_spec = (io_block_spec_t *)spec; /* Since we need to track open state for seek() we only allow one open * spec at a time. When we have dynamic memory we can malloc and set @@ -146,7 +146,7 @@ static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, /* Seek to a particular file offset on the memmap device */ -static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) +static int memmap_block_seek(io_entity_t *entity, int mode, ssize_t offset) { int result = IO_FAIL; @@ -155,7 +155,7 @@ static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) assert(entity != NULL); /* TODO: can we do some basic limit checks on seek? */ - ((file_state *)entity->info)->file_pos = offset; + ((file_state_t *)entity->info)->file_pos = offset; result = IO_SUCCESS; } else { result = IO_FAIL; @@ -166,16 +166,16 @@ static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) /* Read data from a file on the memmap device */ -static int memmap_block_read(struct io_entity *entity, void *buffer, +static int memmap_block_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read) { - file_state *fp; + file_state_t *fp; assert(entity != NULL); assert(buffer != NULL); assert(length_read != NULL); - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; memcpy(buffer, (void *)(fp->base + fp->file_pos), length); @@ -188,16 +188,16 @@ static int memmap_block_read(struct io_entity *entity, void *buffer, /* Write data to a file on the memmap device */ -static int memmap_block_write(struct io_entity *entity, const void *buffer, +static int memmap_block_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written) { - file_state *fp; + file_state_t *fp; assert(entity != NULL); assert(buffer != NULL); assert(length_written != NULL); - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; memcpy((void *)(fp->base + fp->file_pos), buffer, length); @@ -211,7 +211,7 @@ static int memmap_block_write(struct io_entity *entity, const void *buffer, /* Close a file on the memmap device */ -static int memmap_block_close(struct io_entity *entity) +static int memmap_block_close(io_entity_t *entity) { assert(entity != NULL); @@ -227,7 +227,7 @@ static int memmap_block_close(struct io_entity *entity) /* Exported functions */ /* Register the memmap driver with the IO abstraction */ -int register_io_dev_memmap(struct io_dev_connector **dev_con) +int register_io_dev_memmap(io_dev_connector_t **dev_con) { int result = IO_FAIL; assert(dev_con != NULL); diff --git a/drivers/io/io_semihosting.c b/drivers/io/io_semihosting.c index 14ec687c..a37693df 100644 --- a/drivers/io/io_semihosting.c +++ b/drivers/io/io_semihosting.c @@ -29,14 +29,14 @@ */ #include <assert.h> -#include "io_storage.h" -#include "io_driver.h" -#include "semihosting.h" +#include <io_driver.h> +#include <io_storage.h> +#include <semihosting.h> /* Identify the device type as semihosting */ -static io_type device_type_sh(void) +static io_type_t device_type_sh(void) { return IO_TYPE_SEMIHOSTING; } @@ -44,16 +44,16 @@ static io_type device_type_sh(void) /* Semi-hosting functions, device info and handle */ -static int sh_dev_open(void *spec, struct io_dev_info **dev_info); -static int sh_file_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); -static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset); -static int sh_file_len(struct io_entity *entity, size_t *length); -static int sh_file_read(struct io_entity *entity, void *buffer, size_t length, +static int sh_dev_open(void *spec, io_dev_info_t **dev_info); +static int sh_file_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity); +static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset); +static int sh_file_len(io_entity_t *entity, size_t *length); +static int sh_file_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read); -static int sh_file_write(struct io_entity *entity, const void *buffer, +static int sh_file_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written); -static int sh_file_close(struct io_entity *entity); +static int sh_file_close(io_entity_t *entity); static struct io_dev_connector sh_dev_connector = { .dev_open = sh_dev_open @@ -80,7 +80,7 @@ static struct io_dev_info sh_dev_info = { /* Open a connection to the semi-hosting device */ -static int sh_dev_open(void *spec __unused, struct io_dev_info **dev_info) +static int sh_dev_open(void *spec __unused, io_dev_info_t **dev_info) { int result = IO_SUCCESS; assert(dev_info != NULL); @@ -90,12 +90,12 @@ static int sh_dev_open(void *spec __unused, struct io_dev_info **dev_info) /* Open a file on the semi-hosting device */ -static int sh_file_open(struct io_dev_info *dev_info __attribute__((unused)), - const void *spec, struct io_entity *entity) +static int sh_file_open(io_dev_info_t *dev_info __attribute__((unused)), + const void *spec, io_entity_t *entity) { int result = IO_FAIL; long sh_result = -1; - const io_file_spec *file_spec = (io_file_spec *)spec; + const io_file_spec_t *file_spec = (io_file_spec_t *)spec; assert(file_spec != NULL); assert(entity != NULL); @@ -113,7 +113,7 @@ static int sh_file_open(struct io_dev_info *dev_info __attribute__((unused)), /* Seek to a particular file offset on the semi-hosting device */ -static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset) +static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset) { int result = IO_FAIL; long file_handle, sh_result; @@ -131,7 +131,7 @@ static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset) /* Return the size of a file on the semi-hosting device */ -static int sh_file_len(struct io_entity *entity, size_t *length) +static int sh_file_len(io_entity_t *entity, size_t *length) { int result = IO_FAIL; @@ -151,7 +151,7 @@ static int sh_file_len(struct io_entity *entity, size_t *length) /* Read data from a file on the semi-hosting device */ -static int sh_file_read(struct io_entity *entity, void *buffer, size_t length, +static int sh_file_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read) { int result = IO_FAIL; @@ -178,7 +178,7 @@ static int sh_file_read(struct io_entity *entity, void *buffer, size_t length, /* Write data to a file on the semi-hosting device */ -static int sh_file_write(struct io_entity *entity, const void *buffer, +static int sh_file_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written) { int result = IO_FAIL; @@ -205,7 +205,7 @@ static int sh_file_write(struct io_entity *entity, const void *buffer, /* Close a file on the semi-hosting device */ -static int sh_file_close(struct io_entity *entity) +static int sh_file_close(io_entity_t *entity) { int result = IO_FAIL; long sh_result = -1; @@ -226,7 +226,7 @@ static int sh_file_close(struct io_entity *entity) /* Exported functions */ /* Register the semi-hosting driver with the IO abstraction */ -int register_io_dev_sh(struct io_dev_connector **dev_con) +int register_io_dev_sh(io_dev_connector_t **dev_con) { int result = IO_FAIL; assert(dev_con != NULL); diff --git a/drivers/io/io_semihosting.h b/drivers/io/io_semihosting.h deleted file mode 100644 index 7dc632dd..00000000 --- a/drivers/io/io_semihosting.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __IO_SH_H__ -#define __IO_SH_H__ - -int register_io_dev_sh(struct io_dev_connector **dev_con); - -#endif /* __IO_SH_H__ */ diff --git a/drivers/power/fvp_pwrc.c b/drivers/power/fvp_pwrc.c deleted file mode 100644 index 3916c048..00000000 --- a/drivers/power/fvp_pwrc.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <string.h> -#include <stdio.h> -#include <errno.h> -#include <assert.h> -#include <arch_helpers.h> -#include <platform.h> -#include <fvp_pwrc.h> -#include <bakery_lock.h> - -/* - * TODO: Someday there will be a generic power controller api. At the moment - * each platform has its own pwrc so just exporting functions is fine. - */ -static bakery_lock pwrc_lock __attribute__ ((section("tzfw_coherent_mem"))); - -unsigned int fvp_pwrc_get_cpu_wkr(unsigned long mpidr) -{ - unsigned int rc = 0; - bakery_lock_get(mpidr, &pwrc_lock); - mmio_write_32(PWRC_BASE + PSYSR_OFF, (unsigned int) mpidr); - rc = PSYSR_WK(mmio_read_32(PWRC_BASE + PSYSR_OFF)); - bakery_lock_release(mpidr, &pwrc_lock); - return rc; -} - -unsigned int fvp_pwrc_read_psysr(unsigned long mpidr) -{ - unsigned int rc = 0; - bakery_lock_get(mpidr, &pwrc_lock); - mmio_write_32(PWRC_BASE + PSYSR_OFF, (unsigned int) mpidr); - rc = mmio_read_32(PWRC_BASE + PSYSR_OFF); - bakery_lock_release(mpidr, &pwrc_lock); - return rc; -} - -void fvp_pwrc_write_pponr(unsigned long mpidr) -{ - bakery_lock_get(mpidr, &pwrc_lock); - mmio_write_32(PWRC_BASE + PPONR_OFF, (unsigned int) mpidr); - bakery_lock_release(mpidr, &pwrc_lock); -} - -void fvp_pwrc_write_ppoffr(unsigned long mpidr) -{ - bakery_lock_get(mpidr, &pwrc_lock); - mmio_write_32(PWRC_BASE + PPOFFR_OFF, (unsigned int) mpidr); - bakery_lock_release(mpidr, &pwrc_lock); -} - -void fvp_pwrc_set_wen(unsigned long mpidr) -{ - bakery_lock_get(mpidr, &pwrc_lock); - mmio_write_32(PWRC_BASE + PWKUPR_OFF, - (unsigned int) (PWKUPR_WEN | mpidr)); - bakery_lock_release(mpidr, &pwrc_lock); -} - -void fvp_pwrc_clr_wen(unsigned long mpidr) -{ - bakery_lock_get(mpidr, &pwrc_lock); - mmio_write_32(PWRC_BASE + PWKUPR_OFF, - (unsigned int) mpidr); - bakery_lock_release(mpidr, &pwrc_lock); -} - -void fvp_pwrc_write_pcoffr(unsigned long mpidr) -{ - bakery_lock_get(mpidr, &pwrc_lock); - mmio_write_32(PWRC_BASE + PCOFFR_OFF, (unsigned int) mpidr); - bakery_lock_release(mpidr, &pwrc_lock); -} - -/* Nothing else to do here apart from initializing the lock */ -int fvp_pwrc_setup(void) -{ - bakery_lock_init(&pwrc_lock); - return 0; -} - - - diff --git a/drivers/power/fvp_pwrc.h b/drivers/power/fvp_pwrc.h deleted file mode 100644 index f600a241..00000000 --- a/drivers/power/fvp_pwrc.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __FVP_PWRC_H__ -#define __FVP_PWRC_H__ - -/* FVP Power controller register offset etc */ -#define PPOFFR_OFF 0x0 -#define PPONR_OFF 0x4 -#define PCOFFR_OFF 0x8 -#define PWKUPR_OFF 0xc -#define PSYSR_OFF 0x10 - -#define PWKUPR_WEN (1ull << 31) - -#define PSYSR_AFF_L2 (1 << 31) -#define PSYSR_AFF_L1 (1 << 30) -#define PSYSR_AFF_L0 (1 << 29) -#define PSYSR_WEN (1 << 28) -#define PSYSR_PC (1 << 27) -#define PSYSR_PP (1 << 26) - -#define PSYSR_WK_SHIFT 24 -#define PSYSR_WK_MASK 0x3 -#define PSYSR_WK(x) (x >> PSYSR_WK_SHIFT) & PSYSR_WK_MASK - -#define WKUP_COLD 0x0 -#define WKUP_RESET 0x1 -#define WKUP_PPONR 0x2 -#define WKUP_GICREQ 0x3 - -#define PSYSR_INVALID 0xffffffff - -#ifndef __ASSEMBLY__ - -/******************************************************************************* - * Function & variable prototypes - ******************************************************************************/ -extern int fvp_pwrc_setup(void); -extern void fvp_pwrc_write_pcoffr(unsigned long); -extern void fvp_pwrc_write_ppoffr(unsigned long); -extern void fvp_pwrc_write_pponr(unsigned long); -extern void fvp_pwrc_set_wen(unsigned long); -extern void fvp_pwrc_clr_wen(unsigned long); -extern unsigned int fvp_pwrc_read_psysr(unsigned long); -extern unsigned int fvp_pwrc_get_cpu_wkr(unsigned long); - -#endif /*__ASSEMBLY__*/ - -#endif /* __FVP_PWRC_H__ */ |