Skip to content

Commit 91257ee

Browse files
hoshinolinajannau
authored andcommitted
media: apple: isp: Make sub-pmdomain handling explicit
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent ade15c7 commit 91257ee

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

drivers/media/platform/apple/isp/isp-drv.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,21 @@ static int apple_isp_attach_genpd(struct apple_isp *isp)
5454
return -ENOMEM;
5555

5656
for (int i = 0; i < isp->pd_count; i++) {
57+
int flags = DL_FLAG_STATELESS;
58+
59+
/* Primary power domain uses RPM integration */
60+
if (i == 0)
61+
flags |= DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE;
62+
5763
isp->pd_dev[i] = dev_pm_domain_attach_by_id(dev, i);
5864
if (IS_ERR(isp->pd_dev[i])) {
5965
apple_isp_detach_genpd(isp);
6066
return PTR_ERR(isp->pd_dev[i]);
6167
}
6268

6369
isp->pd_link[i] =
64-
device_link_add(dev, isp->pd_dev[i],
65-
DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
66-
DL_FLAG_RPM_ACTIVE);
70+
device_link_add(dev, isp->pd_dev[i], flags);
71+
6772
if (!isp->pd_link[i]) {
6873
apple_isp_detach_genpd(isp);
6974
return -EINVAL;

drivers/media/platform/apple/isp/isp-drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct apple_isp {
198198
int pd_count;
199199
struct device **pd_dev;
200200
struct device_link **pd_link;
201+
bool pds_active;
201202

202203
int irq;
203204

drivers/media/platform/apple/isp/isp-fw.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,46 @@ static inline void isp_gpio_write32(struct apple_isp *isp, u32 reg, u32 val)
4141
writel(val, isp->gpio + reg);
4242
}
4343

44+
int apple_isp_power_up_domains(struct apple_isp *isp)
45+
static int apple_isp_power_up_domains(struct apple_isp *isp)
46+
int ret;
47+
48+
if (isp->pds_active)
49+
return 0;
50+
51+
for (int i = 1; i < isp->pd_count; i++) {
52+
ret = pm_runtime_get_sync(isp->pd_dev[i]);
53+
if (ret < 0) {
54+
dev_err(isp->dev,
55+
"Failed to power up power domain %d: %d\n", i, ret);
56+
while (--i != 1)
57+
pm_runtime_put_sync(isp->pd_dev[i]);
58+
return ret;
59+
}
60+
}
61+
62+
isp->pds_active = true;
63+
64+
return 0;
65+
}
66+
67+
void apple_isp_power_down_domains(struct apple_isp *isp)
68+
static void apple_isp_power_down_domains(struct apple_isp *isp)
69+
int ret;
70+
71+
if (!isp->pds_active)
72+
return;
73+
74+
for (int i = isp->pd_count - 1; i >= 1; i--) {
75+
ret = pm_runtime_put_sync(isp->pd_dev[i]);
76+
if (ret < 0)
77+
dev_err(isp->dev,
78+
"Failed to power up power domain %d: %d\n", i, ret);
79+
}
80+
81+
isp->pds_active = false;
82+
}
83+
4484
void *apple_isp_translate(struct apple_isp *isp, struct isp_surf *surf,
4585
dma_addr_t iova, size_t size)
4686
{
@@ -209,11 +249,16 @@ static int isp_reset_coproc(struct apple_isp *isp)
209249
static void isp_firmware_shutdown_stage1(struct apple_isp *isp)
210250
{
211251
isp_coproc_write32(isp, ISP_COPROC_CONTROL, 0x0);
252+
253+
apple_isp_power_down_domains(isp);
212254
}
213255

214256
static int isp_firmware_boot_stage1(struct apple_isp *isp)
215257
{
216258
int err, retries;
259+
err = apple_isp_power_up_domains(isp);
260+
if (err < 0)
261+
return err;
217262

218263
err = isp_reset_coproc(isp);
219264
if (err < 0)

0 commit comments

Comments
 (0)