sm8750: init kernel modules repo

This commit is contained in:
2025-08-11 12:21:01 +02:00
parent 2681143b87
commit facad83b01
8851 changed files with 6894561 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
*/
#ifndef AUDIO_MOD_DEVICETABLE_H
#define AUDIO_MOD_DEVICETABLE_H
#include <linux/mod_devicetable.h>
/* soundwire */
#define SOUNDWIRE_NAME_SIZE 32
#define SOUNDWIRE_MODULE_PREFIX "swr:"
struct swr_device_id {
char name[SOUNDWIRE_NAME_SIZE];
kernel_ulong_t driver_data; /* Data private to the driver */
};
/* gpr */
#define GPR_NAME_SIZE 32
#define GPR_MODULE_PREFIX "gpr:"
struct gpr_device_id {
char name[GPR_NAME_SIZE];
__u32 domain_id;
__u32 svc_id;
__u32 svc_version;
kernel_ulong_t driver_data; /* Data private to the driver */
};
#endif /* AUDIO_MOD_DEVICETABLE_H */

View File

@@ -0,0 +1,79 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*/
#ifndef _SND_EVENT_H_
#define _SND_EVENT_H_
enum {
SND_EVENT_DOWN = 0,
SND_EVENT_UP,
};
struct snd_event_clients;
struct snd_event_ops {
int (*enable)(struct device *dev, void *data);
void (*disable)(struct device *dev, void *data);
};
#ifdef CONFIG_SND_EVENT
int snd_event_client_register(struct device *dev,
const struct snd_event_ops *snd_ev_ops,
void *data);
int snd_event_client_deregister(struct device *dev);
int snd_event_master_register(struct device *dev,
const struct snd_event_ops *ops,
struct snd_event_clients *clients,
void *data);
int snd_event_master_deregister(struct device *dev);
int snd_event_notify(struct device *dev, unsigned int state);
void snd_event_mstr_add_client(struct snd_event_clients **snd_clients,
int (*compare)(struct device *, void *),
void *data);
static inline bool is_snd_event_fwk_enabled(void)
{
return 1;
}
#else
static inline int snd_event_client_register(struct device *dev,
const struct snd_event_ops *snd_ev_ops,
void *data)
{
return 0;
}
static inline int snd_event_client_deregister(struct device *dev)
{
return 0;
}
static inline int snd_event_master_register(struct device *dev,
const struct snd_event_ops *ops,
struct snd_event_clients *clients,
void *data)
{
return 0;
}
static inline int snd_event_master_deregister(struct device *dev)
{
return 0;
}
static inline int snd_event_notify(struct device *dev, unsigned int state)
{
return 0;
}
static inline void snd_event_mstr_add_client(struct snd_event_clients **snd_clients,
int (*compare)(struct device *, void *),
void *data)
{
return;
}
static inline bool is_snd_event_fwk_enabled(void)
{
return 0;
}
#endif /* CONFIG_SND_EVENT */
#endif /* _SND_EVENT_H_ */

View File

