Commit 830ebd37 authored by Arnd Bergmann's avatar Arnd Bergmann

Merge tag 'qcom-drivers-for-4.16' of...

Merge tag 'qcom-drivers-for-4.16' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/agross/linux into next/drivers

Pull "Qualcomm ARM Based Driver Updates for v4.16 - Redo" from Andy Gross:

* Fix error handling code in SMP2P probe
* Update SMP2P to use ACPS as mailbox client
* Add QMI support
* Fixups for Qualcomm SCM
* Fix licensing on rmtfs_mem
* Correct SMSM child node lookup
* Populate firmware nodes during platform init

* tag 'qcom-drivers-for-4.16' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/agross/linux:
  of: platform: populate /firmware/ node from of_platform_default_populate_init()
  soc: qcom: smp2p: Use common error handling code in qcom_smp2p_probe()
  soc: qcom: Introduce QMI helpers
  soc: qcom: Introduce QMI encoder/decoder
  firmware: qcom_scm: Add dependent headers to qcom_scm.h
  soc: qcom: smp2p: Access APCS as mailbox client
  soc: qcom: rmtfs_mem: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
  soc: qcom: smsm: fix child-node lookup
  firmware: qcom_scm: drop redandant of_platform_populate
parents 57e36159 3aa0582f
...@@ -17,9 +17,15 @@ processor ID) and a string identifier. ...@@ -17,9 +17,15 @@ processor ID) and a string identifier.
Value type: <prop-encoded-array> Value type: <prop-encoded-array>
Definition: one entry specifying the smp2p notification interrupt Definition: one entry specifying the smp2p notification interrupt
- qcom,ipc: - mboxes:
Usage: required Usage: required
Value type: <prop-encoded-array> Value type: <prop-encoded-array>
Definition: reference to the associated doorbell in APCS, as described
in mailbox/mailbox.txt
- qcom,ipc:
Usage: required, unless mboxes is specified
Value type: <prop-encoded-array>
Definition: three entries specifying the outgoing ipc bit used for Definition: three entries specifying the outgoing ipc bit used for
signaling the remote end of the smp2p edge: signaling the remote end of the smp2p edge:
- phandle to a syscon node representing the apcs registers - phandle to a syscon node representing the apcs registers
......
...@@ -622,30 +622,6 @@ static struct platform_driver qcom_scm_driver = { ...@@ -622,30 +622,6 @@ static struct platform_driver qcom_scm_driver = {
static int __init qcom_scm_init(void) static int __init qcom_scm_init(void)
{ {
struct device_node *np, *fw_np;
int ret;
fw_np = of_find_node_by_name(NULL, "firmware");
if (!fw_np)
return -ENODEV;
np = of_find_matching_node(fw_np, qcom_scm_dt_match);
if (!np) {
of_node_put(fw_np);
return -ENODEV;
}
of_node_put(np);
ret = of_platform_populate(fw_np, qcom_scm_dt_match, NULL, NULL);
of_node_put(fw_np);
if (ret)
return ret;
return platform_driver_register(&qcom_scm_driver); return platform_driver_register(&qcom_scm_driver);
} }
subsys_initcall(qcom_scm_init); subsys_initcall(qcom_scm_init);
...@@ -518,6 +518,10 @@ static int __init of_platform_default_populate_init(void) ...@@ -518,6 +518,10 @@ static int __init of_platform_default_populate_init(void)
for_each_matching_node(node, reserved_mem_matches) for_each_matching_node(node, reserved_mem_matches)
of_platform_device_create(node, NULL, NULL); of_platform_device_create(node, NULL, NULL);
node = of_find_node_by_path("/firmware");
if (node)
of_platform_populate(node, NULL, NULL, NULL);
/* Populate everything else. */ /* Populate everything else. */
of_platform_default_populate(NULL, NULL, NULL); of_platform_default_populate(NULL, NULL, NULL);
......
...@@ -35,6 +35,15 @@ config QCOM_PM ...@@ -35,6 +35,15 @@ config QCOM_PM
modes. It interface with various system drivers to put the cores in modes. It interface with various system drivers to put the cores in
low power modes. low power modes.
config QCOM_QMI_HELPERS
tristate
depends on ARCH_QCOM
help
Helper library for handling QMI encoded messages. QMI encoded
messages are used in communication between the majority of QRTR
clients and this helpers provide the common functionality needed for
doing this from a kernel driver.
config QCOM_RMTFS_MEM config QCOM_RMTFS_MEM
tristate "Qualcomm Remote Filesystem memory driver" tristate "Qualcomm Remote Filesystem memory driver"
depends on ARCH_QCOM depends on ARCH_QCOM
...@@ -75,6 +84,7 @@ config QCOM_SMEM_STATE ...@@ -75,6 +84,7 @@ config QCOM_SMEM_STATE
config QCOM_SMP2P config QCOM_SMP2P
tristate "Qualcomm Shared Memory Point to Point support" tristate "Qualcomm Shared Memory Point to Point support"
depends on MAILBOX
depends on QCOM_SMEM depends on QCOM_SMEM
select QCOM_SMEM_STATE select QCOM_SMEM_STATE
help help
......
...@@ -3,6 +3,8 @@ obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o ...@@ -3,6 +3,8 @@ obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o
obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o
obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o
obj-$(CONFIG_QCOM_PM) += spm.o obj-$(CONFIG_QCOM_PM) += spm.o
obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o
qmi_helpers-y += qmi_encdec.o qmi_interface.o
obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o
obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o
obj-$(CONFIG_QCOM_SMEM) += smem.o obj-$(CONFIG_QCOM_SMEM) += smem.o
......
This diff is collapsed.
This diff is collapsed.
...@@ -267,3 +267,7 @@ static void qcom_rmtfs_mem_exit(void) ...@@ -267,3 +267,7 @@ static void qcom_rmtfs_mem_exit(void)
unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX); unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX);
} }
module_exit(qcom_rmtfs_mem_exit); module_exit(qcom_rmtfs_mem_exit);
MODULE_AUTHOR("Linaro Ltd");
MODULE_DESCRIPTION("Qualcomm Remote Filesystem memory driver");
MODULE_LICENSE("GPL v2");
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/mailbox_client.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -126,6 +127,8 @@ struct smp2p_entry { ...@@ -126,6 +127,8 @@ struct smp2p_entry {
* @ipc_regmap: regmap for the outbound ipc * @ipc_regmap: regmap for the outbound ipc
* @ipc_offset: offset within the regmap * @ipc_offset: offset within the regmap
* @ipc_bit: bit in regmap@offset to kick to signal remote processor * @ipc_bit: bit in regmap@offset to kick to signal remote processor
* @mbox_client: mailbox client handle
* @mbox_chan: apcs ipc mailbox channel handle
* @inbound: list of inbound entries * @inbound: list of inbound entries
* @outbound: list of outbound entries * @outbound: list of outbound entries
*/ */
...@@ -146,6 +149,9 @@ struct qcom_smp2p { ...@@ -146,6 +149,9 @@ struct qcom_smp2p {
int ipc_offset; int ipc_offset;
int ipc_bit; int ipc_bit;
struct mbox_client mbox_client;
struct mbox_chan *mbox_chan;
struct list_head inbound; struct list_head inbound;
struct list_head outbound; struct list_head outbound;
}; };
...@@ -154,7 +160,13 @@ static void qcom_smp2p_kick(struct qcom_smp2p *smp2p) ...@@ -154,7 +160,13 @@ static void qcom_smp2p_kick(struct qcom_smp2p *smp2p)
{ {
/* Make sure any updated data is written before the kick */ /* Make sure any updated data is written before the kick */
wmb(); wmb();
regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit));
if (smp2p->mbox_chan) {
mbox_send_message(smp2p->mbox_chan, NULL);
mbox_client_txdone(smp2p->mbox_chan, 0);
} else {
regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit));
}
} }
/** /**
...@@ -453,10 +465,6 @@ static int qcom_smp2p_probe(struct platform_device *pdev) ...@@ -453,10 +465,6 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, smp2p); platform_set_drvdata(pdev, smp2p);
ret = smp2p_parse_ipc(smp2p);
if (ret)
return ret;
key = "qcom,smem"; key = "qcom,smem";
ret = of_property_read_u32_array(pdev->dev.of_node, key, ret = of_property_read_u32_array(pdev->dev.of_node, key,
smp2p->smem_items, 2); smp2p->smem_items, 2);
...@@ -465,17 +473,13 @@ static int qcom_smp2p_probe(struct platform_device *pdev) ...@@ -465,17 +473,13 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
key = "qcom,local-pid"; key = "qcom,local-pid";
ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->local_pid); ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->local_pid);
if (ret < 0) { if (ret)
dev_err(&pdev->dev, "failed to read %s\n", key); goto report_read_failure;
return -EINVAL;
}
key = "qcom,remote-pid"; key = "qcom,remote-pid";
ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->remote_pid); ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->remote_pid);
if (ret < 0) { if (ret)
dev_err(&pdev->dev, "failed to read %s\n", key); goto report_read_failure;
return -EINVAL;
}
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
...@@ -483,9 +487,23 @@ static int qcom_smp2p_probe(struct platform_device *pdev) ...@@ -483,9 +487,23 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
return irq; return irq;
} }
smp2p->mbox_client.dev = &pdev->dev;
smp2p->mbox_client.knows_txdone = true;
smp2p->mbox_chan = mbox_request_channel(&smp2p->mbox_client, 0);
if (IS_ERR(smp2p->mbox_chan)) {
if (PTR_ERR(smp2p->mbox_chan) != -ENODEV)
return PTR_ERR(smp2p->mbox_chan);
smp2p->mbox_chan = NULL;
ret = smp2p_parse_ipc(smp2p);
if (ret)
return ret;
}
ret = qcom_smp2p_alloc_outbound_item(smp2p); ret = qcom_smp2p_alloc_outbound_item(smp2p);
if (ret < 0) if (ret < 0)
return ret; goto release_mbox;
for_each_available_child_of_node(pdev->dev.of_node, node) { for_each_available_child_of_node(pdev->dev.of_node, node) {
entry = devm_kzalloc(&pdev->dev, sizeof(*entry), GFP_KERNEL); entry = devm_kzalloc(&pdev->dev, sizeof(*entry), GFP_KERNEL);
...@@ -540,7 +558,14 @@ static int qcom_smp2p_probe(struct platform_device *pdev) ...@@ -540,7 +558,14 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
smp2p->out->valid_entries = 0; smp2p->out->valid_entries = 0;
release_mbox:
mbox_free_channel(smp2p->mbox_chan);
return ret; return ret;
report_read_failure:
dev_err(&pdev->dev, "failed to read %s\n", key);
return -EINVAL;
} }
static int qcom_smp2p_remove(struct platform_device *pdev) static int qcom_smp2p_remove(struct platform_device *pdev)
...@@ -554,6 +579,8 @@ static int qcom_smp2p_remove(struct platform_device *pdev) ...@@ -554,6 +579,8 @@ static int qcom_smp2p_remove(struct platform_device *pdev)
list_for_each_entry(entry, &smp2p->outbound, node) list_for_each_entry(entry, &smp2p->outbound, node)
qcom_smem_state_unregister(entry->state); qcom_smem_state_unregister(entry->state);
mbox_free_channel(smp2p->mbox_chan);
smp2p->out->valid_entries = 0; smp2p->out->valid_entries = 0;
return 0; return 0;
......
...@@ -496,8 +496,10 @@ static int qcom_smsm_probe(struct platform_device *pdev) ...@@ -496,8 +496,10 @@ static int qcom_smsm_probe(struct platform_device *pdev)
if (!smsm->hosts) if (!smsm->hosts)
return -ENOMEM; return -ENOMEM;
local_node = of_find_node_with_property(of_node_get(pdev->dev.of_node), for_each_child_of_node(pdev->dev.of_node, local_node) {
"#qcom,smem-state-cells"); if (of_find_property(local_node, "#qcom,smem-state-cells", NULL))
break;
}
if (!local_node) { if (!local_node) {
dev_err(&pdev->dev, "no state entry\n"); dev_err(&pdev->dev, "no state entry\n");
return -EINVAL; return -EINVAL;
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#ifndef __QCOM_SCM_H #ifndef __QCOM_SCM_H
#define __QCOM_SCM_H #define __QCOM_SCM_H
#include <linux/types.h>
#include <linux/cpumask.h>
#define QCOM_SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) #define QCOM_SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF))
#define QCOM_SCM_CPU_PWR_DOWN_L2_ON 0x0 #define QCOM_SCM_CPU_PWR_DOWN_L2_ON 0x0
#define QCOM_SCM_CPU_PWR_DOWN_L2_OFF 0x1 #define QCOM_SCM_CPU_PWR_DOWN_L2_OFF 0x1
......
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
* Copyright (c) 2017, Linaro Ltd.
*/
#ifndef __QMI_HELPERS_H__
#define __QMI_HELPERS_H__
#include <linux/completion.h>
#include <linux/idr.h>
#include <linux/list.h>
#include <linux/qrtr.h>
#include <linux/types.h>
#include <linux/workqueue.h>
struct socket;
/**
* qmi_header - wireformat header of QMI messages
* @type: type of message
* @txn_id: transaction id
* @msg_id: message id
* @msg_len: length of message payload following header
*/
struct qmi_header {
u8 type;
u16 txn_id;
u16 msg_id;
u16 msg_len;
} __packed;
#define QMI_REQUEST 0
#define QMI_RESPONSE 2
#define QMI_INDICATION 4
#define QMI_COMMON_TLV_TYPE 0
enum qmi_elem_type {
QMI_EOTI,
QMI_OPT_FLAG,
QMI_DATA_LEN,
QMI_UNSIGNED_1_BYTE,
QMI_UNSIGNED_2_BYTE,
QMI_UNSIGNED_4_BYTE,
QMI_UNSIGNED_8_BYTE,
QMI_SIGNED_2_BYTE_ENUM,
QMI_SIGNED_4_BYTE_ENUM,
QMI_STRUCT,
QMI_STRING,
};
enum qmi_array_type {
NO_ARRAY,
STATIC_ARRAY,
VAR_LEN_ARRAY,
};
/**
* struct qmi_elem_info - describes how to encode a single QMI element
* @data_type: Data type of this element.
* @elem_len: Array length of this element, if an array.
* @elem_size: Size of a single instance of this data type.
* @array_type: Array type of this element.
* @tlv_type: QMI message specific type to identify which element
* is present in an incoming message.
* @offset: Specifies the offset of the first instance of this
* element in the data structure.
* @ei_array: Null-terminated array of @qmi_elem_info to describe nested
* structures.
*/
struct qmi_elem_info {
enum qmi_elem_type data_type;
u32 elem_len;
u32 elem_size;
enum qmi_array_type array_type;
u8 tlv_type;
u32 offset;
struct qmi_elem_info *ei_array;
};
#define QMI_RESULT_SUCCESS_V01 0
#define QMI_RESULT_FAILURE_V01 1
#define QMI_ERR_NONE_V01 0
#define QMI_ERR_MALFORMED_MSG_V01 1
#define QMI_ERR_NO_MEMORY_V01 2
#define QMI_ERR_INTERNAL_V01 3
#define QMI_ERR_CLIENT_IDS_EXHAUSTED_V01 5
#define QMI_ERR_INVALID_ID_V01 41
#define QMI_ERR_ENCODING_V01 58
#define QMI_ERR_INCOMPATIBLE_STATE_V01 90
#define QMI_ERR_NOT_SUPPORTED_V01 94
/**
* qmi_response_type_v01 - common response header (decoded)
* @result: result of the transaction
* @error: error value, when @result is QMI_RESULT_FAILURE_V01
*/
struct qmi_response_type_v01 {
u16 result;
u16 error;
};
extern struct qmi_elem_info qmi_response_type_v01_ei[];
/**
* struct qmi_service - context to track lookup-results
* @service: service type
* @version: version of the @service
* @instance: instance id of the @service
* @node: node of the service
* @port: port of the service
* @priv: handle for client's use
* @list_node: list_head for house keeping
*/
struct qmi_service {
unsigned int service;
unsigned int version;
unsigned int instance;
unsigned int node;
unsigned int port;
void *priv;
struct list_head list_node;
};
struct qmi_handle;
/**
* struct qmi_ops - callbacks for qmi_handle
* @new_server: inform client of a new_server lookup-result, returning
* successfully from this call causes the library to call
* @del_server as the service is removed from the
* lookup-result. @priv of the qmi_service can be used by
* the client
* @del_server: inform client of a del_server lookup-result
* @net_reset: inform client that the name service was restarted and
* that and any state needs to be released
* @msg_handler: invoked for incoming messages, allows a client to
* override the usual QMI message handler
* @bye: inform a client that all clients from a node are gone
* @del_client: inform a client that a particular client is gone
*/
struct qmi_ops {
int (*new_server)(struct qmi_handle *qmi, struct qmi_service *svc);
void (*del_server)(struct qmi_handle *qmi, struct qmi_service *svc);
void (*net_reset)(struct qmi_handle *qmi);
void (*msg_handler)(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
const void *data, size_t count);
void (*bye)(struct qmi_handle *qmi, unsigned int node);
void (*del_client)(struct qmi_handle *qmi,
unsigned int node, unsigned int port);
};
/**
* struct qmi_txn - transaction context
* @qmi: QMI handle this transaction is associated with
* @id: transaction id
* @lock: for synchronization between handler and waiter of messages
* @completion: completion object as the transaction receives a response
* @result: result code for the completed transaction
* @ei: description of the QMI encoded response (optional)
* @dest: destination buffer to decode message into (optional)
*/
struct qmi_txn {
struct qmi_handle *qmi;
int id;
struct mutex lock;
struct completion completion;
int result;
struct qmi_elem_info *ei;
void *dest;
};
/**
* struct qmi_msg_handler - description of QMI message handler
* @type: type of message
* @msg_id: message id
* @ei: description of the QMI encoded message
* @decoded_size: size of the decoded object
* @fn: function to invoke as the message is decoded
*/
struct qmi_msg_handler {
unsigned int type;
unsigned int msg_id;
struct qmi_elem_info *ei;
size_t decoded_size;
void (*fn)(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
struct qmi_txn *txn, const void *decoded);
};
/**
* struct qmi_handle - QMI context
* @sock: socket handle
* @sock_lock: synchronization of @sock modifications
* @sq: sockaddr of @sock
* @work: work for handling incoming messages
* @wq: workqueue to post @work on
* @recv_buf: scratch buffer for handling incoming messages
* @recv_buf_size: size of @recv_buf
* @lookups: list of registered lookup requests
* @lookup_results: list of lookup-results advertised to the client
* @services: list of registered services (by this client)
* @ops: reference to callbacks
* @txns: outstanding transactions
* @txn_lock: lock for modifications of @txns
* @handlers: list of handlers for incoming messages
*/
struct qmi_handle {
struct socket *sock;
struct mutex sock_lock;
struct sockaddr_qrtr sq;
struct work_struct work;
struct workqueue_struct *wq;
void *recv_buf;
size_t recv_buf_size;
struct list_head lookups;
struct list_head lookup_results;
struct list_head services;
struct qmi_ops ops;
struct idr txns;
struct mutex txn_lock;
const struct qmi_msg_handler *handlers;
};
int qmi_add_lookup(struct qmi_handle *qmi, unsigned int service,
unsigned int version, unsigned int instance);
int qmi_add_server(struct qmi_handle *qmi, unsigned int service,
unsigned int version, unsigned int instance);
int qmi_handle_init(struct qmi_handle *qmi, size_t max_msg_len,
const struct qmi_ops *ops,
const struct qmi_msg_handler *handlers);
void qmi_handle_release(struct qmi_handle *qmi);
ssize_t qmi_send_request(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
struct qmi_txn *txn, int msg_id, size_t len,
struct qmi_elem_info *ei, const void *c_struct);
ssize_t qmi_send_response(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
struct qmi_txn *txn, int msg_id, size_t len,
struct qmi_elem_info *ei, const void *c_struct);
ssize_t qmi_send_indication(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
int msg_id, size_t len, struct qmi_elem_info *ei,
const void *c_struct);
void *qmi_encode_message(int type, unsigned int msg_id, size_t *len,
unsigned int txn_id, struct qmi_elem_info *ei,
const void *c_struct);
int qmi_decode_message(const void *buf, size_t len,
struct qmi_elem_info *ei, void *c_struct);
int qmi_txn_init(struct qmi_handle *qmi, struct qmi_txn *txn,
struct qmi_elem_info *ei, void *c_struct);
int qmi_txn_wait(struct qmi_txn *txn, unsigned long timeout);
void qmi_txn_cancel(struct qmi_txn *txn);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment