Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5724c52f authored by Olof Johansson's avatar Olof Johansson
Browse files

Merge tag 'fw-for-3.10' of git://github.com/broadcom/bcm11351 into next/firmware

From Christian Daudt:
l2cache driver for bcm281xx SoC

* tag 'fw-for-3.10' of git://github.com/broadcom/bcm11351

:
  ARM: bcm281xx: Add DT support for SMC handler
  ARM: bcm281xx: Add L2 cache enable code

Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parents a1faef96 7f6c62e2
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
Broadcom Secure Monitor Bounce buffer
-----------------------------------------------------
This binding defines the location of the bounce buffer
used for non-secure to secure communications.

Required properties:
- compatible : "bcm,kona-smc"
- reg : Location and size of bounce buffer

Example:
	smc@0x3404c000 {
		compatible = "bcm,bcm11351-smc", "bcm,kona-smc";
		reg = <0x3404c000 0x400>; //1 KiB in SRAM
	};
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@
		      <0x3ff00100 0x100>;
	};

	smc@0x3404c000 {
		compatible = "bcm,bcm11351-smc", "bcm,kona-smc";
		reg = <0x3404c000 0x400>; //1 KiB in SRAM
	};

	uart@3e000000 {
		compatible = "bcm,bcm11351-dw-apb-uart", "snps,dw-apb-uart";
		status = "disabled";
+3 −1
Original line number Diff line number Diff line
@@ -10,4 +10,6 @@
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

obj-$(CONFIG_ARCH_BCM) := board_bcm.o
obj-$(CONFIG_ARCH_BCM)		:= board_bcm.o bcm_kona_smc.o bcm_kona_smc_asm.o
plus_sec := $(call as-instr,.arch_extension sec,+sec)
AFLAGS_bcm_kona_smc_asm.o	:=-Wa,-march=armv7-a$(plus_sec)
+118 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 Broadcom Corporation
 *
 * 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 version 2.
 *
 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
 * kind, whether express or implied; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <stdarg.h>
#include <linux/smp.h>
#include <linux/io.h>
#include <linux/ioport.h>

#include <asm/cacheflush.h>
#include <linux/of_address.h>

#include "bcm_kona_smc.h"

struct secure_bridge_data {
	void __iomem *bounce;		/* virtual address */
	u32 __iomem buffer_addr;	/* physical address */
	int initialized;
} bridge_data;

struct bcm_kona_smc_data {
	unsigned service_id;
	unsigned arg0;
	unsigned arg1;
	unsigned arg2;
	unsigned arg3;
};

static const struct of_device_id bcm_kona_smc_ids[] __initconst = {
	{.compatible = "bcm,kona-smc"},
	{},
};

/* Map in the bounce area */
void bcm_kona_smc_init(void)
{
	struct device_node *node;

	/* Read buffer addr and size from the device tree node */
	node = of_find_matching_node(NULL, bcm_kona_smc_ids);
	BUG_ON(!node);

	/* Don't care about size or flags of the DT node */
	bridge_data.buffer_addr =
		be32_to_cpu(*of_get_address(node, 0, NULL, NULL));
	BUG_ON(!bridge_data.buffer_addr);

	bridge_data.bounce = of_iomap(node, 0);
	BUG_ON(!bridge_data.bounce);

	bridge_data.initialized = 1;

	pr_info("Secure API initialized!\n");
}

/* __bcm_kona_smc() should only run on CPU 0, with pre-emption disabled */
static void __bcm_kona_smc(void *info)
{
	struct bcm_kona_smc_data *data = info;
	u32 *args = bridge_data.bounce;
	int rc = 0;

	/* Must run on CPU 0 */
	BUG_ON(smp_processor_id() != 0);

	/* Check map in the bounce area */
	BUG_ON(!bridge_data.initialized);

	/* Copy one 32 bit word into the bounce area */
	args[0] = data->arg0;
	args[1] = data->arg1;
	args[2] = data->arg2;
	args[3] = data->arg3;

	/* Flush caches for input data passed to Secure Monitor */
	if (data->service_id != SSAPI_BRCM_START_VC_CORE)
		flush_cache_all();

	/* Trap into Secure Monitor */
	rc = bcm_kona_smc_asm(data->service_id, bridge_data.buffer_addr);

	if (rc != SEC_ROM_RET_OK)
		pr_err("Secure Monitor call failed (0x%x)!\n", rc);
}

unsigned bcm_kona_smc(unsigned service_id, unsigned arg0, unsigned arg1,
		  unsigned arg2, unsigned arg3)
{
	struct bcm_kona_smc_data data;

	data.service_id = service_id;
	data.arg0 = arg0;
	data.arg1 = arg1;
	data.arg2 = arg2;
	data.arg3 = arg3;

	/*
	 * Due to a limitation of the secure monitor, we must use the SMP
	 * infrastructure to forward all secure monitor calls to Core 0.
	 */
	if (get_cpu() != 0)
		smp_call_function_single(0, __bcm_kona_smc, (void *)&data, 1);
	else
		__bcm_kona_smc(&data);

	put_cpu();

	return 0;
}
+80 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 Broadcom Corporation
 *
 * 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 version 2.
 *
 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
 * kind, whether express or implied; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef BCM_KONA_SMC_H
#define BCM_KONA_SMC_H

#include <linux/types.h>
#define FLAGS	(SEC_ROM_ICACHE_ENABLE_MASK | SEC_ROM_DCACHE_ENABLE_MASK | \
			SEC_ROM_IRQ_ENABLE_MASK | SEC_ROM_FIQ_ENABLE_MASK)

