Skip to content

Commit b19e11f

Browse files
bigguinessolofj
authored andcommitted
ARM: ep93xx: use soc bus
Use the soc bus to report the silicon revision and Maverick Key. Both are not currently exposed to the user. In addition, fill in the SoC family and machine for completeness. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: Ryan Mallon <rmallon@gmail.com> Signed-off-by: Ryan Mallon <rmallon@gmail.com> Cc: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Olof Johansson <olof@lixom.net>
1 parent 3a71ae4 commit b19e11f

3 files changed

Lines changed: 110 additions & 2 deletions

File tree

‎arch/arm/mach-ep93xx/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ menu "Cirrus EP93xx Implementation Options"
55
config EP93XX_SOC_COMMON
66
bool
77
default y
8+
select SOC_BUS
89
select LEDS_GPIO_REGISTER
910

1011
config CRUNCH

‎arch/arm/mach-ep93xx/core.c‎

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/platform_device.h>
2222
#include <linux/interrupt.h>
2323
#include <linux/dma-mapping.h>
24+
#include <linux/sys_soc.h>
2425
#include <linux/timex.h>
2526
#include <linux/irq.h>
2627
#include <linux/io.h>
@@ -44,6 +45,7 @@
4445
#include <linux/platform_data/spi-ep93xx.h>
4546
#include <mach/gpio-ep93xx.h>
4647

48+
#include <asm/mach/arch.h>
4749
#include <asm/mach/map.h>
4850
#include <asm/mach/time.h>
4951

@@ -925,8 +927,108 @@ void ep93xx_ide_release_gpio(struct platform_device *pdev)
925927
}
926928
EXPORT_SYMBOL(ep93xx_ide_release_gpio);
927929

