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

Commit a7d2d271 authored by Chandrasekhar Mattaparthy's avatar Chandrasekhar Mattaparthy
Browse files

soc: qcom: Add bgcom driver for sdm429w



The driver loads the BG firmware into memory and sends
a command to the secure userspace application to initiate
secure transfer of the BG firmware into internal memory
of BG and reset BG. The subsystem restart depends on
GPIOs present between SDM429W and BG.

Change-Id: I7122824da2814b37a82f4a480068a5677970db7d
Signed-off-by: default avatarChandrasekhar Mattaparthy <cmatta@codeaurora.org>
parent 2dfedfa3
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
Qualcomm Technologies Inc. bg-daemon

BG-Daemon : When Modem goes down, to re-establish the connections,
BG-Daemon toggles the bg-reset gpio to reset BG.

Required properties:
- compatible : should be "qcom,bg-daemon"
- qcom,bg-reset-gpio : gpio for the apps processor use to soft reset BG
- ssr-reg1-supply : Power supply needed to power up the BG device.
                When BG brought up this regulator will be in normal power mode.
- ssr-reg2-supply : Power supply needed to power up the BG device.
                When BG BG brought up this regulator will be in normal power mode.

Example:
	qcom,bg-daemon {
		compatible = "qcom,bg-daemon";
		qcom,bg-reset-gpio = <&pm660_gpios 5 0>;
		ssr-reg1-supply = <&pm660_l3>;
		ssr-reg2-supply = <&pm660_l9>;
	};
+24 −0
Original line number Diff line number Diff line
Qualcomm technologies Inc bg-spi

BG-COM SPI : bg-spi is used for the  communication with Blackghost
chipset. It uses SPI protocol for communication.
BG-COM: bgcome is a thin transport layer over glink which provides
the read/write APIs to communicate with Blackghost chipset.

Required properties:
- compatible : should be "qcom,bg-spi"
- spi-max-frequency : Maximum SPI clocking speed of device in Hz
- qcom,irq-gpio : GPIO pin
- reg : Register set

Example:
	spi@78b6000 { /* BLSP1 QUP2 */
		status = "ok";
		qcom,bg-spi {
			compatible = "qcom,bg-spi";
			reg = <0>;
			spi-max-frequency = <19200000>;
			interrupt-parent = <&msm_gpio>;
			qcom,irq-gpio = <&msm_gpio 110 1>;
		};
	};
+18 −0
Original line number Diff line number Diff line
@@ -1005,6 +1005,24 @@ config MSM_BAM_DMUX
	  provides a means to support more logical channels
	  via muxing than BAM could without muxing.

        config MSM_BGCOM_INTERFACE
        bool "Driver support for Blackghost Communication"
        depends on MSM_BGCOM
        help
                Create a bg_com_dev device node for user space communication.
                Single user space client can open device node for communication
                from hardware. Hardware will provide access to read
                registers and read/write AHB memory in the device.


        config MSM_BGCOM
        bool "Provide APIs to communicate with Blackghost chipset"
        help
                BGCOM is a thin layer above SPI. It is used whithin a SoC for
                communication between G-Link/bg_com_dev and BG processor over SPI.
                This handle the interrupts raised by BG and notify the G-link with
                interrupt event and event data.

config QCOM_SOC_INFO
	bool "Chip information for QTI SoCs"
	depends on SOC_BUS
+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ ifdef CONFIG_MSM_RPM_SMD
	obj-$(CONFIG_QTI_RPM_STATS_LOG) += rpm_master_stat.o
endif
obj-$(CONFIG_QMP_DEBUGFS_CLIENT) += qmp-debugfs-client.o
obj-$(CONFIG_MSM_BGCOM) += bgcom_spi.o
obj-$(CONFIG_MSM_BGCOM_INTERFACE) += bgcom_interface.o
obj-$(CONFIG_MSM_PERFORMANCE) += msm_performance.o
obj-$(CONFIG_MSM_DRM_NOTIFY) += msm_drm_notify.o
ifdef CONFIG_DEBUG_FS
+214 −0
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018,2020 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.
 *
 */

#ifndef BGCOM_H
#define BGCOM_H

