Application Note. Shared IRQ Line Considerations AN-PM-059

Similar documents
Application Note. Powering Xilinx Zynq with DA9061/2/3 AN-PM-087

Application Note. SLG46824/6 MTP Arduino Programming Example AN-CM-255

Application Note. Binary Parity Generator and Checker AN-CM-242

Application Note. How to replace CD40xx ICs with GreenPAK AN-CM-235

SLG4AX OSFP Low-Speed Module Controller. General Description. Pin Configuration

iw656 USB Power Delivery Controller for AC/DC Power Adapters 1 Description 2 Features 3 Applications

SLG4AX42397 OSFP Low-Speed Module Controller

Application Note. DA9063-A Power Management for R-Car H3 Platform AN-PM-085

iw3623 AC/DC Digital Power Controller for High Power Factor Dimmable LED Drivers 1 Description 2 Features 3 Applications

iw3629 Two-Stage, Flickerless Digital Off-Line LED Driver with High PF and Low THD 1 Description 2 Features 3 Applications

UM0401 User manual. User manual for eight bit port expander STMPE801 demonstration board. Introduction

AN2667 Application note

SmartBond DA Smallest, lowest power and most integrated Bluetooth 5 SoC. Applications DA14585

iw3662 Low Voltage (12V AC ) Dual-Mode Digital Control Dimmable LED Driver 1 Description 2 Features 3 Applications

AN3996 Application Note

AN3279 Application Note

AN3980 Application note

ST19NP18-TPM-I2C Trusted Platform Module (TPM) with I²C Interface Features

STM8 I 2 C optimized examples

ST10F271B/E, ST10F272B/E Errata sheet

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

AN2202 Application note

AN2672 Application note

Questions & Answers SC14CVMDECTDEVKT

AN4113 Application note

iw1782 Rapid Charge AC/DC Digital Quasi-Resonant PWM Controller 1 Description 2 Features 3 Applications

AN2061 APPLICATION NOTE

Description SPC564A-DISP. March 2014 DocID Rev 3 1/5

AN10428 UART-SPI Gateway for Philips SPI slave bridges

HiKey970. I2C Development Guide. Issue 01. Date

Main components USB charging controller with integrated power switch

AN Automatic RS-485 address detection. Document information

INTERRUPTS in microprocessor systems

AN2261 APPLICATION NOTE

Description of STM8 LIN software package (STSW-STM8A-LIN) release 4.1. Table 1. Release information. STM8 LIN package

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

AN Sleep programming for NXP bridge ICs. Document information

AN4274 Application note

How to configure the BlueNRG-1 and BlueNRG-2 devices in network coprocessor mode. Main components Bluetooth Low Energy wireless system-on-chip

AN2825 Application Note

OSPlus USB Extension. OSPlus USB 2.0 extension. Description. Features. Application. TCP/IP stack NexGenOS NexGenIP VFS. FAT Ext2 LVM Device layer

UM2330 User manual. ST8500 boot. Introduction

STLC2500D. Bluetooth V2.1 "Lisbon" + EDR. Features. Description

b. Typical values, independent of external clock frequency and supply voltage. a. TCG website:

AN4308 Application note

AN4440 Application note

UM0693 User manual. 1 Introduction. STM8L101-EVAL demonstration firmware

ST33F1M, ST33F1M0, ST33F896, ST33F768, ST33F640, ST33F512

ST33F1M. Smartcard MCU with 32-bit ARM SecurCore SC300 CPU and 1.25 Mbytes high-density Flash memory. Features. Hardware features.

AN2430 Application note

AN4321 Application note

STM32-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

STA bit single chip baseband controller for GPS and telematic applications. Features

AN4464 Application note

Measuring Interrupt Latency

SmartBeat digital Active Noise Cancellation solution

AN Entering ISP mode from user code. Document information. ARM ISP, bootloader

Future Technology Devices International Ltd. TN_161 FT4222H Errata Technical Note

STM3210B-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

Boot Interrupt Quirks and (RealTime) Interrupt Handling on x86. Olaf Dabrunz, Stefan Assmann