@@ -0,0 +1,420 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _LINUX_SOUNDWIRE_H
#define _LINUX_SOUNDWIRE_H
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/irqdomain.h>
#include <linux/regmap.h>
#include "audio_mod_devicetable.h"
enum {
SWR_UC0 = 0,
SWR_UC1,
SWR_UC2,
SWR_UC3,
SWR_UC_MAX,
};
#define SWR_CLK_RATE_24KHZ 24000
#define SWR_CLK_RATE_48KHZ 48000
#define SWR_CLK_RATE_0P3MHZ 300000
#define SWR_CLK_RATE_0P6MHZ 600000
#define SWR_CLK_RATE_1P2MHZ 1200000
#define SWR_CLK_RATE_2P4MHZ 2400000
#define SWR_CLK_RATE_4P8MHZ 4800000
#define SWR_CLK_RATE_9P6MHZ 9600000
#define SWR_CLK_RATE_11P2896MHZ 11289600
#define SWR_CLK_RATE_12P288MHZ 12288000
extern struct bus_type soundwire_type;
struct swr_device;
/* Soundwire supports max. of 8 channels per port */
#define SWR_MAX_CHANNEL_NUM 8
/* Soundwire supports max. of 14 ports on each device */
#define SWR_MAX_DEV_PORT_NUM 14
/* Maximum number of slave devices that a master can control */
#define SWR_MAX_DEV_NUM 11
/* Maximum number of ports on master so that it can accommodate all the port
* configurations of all devices
*/
#define SWR_MAX_MSTR_PORT_NUM (SWR_MAX_DEV_NUM * SWR_MAX_DEV_PORT_NUM)
/* SWR slave port params count */
#define SWR_PORT_PARAMS 2
/* Regmap support for soundwire interface */
struct regmap *__devm_regmap_init_swr(struct swr_device *dev,
const struct regmap_config *config,
struct lock_class_key *lock_key,
const char *lock_name);
/**
* regmap_init_swr(): Initialise register map
*
* @swr: Device that will be interacted with
* @config: Configuration for register map
*
* The return value will be an ERR_PTR() on error or a valid pointer to
* a struct regmap.
*/
#define regmap_init_swr(swr, config) \
__regmap_lockdep_wrapper(__regmap_init_swr, #config, \
swr, config)
/**
* devm_regmap_init_swr(): Initialise managed register map
*
* @swr: Device that will be interacted with
* @config: Configuration for register map
*
* The return value will be an ERR_PTR() on error or a valid pointer
* to a struct regmap. The regmap will be automatically freed by the
* device management code.
*/
#define devm_regmap_init_swr(swr, config) \
__regmap_lockdep_wrapper(__devm_regmap_init_swr, #config, \
swr, config)
/* Indicates soundwire devices group information */
enum {
SWR_GROUP_NONE = 0,
SWR_GROUP_12 = 12,
SWR_GROUP_13 = 13,
SWR_BROADCAST = 15,
};
/*
* struct swr_port_info - represents new soundwire frame shape
* with full data ports
* @list: link with other soundwire port info nodes
* @dev_num: logical device number of the soundwire slave device
* @port_en: flag indicates whether the port is enabled
* @slave_port_id: logical port number of the soundwire slave device
* @offset1: sample offset indicating the offset of the channel
* from the start of the frame
* @offset2: channel offset indicating offset between to channels
* @hstart: start offset for subframe window.
* @hstop: start offset for subframe window.
* @master_port_id: logical port number of corresponding soundwire master device
* @blk_grp_count: grouping count for n.o of channels.
* @blk_pack_mode: packing mode for channels in each port.
* @sinterval: sample interval indicates spacing from one sample
* event to the next
* @ch_en: channels enabled in a port.
* @req_ch: channels requested to be enabled in a port.
* @num_ch: number of channels enabled in a port
* @ch_rate: sampling rate of the channel with which data will be
* transferred
*
* Soundwire frame shape is created based on swr_port_info struct
* parameters.
*/
struct swr_port_info {
u8 dev_num;
u8 port_en;
u8 slave_port_id;
u8 offset1;
u8 offset2;
u16 sinterval;
struct list_head list;
u8 master_port_id;
u8 hstart;
u8 hstop;
u8 blk_grp_count;
u8 blk_pack_mode;
u8 word_length;
u8 lane_ctrl;
u8 ch_en;
u8 req_ch;
u8 num_ch;
u32 ch_rate;
u32 req_ch_rate;
};
struct swr_port_params {
u32 offset1;
u32 lane_ctrl;
};
struct swr_dev_frame_config {
struct swr_port_params *pp;
};
/*
* struct swr_params - represent transfer of data from soundwire slave
* to soundwire master
* @tid: transaction ID to track each transaction
* @dev_num: logical device number of the soundwire slave device
* @num_port: number of ports that needs to be configured
* @port_id: array of logical port numbers of the soundwire slave device
* @num_ch: array of number of channels enabled
* @ch_rate: array of sampling rate of different channels that need to
* be configured
* @ch_en: array of channels mask for all the ports
* @port_type: the required master port type
*/
struct swr_params {
u8 tid;
u8 dev_num;
u8 num_port;
u8 port_id[SWR_MAX_DEV_PORT_NUM];
u8 num_ch[SWR_MAX_DEV_PORT_NUM];
u32 ch_rate[SWR_MAX_DEV_PORT_NUM];
u8 ch_en[SWR_MAX_DEV_PORT_NUM];
u8 port_type[SWR_MAX_DEV_PORT_NUM];
};
/*
* struct swr_reg - struct to handle soundwire slave register read/writes
* @tid: transaction id for reg read/writes
* @dev_id: logical device number of the soundwire slave device
* @regaddr: 16 bit regaddr of soundwire slave
* @buf: value to be written/read to/from regaddr
* @len: length of the buffer buf
*/
struct swr_reg {
u8 tid;
u8 dev_id;
u32 regaddr;
u32 *buf;
u32 len;
};
/*
* struct swr_master - Interface to the soundwire master controller
* @dev: device interface to this driver
* @list: link with other soundwire master controllers
* @bus_num: board/SoC specific identifier for a soundwire master
* @mlock: mutex protecting master data structures
* @devices: list of devices on this master
* @port: logical port numbers of the soundwire master. This array
* can hold maximum master ports which is equal to number of slave
* devices multiplied by number of ports in each slave device
* @port_txn: table of port config transactions with transaction id
* @reg_txn: table of register transactions with transaction id
* @last_tid: size of table port_txn (can't grow beyond 256 since
* tid is 8 bits)
* @num_port: number of active ports on soundwire master
* @gr_sid: slave id used by the group for write operations
* @connect_port: callback for configuration of soundwire port(s)
* @disconnect_port: callback for disable of soundwire port(s)
* @read: callback for soundwire slave register read
* @write: callback for soundwire slave register write
* @get_logical_dev_num: callback to get soundwire slave logical
* device number
* @port_en_mask: bit mask of active ports on soundwire master
*/
struct swr_master {
struct device dev;
struct list_head list;
unsigned int bus_num;
struct mutex mlock;
struct list_head devices;
struct swr_port_info port[SWR_MAX_MSTR_PORT_NUM];
struct swr_params **port_txn;
struct swr_reg **reg_txn;
u8 last_tid;
u8 num_port;
u8 num_dev;
u8 gr_sid;
int (*connect_port)(struct swr_master *mstr, struct swr_params *txn);
int (*disconnect_port)(struct swr_master *mstr, struct swr_params *txn);
int (*read)(struct swr_master *mstr, u8 dev_num, u16 reg_addr,
void *buf, u32 len);
int (*write)(struct swr_master *mstr, u8 dev_num, u16 reg_addr,
const void *buf);
int (*bulk_write)(struct swr_master *master, u8 dev_num, void *reg,
const void *buf, size_t len);
int (*get_logical_dev_num)(struct swr_master *mstr, u64 dev_id,
u8 *dev_num);
int (*init_port_params)(struct swr_master *mstr, u32 dev_num,
u32 num_ports, struct swr_dev_frame_config *uc_arr);
int (*slvdev_datapath_control)(struct swr_master *mstr, bool enable);
bool (*remove_from_group)(struct swr_master *mstr);
void (*device_wakeup_vote)(struct swr_master *mstr);
void (*device_wakeup_unvote)(struct swr_master *mstr);
u16 port_en_mask;
};
static inline struct swr_master *to_swr_master(struct device *dev)
{
return dev ? container_of(dev, struct swr_master, dev) : NULL;
}
/*
* struct swr_device - represent a soundwire slave device
* @name: indicates the name of the device, defined in devicetree
* binding under soundwire slave device node as a compatible field.
* @master: soundwire master managing the bus hosting this device
* @driver: Device's driver. Pointer to access routines
* @dev_list: list of devices on a controller
* @dev_num: logical device number of the soundwire slave device
* @dev: driver model representation of the device
* @addr: represents "ea-addr" which is unique-id of soundwire slave
* device
* @group_id: group id supported by the slave device
* @slave_irq: irq handle of slave to be invoked by master
* during slave interrupt
*/
struct swr_device {
char name[SOUNDWIRE_NAME_SIZE];
struct swr_master *master;
struct swr_driver *driver;
struct list_head dev_list;
u8 dev_num;
struct device dev;
u64 addr;
u8 group_id;
bool paging_support;
struct irq_domain *slave_irq;
bool slave_irq_pending;
bool clk_scale_initialized;
u8 g_scp1_val; /* used for v1.2 or class devices */
u8 g_scp2_val; /* used for v1.2 or class devices */
};
static inline struct swr_device *to_swr_device(struct device *dev)
{
return dev ? container_of(dev, struct swr_device, dev) : NULL;
}
/*
* struct swr_driver - Manage soundwire slave device driver
* @probe: binds this driver to soundwire device
* @remove: unbinds this driver from soundwire device
* @shutdown: standard shutdown callback used during power down/halt
* @suspend: standard suspend callback used during system suspend
* @resume: standard resume callback used during system resume
* @driver: soundwire device drivers should initialize name and
* owner field of this structure
* @id_table: list of soundwire devices supported by this driver
*/
struct swr_driver {
int (*probe)(struct swr_device *swr);
int (*remove)(struct swr_device *swr);
void (*shutdown)(struct swr_device *swr);
int (*suspend)(struct swr_device *swr, pm_message_t pmesg);
int (*resume)(struct swr_device *swr);
int (*device_up)(struct swr_device *swr);
int (*device_down)(struct swr_device *swr);
int (*reset_device)(struct swr_device *swr);
struct device_driver driver;
const struct swr_device_id *id_table;
};
static inline struct swr_driver *to_swr_driver(struct device_driver *drv)
{
return drv ? container_of(drv, struct swr_driver, driver) : NULL;
}
/*
* struct swr_boardinfo - Declare board info for soundwire device bringup
* @name: name to initialize swr_device.name
* @bus_num: identifies which soundwire master parents the soundwire
* slave_device
* @addr: represents "ea-addr" of soundwire slave device
* @of_node: pointer to OpenFirmware device node
* @swr_slave: device to be registered with soundwire
*/
struct swr_boardinfo {
char name[SOUNDWIRE_NAME_SIZE];
int bus_num;
u64 addr;
struct device_node *of_node;
struct swr_device *swr_slave;
};
static inline void *swr_get_ctrl_data(const struct swr_master *master)
{
return master ? dev_get_drvdata(&master->dev) : NULL;
}
static inline void swr_set_ctrl_data(struct swr_master *master, void *data)
{
dev_set_drvdata(&master->dev, data);
}
static inline void *swr_get_dev_data(const struct swr_device *dev)
{
return dev ? dev_get_drvdata(&dev->dev) : NULL;
}
static inline void swr_set_dev_data(struct swr_device *dev, void *data)
{
dev_set_drvdata(&dev->dev, data);
}
extern int swr_startup_devices(struct swr_device *swr_dev);
extern struct swr_device *swr_new_device(struct swr_master *master,
struct swr_boardinfo const *info);
extern int of_register_swr_devices(struct swr_master *master);
extern void swr_port_response(struct swr_master *mstr, u8 tid);
extern int swr_get_logical_dev_num(struct swr_device *dev, u64 dev_id,
u8 *dev_num);
extern int swr_init_port_params(struct swr_device *dev,
u32 num_ports, struct swr_dev_frame_config *pp);
extern int swr_read(struct swr_device *dev, u8 dev_num, u16 reg_addr,
void *buf, u32 len);
extern int swr_write(struct swr_device *dev, u8 dev_num, u16 reg_addr,
const void *buf);
extern int swr_bulk_write(struct swr_device *dev, u8 dev_num, void *reg_addr,
const void *buf, size_t len);
extern int swr_connect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
u8 *ch_mask, u32 *ch_rate, u8 *num_ch,
u8 *port_type);
extern int swr_disconnect_port(struct swr_device *dev,
u8 *port_id, u8 num_port, u8 *ch_mask,
u8 *port_type);
extern int swr_set_device_group(struct swr_device *swr_dev, u8 id);
extern int swr_driver_register(struct swr_driver *drv);
extern void swr_driver_unregister(struct swr_driver *drv);
extern int swr_add_device(struct swr_master *master,
struct swr_device *swrdev);
extern void swr_remove_device(struct swr_device *swr);
extern void swr_master_add_boarddevices(struct swr_master *master);
extern void swr_unregister_master(struct swr_master *master);
extern int swr_register_master(struct swr_master *master);
extern int swr_device_up(struct swr_device *swr_dev);
extern int swr_device_down(struct swr_device *swr_dev);
extern int swr_reset_device(struct swr_device *swr_dev);
extern int swr_slvdev_datapath_control(struct swr_device *swr_dev, u8 dev_num,
bool enable);
extern int swr_remove_from_group(struct swr_device *dev, u8 dev_num);
extern void swr_remove_device(struct swr_device *swr_dev);
extern struct swr_device *get_matching_swr_slave_device(struct device_node *np);
extern int swr_device_wakeup_vote(struct swr_device *dev);
extern int swr_device_wakeup_unvote(struct swr_device *dev);
#endif /* _LINUX_SOUNDWIRE_H */

