Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d83ea99 authored by Tirupathi Reddy's avatar Tirupathi Reddy
Browse files

msm: pil-bcast: Introduce PIL BCSS driver



PIL BCSS platform driver suppports firmware bundle loading
and authentication for Broadcast subsystem demodulator.

Change-Id: I07f5b3efce894b52e306fc441b1ae23e24fbb43c
Signed-off-by: default avatarTirupathi Reddy <tirupath@codeaurora.org>
parent bfc96c5e
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
* Broadcast Subsystem Peripheral Image Loader

pil-bcss is a peripheral image loading (PIL) driver. It is used for loading
and authenticating broadcast demodulator firmware images.

Required properties:
- compatible: "pil-bcss"
- qcom,firmware-name: Base name of the firmware image. Ex. "bcss"

Example:

	qcom,pil-bcss {
		compatible = "qcom,pil-bcss";

		qcom,firmware-name = "bcss";
	};
+9 −0
Original line number Diff line number Diff line
@@ -1236,6 +1236,15 @@ config MSM_PIL_VPU
	  VPU is the Video Processing subsystem processor used for
	  video processing.

config MSM_PIL_BCSS
	tristate "BCSS (Broadcast Subsystem Boot Support)"
	depends on MSM_PIL && MSM_SUBSYSTEM_RESTART
	help
	  Support for booting and shutdown the Broadcast subsystem demodulator.

	  BCSS is the Broadcast subsystem processor to receive and process the
	  Analog/Digital broadcast data from tuners / external demodulator.

config MSM_PIL_GSS
	tristate "GSS (Cortex A5) Boot Support"
	depends on MSM_PIL && MSM_SUBSYSTEM_RESTART
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ obj-$(CONFIG_MSM_PIL_PRONTO) += pil-pronto.o
obj-$(CONFIG_MSM_PIL_VENUS) += pil-venus.o
obj-$(CONFIG_MSM_PIL_VPU) += pil-vpu.o
obj-$(CONFIG_MSM_PIL_FEMTO) += pil-q6v5.o pil-msa.o pil-femto-modem.o
obj-$(CONFIG_MSM_PIL_BCSS) += pil-bcss.o
obj-$(CONFIG_MSM_FIQ_SUPPORT) += fiq_glue.o
obj-$(CONFIG_MSM_BAM_DMUX) += bam_dmux.o
obj-$(CONFIG_MSM_SMD_LOGGING) += smem_log.o
+182 −0
Original line number Diff line number Diff line
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/delay.h>

#include <mach/subsystem_restart.h>
#include <mach/ramdump.h>

#include "peripheral-loader.h"
#include "scm-pas.h"

struct bcss_data {
	struct pil_desc desc;
	struct subsys_device *subsys;
	struct subsys_desc subsys_desc;
	bool is_booted;
	void *ramdump_dev;
};

static int pil_bcss_init_image(struct pil_desc *pil,
		const u8 *metadata, size_t size)
{
	return pas_init_image(PAS_BCSS, metadata, size);
}

static int pil_bcss_mem_setup(struct pil_desc *pil, phys_addr_t addr,
			       size_t size)
{
	return pas_mem_setup(PAS_BCSS, addr, size);
}

static int pil_bcss_auth(struct pil_desc *pil)
{
	return pas_auth_and_reset(PAS_BCSS);
}

static int pil_bcss_shutdown(struct pil_desc *pil)
{
	return pas_shutdown(PAS_BCSS);
}

static struct pil_reset_ops pil_bcss_ops = {
	.init_image = pil_bcss_init_image,
	.mem_setup =  pil_bcss_mem_setup,
	.auth_and_reset = pil_bcss_auth,
	.shutdown = pil_bcss_shutdown,
};

#define subsys_to_drv(d) container_of(d, struct bcss_data, subsys_desc)

static int bcss_shutdown(const struct subsys_desc *subsys, bool force_stop)
{
	struct bcss_data *drv = subsys_to_drv(subsys);

	pil_shutdown(&drv->desc);

	return 0;
}

static int bcss_powerup(const struct subsys_desc *subsys)
{
	struct bcss_data *drv = subsys_to_drv(subsys);

	return pil_boot(&drv->desc);
}

static int bcss_ramdump(int enable, const struct subsys_desc *subsys)
{
	struct bcss_data *drv = subsys_to_drv(subsys);

	if (!enable)
		return 0;

	return pil_do_ramdump(&drv->desc, drv->ramdump_dev);
}

static int pil_bcss_driver_probe(struct platform_device *pdev)
{
	struct bcss_data *drv;
	struct pil_desc *desc;
	int ret;

	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
	if (!drv)
		return -ENOMEM;
	platform_set_drvdata(pdev, drv);

	desc = &drv->desc;
	ret = of_property_read_string(pdev->dev.of_node, "qcom,firmware-name",
			&desc->name);
	if (ret)
		return ret;

	desc->dev = &pdev->dev;
	desc->owner = THIS_MODULE;

	ret = pas_supported(PAS_BCSS);
	if (ret > 0) {
		desc->ops = &pil_bcss_ops;
		dev_info(&pdev->dev, "using secure boot\n");
	} else {
		dev_err(&pdev->dev, "Secure boot is not supported\n");
		return ret;
	}

	ret = pil_desc_init(desc);
	if (ret)
		return ret;

	drv->subsys_desc.name = desc->name;
	drv->subsys_desc.dev = &pdev->dev;
	drv->subsys_desc.owner = THIS_MODULE;
	drv->subsys_desc.shutdown = bcss_shutdown;
	drv->subsys_desc.powerup = bcss_powerup;
	drv->subsys_desc.ramdump = bcss_ramdump;

	drv->ramdump_dev = create_ramdump_device("bcss", &pdev->dev);
	if (!drv->ramdump_dev) {
		ret = -ENOMEM;
		goto err_ramdump;
	}

	drv->subsys = subsys_register(&drv->subsys_desc);
	if (IS_ERR(drv->subsys)) {
		ret = PTR_ERR(drv->subsys);
		goto err_subsys;
	}
	return ret;

err_subsys:
	destroy_ramdump_device(drv->ramdump_dev);
err_ramdump:
	pil_desc_release(desc);

	return ret;
}

static int pil_bcss_driver_remove(struct platform_device *pdev)
{
	struct bcss_data *drv = platform_get_drvdata(pdev);

	subsys_unregister(drv->subsys);
	destroy_ramdump_device(drv->ramdump_dev);
	pil_desc_release(&drv->desc);

	return 0;
}

static const struct of_device_id msm_pil_bcss_match[] = {
	{.compatible = "qcom,pil-bcss"},
	{}
};

static struct platform_driver pil_bcss_driver = {
	.probe = pil_bcss_driver_probe,
	.remove = pil_bcss_driver_remove,
	.driver = {
		.name = "pil-bcss",
		.owner = THIS_MODULE,
		.of_match_table = of_match_ptr(msm_pil_bcss_match),
	},
};

module_platform_driver(pil_bcss_driver);

MODULE_DESCRIPTION("Support for booting broadcast subsystem");
MODULE_LICENSE("GPL v2");
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ enum pas_id {
	PAS_GSS,
	PAS_VIDC,
	PAS_VPU,
	PAS_BCSS,
};

#ifdef CONFIG_MSM_PIL