mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-05 16:03:51 +00:00
Merge commit 'refs/tmp/pr373' into liuwang-370-373
# Conflicts: # docs/FINDINGS.md
This commit is contained in:
commit
53ef0ff58d
7 files changed
+291
-32
No files matched your search
@@ -193,6 +193,7 @@ what replaced it. The table below gives each section's state.
|
||||
| 205 | The U30 Air's USB 3 link in **device** mode follows the plug orientation (#54): SuperSpeed only in the orientation the PHY/redriver latched at power-on; `mu300-usb pd on` (0020) gives CC and the roles but does not flip the lanes, and a replug does not bring SuperSpeed back (7.2.11) | measured on a U30 Air, 7.2.11; no fix here. #341 on the same unit: orientation A at 10 Gbps, B not seen at all (worse than the USB 2 fallback); the PTN38003A does not answer at i2c 0x30 there |
|
||||
| 206 | Linux 7.3 as a fourth kernel: every patch applies unchanged (none upstream, none dropped); `PROC_SYSCTL` folded into `SYSCTL` (`config-ignored.txt`, checked only where the kernel lacks the symbol), the cfg80211 cookie handed in by value, `dma_capable()` with DMA attributes, `IIO_CONSUMER` for the audio extra; the checksum list from www.kernel.org (the CDN lagged) | current (F50-B Ubuntu: all checks, call audio with the 7.3 extra, the boot fallback; the one hang in a reboot loop was the board's plug pulled by accident, not 7.3; the U30 Air openwrt-luci with the VPN and its kill switch, 2026-10-19; `sprd_wlan_combo` for 6.18.57 and 7.2.11 byte for byte v2026.10.19.3's; released in v2026.10.22.1, F50-B 10/10 boots on 7.3 in a reboot soak) |
|
||||
| 213 | A kernel oops on a restart of mu300-adbd: f_ncm and f_rndis free `os_desc_table` at unbind and keep the pointer, and a bind without MS OS descriptors (adbd's `without_adb` wrote `os_desc/use` 0) leaves it for the next unbind to free again - a kmalloc-16 double free that came back as `kstrdup()` oopsing in the UDC store; patch 0027 clears the pointer (6.18.57, 7.2.11 and 7.3 all have the bug), mu300-adbd keeps the descriptors on for every kernel | current (F50 Ubuntu, 2026-10-24: unpatched 7.3 with the release's mu300-adbd went down within 11 restarts of it once, and oopsed at restart 118 a second time - "Unable to handle kernel paging request" at an address made of string bytes; 6.18.58 with 0027 and the same mu300-adbd 200 restarts clean; unpatched 7.3 with the new mu300-adbd 150 restarts clean. A U30 Air on OpenWrt 6.18.58 dropped off the air during the same loop) |
|
||||
| 218 | CPU0's cluster power-down: USB, IPA and the Wi-Fi's PCIe were not wake sources of LP_AP_INTC (TF-A's IRQ_EN table); `ums9620_lpintc` adds every SPI the kernel enabled | current (U30 Air OpenWrt 6.18.57: USB pings 9.5 ms avg / 42 ms max instead of 15.7 / 69; F50 Ubuntu 6.18.58: 1.2 / 1.5 ms instead of 30.6 / 150; builds for 7.2.12; suspend path not run) |
|
||||
|
||||
## Hardware and firmware facts
|
||||
|
||||
@@ -12828,6 +12829,57 @@ a device hung instead of rebooting.
|
||||
Tests: `tests/test_adb.py` (`GadgetOsDescTable`: both unbinds clear the pointer after the free, one patch with the
|
||||
number 0027, mu300-adbd never turns the descriptors off; `Gadget`: after adb leaves, `os_desc/use` is still 1 and
|
||||
`os_desc/c.1` still a link).
|
||||
### 218. CPU0's cluster power-down: USB, IPA and the Wi-Fi's PCIe were not wake sources (ums9620_lpintc)
|
||||
|
||||
**Status: built for 6.18.57 and measured on a U30 Air (OpenWrt 25.12.5, 6.18.57); built for 6.18.58 and checked on an
|
||||
F50 (Ubuntu 24.04, 2026-10-24: pings over USB from a Mac 1.2 ms on average and 1.5 ms at most with it, 30.6 ms and 150 ms
|
||||
without, 60 each), and builds against 7.2.12; its suspend path not yet run on a device, the power with it not
|
||||
measured.**
|
||||
|
||||
With every cpuidle state allowed, pings over USB from a computer waited up to 120 ms. The waits went away with CPU0
|
||||
kept out of its deepest state, `cluster-pd` (PSCI; the A55 cluster and its DSU powered off), and that was the
|
||||
device-local workaround (`/etc/rc.local` writing `cpu0/cpuidle/state2/disable`). The reason is in TF-A. A powered-down
|
||||
cluster is woken not by the GIC but by the always-on LP_AP_INTC: eight blocks of 32 lines, line b of INTCn being GIC
|
||||
SPI 32n + b, each line a wake source only where its bit in that block's IRQ_EN is set. TF-A (sml) sets those once at
|
||||
boot from its own table (`sml_a.img` + 0x114d8, pairs of register and value): INTC0 0xf5085c00, INTC1 0x2080b9fc,
|
||||
INTC7 0x40, INTC2-6 nothing. The USB controller (dwc3, SPI 142: INTC4 bit 14), the IPA (SPI 136-138) and the Wi-Fi
|
||||
chip's PCIe MSI are in INTC2-6, so while CPU0's cluster was powered down their interrupts waited for something else
|
||||
(the system timer, INTC1) to wake it.
|
||||
|
||||
| block | base | TF-A's IRQ_EN | added on a running U30 Air |
|
||||
|---|---|---|---|
|
||||
| INTC0-5 | 0x640c0000 + n * 0x10000 | 0xf5085c00, 0x2080b9fc, 0, 0, 0, 0 | INTC2 0x00040000, INTC4 0x00044700 |
|
||||
| INTC6, INTC7 | 0x645b0000, 0x645c0000 | 0, 0x40 | INTC6 0x02d40018 |
|
||||
|
||||
Each block: +0x08 IRQ_EN (reads the enabled mask, a 1 written sets that bit), +0x0c IRQ_DIS (a 1 written clears
|
||||
it); the clocks are `ap-intc0..7-eb` (AON gate 0x64900008 bits 11-18, `CLK_IGNORE_UNUSED`). TF-A did not write
|
||||
IRQ_EN again in 60 s of cluster-pd with a bit set by hand.
|
||||
|
||||
`upstream/modules/ums9620_lpintc` (mainline, loaded by `extra-modules` after `mu300_thermal`) adds to IRQ_EN every SPI
|
||||
the kernel has enabled in the GIC distributor (`GICD_ISENABLER1..8`), at load and every 5 s from deferrable work
|
||||
(`period=`), which never wakes a CPU itself, so drivers that come later (Wi-Fi, the IPA delegate) are taken up. It only
|
||||
adds: TF-A's bits stay, and a line disabled again keeps its bit (the GIC still masks it). An enabled interrupt is
|
||||
handled anyway, so waking the cluster for it costs no extra work, only removes the wait. The bits it added are
|
||||
cleared again in its syscore suspend, so `mem` (FINDINGS 37) wakes on exactly what TF-A chose, and set again on resume;
|
||||
`rmmod` clears them the same way (checked: TF-A's values read back at the next load). The suspend and resume hooks
|
||||
have not run on a device yet: two `mem` attempts with pm_test=core were aborted before syscore by the Wi-Fi's
|
||||
WAKE# and by the IPA's and Wi-Fi's wakeup sources (traffic). EN and DIS are single writes, so nothing needs a lock with
|
||||
TF-A. Only the UMS9620 is accepted; a block whose clock is off is left alone.
|
||||
|
||||
Measured from a Windows PC over the USB network (100 pings, 1 s apart; CPU0's cluster-pd allowed):
|
||||
|
||||
| | average | median | 90 % | max |
|
||||
|---|---|---|---|---|
|
||||
| without the module | 15.7 ms | 8 ms | 47 ms | 69 ms |
|
||||
| with it | 9.5 ms | 7 ms | 20 ms | 42 ms |
|
||||
| CPU0 without cluster-pd (the workaround, 60 pings) | 10 ms | | | 70 ms |
|
||||
| every CPU at WFI only (this link's floor, 60 pings) | 7.1 ms | 5 ms | 14 ms | 40 ms |
|
||||
|
||||
So with the module cluster-pd on CPU0 is as fast as the workaround and near what this computer's link gives at all;
|
||||
CPU0 still entered cluster-pd (3600 to 6600 entries over 60 pings). An earlier test with only INTC4 bit 14 set by hand gave
|
||||
85 pings of 85 at 1 ms or less (its link not recorded). With the module loaded the workaround can go: CPU0 keeps
|
||||
its cluster-pd.
|
||||
|
||||
### 219. Call audio on 5.4: the card took two minutes to bind, and every unbind WARNed in `_regulator_put`
|
||||
|
||||
**Status: fixed in mu300-audio v1.0.5 (dikeckaan/mu300-audio#7).** Measured on F50-B with 5.4.254 (Ubuntu 24.04)
|
||||
|
||||
@@ -37,13 +37,17 @@ fi
|
||||
# hands frequency control over. The vendor 5.4 kernel has its own driver for it and no such module. modprobe needs
|
||||
# depmod's index (Ubuntu keeps the bundle's modules in extra/), so insmod by path is the fallback; a failure leaves
|
||||
# thermal-guard in charge, as before.
|
||||
if ! grep -q '^mu300_thermal ' /proc/modules; then
|
||||
for f in "$M/mu300_thermal.ko" "$M/extra/mu300_thermal.ko"; do
|
||||
# ums9620_lpintc (upstream/modules/ums9620_lpintc, docs/FINDINGS.md 218), the same way: the interrupts the kernel
|
||||
# enabled become wake sources of the CPU clusters' power-down, which TF-A left at its own short list (USB, IPA and
|
||||
# the Wi-Fi's PCIe were not on it). Mainline only; without it an interrupt waits for something else to wake the cluster.
|
||||
for m in mu300_thermal ums9620_lpintc; do
|
||||
grep -q "^$m " /proc/modules && continue
|
||||
for f in "$M/$m.ko" "$M/extra/$m.ko"; do
|
||||
[ -f "$f" ] || continue
|
||||
if modprobe mu300_thermal 2>/dev/null || insmod "$f" 2>/dev/null; then echo "loaded mu300_thermal"; else echo "FAILED mu300_thermal"; fi
|
||||
if modprobe "$m" 2>/dev/null || insmod "$f" 2>/dev/null; then echo "loaded $m"; else echo "FAILED $m"; fi
|
||||
break
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
for m in sprd_soc_thm thermal-generic-adc sprd_cpu_cooling leds-sc27xx-bltc zte_sar zte_card_holder_det sc27xx-vibra sprd_cp_dvfs sprd_ddr_dvfs sprd_gpu_cooling mali_kbase; do
|
||||
if modprobe "$m" 2>/tmp/mu300-modprobe.err; then
|
||||
|
||||
@@ -2733,31 +2733,33 @@ class SipaDele(ShellTest):
|
||||
self.assertNotIn('sipa-dele', calls.replace('sipa-dele-start', ''))
|
||||
ko.unlink()
|
||||
|
||||
def test_extra_modules_loads_the_stock_thermal_zone_module_when_the_kernel_has_one(self):
|
||||
"""mu300_thermal (the stock virtual thermal zone, mainline only): loaded once, by name where depmod indexed it
|
||||
and by path where not (Ubuntu's extra/ before depmod ran); the vendor 5.4 kernel has no such module."""
|
||||
for shell in self.each_shell():
|
||||
r, calls = self.run_script(shell, 'extra-modules') # 5.4: no module, nothing tried
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertNotIn('mu300_thermal', calls)
|
||||
for sub in ('', 'extra'):
|
||||
ko = self.mods / sub / 'mu300_thermal.ko'
|
||||
ko.parent.mkdir(exist_ok=True)
|
||||
ko.write_text('')
|
||||
r, calls = self.run_script(shell, 'extra-modules')
|
||||
def test_extra_modules_loads_the_mainline_only_modules_when_the_kernel_has_them(self):
|
||||
"""mu300_thermal (the stock virtual thermal zone) and ums9620_lpintc (the cluster power-down's wake sources,
|
||||
FINDINGS 218), mainline only: each loaded once, by name where depmod indexed it and by path where not
|
||||
(Ubuntu's extra/ before depmod ran); the vendor 5.4 kernel has no such modules."""
|
||||
for m in ('mu300_thermal', 'ums9620_lpintc'):
|
||||
for shell in self.each_shell():
|
||||
r, calls = self.run_script(shell, 'extra-modules') # 5.4: no module, nothing tried
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertIn('modprobe mu300_thermal', calls)
|
||||
self.assertNotIn(f'insmod {ko}', calls)
|
||||
self.assertIn('loaded mu300_thermal', r.stdout)
|
||||
r, calls = self.run_script(shell, 'extra-modules', MODPROBE_RC=1) # no index yet: by path
|
||||
self.assertIn(f'insmod {ko}', calls)
|
||||
self.assertIn('loaded mu300_thermal', r.stdout)
|
||||
r, calls = self.run_script(shell, 'extra-modules', MODPROBE_RC=1, INSMOD_RC=1)
|
||||
self.assertEqual(r.returncode, 0, r.stderr) # a failure is logged, not fatal
|
||||
self.assertIn('FAILED mu300_thermal', r.stdout)
|
||||
r, calls = self.run_script(shell, 'extra-modules', 'mu300_thermal 12288 0 - Live 0x0 (O)\n')
|
||||
self.assertNotIn('mu300_thermal', calls) # loaded already
|
||||
ko.unlink()
|
||||
self.assertNotIn(m, calls)
|
||||
for sub in ('', 'extra'):
|
||||
ko = self.mods / sub / f'{m}.ko'
|
||||
ko.parent.mkdir(exist_ok=True)
|
||||
ko.write_text('')
|
||||
r, calls = self.run_script(shell, 'extra-modules')
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertIn(f'modprobe {m}', calls)
|
||||
self.assertNotIn(f'insmod {ko}', calls)
|
||||
self.assertIn(f'loaded {m}', r.stdout)
|
||||
r, calls = self.run_script(shell, 'extra-modules', MODPROBE_RC=1) # no index yet: by path
|
||||
self.assertIn(f'insmod {ko}', calls)
|
||||
self.assertIn(f'loaded {m}', r.stdout)
|
||||
r, calls = self.run_script(shell, 'extra-modules', MODPROBE_RC=1, INSMOD_RC=1)
|
||||
self.assertEqual(r.returncode, 0, r.stderr) # a failure is logged, not fatal
|
||||
self.assertIn(f'FAILED {m}', r.stdout)
|
||||
r, calls = self.run_script(shell, 'extra-modules', f'{m} 12288 0 - Live 0x0 (O)\n')
|
||||
self.assertNotIn(m, calls) # loaded already
|
||||
ko.unlink()
|
||||
|
||||
def test_refuses_after_the_wait(self):
|
||||
"""K46: the packet domain never comes up: exit 1 after MU300_DELE_WAIT s, the module is not inserted."""
|
||||
|
||||
+3
-1
@@ -224,7 +224,9 @@ Fixes needed on top of the port:
|
||||
- Thermal: vendor `sprd_thermal_r5p0` (19 on-die zones) with calibration from the UMS9620 eFuse; the eFuse
|
||||
provider is built read-only.
|
||||
- cpufreq: vendor `sprd_sip_svc` + `sprd-cpufreq-v2`; ATF does the DVFS, the kernel asks through SIP SMC calls
|
||||
(3 policies: 4 little / 3 mid / 1 big, schedutil). PSCI cpuidle (WFI, core sleep, cluster power-down).
|
||||
(3 policies: 4 little / 3 mid / 1 big, schedutil). PSCI cpuidle (WFI, core sleep, cluster power-down);
|
||||
`modules/ums9620_lpintc` makes the interrupts the kernel enabled wake sources of the cluster power-down, which TF-A
|
||||
left at its own list without USB, IPA and PCIe (docs/FINDINGS.md 218).
|
||||
Idle temperature dropped from ~54 C to ~48 C.
|
||||
- The stock DT has trip points only on the vendor virtual zone (`soc-thmzone`: passive 70/85 C, critical 110 C,
|
||||
cooling maps to the three clusters), whose sensor driver mainline lacks: `modules/mu300_thermal` brings it back
|
||||
|
||||
@@ -8,9 +8,10 @@ K=/src/linux-$KV
|
||||
O=/src/out-$KV
|
||||
OUT=/work/${OUTDIR:-out} # as in build.sh
|
||||
# every out-of-tree module, in dependency order (wlan/bt use wcn_bsp, the PMIC watchdog and Mali the modem's headers;
|
||||
# mu300_thermal, the stock virtual thermal zone, needs only the kernel). The call-audio stack is not here: it is the
|
||||
# audio extra's (https://github.com/dikeckaan/mu300-audio, built against this tree's build kit; FINDINGS 194)
|
||||
mods=${*:-wcn_bsp sprd_wlan_combo sprdbt_tty sprd_modem sprd_pmic_wdt mali mu300_thermal}
|
||||
# mu300_thermal, the stock virtual thermal zone, and ums9620_lpintc, the cluster power-down's wake sources, need only
|
||||
# the kernel). The call-audio stack is not here: it is the audio extra's (https://github.com/dikeckaan/mu300-audio,
|
||||
# built against this tree's build kit; FINDINGS 194)
|
||||
mods=${*:-wcn_bsp sprd_wlan_combo sprdbt_tty sprd_modem sprd_pmic_wdt mali mu300_thermal ums9620_lpintc}
|
||||
mkdir -p $OUT/modules
|
||||
# xt_HL.ko and xt_hl.ko (and three more pairs) must stay two files: not on a host directory that ignores case
|
||||
. /work/case-sensitive.sh
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# The interrupts Linux enabled as wake sources of the UMS9620's CPU cluster power-down (LP_AP_INTC) for the
|
||||
# mainline kernels; no vendor headers. Loaded by extra-modules; docs/FINDINGS.md 218.
|
||||
obj-m += ums9620_lpintc.o
|
||||
@@ -0,0 +1,195 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* ums9620_lpintc: the interrupts Linux enabled as wake sources of the UMS9620's CPU cluster power-down.
|
||||
*
|
||||
* In cluster-pd (the deepest cpuidle state, PSCI) a cluster and its DSU are powered off and the GIC's redistributor
|
||||
* cannot wake them: what does is the always-on LP_AP_INTC, eight blocks of 32 lines, INTCn line b being GIC SPI
|
||||
* 32 * n + b. A line wakes the cluster only where its bit in that block's IRQ_EN is set. TF-A (sml) sets those once at
|
||||
* boot from a table of its own (sml_a.img + 0x114d8): INTC0 0xf5085c00, INTC1 0x2080b9fc, INTC7 0x40, and nothing in
|
||||
* INTC2-6 - where the USB controller (dwc3, SPI 142: INTC4 bit 14), the IPA (SPI 136-138) and the PCIe MSI of the
|
||||
* Wi-Fi chip are. An interrupt of those that came while CPU0's cluster was powered down waited until something else
|
||||
* woke it: pings over USB took up to ~120 ms, and the workaround was CPU0 without cluster-pd.
|
||||
*
|
||||
* This module adds every SPI Linux has enabled in the GIC distributor (GICD_ISENABLER1..8) to IRQ_EN, at load and
|
||||
* then every few seconds from deferrable work (it never wakes a CPU by itself), so drivers loaded later are taken up
|
||||
* too. It only adds: a bit TF-A set is never cleared, and a line Linux disables again keeps its bit (the GIC still
|
||||
* masks it; it can at most wake the cluster for nothing). An enabled interrupt has to be handled anyway, so waking for
|
||||
* it costs no work, only the wait. The bits it added are taken out again before system suspend, so `mem` wakes on
|
||||
* exactly what TF-A chose, and put back on resume. On a U30 Air (6.18.57) with CPU0's cluster-pd allowed, USB pings
|
||||
* from a computer took 9.5 ms on average and 42 ms at most instead of 15.7 and 69 (WFI only on every CPU: 7.1 and 40),
|
||||
* and the cluster still powered down.
|
||||
*
|
||||
* The blocks' registers: +0x08 IRQ_EN reads the enabled mask and sets the bits written as 1, +0x0c IRQ_DIS clears the
|
||||
* bits written as 1; both are single writes, so nothing is read, modified and written back and no lock with TF-A is
|
||||
* needed. A block whose clock (AON gate 0x64900008, ap-intcN-eb, kept on by CLK_IGNORE_UNUSED) is off is left alone.
|
||||
* Only the UMS9620 is accepted. docs/FINDINGS.md 218.
|
||||
*/
|
||||
#include <linux/bits.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/syscore_ops.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
#define LPINTC_BLOCKS 8
|
||||
#define LPINTC_EN 0x08 /* read: enabled mask; write: set */
|
||||
#define LPINTC_DIS 0x0c /* write: clear */
|
||||
#define LPINTC_AON_GATE 0x64900008
|
||||
#define LPINTC_GATE_BIT(n) BIT(11 + (n))
|
||||
#define GICD_ISENABLER(n) (0x100 + 4 * (n)) /* n = 1 is SPI 0-31 */
|
||||
|
||||
static const phys_addr_t lpintc_base[LPINTC_BLOCKS] = {
|
||||
0x640c0000, 0x640d0000, 0x640e0000, 0x640f0000, 0x64100000, 0x64110000, 0x645b0000, 0x645c0000,
|
||||
};
|
||||
|
||||
static unsigned int period = 5;
|
||||
module_param(period, uint, 0444);
|
||||
MODULE_PARM_DESC(period, "seconds between two looks at the GIC for newly enabled interrupts (deferrable)");
|
||||
|
||||
static void __iomem *gicd;
|
||||
static void __iomem *intc[LPINTC_BLOCKS];
|
||||
static u32 added[LPINTC_BLOCKS]; /* the bits this module set: the ones it takes back */
|
||||
static DEFINE_SPINLOCK(lpintc_lock);
|
||||
static struct delayed_work lpintc_work;
|
||||
|
||||
static void lpintc_sync(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
u32 want, now;
|
||||
int n;
|
||||
|
||||
spin_lock_irqsave(&lpintc_lock, flags);
|
||||
for (n = 0; n < LPINTC_BLOCKS; n++) {
|
||||
if (!intc[n])
|
||||
continue;
|
||||
want = readl_relaxed(gicd + GICD_ISENABLER(n + 1));
|
||||
now = readl_relaxed(intc[n] + LPINTC_EN);
|
||||
want &= ~now;
|
||||
if (!want)
|
||||
continue;
|
||||
writel_relaxed(want, intc[n] + LPINTC_EN);
|
||||
added[n] |= want;
|
||||
pr_info("ums9620_lpintc: INTC%d +0x%08x (SPI %d-%d), now 0x%08x\n", n, want, 32 * n, 32 * n + 31,
|
||||
readl_relaxed(intc[n] + LPINTC_EN));
|
||||
}
|
||||
spin_unlock_irqrestore(&lpintc_lock, flags);
|
||||
}
|
||||
|
||||
static void lpintc_work_fn(struct work_struct *work)
|
||||
{
|
||||
lpintc_sync();
|
||||
queue_delayed_work(system_power_efficient_wq, &lpintc_work, period * HZ);
|
||||
}
|
||||
|
||||
/* the bits this module added, out (before suspend, at unload) or back in (after resume) */
|
||||
static void lpintc_apply(unsigned int reg)
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < LPINTC_BLOCKS; n++)
|
||||
if (intc[n] && added[n])
|
||||
writel_relaxed(added[n], intc[n] + reg);
|
||||
}
|
||||
|
||||
/* syscore: one CPU, interrupts off */
|
||||
static int lpintc_suspend(void *data)
|
||||
{
|
||||
lpintc_apply(LPINTC_DIS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lpintc_resume(void *data)
|
||||
{
|
||||
lpintc_apply(LPINTC_EN);
|
||||
}
|
||||
|
||||
static const struct syscore_ops lpintc_syscore_ops = {
|
||||
.suspend = lpintc_suspend,
|
||||
.resume = lpintc_resume,
|
||||
};
|
||||
|
||||
static struct syscore lpintc_syscore = { .ops = &lpintc_syscore_ops };
|
||||
|
||||
static void lpintc_unmap(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < LPINTC_BLOCKS; n++)
|
||||
if (intc[n])
|
||||
iounmap(intc[n]);
|
||||
if (gicd)
|
||||
iounmap(gicd);
|
||||
}
|
||||
|
||||
static int __init lpintc_init(void)
|
||||
{
|
||||
struct device_node *np;
|
||||
void __iomem *gate;
|
||||
u32 eb;
|
||||
int n, used = 0;
|
||||
|
||||
if (!of_machine_is_compatible("sprd,ums9620"))
|
||||
return -ENODEV;
|
||||
if (!period)
|
||||
period = 1;
|
||||
|
||||
np = of_find_compatible_node(NULL, NULL, "arm,gic-v3");
|
||||
if (!np)
|
||||
return -ENODEV;
|
||||
gicd = of_iomap(np, 0);
|
||||
of_node_put(np);
|
||||
if (!gicd)
|
||||
return -ENOMEM;
|
||||
|
||||
gate = ioremap(LPINTC_AON_GATE, 4);
|
||||
if (!gate) {
|
||||
lpintc_unmap();
|
||||
return -ENOMEM;
|
||||
}
|
||||
eb = readl(gate);
|
||||
iounmap(gate);
|
||||
|
||||
for (n = 0; n < LPINTC_BLOCKS; n++) {
|
||||
if (!(eb & LPINTC_GATE_BIT(n))) {
|
||||
pr_warn("ums9620_lpintc: INTC%d clock off (AON gate 0x%08x), left alone\n", n, eb);
|
||||
continue;
|
||||
}
|
||||
intc[n] = ioremap(lpintc_base[n], 0x10);
|
||||
if (intc[n])
|
||||
used++;
|
||||
}
|
||||
if (!used) {
|
||||
lpintc_unmap();
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
for (n = 0; n < LPINTC_BLOCKS; n++)
|
||||
if (intc[n])
|
||||
pr_info("ums9620_lpintc: INTC%d IRQ_EN 0x%08x as found\n", n, readl(intc[n] + LPINTC_EN));
|
||||
|
||||
lpintc_sync();
|
||||
register_syscore(&lpintc_syscore);
|
||||
INIT_DEFERRABLE_WORK(&lpintc_work, lpintc_work_fn);
|
||||
queue_delayed_work(system_power_efficient_wq, &lpintc_work, period * HZ);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit lpintc_exit(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
cancel_delayed_work_sync(&lpintc_work);
|
||||
unregister_syscore(&lpintc_syscore);
|
||||
spin_lock_irqsave(&lpintc_lock, flags);
|
||||
lpintc_apply(LPINTC_DIS);
|
||||
spin_unlock_irqrestore(&lpintc_lock, flags);
|
||||
lpintc_unmap();
|
||||
}
|
||||
|
||||
module_init(lpintc_init);
|
||||
module_exit(lpintc_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("UMS9620: the GIC's enabled interrupts as wake sources of the CPU cluster power-down (LP_AP_INTC)");
|
||||
Reference in new issue
Block a user