928-
void __init ep93xx_init_devices(void)
930+
/*************************************************************************
931+
* EP93xx Security peripheral
932+
*************************************************************************/
933+
934+
/*
935+
* The Maverick Key is 256 bits of micro fuses blown at the factory during
936+
* manufacturing to uniquely identify a part.
937+
*
938+
* See: http://arm.cirrus.com/forum/viewtopic.php?t=486&highlight=maverick+key
939+
*/
940+
#define EP93XX_SECURITY_REG(x) (EP93XX_SECURITY_BASE + (x))
941+
#define EP93XX_SECURITY_SECFLG EP93XX_SECURITY_REG(0x2400)
942+
#define EP93XX_SECURITY_FUSEFLG EP93XX_SECURITY_REG(0x2410)
943+
#define EP93XX_SECURITY_UNIQID EP93XX_SECURITY_REG(0x2440)
944+
#define EP93XX_SECURITY_UNIQCHK EP93XX_SECURITY_REG(0x2450)
945+
#define EP93XX_SECURITY_UNIQVAL EP93XX_SECURITY_REG(0x2460)
946+
#define EP93XX_SECURITY_SECID1 EP93XX_SECURITY_REG(0x2500)
947+
#define EP93XX_SECURITY_SECID2 EP93XX_SECURITY_REG(0x2504)
948+
#define EP93XX_SECURITY_SECCHK1 EP93XX_SECURITY_REG(0x2520)
949+
#define EP93XX_SECURITY_SECCHK2 EP93XX_SECURITY_REG(0x2524)
950+
#define EP93XX_SECURITY_UNIQID2 EP93XX_SECURITY_REG(0x2700)
951+
#define EP93XX_SECURITY_UNIQID3 EP93XX_SECURITY_REG(0x2704)
952+
#define EP93XX_SECURITY_UNIQID4 EP93XX_SECURITY_REG(0x2708)
953+
#define EP93XX_SECURITY_UNIQID5 EP93XX_SECURITY_REG(0x270c)
954+
955+
static char ep93xx_soc_id[33];
956+
957+
static const char __init *ep93xx_get_soc_id(void)
929958
{
959+
unsigned int id, id2, id3, id4, id5;
960+
961+
if (__raw_readl(EP93XX_SECURITY_UNIQVAL) != 1)
962+
return "bad Hamming code";
963+
964+
id = __raw_readl(EP93XX_SECURITY_UNIQID);
965+
id2 = __raw_readl(EP93XX_SECURITY_UNIQID2);
966+
id3 = __raw_readl(EP93XX_SECURITY_UNIQID3);
967+
id4 = __raw_readl(EP93XX_SECURITY_UNIQID4);
968+
id5 = __raw_readl(EP93XX_SECURITY_UNIQID5);
969+
970+
if (id != id2)
971+
return "invalid";
972+
973+
snprintf(ep93xx_soc_id, sizeof(ep93xx_soc_id),
974+
"%08x%08x%08x%08x", id2, id3, id4, id5);
975+
976+
return ep93xx_soc_id;
977+
}
978+
979+
static const char __init *ep93xx_get_soc_rev(void)
980+
{
981+
int rev = ep93xx_chip_revision();
982+
983+
switch (rev) {
984+
case EP93XX_CHIP_REV_D0:
985+
return "D0";
986+
case EP93XX_CHIP_REV_D1:
987+
return "D1";
988+
case EP93XX_CHIP_REV_E0:
989+
return "E0";
990+
case EP93XX_CHIP_REV_E1:
991+
return "E1";
992+
case EP93XX_CHIP_REV_E2:
993+
return "E2";
994+
default:
995+
return "unknown";
996+
}
997+
}
998+
999+
static const char __init *ep93xx_get_machine_name(void)
1000+
{
1001+
return kasprintf(GFP_KERNEL,"%s", machine_desc->name);
1002+
}
1003+
1004+
static struct device __init *ep93xx_init_soc(void)
1005+
{
1006+
struct soc_device_attribute *soc_dev_attr;
1007+
struct soc_device *soc_dev;
1008+
1009+
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
1010+
if (!soc_dev_attr)
1011+
return NULL;
1012+
1013+
soc_dev_attr->machine = ep93xx_get_machine_name();
1014+
soc_dev_attr->family = "Cirrus Logic EP93xx";
1015+
soc_dev_attr->revision = ep93xx_get_soc_rev();
1016+
soc_dev_attr->soc_id = ep93xx_get_soc_id();
1017+
1018+
soc_dev = soc_device_register(soc_dev_attr);
1019+
if (IS_ERR(soc_dev)) {
1020+
kfree(soc_dev_attr->machine);
1021+
kfree(soc_dev_attr);
1022+
return NULL;
1023+
}
1024+
1025+
return soc_device_to_device(soc_dev);
1026+
}
1027+
1028+
struct device __init *ep93xx_init_devices(void)
1029+
{
1030+
struct device *parent;
1031+
9301032
/* Disallow access to MaverickCrunch initially */
9311033
ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA);
9321034

@@ -937,6 +1039,8 @@ void __init ep93xx_init_devices(void)
9371039
EP93XX_SYSCON_DEVCFG_GONIDE |
9381040
EP93XX_SYSCON_DEVCFG_HONIDE);
9391041

1042+
parent = ep93xx_init_soc();
1043+
9401044
/* Get the GPIO working early, other devices need it */
9411045
platform_device_register(&ep93xx_gpio_device);
9421046

@@ -949,6 +1053,8 @@ void __init ep93xx_init_devices(void)
9491053
platform_device_register(&ep93xx_wdt_device);
9501054

9511055
gpio_led_register_device(-1, &ep93xx_led_data);
1056+
1057+
return parent;
9521058
}
9531059

9541060
void ep93xx_restart(enum reboot_mode mode, const char *cmd)

‎arch/arm/mach-ep93xx/include/mach/platform.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/reboot.h>
88

9+
struct device;
910
struct i2c_gpio_platform_data;
1011
struct i2c_board_info;
1112
struct spi_board_info;
@@ -54,7 +55,7 @@ void ep93xx_register_ide(void);
5455
int ep93xx_ide_acquire_gpio(struct platform_device *pdev);
5556
void ep93xx_ide_release_gpio(struct platform_device *pdev);
5657

57-
void ep93xx_init_devices(void);
58+
struct device *ep93xx_init_devices(void);
5859
extern void ep93xx_timer_init(void);
5960

6061
void ep93xx_restart(enum reboot_mode, const char *);

0 commit comments

Comments
 (0)