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>
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}
926928EXPORT_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
9541060void ep93xx_restart (enum reboot_mode mode , const char * cmd )
0 commit comments