Skip to content

Commit de4ee22

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

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
@@ -39,6 +39,46 @@ static inline void isp_gpio_write32(struct apple_isp *isp, u32 reg, u32 val)
3939
writel(val, isp->gpio + reg);
4040
}
4141

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

212254
static int isp_firmware_boot_stage1(struct apple_isp *isp)
213255
{
214256
int err, retries;
257+
err = apple_isp_power_up_domains(isp);
258+
if (err < 0)
259+
return err;
215260

216261
err = isp_reset_coproc(isp);
217262
if (err < 0)

0 commit comments

Comments
 (0)