#define BGCOM_REG_TZ_TO_MASTER_STATUS        0x01
#define BGCOM_REG_TZ_TO_MASTER_DATA          0x03
#define BGCOM_REG_SLAVE_STATUS               0x05
#define BGCOM_REG_TIMESTAMP                  0x07
#define BGCOM_REG_SLAVE_STATUS_AUTO_CLEAR    0x09
#define BGCOM_REG_FIFO_FILL                  0x0B
#define BGCOM_REG_FIFO_SIZE                  0x0D
#define BGCOM_REG_TZ_TO_SLAVE_COMMAND        0x0E
#define BGCOM_REG_TZ_TO_SLAVE_DATA           0x10
#define BGCOM_REG_MASTER_STATUS              0x12
#define BGCOM_REG_MASTER_COMMAND             0x14
#define BGCOM_REG_MSG_WR_REG_4               0x16
#define BGCOM_REG_TO_SLAVE_FIFO              0x40
#define BGCOM_REG_TO_MASTER_FIFO             0x41
#define BGCOM_REG_TO_SLAVE_AHB               0x42
#define BGCOM_REG_TO_MASTER_AHB              0x43

/* Enum to define the bgcom SPI state */
enum bgcom_spi_state {
	BGCOM_SPI_FREE = 0,
	BGCOM_SPI_BUSY,
};

/* Enums to identify Blackghost events */
enum bgcom_event_type {
	BGCOM_EVENT_NONE	= 0,
	BGCOM_EVENT_APPLICATION_RUNNING,
	BGCOM_EVENT_TO_SLAVE_FIFO_READY,
	BGCOM_EVENT_TO_MASTER_FIFO_READY,
	BGCOM_EVENT_AHB_READY,
	BGCOM_EVENT_TO_MASTER_FIFO_USED,
	BGCOM_EVENT_TO_SLAVE_FIFO_FREE,
	BGCOM_EVENT_TIMESTAMP_UPDATE,
	BGCOM_EVENT_RESET_OCCURRED,

	BGCOM_EVENT_ERROR_WRITE_FIFO_OVERRUN,
	BGCOM_EVENT_ERROR_WRITE_FIFO_BUS_ERR,
	BGCOM_EVENT_ERROR_WRITE_FIFO_ACCESS,
	BGCOM_EVENT_ERROR_READ_FIFO_UNDERRUN,
	BGCOM_EVENT_ERROR_READ_FIFO_BUS_ERR,
	BGCOM_EVENT_ERROR_READ_FIFO_ACCESS,
	BGCOM_EVENT_ERROR_TRUNCATED_READ,
	BGCOM_EVENT_ERROR_TRUNCATED_WRITE,
	BGCOM_EVENT_ERROR_AHB_ILLEGAL_ADDRESS,
	BGCOM_EVENT_ERROR_AHB_BUS_ERR,
	BGCOM_EVENT_ERROR_UNKNOWN,
};

/* Event specific data */
union bgcom_event_data_type {
	uint32_t unused;
	bool application_running;      /* BGCOM_EVENT_APPLICATION_RUNNING */
	bool to_slave_fifo_ready;      /* BGCOM_EVENT_TO_SLAVE_FIFO_READY */
	bool to_master_fifo_ready;     /* BGCOM_EVENT_TO_MASTER_FIFO_READY */
	bool ahb_ready;                /* BGCOM_EVENT_AHB_READY */
	uint16_t to_slave_fifo_free;	/* BGCOM_EVENT_TO_SLAVE_FIFO_FREE */
	struct fifo_event_data {
		uint16_t to_master_fifo_used;
		void *data;
	} fifo_data;
};

/* Client specific data */
struct bgcom_open_config_type {
	/** Private data pointer for client to maintain context.
	 * This data is passed back to client in the notification callbacks.
	 */
	void		*priv;

	/* Notification callbacks to notify the BG events */
	void (*bgcom_notification_cb)(void *handle, void *priv,
			enum bgcom_event_type event,
			union bgcom_event_data_type *event_data);
};

/**
 * bgcom_open() - opens a channel to interact with Blackghost
 * @open_config: pointer to the open configuration structure
 *
 * Open a new connection to blackghost
 *
 * Return a handle on success or NULL on error
 */