STM32 embedded target for MATLAB and Simulink release 3.1. Summary for STM32 embedded target for MATLAB and Simulink release 3.1:

AN1335 APPLICATION NOTE

STEVAL-CCM002V1. TFT-LCD panel demonstration board based on the STM32 as LCD controller. Features. Description

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

ST21NFCB. Near field communication controller. Features. RF communications. Hardware features. Communication interfaces. Electrical characteristics

STM32-SK/RAIS,STR91X-SK/RAI,STR7-SK/RAIS STM32-D/RAIS,STR9-D/RAIS,STR7-D/RAIS

ST19WR08 Dual Contactless Smartcard MCU With RF UART, IART & 8 Kbytes EEPROM Features Contactless specific features

TN0132 Technical note

AN2442 Application note

AN3265 Application note

AN3154 Application note

Section 5 SERCOM. Tasks SPI. In this section you will learn:

Future Technology Devices International Ltd. Application Note AN_172. Vinculum-II. Using the USB Slave Driver

APPLICATION NOTE. Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20. Description. Features

S1V30080 Series I2C Interface Sample Program Specifications

IIC Driver for the MC9S08GW64

MCF54451, MCF54452, MCF54453, MCF54454,

UM1488 User manual. STPMC1 evaluation software. Introduction

AN2592 Application note

ECO and Workarounds for Bugs in ESP32

INPUT/OUTPUT ORGANIZATION

spwr_base & spwr_chan

L6460. SPI configurable stepper and DC multi motor driver. Features. Description

PAC52XX GPIO Peripheral Firmware Design

AN3354 Application note

AN2792 Application note

STTS V memory module temperature sensor. Features

Mask Set Errata for Mask 2M40J

AN2676 Application note

DSP56F827 Digital Signal Controller

OLED display with pixels resolution Ambient light sensor CPU load Analog filter Quadrature Encoder with push button Digital I/O

AN2618 Application note

V850ES/Fx2. Customer Notification. 32-bit Single-Chip Microcontrollers. Operating Precautions. µpd70323x

Using IIC to Read ADC Values on MC9S08QG8

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

DYNAMIC ENGINEERING 150 DuBois St. Suite C, Santa Cruz, CA Fax Est.

AN3423 Application note

Intel Acceleration Stack for Intel Xeon CPU with FPGAs Version 1.2 Release Notes

ETAS RTA-HVR Hypervisor & Multi RTA-OS Profiling

DYNAMIC ENGINEERING 435 Park Dr., Ben Lomond, Calif Fax Est

Transcription:

Application Note AN-PM-059 Abstract When IRQ line-sharing between multiple devices has been imposed by the target hardware design, a system failure may occur that is intrinsic to the Linux kernel. This document outlines recommendations to avoid such issues. Several solutions have been identified and each should be considered on its merits for the target platform under examination.

Contents Abstract... 1 Contents... 2 Figures... 2 1 Terms and Definitions... 3 2 References... 3 3 Introduction... 4 4 Shared Interrupt Line... 4 4.1 Symptoms and Mode of Failure in the Linux Kernel... 4 4.2 Example of Causation... 5 4.3 General Causes... 5 5 Solutions... 6 5.1 Allocate a Dedicated IRQ Line... 6 5.2 OTP IRQ Mask Programming for all Interrupts... 6 5.3 Bootloader IRQ Masking... 6 5.4 Kernel Platform Quirk IRQ Masking... 6 5.5 Disable the OS from Receiving Interrupts... 7 5.6 Disable the IRQ Input in the SoC GPIO... 7 5.7 Static Arrangement of Device Driver Installation Order... 7 6 Specific PMIC Recommendations... 8 6.1 DA9210... 8 6.1.1 Interrupt Masks... 8 6.1.2 Event Bits... 8 6.2 DA9063... 8 6.2.1 Fault Log Clearance... 8 7 Conclusions... 9 Appendix A Linux Kernel Platform Quirk... 10 A.1 I 2 C Platform Quirk for Altering IRQ Mask Registers during Linux Startup... 10 A.2 Installing the Quirk into the Linux Build... 10 Appendix B Software Fault Log Clearance for the DA9063... 11 B.1 Kernel Clearance... 11 B.2 U-Boot Bootloader Clearance... 11 Revision History... 12 Figures Figure 1: Shared Interrupt Line Block Diagram Example... 4 Figure 2: IRQ masking quirk for the Linux kernel... 10 Figure 3: DA9063 FAULT_LOG reset source code for U-Boot... 11 CFR0014 2 of 13 2016 Dialog Semiconductor