/*!
 * Definitions for IRQ & FIQ Mask for ARM
 */

#define FIQ_IRQ_MASK						0xC0
#define FIQ_MASK						0x40
#define IRQ_MASK						0x80

/*!
 * Secure Mode FLAGs
 */

/* When set, enables ICache within the secure mode */
#define SEC_ROM_ICACHE_ENABLE_MASK                        0x00000001

/* When set, enables DCache within the secure mode */
#define SEC_ROM_DCACHE_ENABLE_MASK                        0x00000002

/* When set, enables IRQ within the secure mode */
#define SEC_ROM_IRQ_ENABLE_MASK                           0x00000004

/* When set, enables FIQ within the secure mode */
#define SEC_ROM_FIQ_ENABLE_MASK                           0x00000008

/* When set, enables Unified L2 cache within the secure mode */
#define SEC_ROM_UL2_CACHE_ENABLE_MASK                     0x00000010

/* Broadcom Secure Service API Service IDs */
#define SSAPI_DORMANT_ENTRY_SERV                          0x01000000
#define SSAPI_PUBLIC_OTP_SERV                             0x01000001
#define SSAPI_ENABLE_L2_CACHE                             0x01000002
#define SSAPI_DISABLE_L2_CACHE                            0x01000003
#define SSAPI_WRITE_SCU_STATUS                            0x01000004
#define SSAPI_WRITE_PWR_GATE                              0x01000005

/* Broadcom Secure Service API Return Codes */
#define SEC_ROM_RET_OK			0x00000001
#define SEC_ROM_RET_FAIL		0x00000009

#define SSAPI_RET_FROM_INT_SERV		0x4
#define SEC_EXIT_NORMAL			0x1

#define SSAPI_ROW_AES			0x0E000006
#define SSAPI_BRCM_START_VC_CORE	0x0E000008

#ifndef	__ASSEMBLY__
extern void bcm_kona_smc_init(void);

extern unsigned bcm_kona_smc(unsigned service_id,
			     unsigned arg0,
			     unsigned arg1,
			     unsigned arg2,
			     unsigned arg3);

extern int bcm_kona_smc_asm(u32 service_id,
			    u32 buffer_addr);

#endif	/* __ASSEMBLY__ */

#endif /* BCM_KONA_SMC_H */
Loading