summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuinn Jensen <quinn.jensen@freescale.com>2007-10-24 21:22:06 -0600
committerQuinn Jensen <quinn.jensen@freescale.com>2007-10-24 21:22:06 -0600
commit19f48fbe00e75572b2e28fd031bed5d0fa0d73f6 (patch)
treed618d93a7a432b7853b035cc1406cd3b1cb051bb
parent28e0402d101282efefd3d3310119b4662908bc4b (diff)
CR ENGR00043063: platform device for scc added
Patch for CR ENGR00043063: add platform device support for scc. Applies to linux 2.6.22 kernel for MX platforms. http://www.bitshrine.org/gpp/linux-2.6.22-mx-CR-ENGR00043063-platform-device-for-scc-ad.patch
-rw-r--r--arch/arm/mach-mx27/devices.c18
-rw-r--r--arch/arm/mach-mx3/devices.c18
-rw-r--r--drivers/mxc/security/mxc_scc.c69
3 files changed, 63 insertions, 42 deletions
diff --git a/arch/arm/mach-mx27/devices.c b/arch/arm/mach-mx27/devices.c
index e22020206c83..0df427998b7c 100644
--- a/arch/arm/mach-mx27/devices.c
+++ b/arch/arm/mach-mx27/devices.c
@@ -122,7 +122,24 @@ static inline void mxc_init_wdt(void)
{
}
#endif
+/*!
+ * This is platform device structure for adding SCC
+ */
+#if defined(CONFIG_MXC_SECURITY_SCC) || defined(CONFIG_MXC_SECURITY_SCC_MODULE)
+static struct platform_device mxc_scc_device = {
+ .name = "mxc_scc",
+ .id = 0,
+};
+static void mxc_init_scc(void)
+{
+ platform_device_register(&mxc_scc_device);
+}
+#else
+static inline void mxc_init_scc(void)
+{
+}
+#endif
/* MMC device data */
#if defined(CONFIG_MMC_MXC) || defined(CONFIG_MMC_MXC_MODULE)
@@ -588,6 +605,7 @@ static int __init mxc_init_devices(void)
mxc_init_spi();
mxc_init_i2c();
mxc_init_rtc();
+ mxc_init_scc();
mxc_init_owire();
mxc_init_vpu();
#ifndef CONFIG_MX27_DPTC
diff --git a/arch/arm/mach-mx3/devices.c b/arch/arm/mach-mx3/devices.c
index 74205972ba67..51ff2253cef5 100644
--- a/arch/arm/mach-mx3/devices.c
+++ b/arch/arm/mach-mx3/devices.c
@@ -335,7 +335,24 @@ static inline void mxc_init_ir(void)
{
}
#endif
+/*!
+ * This is platform device structure for adding SCC
+ */
+#if defined(CONFIG_MXC_SECURITY_SCC) || defined(CONFIG_MXC_SECURITY_SCC_MODULE)
+static struct platform_device mxc_scc_device = {
+ .name = "mxc_scc",
+ .id = 0,
+};
+static void mxc_init_scc(void)
+{
+ platform_device_register(&mxc_scc_device);
+}
+#else
+static inline void mxc_init_scc(void)
+{
+}
+#endif
/* MMC device data */
#if defined(CONFIG_MMC_MXC) || defined(CONFIG_MMC_MXC_MODULE)
@@ -863,6 +880,7 @@ static int __init mxc_init_devices(void)
mxc_init_rtc();
mxc_init_owire();
mxc_init_pcmcia();
+ mxc_init_scc();
mxc_init_hmp4e();
mxc_init_dma();
#ifndef CONFIG_MXC_DPTC
diff --git a/drivers/mxc/security/mxc_scc.c b/drivers/mxc/security/mxc_scc.c
index 942ef7a52a28..1d9a782bbe3f 100644
--- a/drivers/mxc/security/mxc_scc.c
+++ b/drivers/mxc/security/mxc_scc.c
@@ -189,18 +189,34 @@ static int mxc_scc_resume(struct platform_device *pdev)
return 0;
}
+static int mxc_scc_probe(struct platform_device *pdev);
+static int mxc_scc_remove(struct platform_device *pdev);
/*!
* This structure contains pointers to the power management callback functions.
*/
static struct platform_driver mxc_scc_driver = {
.driver = {
.name = "mxc_scc",
+ .bus = &platform_bus_type,
+ .owner = THIS_MODULE,
},
+ .probe = mxc_scc_probe,
+ .remove = mxc_scc_remove,
.suspend = mxc_scc_suspend,
.resume = mxc_scc_resume,
};
#undef static
+/*!
+ * Registering the SCC driver
+ *
+ */
+static int scc_init(void)
+{
+ int ret;
+ ret = platform_driver_register(&mxc_scc_driver);
+ return ret;
+}
/******************************************************************************
*
@@ -209,7 +225,7 @@ static struct platform_driver mxc_scc_driver = {
*****************************************************************************/
/*****************************************************************************/
-/* fn scc_init() */
+/* fn mxc_scc_probe() */
/*****************************************************************************/
/*!
* Initialize the driver at boot time or module load time.
@@ -227,23 +243,15 @@ static struct platform_driver mxc_scc_driver = {
*
* The availability fuse may be checked, depending on platform.
*/
-static int scc_init(void)
+static int mxc_scc_probe(struct platform_device *pdev)
{
uint32_t smn_status;
int i;
- int ret;
int return_value = -EIO; /* assume error */
/* Enable the SCC clocks */
pr_debug(KERN_ALERT "SCC: Enabling the SCC CLK ... \n");
scc_clk = clk_get(NULL, "scc_clk");
clk_enable(scc_clk);
-
- ret = platform_driver_register(&mxc_scc_driver);
-
- if (ret != 0) {
- return return_value;
- }
-
if (scc_availability == SCC_STATUS_INITIAL) {
/* Set this until we get an initial reading */
@@ -360,7 +368,7 @@ static int scc_init(void)
SCC_STATUS_FAILED) ? "FAILED" : "UNKNOWN");
return return_value;
-} /* scc_init */
+} /* mxc_scc_probe */
/*****************************************************************************/
/* fn scc_cleanup() */
@@ -379,11 +387,10 @@ static int scc_init(void)
* pointers). Deregister the interrupt handler(s). Unmap SCC registers.
*
*/
-static void scc_cleanup(void)
+static int mxc_scc_remove(struct platform_device *pdev)
{
int i;
- platform_driver_unregister(&mxc_scc_driver);
/* Mark the driver / SCC as unusable. */
scc_availability = SCC_STATUS_UNIMPLEMENTED;
@@ -423,21 +430,20 @@ static void scc_cleanup(void)
#endif
}
pr_debug("SCC driver cleaned up.\n");
+ return 0;
-} /* scc_cleanup */
+} /* mxc_scc_remove */
+
+static void scc_cleanup(void)
+{
+ platform_driver_unregister(&mxc_scc_driver);
+}
/*****************************************************************************/
/* fn scc_get_configuration() */
/*****************************************************************************/
scc_config_t *scc_get_configuration(void)
{
- /*
- * If some other driver calls scc before the kernel does, make sure that
- * this driver's initialization is performed.
- */
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
/**
* If there is no SCC, yet the driver exists, the value -1 will be in
@@ -454,9 +460,6 @@ scc_return_t scc_zeroize_memories(void)
scc_return_t return_status = SCC_RET_FAIL;
uint32_t status;
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
if (scc_availability == SCC_STATUS_OK) {
unsigned long irq_flags; /* for IRQ save/restore */
@@ -510,9 +513,6 @@ scc_crypt(unsigned long count_in_bytes, uint8_t * data_in,
{
scc_return_t return_code = SCC_RET_FAIL;
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
(void)scc_update_state(); /* in case no interrupt line from SMN */
@@ -641,9 +641,6 @@ scc_crypt(unsigned long count_in_bytes, uint8_t * data_in,
void scc_set_sw_alarm(void)
{
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
/* Update scc_availability based on current SMN status. This might
* perform callbacks.
@@ -675,9 +672,6 @@ scc_return_t scc_monitor_security_failure(void callback_func(void))
scc_return_t return_status = SCC_RET_TOO_MANY_FUNCTIONS;
int function_stored = FALSE;
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
/* Acquire lock of callbacks table. Could be spin_lock_irq() if this
* routine were just called from base (not interrupt) level
@@ -716,9 +710,6 @@ void scc_stop_monitoring_security_failure(void callback_func(void))
unsigned long irq_flags; /* for IRQ save/restore */
int i;
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
/* Acquire lock of callbacks table. Could be spin_lock_irq() if this
* routine were just called from base (not interrupt) level
@@ -748,9 +739,6 @@ scc_return_t scc_read_register(int register_offset, uint32_t * value)
uint32_t smn_status;
uint32_t scm_status;
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
/* First layer of protection -- completely unaccessible SCC */
if (scc_availability != SCC_STATUS_UNIMPLEMENTED) {
@@ -789,9 +777,6 @@ scc_return_t scc_write_register(int register_offset, uint32_t value)
uint32_t smn_status;
uint32_t scm_status;
- if (scc_availability == SCC_STATUS_INITIAL) {
- scc_init();
- }
/* First layer of protection -- completely unaccessible SCC */
if (scc_availability != SCC_STATUS_UNIMPLEMENTED) {