View File

@@ -0,0 +1,41 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2015, 2017-2021 The Linux Foundation. All rights reserved.
*/
#ifndef _LINUX_SWR_COMMON_H
#define _LINUX_SWR_COMMON_H
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/device.h>
#include <linux/bitops.h>
struct port_params {
u16 si;
u8 off1;
u8 off2;
u8 hstart;/* head start */
u8 hstop; /* head stop */
u8 wd_len;/* word length */
u8 bp_mode; /* block pack mode */
u8 bgp_ctrl;/* block group control */
u8 lane_ctrl;/* lane to be used */
u8 dir; /* master port dir: OUT = 0 IN = 1 */
u8 stream_type; /* PDM = 0, PCM = 1 */
};
struct swrm_port_config {
u32 size;
u32 uc;
void *params;
};
struct swr_mstr_port_map {
u32 id;
u32 uc;
struct port_params *swr_port_params;
};
#define SWR_MSTR_PORT_LEN 13 /* Number of master ports */
#endif /* _LINUX_SWR_COMMON_H */

View File

@@ -0,0 +1,50 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2015, 2017-2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _LINUX_SWR_WCD_H
#define _LINUX_SWR_WCD_H
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/device.h>
#include <linux/bitops.h>
enum {
SWR_CH_MAP,
SWR_DEVICE_DOWN,
SWR_DEVICE_UP,
SWR_SUBSYS_RESTART,
SWR_SET_NUM_RX_CH,
SWR_CLK_FREQ,
SWR_DEVICE_SSR_DOWN,
SWR_DEVICE_SSR_UP,
SWR_REGISTER_WAKE_IRQ,
SWR_SET_PORT_MAP,
SWR_REQ_CLK_SWITCH,
SWR_REGISTER_WAKEUP,
SWR_DEREGISTER_WAKEUP,
};
struct swr_mstr_port {
int num_port;
u8 *port;
};
#define MCLK_FREQ 9600000
#define MCLK_FREQ_LP 600000
#define MCLK_FREQ_NATIVE 11289600
#define MCLK_FREQ_12288 12288000
#if (IS_ENABLED(CONFIG_SOUNDWIRE_WCD_CTRL) || \
IS_ENABLED(CONFIG_SOUNDWIRE_MSTR_CTRL))
extern int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data);
#else /* CONFIG_SOUNDWIRE_WCD_CTRL */
static inline int swrm_wcd_notify(struct platform_device *pdev, u32 id,
void *data)
{
return 0;
}
#endif /* CONFIG_SOUNDWIRE_WCD_CTRL */
#endif /* _LINUX_SWR_WCD_H */

View File

@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*/
#ifndef __WCD_SPI_AC_H__
#define __WCD_SPI_AC_H__
#include <linux/types.h>
#include <linux/bitops.h>
enum wcd_spi_acc_req {
WCD_SPI_ACCESS_REQUEST,
WCD_SPI_ACCESS_RELEASE,
WCD_SPI_ACCESS_MAX,
};
#define WCD_SPI_AC_DATA_TRANSFER BIT(0)
#define WCD_SPI_AC_CONCURRENCY BIT(1)
#define WCD_SPI_AC_REMOTE_DOWN BIT(2)
#define WCD_SPI_AC_SVC_OFFLINE BIT(3)
#define WCD_SPI_AC_UNINITIALIZED BIT(4)
#if IS_ENABLED(CONFIG_WCD_SPI_AC)
int wcd_spi_access_ctl(struct device *dev,
enum wcd_spi_acc_req req,
u32 reason);
#else
int wcd_spi_access_ctl(struct device *dev,
enum wcd_spi_acc_req req,
u32 reason)
{
return 0;
}
#endif /* end of CONFIG_WCD_SPI_AC */
#endif /* end of __WCD_SPI_AC_H__ */