1 Terms and Definitions CPU GPIO I 2 C ISR IRQ OTP OS PMIC POR RTC SoC SPI Central Processing Unit General Purpose Input/Output Inter-Integrated Circuit (bus) Interrupt Service Routine Interrupt Request (Line) One Time Programmable (memory) Operating System Power Management Integrated Circuit Power On Request Real Time Clock System on Chip Serial Peripheral Interface 2 References [1] DA9063, Datasheet, Dialog Semiconductor [2] AN-PM-047, Renesas R-Car E2 platform for automotive infotainment, Application Note, Dialog Semiconductor [3] AN-PM-049, Renesas R-Car M2 platform for automotive applications, Application Note, Dialog Semiconductor [4] AN-PM-050, Renesas R-Car H2 platform for automotive applications, Application Note, Dialog Semiconductor CFR0014 3 of 13 2016 Dialog Semiconductor

3 Introduction This document describes a system failure intrinsic to the Linux kernel when IRQ line-sharing has been imposed by the target hardware design. 4 Shared Interrupt Line Figure 1 shows a typical system where a Dialog PMIC delivers power to the SoC and shares the IRQx input with two other devices. Each device has its own software interrupt service routine (ISR). These ISRs are called in turn by the operating system once the IRQx is received. Power POR IRQx CPU Interrupt Controller GPIO Dev-A (Sensor) TA Dev-B (PMIC) Onkey Dev-C (HID) SoC Charger Figure 1: Shared Interrupt Line Block Diagram Example 4.1 Symptoms and Mode of Failure in the Linux Kernel The first sign of a failure within the Linux kernel is an unhandled interrupt. This behavior can be seen by polling the filesystem s proc interface (if this filesystem has been enabled in the kernel). cat /proc/interrupts Checking the console output for a rapidly increasing number of interrupt calls can provide the first indication that an IRQ is not being handled correctly. If this first symptom is ignored, the next direct manifestation will be a kernel message of the form: irq N: nobody cared (try booting with the "irqpoll" option) Disabling IRQ #N The next kernel action is to disable the IRQ that remains un-serviced. There is a risk that the kernel will disable all shared interrupts on the IRQ line, including those that may be from correctly functioning devices. The exact conditions are set in the Linux kernel core but, if approximately 100 000 interrupts have not been handled, the assumption is made that the IRQ is held in some manner and is not being serviced correctly. A diagnostic message and stack trace are sent to the console, then the kernel attempts to turn off the offending IRQ. Future IRQ notifications on the line are then ignored. CFR0014 4 of 13 2016 Dialog Semiconductor

4.2 Example of Causation The following related events are required to cause the fault behavior. 1. An event wakes up the PMIC, such as ONKEY, RTC alarm, or charger insertion. 2. The PMIC establishes the power rails. 3. If a corresponding wake-up event is unmasked, the Dev-B (PMIC) may assert its nirq output (low). 4. The system loads and runs the OS. 5. During initialization, the kernel installs the drivers and registers the corresponding ISR for each device in a predetermined order (this ordering is system dependent and assumed unknown). The first handler registered causes the IRQ line to the CPU to be enabled. 6. The SoC GPIO and interrupt controller are configured to receive interrupt request IRQx. The registered ISRs for the IRQx are called by the OS in turn until the IRQx becomes de-asserted. 7. If an ISR for either Dev-A or Dev-C is called before the PMIC device driver has been installed, the CPU may repeatedly call the Dev-A and/or Dev-C ISR as the interrupt line will still be held by Dev-B (PMIC). 4.3 General Causes The PMIC issues an interrupt request before the system is ready to receive it. The PMIC OTP does not mask all interrupts by default. An inability to control the order of Linux device driver installation. Interrupt line-sharing has not been considered during the system integration of the device drivers. The driver has not registered all of its IRQ entries with the kernel core and therefore the IRQs are not properly controlled or masked by the kernel. CFR0014 5 of 13 2016 Dialog Semiconductor