void *bgcom_open(struct bgcom_open_config_type *open_config);

/**
 * bgcom_close() - close the exsting with Blackghost
 * @handle: pointer to the handle, provided by bgcom at
 *	bgcom_open
 *
 * Open a new connection to blackghost
 *
 * Return 0 on success or error on invalid handle
 */
int bgcom_close(void **handle);

/**
 * bgcom_reg_read() - Read from the one or more contiguous registers from BG
 * @handle: BGCOM handle associated with the channel
 * @reg_start_addr : 8 bit start address of the registers to read from
 * @num_regs :	Number of contiguous registers to read, starting
 *				from reg_start_addr.
 * @read_buf : Buffer to read from the registers.
 * Return 0 on success or -Ve on error
 */
int bgcom_reg_read(void *handle, uint8_t reg_start_addr,
			uint32_t num_regs, void *read_buf);

/**
 * Write into the one or more contiguous registers.
 *
 * @param[in] handle         BGCOM handle associated with the channel.
 * @param[in] reg_start_addr 8bit start address of the registers to write into.
 * @param[in] num_regs       Number of contiguous registers to write, starting
 *                           from reg_start_addr.
 * @param[in] write_buf      Buffer to write into the registers.
 *
 * @return
 * 0 if function is successful,
 * Otherwise returns error code.
 *
 * @sideeffects  Causes the Blackghost SPI slave to wakeup. Depending up on
 * the operation, it may also wakeup the complete Blackghost.
 */

/**
 * bgcom_reg_write() - Write to the one or more contiguous registers on BG
 * @handle: BGCOM handle associated with the channel
 * @reg_start_addr : 8 bit start address of the registers to read from
 * @num_regs :	Number of contiguous registers to write, starting
 *				from reg_start_addr.
 * @write_buf : Buffer to be written to the registers.
 * Return 0 on success or -Ve on error
 */
int bgcom_reg_write(void *handle, uint8_t reg_start_addr,
	uint8_t num_regs, void *write_buf);

/**
 * bgcom_fifo_read() - Read data from the TO_MASTER_FIFO.
 * @handle: BGCOM handle associated with the channel
 * @num_words : number of words to read from FIFO
 * @read_buf : Buffer read from FIFO.
 * Return 0 on success or -Ve on error
 */
int bgcom_fifo_read(void *handle, uint32_t num_words,
		void *read_buf);

/**
 * bgcom_fifo_write() - Write data to the TO_SLAVE_FIFO.
 * @handle: BGCOM handle associated with the channel
 * @num_words : number of words to write on FIFO
 * @write_buf : Buffer written to FIFO.
 * Return 0 on success or -Ve on error
 */
int bgcom_fifo_write(void *handle, uint32_t num_words,
		void *write_buf);

/**
 * bgcom_ahb_read() - Read data from the AHB memory.
 * @handle: BGCOM handle associated with the channel
 * @ahb_start_addr : Memory start address from where to read
 * @num_words : number of words to read from AHB
 * @read_buf : Buffer read from FIFO.
 * Return 0 on success or -Ve on error
 */
int bgcom_ahb_read(void *handle, uint32_t ahb_start_addr,
		uint32_t num_words, void *read_buf);

/**
 * bgcom_ahb_write() - Write data to the AHB memory.
 * @handle: BGCOM handle associated with the channel
 * @ahb_start_addr : Memory start address from where to start write
 * @num_words : number of words to read from AHB
 * @write_buf : Buffer to write in AHB.
 * Return 0 on success or -Ve on error
 */
int bgcom_ahb_write(void *handle, uint32_t ahb_start_addr,
		uint32_t num_words, void *write_buf);

/**
 * bgcom_suspend() - Suspends the channel.
 * @handle: BGCOM handle associated with the channel
 * Return 0 on success or -Ve on error
 */
int bgcom_suspend(void *handle);

/**
 * bgcom_resume() - Resumes the channel.
 * @handle: BGCOM handle associated with the channel
 * Return 0 on success or -Ve on error
 */
int bgcom_resume(void *handle);

int bgcom_set_spi_state(enum bgcom_spi_state state);

void bgcom_bgdown_handler(void);

#endif /* BGCOM_H */
Loading