Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions drivers/media/platform/apple/isp/isp-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,8 @@ static const struct apple_isp_hw apple_isp_hw_t8132 = {
.shared_size = 0xdec00000,
.fw_restore = true,
.deferred_start = true,
/* macOS never writes its coprocessor control word 0 at power-down */
.macos_stop = true,
};

/*
Expand Down
5 changes: 5 additions & 0 deletions drivers/media/platform/apple/isp/isp-drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ struct apple_isp_hw {
* reopen the camera, does not wait for another firmware start.
*/
unsigned int fw_idle_ms;

/* Power down as macOS does: the coprocessor control word is left as it is */
bool macos_stop;
};

enum isp_sensor_id {
Expand Down Expand Up @@ -503,6 +506,8 @@ struct apple_isp {
* resident firmware cannot be started again before the next boot.
*/
bool ipc_failed;
/* The last power-down left the coprocessor control word as it was */
bool macos_stopped;
};

struct isp_chan_ops {
Expand Down
20 changes: 18 additions & 2 deletions drivers/media/platform/apple/isp/isp-fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/iommu.h>
#include <linux/iopoll.h>
#include <linux/ktime.h>
#include <linux/moduleparam.h>
#include <linux/overflow.h>
#include <linux/pm_runtime.h>
#include <linux/soc/apple/sleep.h>
Expand All @@ -23,6 +24,15 @@
#include "isp-iommu.h"
#include "isp-ipc.h"
#include "isp-regs.h"

/*
* macOS powers the T8132 ISP down without writing the coprocessor control
* word 0. macos_stop=N writes it again, as before.
*/
static bool macos_stop = true;
module_param(macos_stop, bool, 0644);
MODULE_PARM_DESC(macos_stop,
"Power the ISP down as macOS does where known, e.g. T8132: leave the control word alone (default: on)");
#include "isp-v4l2.h"

#define ISP_FIRMWARE_POLL_US 1000
Expand Down Expand Up @@ -356,7 +366,11 @@ static int isp_check_coproc_t6040(struct apple_isp *isp)
u32 control = isp_coproc_read32(isp, isp_coproc_control(isp));
u64 rvbar = readq(isp->coproc + ISP_COPROC_RVBAR);

if (control) {
/*
* A macOS-style power-down leaves the start word (0x10) where the
* domain kept it; the boot writes 0 then 0x10 as for a fresh start.
*/
if (control && !(isp->macos_stopped && control == 0x10)) {
isp_err(isp, "coprocessor already started (control 0x%x)\n",
control);
return -EBUSY;
Expand Down Expand Up @@ -477,6 +491,7 @@ static void isp_firmware_shutdown_stage1(struct apple_isp *isp)
/* Only a coprocessor that was started has to settle and quiesce */
bool started = isp->hw->coproc_quiesce &&
isp_coproc_read32(isp, isp_coproc_control(isp));
bool macos = READ_ONCE(macos_stop) && isp->hw->macos_stop;
u32 val;

/* A coprocessor that powered down waits in WFI */
Expand All @@ -491,7 +506,7 @@ static void isp_firmware_shutdown_stage1(struct apple_isp *isp)
* engine's own restore of the ISP in a wake that kept DRAM up depends on it:
* with the bit cleared that wake stalls until the SoC's watchdog resets it.
*/
if (isp->hw->gen != ISP_GEN_T8140)
if (isp->hw->gen != ISP_GEN_T8140 && !macos)
isp_coproc_write32(isp, isp_coproc_control(isp), 0x0);

if (started) {
Expand All @@ -503,6 +518,7 @@ static void isp_firmware_shutdown_stage1(struct apple_isp *isp)
}

apple_isp_power_down_domains(isp);
isp->macos_stopped = macos;
}

static int isp_firmware_boot_stage1(struct apple_isp *isp)
Expand Down
Loading