5 Solutions There are several software solutions to handling a shared interrupt line which can be categorized as: configuration or hardware-based run-time solutions executed in software 5.1 Allocate a Dedicated IRQ Line Whilst not always possible, allocating a dedicated IRQ input for the Dialog PMIC device resolves the line-sharing issue and does not require any workarounds or software intervention. 5.2 OTP IRQ Mask Programming for all Interrupts Preventing the Dialog PMIC from generating an IRQ during the system start-up sequence is suited to all OS applications and does not require any software workarounds in the bootloader or Linux kernel. Programming the IRQ mask bits in the PMIC OTP could resolve the issue. However, these mask bits are generally left disabled in some PMICs to retain compatibility with other system requirements. Programming these OTP bits therefore cannot be considered a general solution. See Section 6 for device-specific recommendations. In some PMICs, masking all interrupts can have side-effects and may affect wake-up operations: for example, the DA9063 Wake-up port (CHG_WAKE) feature would be disabled since, The IRQ assertion and wake-up event can be suppressed via the interrupt mask M_WAKE. See [1], page 45. 5.3 Bootloader IRQ Masking Early masking of interrupts within the PMIC can be performed during the bootloader section of startup. This is the software equivalent solution of Section 5.2 and requires a bootloader to exist in the system and the capability to modify the software in the bootloader accordingly. This software workaround requires a customer- or platform-specific implementation and its suitability is therefore limited to a fully-integrated target system. 5.4 Kernel Platform Quirk IRQ Masking A kernel-only solution can be implemented using a kernel quirk. A kernel quirk is usually a platformspecific modification which is called during the start-up code of the Linux kernel. This solution has the disadvantage of requiring specific workaround quirks for each target platform and also ignores the IRQ problem until the kernel has started to load. It has the advantage of being available to all identified platforms as part of the integrated kernel distribution. See the Linux kernel example for platform solutions for the compatible targets renesas,koelsch and renesas,lager : arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c The PMICs used in these target systems are DA9063 and DA9210. The OTP settings used for these platforms have been set such that the PMIC cold boot or restart has unmasked interrupts. Any interrupts that are triggered upon PMIC start-up are a cause of an interrupt storm. Without the quirk, an IRQ line-sharing failure occurs as soon as one driver is installed by the Linux kernel and requests the IRQ. It immediately gets stuck in an infinite loop since it can only de-assert its own interrupt request line, and because the other driver has not yet installed an interrupt handler. The quirk masks the interrupts in both the DA9063 and DA9210: it must execute after the I 2 C master driver but before the I 2 C slave drivers are initialized. See Appendix A for further details. CFR0014 6 of 13 2016 Dialog Semiconductor

5.5 Disable the OS from Receiving Interrupts Specific code can be added during driver initializations to prevent the OS from receiving a PMIC interrupt until the PMIC device driver has been installed correctly. This disallows IRQ sources until all driver IRQ handlers have been serviced. This is an intrusive solution and requires significant code alteration specific to the OS being used. 5.6 Disable the IRQ Input in the SoC GPIO Interrupts can be masked by I 2 C/SPI commands to the SoC, before installing any device drivers that use the IRQx line shared with the PMIC. This disallows IRQ sources until the driver IRQ handlers are all serviced. However, the alteration would be application-dependent and require deep understanding of the target system. This level of information may not be readily accessible when designing a system that is not open source. 5.7 Static Arrangement of Device Driver Installation Order This solution involves statically arranging the device driver installation into a fixed order within the Linux kernel to avoid any driver installation race conditions that would otherwise cause an interrupt storm problem. This could be used as a temporary fix in some cases, however it is not a general solution in most practical applications for several reasons. For example, if multiple devices flag an IRQ at start-up, an IRQ storm will still occur regardless of ordering. Also, when using later Linux kernels and a device tree solution, this would be totally dependent on the device tree implementation or would involve modification of the Linux core functions. In general, such modification is difficult to achieve for most large scale OS-based applications. CFR0014 7 of 13 2016 Dialog Semiconductor

