2 * Copyright (C) 2017 Linaro Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <linux/device.h>
16 #include <linux/firmware.h>
17 #include <linux/kernel.h>
20 #include <linux/of_address.h>
21 #include <linux/qcom_scm.h>
22 #include <linux/sizes.h>
23 #include <linux/soc/qcom/mdt_loader.h>
27 #define VENUS_PAS_ID 9
28 #define VENUS_FW_MEM_SIZE (6 * SZ_1M)
30 int venus_boot(struct device
*dev
, const char *fwname
)
32 const struct firmware
*mdt
;
33 struct device_node
*node
;
41 if (!IS_ENABLED(CONFIG_QCOM_MDT_LOADER
) || !qcom_scm_is_available())
44 node
= of_parse_phandle(dev
->of_node
, "memory-region", 0);
46 dev_err(dev
, "no memory-region specified\n");
50 ret
= of_address_to_resource(node
, 0, &r
);
55 mem_size
= resource_size(&r
);
57 if (mem_size
< VENUS_FW_MEM_SIZE
)
60 mem_va
= memremap(r
.start
, mem_size
, MEMREMAP_WC
);
62 dev_err(dev
, "unable to map memory region: %pa+%zx\n",
67 ret
= request_firmware(&mdt
, fwname
, dev
);
71 fw_size
= qcom_mdt_get_size(mdt
);
74 release_firmware(mdt
);
78 ret
= qcom_mdt_load(dev
, mdt
, fwname
, VENUS_PAS_ID
, mem_va
, mem_phys
,
81 release_firmware(mdt
);
86 ret
= qcom_scm_pas_auth_and_reset(VENUS_PAS_ID
);
95 int venus_shutdown(struct device
*dev
)
97 return qcom_scm_pas_shutdown(VENUS_PAS_ID
);