Copyright 2023 Canaan Inc. ©
The products, services or features you purchase should be subject to Canaan Inc. ("Company", hereinafter referred to as "Company") and its affiliates are bound by the commercial contracts and terms and conditions of all or part of the products, services or features described in this document may not be covered by your purchase or use. Unless otherwise agreed in the contract, the Company does not provide any express or implied representations or warranties as to the correctness, reliability, completeness, merchantability, fitness for a particular purpose and non-infringement of any statements, information, or content in this document. Unless otherwise agreed, this document is intended as a guide for use only.
Due to product version upgrades or other reasons, the content of this document may be updated or modified from time to time without any notice.
, "Canaan" and other Canaan trademarks are trademarks of Canaan Inc. and its affiliates. All other trademarks or registered trademarks that may be mentioned in this document are owned by their respective owners.
Copyright 2023 Canaan Inc.. © All Rights Reserved. Without the written permission of the company, no unit or individual may extract or copy part or all of the content of this document without authorization, and shall not disseminate it in any form.
[TOC]
This document describes the specific usage methods of PMU modules and SDK configuration compilation methods, including the construction of software and hardware environments, and introduces the control interface.
This document (this guide) is intended primarily for:
abbreviation | illustrate |
---|---|
PMU | Power Management Unit |
Document version number | Modify the description | Author | date |
---|---|---|---|
V1.0 | Initial edition | Zhang Tao | 2023/05/19 |
The PMU module provides 6 input and 2 output ports, each with the following functions:
The PMU module also provides a log storage function of 64Byte, of which the last 4Byte is used by the driver and the remaining 60Byte is left to the user
The PMU can be controlled by the user through the device tree and sysfs, the PMU can be configured through the device tree at system startup, and the PMU can be dynamically configured through sysfs after startup
pmu: pmu@0x91000000 {
compatible = "kendryte, k230-pmu";
reg = <0x0 0x91000000 0x0 0xb0>;
interrupt-parent = <&intc>;
interrupts = <175>;
status = "disabled";
/*
int0 {
force-powerdown-value = <320000>;
power-event-value = <96000>;
debounce-value = <256>;
type = <IRQ_TYPE_EDGE_RISING>;
wakeup;
event;
};
int1 {
debounce-value = <256>;
edge-cnt-type = <IRQ_TYPE_EDGE_RISING>;
edge-cnt-value = <1>;
edge-cnt-wakeup;
edge-cnt-event;
type = <IRQ_TYPE_EDGE_RISING>;
wakeup;
event;
};
int2 {
debounce-value = <256>;
type = <IRQ_TYPE_EDGE_RISING>;
wakeup;
event;
};
int3 {
debounce-value = <256>;
type = <IRQ_TYPE_EDGE_RISING>;
wakeup;
event;
};
int4 {
type = <IRQ_TYPE_EDGE_FALLING>;
wakeup;
event;
};
int5 {
type = <IRQ_TYPE_EDGE_RISING>;
wakeup;
event;
};
rtc {
alarm-wakeup;
alarm-event;
tick-wakeup;
tick-event;
};
*/
};
Key field meanings:
force-powerdown-value
Long press to force shutdown timepower-event-value
Long press on and long press on the shutdown event timedebounce-value
Debounce timetype
Detection type, support rising edge, falling edge, high level, low levelwakeup
Enable power-on to wake up red energyevent
Enable event reportingedge-cnt-type
Detection type, support rising edge, falling edgeedge-cnt-value
Edge count valueAll times are measured in (1/32768) seconds, e.g. 327680 for 10 seconds
PMU sysfs is located in /sys/devices/platform/soc/91000000.pmu
the directory and the file structure is as follows:
.
|-- driver -> ../../../../bus/platform/drivers/k230-pmu
|-- driver_override
|-- int0
| |-- debounce_value
| |-- event
| |-- force_powerdown_value
| |-- power_event_value
| |-- type
| `-- wakeup
|-- int1
| |-- debounce_value
| |-- edge_cnt_event
| |-- edge_cnt_type
| |-- edge_cnt_value
| |-- edge_cnt_wakeup
| |-- event
| |-- type
| `-- wakeup
|-- int2
| |-- debounce_value
| |-- event
| |-- type
| `-- wakeup
|-- int3
| |-- debounce_value
| |-- event
| |-- type
| `-- wakeup
|-- int4
| |-- event
| |-- type
| `-- wakeup
|-- int5
| |-- event
| |-- type
| `-- wakeup
|-- modalias
|-- of_node -> ../../../../firmware/devicetree/base/soc/pmu@0x91000000
|-- pmu
| |-- pmu_logs
| |-- pmu_regs
| |-- pmu_status
| `-- wakeup_source
|-- rtc
| |-- alarm_event
| |-- alarm_wakeup
| |-- tick_event
| `-- tick_wakeup
|-- subsystem -> ../../../../bus/platform
`-- uevent
Main file features:
pmu/pmu_status
PMU Status (read-only)
PMU_RESET
The PMU is powered offSOC_FORCE_PD
The SoC is forced to power downSOC_NORMAL_PD
The SoC is powered off normallySOC_RESET
The SoC is resetpmu/wakeup_source
system wakeup source (read-only)
INT0,INT1,INT2,INT3,INT4,INT5,RTC_ALARM,RTC_TICKpmu/pmu_logs
User LOG file (binary file, 4-byte alignment required for read and write)pmu/pmu_regs
PMU debugging (binary, 4-byte alignment required for read and write)int0/force_powerdown_value
Long press to force shutdown timeint0/power_event_value
Long press on and long press on the shutdown event timeint1/edge_cnt_type
Detection type, valid values "rising", "falling"int1/edge_cnt_value
Edge count value*/debounce_value
Debounce time*/type
Detection type, valid values "rising", "falling", "low", "high"*/*wakeup
Wake up, valid values "enabled", "disabled"*/*event
Event reported, valid values "enabled", "disabled"For example, enable INT1 rising edge to wake up:
cd /sys/devices/platform/soc/91000000.pmu/int1
echo rising > type
echo enabled > wakeup
For example, enable INT2 falling edge events to be reported:
cd /sys/devices/platform/soc/91000000.pmu/int2
echo falling > type
echo enabled > event
PMU uses the input subsystem to report events, and the reported event code is so EV_KEY
that users can perform business processing after receiving the corresponding events. For example, after receivingKEY_POWER
the key value, the user can perform shutdown preparation and invoke thepoweroff
shutdown command
You can use the evtest
tool for testing with the following event table:
action | Key value |
---|---|
INT0 Press and hold to shut down | KEY_POWER |
INT0 level or edge | BTN_0 |
INT1 level or edge or edge count | BTN_1 |
INT2 level or edge | BTN_2 |
INT3 level or edge | BTN_3 |
INT4 level or edge | BTN_4 |
INT5 level or edge | BTN_5 |
RTC_ALARM | BTN_6 |
RTC_TICK | BTN_7 |
poweroff
the command shutdownWhen using a PMU, you need to set up the EVB board as follows
Wake source | PIN | label |
---|---|---|
INT0 | 1 | INT0 |
INT1 | 3 | INT1 |
INT2 | 5 | INT2 |
INT3 | 7 | INT3 |
INT4 | 9 | INT4 |
INT5 | 11 | INT5 |
Connection diagram using INT0 as a wake-up source:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。