6 Specific PMIC Recommendations The following recommendations are made for individual PMICs. 6.1 DA9210 There are several recommendations for DA9210: OTP default for setting all interrupt masks clearance of event bits upon start-up 6.1.1 Interrupt Masks The standard OTP for DA9210 has all interrupts masked by default. However, the OTP mask settings should be verified for each system since they can be unmasked for some OTP variants. For specific details of Renesas R-Car E2, M2 and H2 platforms see [2], [3], and [4]. 6.1.2 Event Bits If OVCURR or NPWRGOOD occurs during the DA9210 boot-up, and they are deemed to be unintentional events, the event flag of E_OVCURR or E_NPWRGOOD is set even if the masking nirq toggle on MASK_B has been set by the OTP configuration settings. The recommendation is for the system software to read the EVENT_B register and clear the flags on EVENT_B during the start-up flow. Table 1: Event Bit Fields Associated with DA9210 Event Bit Field DA9210_E_OVCURR DA9210_E_NPWRGOOD DA9210_E_TEMP_WARN DA9210_E_TEMP_CRIT DA9210_E_VMAX Recommended for Clearance on Start-up Yes Yes No No No 6.2 DA9063 The general recommendation for DA9063 is to clear the FAULT_LOG register on start-up. 6.2.1 Fault Log Clearance If the DA9063 has been shutdown using the hardware ONKEY reset function (long press of ONKEY when the software fails to respond), the standard DA9063 ONKEY Linux device driver will not be able to reset the KEY_RESET within the FAULT_LOG register. The FAULT_LOG is a persistent register which holds its value across a reboot and therefore will affect the start-up sequence during the next system restart. The KEY_RESET bit triggers a non-maskable interrupt which has no corresponding event bit in the event registers and therefore cannot be handled by the Linux framework in the normal way. This bit should be cleared upon start-up, either during the bootloader or the kernel driver probe operation. See Appendix B for further details. CFR0014 8 of 13 2016 Dialog Semiconductor

7 Conclusions The software device driver issues caused by IRQ line-sharing between multiple devices can be avoided if the recommendations presented in this document are followed. Each solution described should be considered on its own merits and the most appropriate way forward should be chosen for the target platform. No single solution can be identified to solve this problem. CFR0014 9 of 13 2016 Dialog Semiconductor

Appendix A Linux Kernel Platform Quirk This example is intended for the Linux kernel and should be modified for the platform device requirements. It assumes the following: arch/arm/mach-imx/platform-quirk.c The location for setting IRQ mask registers is indicated by /*SET IRQ MASKS */. A.1 I 2 C Platform Quirk for Altering IRQ Mask Registers during Linux Startup #include <linux/mfd/da9xxx/registers.h> static int platform_i2c_bus_notify(struct notifier_block *nb, unsigned long action, void *data) { struct device *dev = data; struct i2c_client *client; if (action!= BUS_NOTIFY_ADD_DEVICE dev->type == &i2c_adapter_type) return 0; client = to_i2c_client(dev); /* Assume I2C slave address 0x68 and da90xxx name */ if ((client->addr == 0x68 &&!strcmp(client->name, "da9xxx"))) { /* SET IRQ MASKS */ i2c_smbus_write_byte_data(client, <REGISTER>, <VALUE> ); bus_unregister_notifier(&i2c_bus_type, nb); } } return 0; static struct notifier_block platform_i2c_bus_nb = {.notifier_call = platform_i2c_bus_notify }; static int init platform_quirk(void) { bus_register_notifier(&i2c_bus_type, &platform_i2c_bus_nb); return 0; } arch_initcall(platform_quirk); Figure 2: IRQ masking quirk for the Linux kernel A.2 Installing the Quirk into the Linux Build To include the quirk, a modification to the Makefile will be necessary: arch/arm/mach-imx/makefile obj-$(config_soc_imx6q) += clk-imx6q.o mach-imx6q.o platform-quirk.o CFR0014 10 of 13 2016 Dialog Semiconductor

