How to do Call Poweroff from Linux Driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to do Call Poweroff from Linux Driver

Jump to solution
1,666 Views
arunkmrvn
Contributor II

Hi,

I want to do GPIO Shutdown in MX51. I did GPIO Interrupt driver and trying to send poweroff command to userspace using 

call_usermodehelper() function. But I am facing issues in that, Unable to run ..... Tell the exact procedure to do shutdown using call_usermode.

I am trying one more method. Once if i press the button, inside interrupt function, i want to call power_off function from kernel space instead of using call_usemodehelper() from userspace. So anyone suggest me how to do shutdown. 

Thanks

Labels (3)
1 Solution
1,319 Views
igorpadykov
NXP Employee
NXP Employee

Hi Arun

for i.MX51 poweroff example one can look at attached Linux Manual

Chapter 7 Low-level Power Management (PM) Driver and use solution

from i.MX51 EVK where MC13892 PWRON signal connected to PMIC_ON_REQ i.MX51,
please check SPF-26203  p.7 on i.MX51 EVK schematic

Schematics (1)
IMX51_EVK16_DESIGN_FILES
http://www.nxp.com/products/automotive-products/energy-power-management/switching-regulator/i.mx51-e...

i.MX51 EVK Linux:

Board Support Packages (8)
Linux 2.6.35 Source Code Files 2010.11 for i.MX51. Engineering Release(REV ER2010.11)
https://www.nxp.com/webapp/Download?colCode=L2.6.35_10.11_ER_SOURCE&appType=license&Parent_nodeId=12...

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
1,320 Views
igorpadykov
NXP Employee
NXP Employee

Hi Arun

for i.MX51 poweroff example one can look at attached Linux Manual

Chapter 7 Low-level Power Management (PM) Driver and use solution

from i.MX51 EVK where MC13892 PWRON signal connected to PMIC_ON_REQ i.MX51,
please check SPF-26203  p.7 on i.MX51 EVK schematic

Schematics (1)
IMX51_EVK16_DESIGN_FILES
http://www.nxp.com/products/automotive-products/energy-power-management/switching-regulator/i.mx51-e...

i.MX51 EVK Linux:

Board Support Packages (8)
Linux 2.6.35 Source Code Files 2010.11 for i.MX51. Engineering Release(REV ER2010.11)
https://www.nxp.com/webapp/Download?colCode=L2.6.35_10.11_ER_SOURCE&appType=license&Parent_nodeId=12...

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,319 Views
arunkmrvn
Contributor II

I tried to build the driver as mentioned in BSP (Low-level Power Management (PM) Driver). But its showing warning ???

Unable to include the mach/irqs.h. so its showing warning

unknown symbol mxc_cpu_lp_set() 

unknown symbol suspend_in_iram()

unknown symbol cpu_do_idle()

Added to interrupt code like below 

void __iomem *sdclk_iomux_addr = IO_ADDRESS(IOMUXC_BASE_ADDR + 0x4b8);
u32 * wake_src;

mxc_get_wake_irq(&wake_src);
if ( !wake_src[0] && !wake_src[1] && !wake_src[2] && !wake_src[3] )
{
printk(KERN_ERR "No sources enabled for wake-up! Sleep abort.\n");
return -EINVAL;
}

printk("inside gpio shutdown interrupt\n");
input_report_shutdown(dev,BTN_0,EV_SHUTDOWN);
input_sync(dev);

if (gpc_dvfs_clk == NULL)
gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs_clk");

clk_enable(gpc_dvfs_clk);
mxc_cpu_lp_set(STOP_POWER_OFF);
cpu_do_idle();
local_flush_tlb_all();
flush_cache_all();
/* Run the suspend code from iRAM. */
suspend_in_iram(sdclk_iomux_addr);

/*clear the EMPGC0/1 bits */
__raw_writel(0, MXC_SRPG_EMPGC0_SRPGCR);
__raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR);

clk_disable(gpc_dvfs_clk);
return IRQ_HANDLED;

I want to do any changes in configuration apart from mentioned in BSP or any other changes need. Can anyone suggest

Thanks before, 

Regards,

ARUN

0 Kudos
1,319 Views
arunkmrvn
Contributor II

Thank you.

0 Kudos