Appendix B Software Fault Log Clearance for the DA9063 B.1 Kernel Clearance Clearing the FAULT_LOG register can be implemented during the device driver probe of the DA9063. See the file drivers/mfd/da9063-core.c and function da9063_clear_fault_log implemented in the linux-mainline/v4.2 kernels onwards. B.2 U-Boot Bootloader Clearance The same code example as described in Section B.1 but targeted at U-Boot is given in Figure 3. #define DA9063_I2C_SLAVE 0x58 #define DA9063_FAULT_LOG_REG 0x05 unsigned char value = 0; if (!(i2c_read(da9063_i2c_slave, DA9063_FAULT_LOG_REG, 1, &value, 1))) { if (value & 0x20) printf("power down from a long press of nonkey or GPIO14/15\n"); /* Clear the DA9063 FAULT_LOG on start-up */ i2c_write(da9063_i2c_slave, DA9063_FAULT_LOG_REG, 1, &value, 1); } Figure 3: DA9063 FAULT_LOG reset source code for U-Boot CFR0014 11 of 13 2016 Dialog Semiconductor

Revision History Revision Date Description 1.0 18-Sep-2015 Initial version. 1.1 12-Oct-2015 Positive rewording of the abstract to reflect multiple solutions offered by this document. 1.2 24-Jun-2016 Update formatting style to follow document conventions. Section 5.2 combines two sections into one, clarifying that normal IRQs and wake-up interrupts would cause the same problems. CFR0014 12 of 13 2016 Dialog Semiconductor

Status Definitions Status DRAFT APPROVED or unmarked Definition The content of this document is under review and subject to formal approval, which may result in modifications or additions. The content of this document has been approved for publication. Disclaimer Information in this document is believed to be accurate and reliable. However, Dialog Semiconductor does not give any representations or warranties, expressed or implied, as to the accuracy or completeness of such information. Dialog Semiconductor furthermore takes no responsibility whatsoever for the content in this document if provided by any information source outside of Dialog Semiconductor. Dialog Semiconductor reserves the right to change without notice the information published in this document, including without limitation the specification and the design of the related semiconductor products, software and applications. Applications, software, and semiconductor products described in this document are for illustrative purposes only. Dialog Semiconductor makes no representation or warranty that such applications, software and semiconductor products will be suitable for the specified use without further testing or modification. Unless otherwise agreed in writing, such testing or modification is the sole responsibility of the customer and Dialog Semiconductor excludes all liability in this respect. Customer notes that nothing in this document may be construed as a license for customer to use the Dialog Semiconductor products, software and applications referred to in this document. Such license must be separately sought by customer with Dialog Semiconductor. All use of Dialog Semiconductor products, software and applications referred to in this document are subject to Dialog Semiconductor s Standard Terms and Conditions of Sale, available on the company website (www.dialog-semiconductor.com) unless otherwise stated. Dialog and the Dialog logo are trademarks of Dialog Semiconductor plc or its subsidiaries. All other product or service names are the property of their respective owners. 2016 Dialog Semiconductor. All rights reserved. Contacting Dialog Semiconductor United Kingdom (Headquarters) Dialog Semiconductor (UK) LTD Phone: +44 1793 757700 Germany Dialog Semiconductor GmbH Phone: +49 7021 805-0 The Netherlands Dialog Semiconductor B.V. Phone: +31 73 640 8822 Email: enquiry@diasemi.com North America Dialog Semiconductor Inc. Phone: +1 408 845 8500 Japan Dialog Semiconductor K. K. Phone: +81 3 5425 4567 Taiwan Dialog Semiconductor Taiwan Phone: +886 281 786 222 Web site: www.dialog-semiconductor.com Singapore Dialog Semiconductor Singapore Phone: +65 64 8499 29 Hong Kong Dialog Semiconductor Hong Kong Phone: +852 3769 5200 Korea Dialog Semiconductor Korea Phone: +82 2 3469 8200 China (Shenzhen) Dialog Semiconductor China Phone: +86 755 2981 3669 China (Shanghai) Dialog Semiconductor China Phone: +86 21 5424 9058 CFR0014 13 of 13 2016 Dialog Semiconductor