diff options
Diffstat (limited to 'include/soc/qcom')
55 files changed, 7830 insertions, 0 deletions
diff --git a/include/soc/qcom/ais.h b/include/soc/qcom/ais.h new file mode 100644 index 000000000000..a1486269dfd5 --- /dev/null +++ b/include/soc/qcom/ais.h @@ -0,0 +1,223 @@ +/* Copyright (c) 2011-2017, 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 __AIS_H__ +#define __AIS_H__ + +#include <media/ais/msm_ais_sensor.h> +#include <linux/interrupt.h> +#include <linux/of_platform.h> +#include <linux/of_device.h> +#include <linux/of.h> + + +enum msm_camera_device_type_t { + MSM_CAMERA_I2C_DEVICE, + MSM_CAMERA_PLATFORM_DEVICE, + MSM_CAMERA_SPI_DEVICE, +}; + +enum msm_bus_perf_setting { + S_INIT, + S_PREVIEW, + S_VIDEO, + S_CAPTURE, + S_ZSL, + S_STEREO_VIDEO, + S_STEREO_CAPTURE, + S_DEFAULT, + S_LIVESHOT, + S_DUAL, + S_EXIT +}; + +struct msm_camera_slave_info { + uint16_t sensor_slave_addr; + uint16_t sensor_id_reg_addr; + uint16_t sensor_id; + uint16_t sensor_id_mask; +}; + +struct msm_cam_clk_info { + const char *clk_name; + long clk_rate; + uint32_t delay; +}; + +struct msm_pinctrl_info { + struct pinctrl *pinctrl; + struct pinctrl_state *gpio_state_active; + struct pinctrl_state *gpio_state_suspend; + bool use_pinctrl; +}; + +struct msm_cam_clk_setting { + struct msm_cam_clk_info *clk_info; + uint16_t num_clk_info; + uint8_t enable; +}; + +struct v4l2_subdev_info { + u32 code; + enum v4l2_colorspace colorspace; + uint16_t fmt; + uint16_t order; +}; + +struct msm_camera_gpio_num_info { + uint16_t gpio_num[SENSOR_GPIO_MAX]; + uint8_t valid[SENSOR_GPIO_MAX]; +}; + +struct msm_camera_gpio_conf { + void *cam_gpiomux_conf_tbl; + uint8_t cam_gpiomux_conf_tbl_size; + struct gpio *cam_gpio_common_tbl; + uint8_t cam_gpio_common_tbl_size; + struct gpio *cam_gpio_req_tbl; + uint8_t cam_gpio_req_tbl_size; + uint32_t gpio_no_mux; + uint32_t *camera_off_table; + uint8_t camera_off_table_size; + uint32_t *camera_on_table; + uint8_t camera_on_table_size; + struct msm_camera_gpio_num_info *gpio_num_info; +}; + +struct msm_camera_power_ctrl_t { + struct device *dev; + struct msm_sensor_power_setting *power_setting; + uint16_t power_setting_size; + struct msm_sensor_power_setting *power_down_setting; + uint16_t power_down_setting_size; + struct msm_camera_gpio_conf *gpio_conf; + struct camera_vreg_t *cam_vreg; + int num_vreg; + struct msm_camera_i2c_conf *i2c_conf; + struct clk **clk_ptr; + struct msm_cam_clk_info *clk_info; + struct msm_pinctrl_info pinctrl_info; + uint8_t cam_pinctrl_status; + size_t clk_info_size; +}; + +enum msm_camera_actuator_name { + MSM_ACTUATOR_MAIN_CAM_0, + MSM_ACTUATOR_MAIN_CAM_1, + MSM_ACTUATOR_MAIN_CAM_2, + MSM_ACTUATOR_MAIN_CAM_3, + MSM_ACTUATOR_MAIN_CAM_4, + MSM_ACTUATOR_MAIN_CAM_5, + MSM_ACTUATOR_WEB_CAM_0, + MSM_ACTUATOR_WEB_CAM_1, + MSM_ACTUATOR_WEB_CAM_2, +}; + +struct msm_actuator_info { + struct i2c_board_info const *board_info; + enum msm_camera_actuator_name cam_name; + int bus_id; + int vcm_pwd; + int vcm_enable; +}; +enum msm_camera_i2c_mux_mode { + MODE_R, + MODE_L, + MODE_DUAL +}; + +struct msm_camera_i2c_conf { + uint8_t use_i2c_mux; + struct platform_device *mux_dev; + enum msm_camera_i2c_mux_mode i2c_mux_mode; +}; + +struct msm_camera_sensor_board_info { + const char *sensor_name; + const char *eeprom_name; + const char *actuator_name; + const char *ois_name; + struct msm_camera_slave_info *slave_info; + struct msm_camera_csi_lane_params *csi_lane_params; + struct msm_camera_sensor_strobe_flash_data *strobe_flash_data; + struct msm_actuator_info *actuator_info; + struct msm_sensor_info_t *sensor_info; + const char *misc_regulator; + struct msm_camera_power_ctrl_t power_info; + struct msm_camera_sensor_slave_info *cam_slave_info; +}; + +enum msm_camera_i2c_cmd_type { + MSM_CAMERA_I2C_CMD_WRITE, + MSM_CAMERA_I2C_CMD_POLL, +}; + +struct msm_camera_i2c_reg_conf { + uint16_t reg_addr; + uint16_t reg_data; + enum msm_camera_i2c_data_type dt; + enum msm_camera_i2c_cmd_type cmd_type; + int16_t mask; +}; + +struct msm_camera_i2c_conf_array { + struct msm_camera_i2c_reg_conf *conf; + uint16_t size; + uint16_t delay; + enum msm_camera_i2c_data_type data_type; +}; + +struct eeprom_map_t { + uint32_t valid_size; + uint32_t addr; + uint32_t addr_t; + uint32_t data; + uint32_t data_t; + uint32_t delay; +}; + +struct eeprom_slave_add_t { + uint32_t addr; +}; + +struct msm_eeprom_memory_map_t { + struct eeprom_map_t page; + struct eeprom_map_t pageen; + struct eeprom_map_t poll; + struct eeprom_map_t mem; + struct eeprom_slave_add_t saddr; +}; + +struct msm_eeprom_memory_block_t { + struct msm_eeprom_memory_map_t *map; + uint32_t num_map; /* number of map blocks */ + uint8_t *mapdata; + uint32_t num_data; /* size of total mapdata */ +}; + +struct msm_eeprom_cmm_t { + uint32_t cmm_support; + uint32_t cmm_compression; + uint32_t cmm_offset; + uint32_t cmm_size; +}; + +struct msm_eeprom_board_info { + const char *eeprom_name; + uint16_t i2c_slaveaddr; + struct msm_camera_power_ctrl_t power_info; + struct msm_eeprom_cmm_t cmm_data; + enum i2c_freq_mode_t i2c_freq_mode; +}; + +#endif diff --git a/include/soc/qcom/boot_stats.h b/include/soc/qcom/boot_stats.h new file mode 100644 index 000000000000..777cc247e5df --- /dev/null +++ b/include/soc/qcom/boot_stats.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2013-2014,2016,2018 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. + */ + +#ifdef CONFIG_MSM_BOOT_STATS + +#define TIMER_KHZ 32768 +extern struct boot_stats __iomem *boot_stats; + +struct boot_stats { + uint32_t bootloader_start; + uint32_t bootloader_end; + uint32_t bootloader_display; + uint32_t bootloader_load_kernel; + uint32_t load_kernel_start; + uint32_t load_kernel_end; +#ifdef CONFIG_MSM_BOOT_TIME_MARKER + uint32_t bootloader_early_domain_start; + uint32_t bootloader_checksum; + uint32_t bootloader_checksum_start; + uint32_t bootloader_checksum_end; + uint32_t bootloader_early_camera_start; +#endif +}; + +int boot_stats_init(void); +int boot_stats_exit(void); +unsigned long long int msm_timer_get_sclk_ticks(void); +phys_addr_t msm_timer_get_pa(void); +#else +static inline int boot_stats_init(void) { return 0; } +static inline unsigned long long int msm_timer_get_sclk_ticks(void) +{ + return 0; +} +static inline phys_addr_t msm_timer_get_pa(void) { return 0; } +#endif + +#ifdef CONFIG_MSM_BOOT_TIME_MARKER + +static inline int boot_marker_enabled(void) { return 1; } +void place_marker(const char *name); +#else +static inline void place_marker(char *name) { }; +static inline int boot_marker_enabled(void) { return 0; } +#endif diff --git a/include/soc/qcom/camera2.h b/include/soc/qcom/camera2.h new file mode 100644 index 000000000000..5a61d2b372c3 --- /dev/null +++ b/include/soc/qcom/camera2.h @@ -0,0 +1,227 @@ +/* Copyright (c) 2011-2016, 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 __CAMERA2_H__ +#define __CAMERA2_H__ + +#include <media/msm_cam_sensor.h> +#include <linux/interrupt.h> +#include <linux/of_platform.h> +#include <linux/of_device.h> +#include <linux/of.h> + +#define MAX_SPECIAL_SUPPORT_SIZE 10 + +enum msm_camera_device_type_t { + MSM_CAMERA_I2C_DEVICE, + MSM_CAMERA_PLATFORM_DEVICE, + MSM_CAMERA_SPI_DEVICE, +}; + +enum msm_bus_perf_setting { + S_INIT, + S_PREVIEW, + S_VIDEO, + S_CAPTURE, + S_ZSL, + S_STEREO_VIDEO, + S_STEREO_CAPTURE, + S_DEFAULT, + S_LIVESHOT, + S_DUAL, + S_EXIT +}; + +struct msm_camera_slave_info { + uint16_t sensor_slave_addr; + uint16_t sensor_id_reg_addr; + uint16_t sensor_id; + uint16_t sensor_id_mask; +}; + +struct msm_cam_clk_info { + const char *clk_name; + long clk_rate; + uint32_t delay; +}; + +struct msm_pinctrl_info { + struct pinctrl *pinctrl; + struct pinctrl_state *gpio_state_active; + struct pinctrl_state *gpio_state_suspend; + bool use_pinctrl; +}; + +struct msm_cam_clk_setting { + struct msm_cam_clk_info *clk_info; + uint16_t num_clk_info; + uint8_t enable; +}; + +struct v4l2_subdev_info { + uint32_t code; + enum v4l2_colorspace colorspace; + uint16_t fmt; + uint16_t order; +}; + +struct msm_camera_gpio_num_info { + uint16_t gpio_num[SENSOR_GPIO_MAX]; + uint8_t valid[SENSOR_GPIO_MAX]; +}; + +struct msm_camera_gpio_conf { + void *cam_gpiomux_conf_tbl; + uint8_t cam_gpiomux_conf_tbl_size; + struct gpio *cam_gpio_common_tbl; + uint8_t cam_gpio_common_tbl_size; + struct gpio *cam_gpio_req_tbl; + uint8_t cam_gpio_req_tbl_size; + uint32_t gpio_no_mux; + uint32_t *camera_off_table; + uint8_t camera_off_table_size; + uint32_t *camera_on_table; + uint8_t camera_on_table_size; + struct msm_camera_gpio_num_info *gpio_num_info; +}; + +struct msm_camera_power_ctrl_t { + struct device *dev; + struct msm_sensor_power_setting *power_setting; + uint16_t power_setting_size; + struct msm_sensor_power_setting *power_down_setting; + uint16_t power_down_setting_size; + struct msm_camera_gpio_conf *gpio_conf; + struct camera_vreg_t *cam_vreg; + int num_vreg; + struct msm_camera_i2c_conf *i2c_conf; + struct clk **clk_ptr; + struct msm_cam_clk_info *clk_info; + struct msm_pinctrl_info pinctrl_info; + uint8_t cam_pinctrl_status; + size_t clk_info_size; +}; + +enum msm_camera_actuator_name { + MSM_ACTUATOR_MAIN_CAM_0, + MSM_ACTUATOR_MAIN_CAM_1, + MSM_ACTUATOR_MAIN_CAM_2, + MSM_ACTUATOR_MAIN_CAM_3, + MSM_ACTUATOR_MAIN_CAM_4, + MSM_ACTUATOR_MAIN_CAM_5, + MSM_ACTUATOR_WEB_CAM_0, + MSM_ACTUATOR_WEB_CAM_1, + MSM_ACTUATOR_WEB_CAM_2, +}; + +struct msm_actuator_info { + struct i2c_board_info const *board_info; + enum msm_camera_actuator_name cam_name; + int bus_id; + int vcm_pwd; + int vcm_enable; +}; +enum msm_camera_i2c_mux_mode { + MODE_R, + MODE_L, + MODE_DUAL +}; + +struct msm_camera_i2c_conf { + uint8_t use_i2c_mux; + struct platform_device *mux_dev; + enum msm_camera_i2c_mux_mode i2c_mux_mode; +}; + +struct msm_camera_sensor_board_info { + const char *sensor_name; + const char *eeprom_name; + const char *actuator_name; + const char *ois_name; + const char *flash_name; + const char *special_support_sensors[MAX_SPECIAL_SUPPORT_SIZE]; + int32_t special_support_size; + struct msm_camera_slave_info *slave_info; + struct msm_camera_csi_lane_params *csi_lane_params; + struct msm_camera_sensor_strobe_flash_data *strobe_flash_data; + struct msm_actuator_info *actuator_info; + struct msm_sensor_info_t *sensor_info; + const char *misc_regulator; + struct msm_camera_power_ctrl_t power_info; + struct msm_camera_sensor_slave_info *cam_slave_info; +}; + +enum msm_camera_i2c_cmd_type { + MSM_CAMERA_I2C_CMD_WRITE, + MSM_CAMERA_I2C_CMD_POLL, +}; + +struct msm_camera_i2c_reg_conf { + uint16_t reg_addr; + uint16_t reg_data; + enum msm_camera_i2c_data_type dt; + enum msm_camera_i2c_cmd_type cmd_type; + int16_t mask; +}; + +struct msm_camera_i2c_conf_array { + struct msm_camera_i2c_reg_conf *conf; + uint16_t size; + uint16_t delay; + enum msm_camera_i2c_data_type data_type; +}; + +struct eeprom_map_t { + uint32_t valid_size; + uint32_t addr; + uint32_t addr_t; + uint32_t data; + uint32_t data_t; + uint32_t delay; +}; + +struct eeprom_slave_add_t { + uint32_t addr; +}; + +struct msm_eeprom_memory_map_t { + struct eeprom_map_t page; + struct eeprom_map_t pageen; + struct eeprom_map_t poll; + struct eeprom_map_t mem; + struct eeprom_slave_add_t saddr; +}; + +struct msm_eeprom_memory_block_t { + struct msm_eeprom_memory_map_t *map; + uint32_t num_map; /* number of map blocks */ + uint8_t *mapdata; + uint32_t num_data; /* size of total mapdata */ +}; + +struct msm_eeprom_cmm_t { + uint32_t cmm_support; + uint32_t cmm_compression; + uint32_t cmm_offset; + uint32_t cmm_size; +}; + +struct msm_eeprom_board_info { + const char *eeprom_name; + uint16_t i2c_slaveaddr; + struct msm_camera_power_ctrl_t power_info; + struct msm_eeprom_cmm_t cmm_data; + enum i2c_freq_mode_t i2c_freq_mode; +}; + +#endif diff --git a/include/soc/qcom/clock-alpha-pll.h b/include/soc/qcom/clock-alpha-pll.h new file mode 100644 index 000000000000..acffe33dc4f3 --- /dev/null +++ b/include/soc/qcom/clock-alpha-pll.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2012-2016, 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 __ARCH_ARM_MACH_MSM_CLOCK_ALPHA_PLL_H +#define __ARCH_ARM_MACH_MSM_CLOCK_ALPHA_PLL_H + +#include <linux/spinlock.h> +#include <linux/clk/msm-clk-provider.h> + +struct alpha_pll_masks { + u32 lock_mask; /* lock_det bit */ + u32 active_mask; /* active_flag in FSM mode */ + u32 update_mask; /* update bit for dynamic update */ + u32 vco_mask; /* vco_sel bits */ + u32 vco_shift; + u32 alpha_en_mask; /* alpha_en bit */ + u32 output_mask; /* pllout_* bits */ + u32 post_div_mask; + + u32 test_ctl_lo_mask; + u32 test_ctl_hi_mask; +}; + +struct alpha_pll_vco_tbl { + u32 vco_val; + unsigned long min_freq; + unsigned long max_freq; +}; + +#define VCO(a, b, c) { \ + .vco_val = a,\ + .min_freq = b,\ + .max_freq = c,\ +} + +struct alpha_pll_clk { + struct alpha_pll_masks *masks; + void *const __iomem *base; + u32 offset; + + /* if fsm_en_mask is set, config PLL to FSM mode */ + u32 fsm_reg_offset; + u32 fsm_en_mask; + + u32 enable_config; /* bitmask of outputs to be enabled */ + u32 post_div_config; /* masked post divider setting */ + u32 config_ctl_val; /* config register init value */ + u32 test_ctl_lo_val; /* test control settings */ + u32 test_ctl_hi_val; + + struct alpha_pll_vco_tbl *vco_tbl; + u32 num_vco; + u32 current_vco_val; + bool inited; + bool slew; + bool no_prepared_reconfig; + + /* some PLLs support dynamically updating their rate + * without disabling the PLL first. Set this flag + * to enable this support. + */ + bool dynamic_update; + + /* + * Some chipsets need the offline request bit to be + * cleared on a second write to the register, even though + * SW wants the bit to be set. Set this flag to indicate + * that the workaround is required. + */ + bool offline_bit_workaround; + bool no_irq_dis; + bool is_fabia; + unsigned long min_supported_freq; + struct clk c; +}; + +static inline struct alpha_pll_clk *to_alpha_pll_clk(struct clk *c) +{ + return container_of(c, struct alpha_pll_clk, c); +} + + +#endif +extern void __init_alpha_pll(struct clk *c); +extern struct clk_ops clk_ops_alpha_pll; +extern struct clk_ops clk_ops_alpha_pll_hwfsm; +extern struct clk_ops clk_ops_fixed_alpha_pll; +extern struct clk_ops clk_ops_dyna_alpha_pll; +extern struct clk_ops clk_ops_fixed_fabia_alpha_pll; +extern struct clk_ops clk_ops_fabia_alpha_pll; diff --git a/include/soc/qcom/clock-local2.h b/include/soc/qcom/clock-local2.h new file mode 100644 index 000000000000..4f2fa36e920f --- /dev/null +++ b/include/soc/qcom/clock-local2.h @@ -0,0 +1,284 @@ +/* Copyright (c) 2012-2016, 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 __ARCH_ARM_MACH_MSM_CLOCK_LOCAL_2_H +#define __ARCH_ARM_MACH_MSM_CLOCK_LOCAL_2_H + +#include <linux/spinlock.h> +#include <linux/clk/msm-clk-provider.h> +#include <linux/clk/msm-clk.h> + +/* + * Generic frequency-definition structs and macros + */ + +/** + * @freq_hz: output rate + * @src_freq: source freq for dynamic pll. For fixed plls, set to 0. + * @src_clk: source clock for freq_hz + * @m_val: M value corresponding to freq_hz + * @n_val: N value corresponding to freq_hz + * @d_val: D value corresponding to freq_hz + * @div_src_val: Pre divider value and source selection mux index for freq_hz + * @sys_vdd: Voltage level required for freq_hz + */ +struct clk_freq_tbl { + unsigned long freq_hz; + unsigned long src_freq; + struct clk *src_clk; + u32 m_val; + u32 n_val; + u32 d_val; + u32 div_src_val; + const unsigned sys_vdd; +}; + +#define FREQ_END (ULONG_MAX-1) +#define F_END { .freq_hz = FREQ_END } +#define FIXED_CLK_SRC 0 +/* + * Generic clock-definition struct and macros + */ +/** + * struct rcg_clk - root clock generator + * @cmd_rcgr_reg: command register + * @set_rate: function to set frequency + * @freq_tbl: frequency table for this RCG + * @current_freq: current RCG frequency + * @c: generic clock data + * @non_local_children: set if RCG has at least one branch owned by a diff EE + * @non_local_control_timeout: configurable RCG timeout needed when all RCG + * children can be controlled by an entity outside of + HLOS. + * @force_enable_rcgr: set if RCG needs to be force enabled/disabled during + * power sequence + * @base: pointer to base address of ioremapped registers. + */ +struct rcg_clk { + u32 cmd_rcgr_reg; + + void (*set_rate)(struct rcg_clk *, struct clk_freq_tbl *); + + struct clk_freq_tbl *freq_tbl; + struct clk_freq_tbl *current_freq; + struct clk c; + + bool non_local_children; + int non_local_control_timeout; + bool force_enable_rcgr; + void *const __iomem *base; +}; + +static inline struct rcg_clk *to_rcg_clk(struct clk *clk) +{ + return container_of(clk, struct rcg_clk, c); +} + +extern struct clk_freq_tbl rcg_dummy_freq; + +/** + * struct branch_clk - branch clock + * @set_rate: Set the frequency of this branch clock. + * @c: clk + * @cbcr_reg: branch control register + * @bcr_reg: block reset register + * @has_sibling: true if other branches are derived from this branch's source + * @cur_div: current branch divider value + * @max_div: maximum branch divider value (if zero, no divider exists) + * @halt_check: halt checking type + * @toggle_memory: toggle memory during enable/disable if true + * @no_halt_check_on_disable: When set, do not check status bit during + * clk_disable(). + * @check_enable_bit: Check the enable bit to determine clock status + during handoff. + * @aggr_sibling_rates: Set if there are multiple branch clocks with rate + setting capability on the common RCG. + * @is_prepared: Set if clock's prepare count is greater than 0. + * @base: pointer to base address of ioremapped registers. + */ +struct branch_clk { + void (*set_rate)(struct branch_clk *, struct clk_freq_tbl *); + struct clk c; + u32 cbcr_reg; + u32 bcr_reg; + int has_sibling; + u32 cur_div; + u32 max_div; + const u32 halt_check; + bool toggle_memory; + bool no_halt_check_on_disable; + bool check_enable_bit; + bool aggr_sibling_rates; + bool is_prepared; + void *const __iomem *base; +}; + +static inline struct branch_clk *to_branch_clk(struct clk *clk) +{ + return container_of(clk, struct branch_clk, c); +} + +/** + * struct hw_ctl_clk - Clock structure to enable/disable dynamic clock gating + * @c: clk + * @cbcr_reg: branch control register + * @base: pointer to base address of ioremapped registers. + */ +struct hw_ctl_clk { + struct clk c; + u32 cbcr_reg; + void __iomem *const *base; +}; + +static inline struct hw_ctl_clk *to_hw_ctl_clk(struct clk *clk) +{ + return container_of(clk, struct hw_ctl_clk, c); +} + +/** + * struct local_vote_clk - Voteable branch clock + * @c: clk + * @cbcr_reg: branch control register + * @vote_reg: voting register + * @en_mask: enable mask + * @halt_check: halt checking type + * @base: pointer to base address of ioremapped registers. + * An on/off switch with a rate derived from the parent. + */ +struct local_vote_clk { + struct clk c; + u32 cbcr_reg; + u32 vote_reg; + u32 bcr_reg; + u32 en_mask; + const u32 halt_check; + void * __iomem *base; +}; + +static inline struct local_vote_clk *to_local_vote_clk(struct clk *clk) +{ + return container_of(clk, struct local_vote_clk, c); +} + +/** + * struct reset_clk - Reset clock + * @c: clk + * @reset_reg: block reset register + * @base: pointer to base address of ioremapped registers. + */ +struct reset_clk { + struct clk c; + u32 reset_reg; + void *__iomem *base; +}; + +static inline struct reset_clk *to_reset_clk(struct clk *clk) +{ + return container_of(clk, struct reset_clk, c); +} +/** + * struct measure_clk - for rate measurement debug use + * @sample_ticks: sample period in reference clock ticks + * @multiplier: measurement scale-up factor + * @divider: measurement scale-down factor + * @c: clk +*/ +struct measure_clk { + u64 sample_ticks; + u32 multiplier; + u32 divider; + + struct clk c; +}; + +struct measure_clk_data { + struct clk *cxo; + u32 plltest_reg; + u32 plltest_val; + u32 xo_div4_cbcr; + u32 ctl_reg; + u32 status_reg; + void *const __iomem *base; +}; + +static inline struct measure_clk *to_measure_clk(struct clk *clk) +{ + return container_of(clk, struct measure_clk, c); +} + +/** + * struct gate_clk + * @c: clk + * @en_mask: ORed with @en_reg to enable gate clk + * @en_reg: register used to enable/disable gate clk + * @base: pointer to base address of ioremapped registers + */ +struct gate_clk { + struct clk c; + u32 en_mask; + u32 en_reg; + unsigned int delay_us; + void *const __iomem *base; +}; + +static inline struct gate_clk *to_gate_clk(struct clk *clk) +{ + return container_of(clk, struct gate_clk, c); +} + +/* + * Generic set-rate implementations + */ +void set_rate_mnd(struct rcg_clk *clk, struct clk_freq_tbl *nf); +void set_rate_hid(struct rcg_clk *clk, struct clk_freq_tbl *nf); + +/* + * Variables from the clock-local driver + */ +extern spinlock_t local_clock_reg_lock; + +extern struct clk_ops clk_ops_empty; +extern struct clk_ops clk_ops_rcg; +extern struct clk_ops clk_ops_rcg_mnd; +extern struct clk_ops clk_ops_branch; +extern struct clk_ops clk_ops_branch_hw_ctl; +extern struct clk_ops clk_ops_vote; +extern struct clk_ops clk_ops_rcg_hdmi; +extern struct clk_ops clk_ops_rcg_edp; +extern struct clk_ops clk_ops_rcg_dp; +extern struct clk_ops clk_ops_byte; +extern struct clk_ops clk_ops_pixel; +extern struct clk_ops clk_ops_byte_multiparent; +extern struct clk_ops clk_ops_pixel_multiparent; +extern struct clk_ops clk_ops_edppixel; +extern struct clk_ops clk_ops_gate; +extern struct clk_ops clk_ops_rst; +extern struct clk_mux_ops mux_reg_ops; +extern struct mux_div_ops rcg_mux_div_ops; +extern struct clk_div_ops postdiv_reg_ops; + +enum handoff pixel_rcg_handoff(struct clk *clk); +enum handoff byte_rcg_handoff(struct clk *clk); +unsigned long measure_get_rate(struct clk *c); + +/* + * Clock definition macros + */ +#define DEFINE_CLK_MEASURE(name) \ + struct clk name = { \ + .ops = &clk_ops_empty, \ + .dbg_name = #name, \ + CLK_INIT(name), \ + }; \ + +#endif /* __ARCH_ARM_MACH_MSM_CLOCK_LOCAL_2_H */ diff --git a/include/soc/qcom/clock-pll.h b/include/soc/qcom/clock-pll.h new file mode 100644 index 000000000000..c17376966a09 --- /dev/null +++ b/include/soc/qcom/clock-pll.h @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2012-2015, 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 __ARCH_ARM_MACH_MSM_CLOCK_PLL_H +#define __ARCH_ARM_MACH_MSM_CLOCK_PLL_H + +#include <linux/clk/msm-clk-provider.h> + +/** + * struct pll_freq_tbl - generic PLL frequency definition + * @freq_hz: pll frequency in hz + * @l_val: pll l value + * @m_val: pll m value + * @n_val: pll n value + * @post_div_val: pll post divider value + * @pre_div_val: pll pre-divider value + * @vco_val: pll vco value + */ +struct pll_freq_tbl { + const u32 freq_hz; + const u32 l_val; + const u32 m_val; + const u32 n_val; + const u32 post_div_val; + const u32 pre_div_val; + const u32 vco_val; +}; + +/** + * struct pll_config_masks - PLL config masks struct + * @post_div_mask: mask for post divider bits location + * @pre_div_mask: mask for pre-divider bits location + * @vco_mask: mask for vco bits location + * @mn_en_mask: ORed with pll config register to enable the mn counter + * @main_output_mask: ORed with pll config register to enable the main output + * @apc_pdn_mask: ORed with pll config register to enable/disable APC PDN + * @lock_mask: Mask that indicates that the PLL has locked + */ +struct pll_config_masks { + u32 apc_pdn_mask; + u32 post_div_mask; + u32 pre_div_mask; + u32 vco_mask; + u32 mn_en_mask; + u32 main_output_mask; + u32 early_output_mask; + u32 lock_mask; +}; + +struct pll_config_vals { + u32 post_div_masked; + u32 pre_div_masked; + u32 config_ctl_val; + u32 config_ctl_hi_val; + u32 test_ctl_lo_val; + u32 test_ctl_hi_val; + u32 alpha_val; + bool enable_mn; +}; + +struct pll_spm_ctrl { + u32 offset; + u32 event_bit; + void __iomem *spm_base; +}; + +#define PLL_FREQ_END (UINT_MAX-1) +#define PLL_F_END { .freq_hz = PLL_FREQ_END } + +/** + * struct pll_vote_clk - phase locked loop (HW voteable) + * @soft_vote: soft voting variable for multiple PLL software instances + * @soft_vote_mask: soft voting mask for multiple PLL software instances + * @en_reg: enable register + * @en_mask: ORed with @en_reg to enable the clock + * @status_mask: ANDed with @status_reg to determine if PLL is active. + * @status_reg: status register + * @c: clock + */ +struct pll_vote_clk { + u32 *soft_vote; + u32 soft_vote_mask; + void __iomem *const en_reg; + u32 en_mask; + void __iomem *const status_reg; + u32 status_mask; + + struct clk c; + void *const __iomem *base; +}; + +extern struct clk_ops clk_ops_pll_vote; +extern struct clk_ops clk_ops_pll_acpu_vote; +extern struct clk_ops clk_ops_pll_sleep_vote; + +/* Soft voting values */ +#define PLL_SOFT_VOTE_PRIMARY BIT(0) +#define PLL_SOFT_VOTE_ACPU BIT(1) +#define PLL_SOFT_VOTE_AUX BIT(2) + +static inline struct pll_vote_clk *to_pll_vote_clk(struct clk *c) +{ + return container_of(c, struct pll_vote_clk, c); +} + +/** + * struct pll_clk - phase locked loop + * @mode_reg: enable register + * @l_reg: l value register + * @m_reg: m value register + * @n_reg: n value register + * @config_reg: configuration register, contains mn divider enable, pre divider, + * post divider and vco configuration. register name can be configure register + * or user_ctl register depending on targets + * @config_ctl_reg: "expert" configuration register + * @config_ctl_hi_reg: upper 32 bits of the "expert" configuration register + * @status_reg: status register, contains the lock detection bit + * @init_test_ctl: initialize the test control register + * @pgm_test_ctl_enable: program the test_ctl register in the enable sequence + * @test_ctl_dbg: if false will configure the test control registers. + * @masks: masks used for settings in config_reg + * @vals: configuration values to be written to PLL registers + * @freq_tbl: pll freq table + * @no_prepared_reconfig: Fail round_rate if pll is prepared + * @c: clk + * @base: pointer to base address of ioremapped registers. + */ +struct pll_clk { + void __iomem *const mode_reg; + void __iomem *const l_reg; + void __iomem *const m_reg; + void __iomem *const n_reg; + void __iomem *const alpha_reg; + void __iomem *const config_reg; + void __iomem *const config_ctl_reg; + void __iomem *const config_ctl_hi_reg; + void __iomem *const status_reg; + void __iomem *const alt_status_reg; + void __iomem *const test_ctl_lo_reg; + void __iomem *const test_ctl_hi_reg; + + bool init_test_ctl; + bool pgm_test_ctl_enable; + bool test_ctl_dbg; + + struct pll_config_masks masks; + struct pll_config_vals vals; + struct pll_freq_tbl *freq_tbl; + + unsigned long src_rate; + unsigned long min_rate; + unsigned long max_rate; + + bool inited; + bool no_prepared_reconfig; + + struct pll_spm_ctrl spm_ctrl; + struct clk c; + void *const __iomem *base; +}; + +extern struct clk_ops clk_ops_local_pll; +extern struct clk_ops clk_ops_sr2_pll; +extern struct clk_ops clk_ops_variable_rate_pll; +extern struct clk_ops clk_ops_variable_rate_pll_hwfsm; + +void __variable_rate_pll_init(struct clk *c); + +static inline struct pll_clk *to_pll_clk(struct clk *c) +{ + return container_of(c, struct pll_clk, c); +} + +int sr_pll_clk_enable(struct clk *c); +int sr_hpm_lp_pll_clk_enable(struct clk *c); + +struct pll_alt_config { + u32 val; + u32 mask; +}; + +struct pll_config { + u32 l; + u32 m; + u32 n; + u32 vco_val; + u32 vco_mask; + u32 pre_div_val; + u32 pre_div_mask; + u32 post_div_val; + u32 post_div_mask; + u32 mn_ena_val; + u32 mn_ena_mask; + u32 main_output_val; + u32 main_output_mask; + u32 aux_output_val; + u32 aux_output_mask; + u32 cfg_ctl_val; + /* SR2 PLL specific fields */ + u32 add_factor_val; + u32 add_factor_mask; + struct pll_alt_config alt_cfg; +}; + +struct pll_config_regs { + void __iomem *l_reg; + void __iomem *m_reg; + void __iomem *n_reg; + void __iomem *config_reg; + void __iomem *config_alt_reg; + void __iomem *config_ctl_reg; + void __iomem *mode_reg; + void *const __iomem *base; +}; + +void configure_sr_pll(struct pll_config *config, struct pll_config_regs *regs, + u32 ena_fsm_mode); +void configure_sr_hpm_lp_pll(struct pll_config *config, + struct pll_config_regs *, u32 ena_fsm_mode); +#endif diff --git a/include/soc/qcom/clock-rpm.h b/include/soc/qcom/clock-rpm.h new file mode 100644 index 000000000000..18fedd4c97f7 --- /dev/null +++ b/include/soc/qcom/clock-rpm.h @@ -0,0 +1,180 @@ +/* Copyright (c) 2010-2015, 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 __ARCH_ARM_MACH_MSM_CLOCK_RPM_H +#define __ARCH_ARM_MACH_MSM_CLOCK_RPM_H + +#include <linux/clk/msm-clk-provider.h> +#include <soc/qcom/rpm-smd.h> + +#define RPM_SMD_KEY_RATE 0x007A484B +#define RPM_SMD_KEY_ENABLE 0x62616E45 +#define RPM_SMD_KEY_STATE 0x54415453 + +#define RPM_CLK_BUFFER_A_REQ 0x616B6C63 +#define RPM_KEY_SOFTWARE_ENABLE 0x6E657773 +#define RPM_KEY_PIN_CTRL_CLK_BUFFER_ENABLE_KEY 0x62636370 + +struct clk_ops; +struct clk_rpmrs_data; +extern struct clk_ops clk_ops_rpm; +extern struct clk_ops clk_ops_rpm_branch; + +struct rpm_clk { + int rpm_res_type; + int rpm_key; + int rpm_clk_id; + const int rpm_status_id; + bool active_only; + bool enabled; + bool branch; /* true: RPM only accepts 1 for ON and 0 for OFF */ + struct clk_rpmrs_data *rpmrs_data; + struct rpm_clk *peer; + struct clk c; + uint32_t *last_active_set_vote; + uint32_t *last_sleep_set_vote; +}; + +static inline struct rpm_clk *to_rpm_clk(struct clk *clk) +{ + return container_of(clk, struct rpm_clk, c); +} + +/* + * RPM scaling enable function used for target that has an RPM resource for + * rpm clock scaling enable. + */ +int enable_rpm_scaling(void); + +int vote_bimc(struct rpm_clk *r, uint32_t value); + +extern struct clk_rpmrs_data clk_rpmrs_data_smd; + +/* + * A note on name##last_{active,sleep}_set_vote below: + * We track the last active and sleep set votes across both + * active-only and active+sleep set clocks. We use the same + * tracking variables for both clocks in order to keep both + * updated about the last vote irrespective of which clock + * actually made the request. This is the only way to allow + * optimizations that prevent duplicate requests from being sent + * to the RPM. Separate tracking does not work since it is not + * possible to know if the peer's last request was actually sent + * to the RPM. + */ + +#define __DEFINE_CLK_RPM(name, active, type, r_id, stat_id, dep, key, \ + rpmrsdata) \ + static struct rpm_clk active; \ + static uint32_t name##last_active_set_vote; \ + static uint32_t name##last_sleep_set_vote; \ + static struct rpm_clk name = { \ + .rpm_res_type = (type), \ + .rpm_clk_id = (r_id), \ + .rpm_status_id = (stat_id), \ + .rpm_key = (key), \ + .peer = &active, \ + .rpmrs_data = (rpmrsdata),\ + .last_active_set_vote = &name##last_active_set_vote, \ + .last_sleep_set_vote = &name##last_sleep_set_vote, \ + .c = { \ + .ops = &clk_ops_rpm, \ + .dbg_name = #name, \ + CLK_INIT(name.c), \ + .depends = dep, \ + }, \ + }; \ + static struct rpm_clk active = { \ + .rpm_res_type = (type), \ + .rpm_clk_id = (r_id), \ + .rpm_status_id = (stat_id), \ + .rpm_key = (key), \ + .peer = &name, \ + .active_only = true, \ + .rpmrs_data = (rpmrsdata),\ + .last_active_set_vote = &name##last_active_set_vote, \ + .last_sleep_set_vote = &name##last_sleep_set_vote, \ + .c = { \ + .ops = &clk_ops_rpm, \ + .dbg_name = #active, \ + CLK_INIT(active.c), \ + .depends = dep, \ + }, \ + }; + +#define __DEFINE_CLK_RPM_BRANCH(name, active, type, r_id, stat_id, r, \ + key, rpmrsdata) \ + static struct rpm_clk active; \ + static uint32_t name##last_active_set_vote; \ + static uint32_t name##last_sleep_set_vote; \ + static struct rpm_clk name = { \ + .rpm_res_type = (type), \ + .rpm_clk_id = (r_id), \ + .rpm_status_id = (stat_id), \ + .rpm_key = (key), \ + .peer = &active, \ + .branch = true, \ + .rpmrs_data = (rpmrsdata),\ + .last_active_set_vote = &name##last_active_set_vote, \ + .last_sleep_set_vote = &name##last_sleep_set_vote, \ + .c = { \ + .ops = &clk_ops_rpm_branch, \ + .dbg_name = #name, \ + .rate = (r), \ + CLK_INIT(name.c), \ + }, \ + }; \ + static struct rpm_clk active = { \ + .rpm_res_type = (type), \ + .rpm_clk_id = (r_id), \ + .rpm_status_id = (stat_id), \ + .rpm_key = (key), \ + .peer = &name, \ + .active_only = true, \ + .branch = true, \ + .rpmrs_data = (rpmrsdata),\ + .last_active_set_vote = &name##last_active_set_vote, \ + .last_sleep_set_vote = &name##last_sleep_set_vote, \ + .c = { \ + .ops = &clk_ops_rpm_branch, \ + .dbg_name = #active, \ + .rate = (r), \ + CLK_INIT(active.c), \ + }, \ + }; + +#define DEFINE_CLK_RPM_SMD(name, active, type, r_id, dep) \ + __DEFINE_CLK_RPM(name, active, type, r_id, 0, dep, \ + RPM_SMD_KEY_RATE, &clk_rpmrs_data_smd) + +#define DEFINE_CLK_RPM_SMD_BRANCH(name, active, type, r_id, r) \ + __DEFINE_CLK_RPM_BRANCH(name, active, type, r_id, 0, r, \ + RPM_SMD_KEY_ENABLE, &clk_rpmrs_data_smd) + +#define DEFINE_CLK_RPM_SMD_QDSS(name, active, type, r_id) \ + __DEFINE_CLK_RPM(name, active, type, r_id, \ + 0, 0, RPM_SMD_KEY_STATE, &clk_rpmrs_data_smd) +/* + * The RPM XO buffer clock management code aggregates votes for pin-control mode + * and software mode separately. Software-enable has higher priority over pin- + * control, and if the software-mode aggregation results in a 'disable', the + * buffer will be left in pin-control mode if a pin-control vote is in place. + */ +#define DEFINE_CLK_RPM_SMD_XO_BUFFER(name, active, r_id) \ + __DEFINE_CLK_RPM_BRANCH(name, active, RPM_CLK_BUFFER_A_REQ, r_id, 0, \ + 1000, RPM_KEY_SOFTWARE_ENABLE, &clk_rpmrs_data_smd) + +#define DEFINE_CLK_RPM_SMD_XO_BUFFER_PINCTRL(name, active, r_id) \ + __DEFINE_CLK_RPM_BRANCH(name, active, RPM_CLK_BUFFER_A_REQ, r_id, 0, \ + 1000, RPM_KEY_PIN_CTRL_CLK_BUFFER_ENABLE_KEY, &clk_rpmrs_data_smd) +#endif diff --git a/include/soc/qcom/clock-voter.h b/include/soc/qcom/clock-voter.h new file mode 100644 index 000000000000..9eb3898db1e8 --- /dev/null +++ b/include/soc/qcom/clock-voter.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2010-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. + * + */ + +#ifndef __ARCH_ARM_MACH_MSM_CLOCK_VOTER_H +#define __ARCH_ARM_MACH_MSM_CLOCK_VOTER_H + +#include <linux/clk/msm-clk-provider.h> + +struct clk_ops; +extern struct clk_ops clk_ops_voter; + +struct clk_voter { + int is_branch; + bool enabled; + struct clk c; +}; + +static inline struct clk_voter *to_clk_voter(struct clk *clk) +{ + return container_of(clk, struct clk_voter, c); +} + +#define __DEFINE_CLK_VOTER(clk_name, _parent, _default_rate, _is_branch) \ + struct clk_voter clk_name = { \ + .is_branch = (_is_branch), \ + .c = { \ + .parent = _parent, \ + .dbg_name = #clk_name, \ + .ops = &clk_ops_voter, \ + .rate = _default_rate, \ + CLK_INIT(clk_name.c), \ + }, \ + } + +#define DEFINE_CLK_VOTER(clk_name, _parent, _default_rate) \ + __DEFINE_CLK_VOTER(clk_name, _parent, _default_rate, 0) + +#define DEFINE_CLK_BRANCH_VOTER(clk_name, _parent) \ + __DEFINE_CLK_VOTER(clk_name, _parent, 1000, 1) + +#endif diff --git a/include/soc/qcom/cx_ipeak.h b/include/soc/qcom/cx_ipeak.h new file mode 100644 index 000000000000..b47e6b4f9b9d --- /dev/null +++ b/include/soc/qcom/cx_ipeak.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2016-2017, 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 __SOC_COM_CX_IPEAK_H +#define __SOC_COM_CX_IPEAK_H + +struct device_node; +struct cx_ipeak_client; + +#ifndef CONFIG_QCOM_CX_IPEAK + +static inline struct cx_ipeak_client *cx_ipeak_register( + struct device_node *dev_node, + const char *client_name) +{ + return NULL; +} + +static inline void cx_ipeak_unregister(struct cx_ipeak_client *client) +{ +} + +static inline int cx_ipeak_update(struct cx_ipeak_client *ipeak_client, + bool vote) +{ + return 0; +} +#else + +struct cx_ipeak_client *cx_ipeak_register(struct device_node *dev_node, + const char *client_name); +void cx_ipeak_unregister(struct cx_ipeak_client *client); +int cx_ipeak_update(struct cx_ipeak_client *ipeak_client, bool vote); + +#endif + +#endif /*__SOC_COM_CX_IPEAK_H*/ diff --git a/include/soc/qcom/devfreq_devbw.h b/include/soc/qcom/devfreq_devbw.h new file mode 100644 index 000000000000..7edb2abba487 --- /dev/null +++ b/include/soc/qcom/devfreq_devbw.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014, 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 _DEVFREQ_DEVBW_H +#define _DEVFREQ_DEVBW_H + +#include <linux/devfreq.h> + +#ifdef CONFIG_MSM_DEVFREQ_DEVBW +int devfreq_add_devbw(struct device *dev); +int devfreq_remove_devbw(struct device *dev); +int devfreq_suspend_devbw(struct device *dev); +int devfreq_resume_devbw(struct device *dev); +#else +static inline int devfreq_add_devbw(struct device *dev) +{ + return 0; +} +static inline int devfreq_remove_devbw(struct device *dev) +{ + return 0; +} +static inline int devfreq_suspend_devbw(struct device *dev) +{ + return 0; +} +static inline int devfreq_resume_devbw(struct device *dev) +{ + return 0; +} +#endif + +#endif /* _DEVFREQ_DEVBW_H */ diff --git a/include/soc/qcom/early_domain.h b/include/soc/qcom/early_domain.h new file mode 100644 index 000000000000..076f2d6fac2b --- /dev/null +++ b/include/soc/qcom/early_domain.h @@ -0,0 +1,98 @@ +/* Copyright (c) 2018, 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. + */ + +/* Early domain services invoked in bootloaders run in parallel after + * kernel takes over. One page in memory is reserved to pass information + * between bootloader and kernel. This page has a header to capture status, + * request and cpumask described in structure early_domain_header. Early + * domain core driver in kernel reads this header to decide the status of + * services and takes necessary action. The rest of the page is intended to + * pass service specific information. Offset for service specific area are + * defined in macros, and its the service specific driver's responsiblity + * to operate in their defined areas to pass service specific information. + * * + * * + * * + * ***************************************** + * * Header * + * * * + * ***************************************** + * * * + * * Early display * + * * * + * * * + * ***************************************** + * * * + * * Early camera * + * * * + * * * + * ***************************************** + * * * + * * Early audio * + * * * + * * * + * ***************************************** + * * + */ + +enum service_id { + EARLY_DOMAIN_CORE = 0, + EARLY_DISPLAY, + EARLY_CAMERA, + EARLY_AUDIO, +}; + +#ifdef CONFIG_QCOM_EARLY_DOMAIN +#include <linux/workqueue.h> +#include <linux/cpumask.h> +#include <linux/pm_qos.h> +#include <linux/notifier.h> + +#define EARLY_DOMAIN_MAGIC "ERLYDOM" +#define MAGIC_SIZE 8 +#define NUM_SERVICES 3 +#define SERVICE_SHARED_MEM_SIZE ((PAGE_SIZE)/(NUM_SERVICES)) + +struct early_domain_header { + char magic[MAGIC_SIZE]; + unsigned long cpumask; + unsigned long early_domain_status; + unsigned long early_domain_request; +}; + +struct early_domain_core { + struct platform_device *pdev; + struct early_domain_header *pdata; + struct work_struct early_domain_work; + phys_addr_t lk_pool_paddr; + size_t lk_pool_size; + phys_addr_t early_domain_shm; + size_t early_domain_shm_size; + cpumask_t cpumask; + struct notifier_block ed_notifier; + struct pm_qos_request ed_qos_request; + struct wakeup_source ed_wake_lock; +}; + +void request_early_service_shutdown(enum service_id); +bool get_early_service_status(enum service_id sid); +void *get_service_shared_mem_start(enum service_id sid); + +#else + +static inline void request_early_service_shutdown(enum service_id sid) {} +static inline bool get_early_service_status(enum service_id sid) + { return false; } +static inline void *get_service_shared_mem_start(enum service_id sid) + { return NULL; } + +#endif diff --git a/include/soc/qcom/event_timer.h b/include/soc/qcom/event_timer.h new file mode 100644 index 000000000000..6f2a1aa2f9b1 --- /dev/null +++ b/include/soc/qcom/event_timer.h @@ -0,0 +1,80 @@ +/* Copyright (c) 2012, 2014, 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 __ARCH_ARM_MACH_MSM_EVENT_TIMER_H +#define __ARCH_ARM_MACH_MSM_EVENT_TIMER_H + +#include <linux/hrtimer.h> + +struct event_timer_info; + +#ifdef CONFIG_MSM_EVENT_TIMER +/** + * add_event_timer() : Add a wakeup event. Intended to be called + * by clients once. Returns a handle to be used + * for future transactions. + * @irq : Interrupt number to track affinity. + * @function : The callback function will be called when event + * timer expires. + * @data : Callback data provided by client. + */ +struct event_timer_info *add_event_timer(uint32_t irq, + void (*function)(void *), void *data); + +/** activate_event_timer() : Set the expiration time for an event in absolute + * ktime. This is a oneshot event timer, clients + * should call this again to set another expiration. + * @event : Event handle. + * @event_time : Event time in absolute ktime. + */ +void activate_event_timer(struct event_timer_info *event, ktime_t event_time); + +/** + * deactivate_event_timer() : Deactivate an event timer. + * @event: event handle. + */ +void deactivate_event_timer(struct event_timer_info *event); + +/** + * destroy_event_timer() : Free the event info data structure allocated during + * add_event_timer(). + * @event: event handle. + */ +void destroy_event_timer(struct event_timer_info *event); + +/** + * get_next_event_timer() : Get the next wakeup event. + * returns a ktime value of the next + * expiring event. + */ +ktime_t get_next_event_time(int cpu); +#else +static inline void *add_event_timer(uint32_t irq, void (*function)(void *), + void *data) +{ + return NULL; +} + +static inline void activate_event_timer(void *event, ktime_t event_time) {} + +static inline void deactivate_event_timer(void *event) {} + +static inline void destroy_event_timer(void *event) {} + +static inline ktime_t get_next_event_time(int cpu) +{ + return ns_to_ktime(0); +} + +#endif /* CONFIG_MSM_EVENT_TIMER_MANAGER */ +#endif /* __ARCH_ARM_MACH_MSM_EVENT_TIMER_H */ diff --git a/include/soc/qcom/glink.h b/include/soc/qcom/glink.h new file mode 100644 index 000000000000..cecd0c01d69a --- /dev/null +++ b/include/soc/qcom/glink.h @@ -0,0 +1,458 @@ +/* Copyright (c) 2014-2015,2017 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 _SOC_QCOM_GLINK_H_ +#define _SOC_QCOM_GLINK_H_ + +#include <linux/types.h> + +/* Maximum size (including null) for channel, edge, or transport names */ +#define GLINK_NAME_SIZE 32 + +/* Maximum packet size for TX and RX */ +#define GLINK_MAX_PKT_SIZE SZ_1M + +/** + * G-Link Port State Notification Values + */ +enum { + GLINK_CONNECTED, + GLINK_LOCAL_DISCONNECTED, + GLINK_REMOTE_DISCONNECTED, +}; + +/** + * G-Link Open Options + * + * Used to define the glink_open_config::options field which is passed into + * glink_open(). + */ +enum { + GLINK_OPT_INITIAL_XPORT = BIT(0), + GLINK_OPT_RX_INTENT_NOTIF = BIT(1), +}; + +/** + * Open configuration. + * + * priv: Private data passed into user callbacks + * options: Open option flags + * rx_intent_req_timeout_ms: Timeout for requesting an RX intent, in + * milliseconds; if set to 0, timeout is infinite + * notify_rx: Receive notification function (required) + * notify_tx_done: Transmit-done notification function (required) + * notify_state: State-change notification (required) + * notify_rx_intent_req: Receive intent request (optional) + * notify_rxv: Receive notification function for vector buffers + * (required if notify_rx is not provided) + * notify_sig: Signal-change notification (optional) + * notify_rx_tracer_pkt: Receive notification for tracer packet + * notify_remote_rx_intent: Receive notification for remote-queued RX intent + * + * This structure is passed into the glink_open() call to setup + * configuration handles. All unused fields should be set to 0. + * + * The structure is copied internally before the call to glink_open() returns. + */ +struct glink_open_config { + void *priv; + uint32_t options; + + const char *transport; + const char *edge; + const char *name; + unsigned int rx_intent_req_timeout_ms; + + void (*notify_rx)(void *handle, const void *priv, const void *pkt_priv, + const void *ptr, size_t size); + void (*notify_tx_done)(void *handle, const void *priv, + const void *pkt_priv, const void *ptr); + void (*notify_state)(void *handle, const void *priv, unsigned event); + bool (*notify_rx_intent_req)(void *handle, const void *priv, + size_t req_size); + void (*notify_rxv)(void *handle, const void *priv, const void *pkt_priv, + void *iovec, size_t size, + void * (*vbuf_provider)(void *iovec, size_t offset, + size_t *size), + void * (*pbuf_provider)(void *iovec, size_t offset, + size_t *size)); + void (*notify_rx_sigs)(void *handle, const void *priv, + uint32_t old_sigs, uint32_t new_sigs); + void (*notify_rx_abort)(void *handle, const void *priv, + const void *pkt_priv); + void (*notify_tx_abort)(void *handle, const void *priv, + const void *pkt_priv); + void (*notify_rx_tracer_pkt)(void *handle, const void *priv, + const void *pkt_priv, const void *ptr, size_t size); + void (*notify_remote_rx_intent)(void *handle, const void *priv, + size_t size); +}; + +enum glink_link_state { + GLINK_LINK_STATE_UP, + GLINK_LINK_STATE_DOWN, +}; + +/** + * Data structure containing information during Link State callback + * transport: String identifying the transport. + * edge: String identifying the edge. + * link_state: Link state(UP?DOWN). + */ +struct glink_link_state_cb_info { + const char *transport; + const char *edge; + enum glink_link_state link_state; +}; + +/** + * Data structure containing information for link state registration + * transport: String identifying the transport. + * edge: String identifying the edge. + * glink_link_state_notif_cb: Callback function used to pass the event. + */ +struct glink_link_info { + const char *transport; + const char *edge; + void (*glink_link_state_notif_cb)( + struct glink_link_state_cb_info *cb_info, + void *priv); +}; + +enum tx_flags { + GLINK_TX_REQ_INTENT = 0x1, + GLINK_TX_SINGLE_THREADED = 0x2, + GLINK_TX_TRACER_PKT = 0x4, + GLINK_TX_ATOMIC = 0x8, +}; + +#ifdef CONFIG_MSM_GLINK +/** + * Open GLINK channel. + * + * @cfg_ptr: Open configuration structure (the structure is copied before + * glink_open returns). All unused fields should be zero-filled. + * + * This should not be called from link state callback context by clients. + * It is recommended that client should invoke this function from their own + * thread. + * + * Return: Pointer to channel on success, PTR_ERR() with standard Linux + * error code on failure. + */ +void *glink_open(const struct glink_open_config *cfg_ptr); + +/** + * glink_close() - Close a previously opened channel. + * + * @handle: handle to close + * + * Once the closing process has been completed, the GLINK_LOCAL_DISCONNECTED + * state event will be sent and the channel can be reopened. + * + * Return: 0 on success; -EINVAL for invalid handle, -EBUSY is close is + * already in progress, standard Linux Error code otherwise. + */ +int glink_close(void *handle); + +/** + * glink_tx() - Transmit packet. + * + * @handle: handle returned by glink_open() + * @pkt_priv: opaque data value that will be returned to client with + * notify_tx_done notification + * @data: pointer to the data + * @size: size of data + * @tx_flags: Flags to specify transmit specific options + * + * Return: -EINVAL for invalid handle; -EBUSY if channel isn't ready for + * transmit operation (not fully opened); -EAGAIN if remote side + * has not provided a receive intent that is big enough. + */ +int glink_tx(void *handle, void *pkt_priv, void *data, size_t size, + uint32_t tx_flags); + +/** + * glink_queue_rx_intent() - Register an intent to receive data. + * + * @handle: handle returned by glink_open() + * @pkt_priv: opaque data type that is returned when a packet is received + * size: maximum size of data to receive + * + * Return: 0 for success; standard Linux error code for failure case + */ +int glink_queue_rx_intent(void *handle, const void *pkt_priv, size_t size); + +/** + * glink_rx_intent_exists() - Check if an intent of size exists. + * + * @handle: handle returned by glink_open() + * @size: size of an intent to check or 0 for any intent + * + * Return: TRUE if an intent exists with greater than or equal to the size + * else FALSE + */ +bool glink_rx_intent_exists(void *handle, size_t size); + +/** + * glink_rx_done() - Return receive buffer to remote side. + * + * @handle: handle returned by glink_open() + * @ptr: data pointer provided in the notify_rx() call + * @reuse: if true, receive intent is re-used + * + * Return: 0 for success; standard Linux error code for failure case + */ +int glink_rx_done(void *handle, const void *ptr, bool reuse); + +/** + * glink_txv() - Transmit a packet in vector form. + * + * @handle: handle returned by glink_open() + * @pkt_priv: opaque data value that will be returned to client with + * notify_tx_done notification + * @iovec: pointer to the vector (must remain valid until notify_tx_done + * notification) + * @size: size of data/vector + * @vbuf_provider: Client provided helper function to iterate the vector + * in physical address space + * @pbuf_provider: Client provided helper function to iterate the vector + * in virtual address space + * @tx_flags: Flags to specify transmit specific options + * + * Return: -EINVAL for invalid handle; -EBUSY if channel isn't ready for + * transmit operation (not fully opened); -EAGAIN if remote side has + * not provided a receive intent that is big enough. + */ +int glink_txv(void *handle, void *pkt_priv, + void *iovec, size_t size, + void * (*vbuf_provider)(void *iovec, size_t offset, size_t *size), + void * (*pbuf_provider)(void *iovec, size_t offset, size_t *size), + uint32_t tx_flags); + +/** + * glink_sigs_set() - Set the local signals for the GLINK channel + * + * @handle: handle returned by glink_open() + * @sigs: modified signal value + * + * Return: 0 for success; standard Linux error code for failure case + */ +int glink_sigs_set(void *handle, uint32_t sigs); + +/** + * glink_sigs_local_get() - Get the local signals for the GLINK channel + * + * handle: handle returned by glink_open() + * sigs: Pointer to hold the signals + * + * Return: 0 for success; standard Linux error code for failure case + */ +int glink_sigs_local_get(void *handle, uint32_t *sigs); + +/** + * glink_sigs_remote_get() - Get the Remote signals for the GLINK channel + * + * handle: handle returned by glink_open() + * sigs: Pointer to hold the signals + * + * Return: 0 for success; standard Linux error code for failure case + */ +int glink_sigs_remote_get(void *handle, uint32_t *sigs); + +/** + * glink_register_link_state_cb() - Register for link state notification + * @link_info: Data structure containing the link identification and callback. + * @priv: Private information to be passed with the callback. + * + * This function is used to register a notifier to receive the updates about a + * link's/transport's state. This notifier needs to be registered first before + * an attempt to open a channel. + * + * Return: a reference to the notifier handle. + */ +void *glink_register_link_state_cb(struct glink_link_info *link_info, + void *priv); + +/** + * glink_unregister_link_state_cb() - Unregister the link state notification + * notif_handle: Handle to be unregistered. + * + * This function is used to unregister a notifier to stop receiving the updates + * about a link's/transport's state. + */ +void glink_unregister_link_state_cb(void *notif_handle); + +/** + * glink_qos_latency() - Register the latency QoS requirement + * @handle: Channel handle in which the latency is required. + * @latency_us: Latency requirement in units of micro-seconds. + * @pkt_size: Worst case packet size for which the latency is required. + * + * This function is used to register the latency requirement for a channel + * and ensures that the latency requirement for this channel is met without + * impacting the existing latency requirements of other channels. + * + * Return: 0 if QoS request is achievable, standard Linux error codes on error + */ +int glink_qos_latency(void *handle, unsigned long latency_us, size_t pkt_size); + +/** + * glink_qos_cancel() - Cancel or unregister the QoS request + * @handle: Channel handle for which the QoS request is cancelled. + * + * This function is used to cancel/unregister the QoS requests for a channel. + * + * Return: 0 on success, standard Linux error codes on failure + */ +int glink_qos_cancel(void *handle); + +/** + * glink_qos_start() - Start of the transmission requiring QoS + * @handle: Channel handle in which the transmit activity is performed. + * + * This function is called by the clients to indicate G-Link regarding the + * start of the transmission which requires a certain QoS. The clients + * must account for the QoS ramp time to ensure meeting the QoS. + * + * Return: 0 on success, standard Linux error codes on failure + */ +int glink_qos_start(void *handle); + +/** + * glink_qos_get_ramp_time() - Get the QoS ramp time + * @handle: Channel handle for which the QoS ramp time is required. + * @pkt_size: Worst case packet size. + * + * This function is called by the clients to obtain the ramp time required + * to meet the QoS requirements. + * + * Return: QoS ramp time is returned in units of micro-seconds + */ +unsigned long glink_qos_get_ramp_time(void *handle, size_t pkt_size); + +/** + * glink_start_rx_rt() - Vote for RT thread priority on RX. + * @handle: Channel handle for which transaction are occurring. + * + * Return: 0 on success, standard Linux error codes on failure + */ +int glink_start_rx_rt(void *handle); + +/** + * glink_end_rx_rt() - Vote for RT thread priority on RX. + * @handle: Channel handle for which transaction are occurring. + * + * Return: 0 on success, standard Linux error codes on failure + */ +int glink_end_rx_rt(void *handle); + +#else /* CONFIG_MSM_GLINK */ +static inline void *glink_open(const struct glink_open_config *cfg_ptr) +{ + return NULL; +} + +static inline int glink_close(void *handle) +{ + return -ENODEV; +} + +static inline int glink_tx(void *handle, void *pkt_priv, void *data, + size_t size, uint32_t tx_flags) +{ + return -ENODEV; +} + +static inline int glink_queue_rx_intent(void *handle, const void *pkt_priv, + size_t size) +{ + return -ENODEV; +} + +static inline bool glink_rx_intent_exists(void *handle, size_t size) +{ + return -ENODEV; +} + +static inline int glink_rx_done(void *handle, const void *ptr, bool reuse) +{ + return -ENODEV; +} + +static inline int glink_txv(void *handle, void *pkt_priv, + void *iovec, size_t size, + void * (*vbuf_provider)(void *iovec, size_t offset, size_t *size), + void * (*pbuf_provider)(void *iovec, size_t offset, size_t *size), + uint32_t tx_flags) +{ + return -ENODEV; +} + +static inline int glink_sigs_set(void *handle, uint32_t sigs) +{ + return -ENODEV; +} + +static inline int glink_sigs_local_get(void *handle, uint32_t *sigs) +{ + return -ENODEV; +} + +static inline int glink_sigs_remote_get(void *handle, uint32_t *sigs) +{ + return -ENODEV; +} + +static inline void *glink_register_link_state_cb( + struct glink_link_info *link_info, void *priv) +{ + return NULL; +} + +static inline void glink_unregister_link_state_cb(void *notif_handle) +{ +} + +static inline int glink_qos_latency(void *handle, unsigned long latency_us, + size_t pkt_size) +{ + return -ENODEV; +} + +static inline int glink_qos_cancel(void *handle) +{ + return -ENODEV; +} + +static inline int glink_qos_start(void *handle) +{ + return -ENODEV; +} + +static inline unsigned long glink_qos_get_ramp_time(void *handle, + size_t pkt_size) +{ + return 0; +} + +static inline int glink_start_rx_rt(void *handle) +{ + return -ENODEV; +} + +static inline int glink_end_rx_rt(void *handle) +{ + return -ENODEV; +} + +#endif /* CONFIG_MSM_GLINK */ +#endif /* _SOC_QCOM_GLINK_H_ */ diff --git a/include/soc/qcom/glink_rpm_xprt.h b/include/soc/qcom/glink_rpm_xprt.h new file mode 100644 index 000000000000..8dfd43783e57 --- /dev/null +++ b/include/soc/qcom/glink_rpm_xprt.h @@ -0,0 +1,78 @@ +/* Copyright (c) 2014-2015, 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 _SOC_QCOM_GLINK_RPM_XPRT_H_ +#define _SOC_QCOM_GLINK_RPM_XPRT_H_ + +#include <linux/types.h> + +#ifdef CONFIG_MSM_GLINK + +/** + * glink_rpm_rx_poll() - Poll and receive any available events + * @handle: Channel handle in which this operation is performed. + * + * This function is used to poll and receive events and packets while the + * receive interrupt from RPM is disabled. + * + * Note that even if a return value > 0 is returned indicating that some events + * were processed, clients should only use the notification functions passed + * into glink_open() to determine if an entire packet has been received since + * some events may be internal details that are not visible to clients. + * + * Return: 0 for no packets available; > 0 for events available; standard + * Linux error codes on failure. + */ +int glink_rpm_rx_poll(void *handle); + +/** + * glink_rpm_mask_rx_interrupt() - Mask or unmask the RPM receive interrupt + * @handle: Channel handle in which this operation is performed. + * @mask: Flag to mask or unmask the interrupt. + * @pstruct: Pointer to any platform specific data. + * + * This function is used to mask or unmask the receive interrupt from RPM. + * "mask" set to true indicates masking the interrupt and when set to false + * indicates unmasking the interrupt. + * + * Return: 0 on success, standard Linux error codes on failure. + */ +int glink_rpm_mask_rx_interrupt(void *handle, bool mask, void *pstruct); + +/** + * glink_wait_link_down() - Return whether read/write indices in FIFO are all 0. + * @handle: Channel handle in which this operation is performed. + * + * This function returns the status of the read/write indices in the FIFO. + * + * Return: 1 if the indices are all 0, 0 otherwise. + */ +int glink_wait_link_down(void *handle); + +#else +static inline int glink_rpm_rx_poll(void *handle) +{ + return -ENODEV; +} + +static inline int glink_rpm_mask_rx_interrupt(void *handle, bool mask, + void *pstruct) +{ + return -ENODEV; +} +static inline int glink_wait_link_down(void *handle) +{ + return -ENODEV; +} + +#endif /* CONFIG_MSM_GLINK */ + +#endif /* _SOC_QCOM_GLINK_RPM_XPRT_H_ */ diff --git a/include/soc/qcom/hsic_sysmon.h b/include/soc/qcom/hsic_sysmon.h new file mode 100644 index 000000000000..f6efbe647f00 --- /dev/null +++ b/include/soc/qcom/hsic_sysmon.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2012-2013,2016 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 __HSIC_SYSMON_H__ +#define __HSIC_SYSMON_H__ + +/** + * enum hsic_sysmon_device_id - Supported HSIC subsystem devices + */ +enum hsic_sysmon_device_id { + HSIC_SYSMON_DEV_EXT_MODEM, + HSIC_SYSMON_DEV_EXT_MODEM_2, + NUM_HSIC_SYSMON_DEVS +}; + +#if defined(CONFIG_MSM_HSIC_SYSMON) || defined(CONFIG_MSM_HSIC_SYSMON_MODULE) + +extern int hsic_sysmon_open(enum hsic_sysmon_device_id id); +extern void hsic_sysmon_close(enum hsic_sysmon_device_id id); +extern int hsic_sysmon_read(enum hsic_sysmon_device_id id, char *data, + size_t len, size_t *actual_len, int timeout); +extern int hsic_sysmon_write(enum hsic_sysmon_device_id id, const char *data, + size_t len, int timeout); + +#else /* CONFIG_MSM_HSIC_SYSMON || CONFIG_MSM_HSIC_SYSMON_MODULE */ + +static inline int hsic_sysmon_open(enum hsic_sysmon_device_id id) +{ + return -ENODEV; +} + +static inline void hsic_sysmon_close(enum hsic_sysmon_device_id id) { } + +static inline int hsic_sysmon_read(enum hsic_sysmon_device_id id, char *data, + size_t len, size_t *actual_len, int timeout) +{ + return -ENODEV; +} + +static inline int hsic_sysmon_write(enum hsic_sysmon_device_id id, + const char *data, size_t len, int timeout) +{ + return -ENODEV; +} + +#endif /* CONFIG_MSM_HSIC_SYSMON || CONFIG_MSM_HSIC_SYSMON_MODULE */ + +#endif /* __HSIC_SYSMON_H__ */ diff --git a/include/soc/qcom/hvc.h b/include/soc/qcom/hvc.h new file mode 100644 index 000000000000..435729b13490 --- /dev/null +++ b/include/soc/qcom/hvc.h @@ -0,0 +1,58 @@ +/* Copyright (c) 2014, 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 __MSM_HVC_H +#define __MSM_HVC_H + +#ifdef CONFIG_ARM64 +#define HVC_FN_ARM_BASE 0xC0000000 +#define HVC_FN_CPU_BASE 0xC1000000 +#define HVC_FN_SIP_BASE 0xC2000000 +#define HVC_FN_OEM_BASE 0xC3000000 +#define HVC_FN_APP_BASE 0xF0000000 +#define HVC_FN_OS_BASE 0xF2000000 +#else +#define HVC_FN_ARM_BASE 0x80000000 +#define HVC_FN_CPU_BASE 0x81000000 +#define HVC_FN_SIP_BASE 0x82000000 +#define HVC_FN_OEM_BASE 0x83000000 +#define HVC_FN_APP_BASE 0xB0000000 +#define HVC_FN_OS_BASE 0xB2000000 +#endif + +#define HVC_FN_ARM(n) (HVC_FN_ARM_BASE + (n)) +#define HVC_FN_CPU(n) (HVC_FN_CPU_BASE + (n)) +#define HVC_FN_SIP(n) (HVC_FN_SIP_BASE + (n)) +#define HVC_FN_OEM(n) (HVC_FN_OEM_BASE + (n)) +#define HVC_FN_APP(n) (HVC_FN_APP_BASE + (n)) +#define HVC_FN_OS(n) (HVC_FN_OS_BASE + (n)) + +#define HVC_MAX_ARGS 6 +#define HVC_MAX_RETS 3 +#define HVC_MAX_EXTRA_ARGS 4 + +struct hvc_desc { + u64 arg[HVC_MAX_ARGS]; + u64 ret[HVC_MAX_RETS]; +}; + +struct hvc_extra_args { + u64 arg[HVC_MAX_EXTRA_ARGS]; +}; + +#ifdef CONFIG_MSM_HVC +extern int hvc(u64 func_id, struct hvc_desc *desc); +#else +static inline int hvc(u64 func_id, struct hvc_desc *desc) { return 0; } +#endif + +#endif diff --git a/include/soc/qcom/icnss.h b/include/soc/qcom/icnss.h new file mode 100644 index 000000000000..716e28054e60 --- /dev/null +++ b/include/soc/qcom/icnss.h @@ -0,0 +1,166 @@ +/* Copyright (c) 2015-2019, 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 _ICNSS_WLAN_H_ +#define _ICNSS_WLAN_H_ + +#include <linux/interrupt.h> +#include <linux/device.h> + +#define ICNSS_MAX_IRQ_REGISTRATIONS 12 +#define ICNSS_MAX_TIMESTAMP_LEN 32 + +#ifndef ICNSS_API_WITH_DEV +#define ICNSS_API_WITH_DEV +#endif + +enum icnss_uevent { + ICNSS_UEVENT_FW_CRASHED, + ICNSS_UEVENT_FW_DOWN, +}; + +enum cnss_cc_src { + CNSS_SOURCE_CORE, + CNSS_SOURCE_11D, + CNSS_SOURCE_USER +}; + +struct icnss_uevent_fw_down_data { + bool crashed; +}; + +struct icnss_uevent_data { + enum icnss_uevent uevent; + void *data; +}; + +struct icnss_driver_ops { + char *name; + unsigned long drv_state; + struct device_driver driver; + int (*probe)(struct device *dev); + void (*remove)(struct device *dev); + void (*shutdown)(struct device *dev); + int (*reinit)(struct device *dev); + void (*crash_shutdown)(void *pdev); + int (*pm_suspend)(struct device *dev); + int (*pm_resume)(struct device *dev); + int (*suspend_noirq)(struct device *dev); + int (*resume_noirq)(struct device *dev); + int (*uevent)(struct device *dev, struct icnss_uevent_data *uevent); + int (*idle_shutdown)(struct device *dev); + int (*idle_restart)(struct device *dev); +}; + + +struct ce_tgt_pipe_cfg { + u32 pipe_num; + u32 pipe_dir; + u32 nentries; + u32 nbytes_max; + u32 flags; + u32 reserved; +}; + +struct ce_svc_pipe_cfg { + u32 service_id; + u32 pipe_dir; + u32 pipe_num; +}; + +struct icnss_shadow_reg_cfg { + u16 ce_id; + u16 reg_offset; +}; + +/* CE configuration to target */ +struct icnss_wlan_enable_cfg { + u32 num_ce_tgt_cfg; + struct ce_tgt_pipe_cfg *ce_tgt_cfg; + u32 num_ce_svc_pipe_cfg; + struct ce_svc_pipe_cfg *ce_svc_cfg; + u32 num_shadow_reg_cfg; + struct icnss_shadow_reg_cfg *shadow_reg_cfg; +}; + +/* driver modes */ +enum icnss_driver_mode { + ICNSS_MISSION, + ICNSS_FTM, + ICNSS_EPPING, + ICNSS_WALTEST, + ICNSS_OFF, + ICNSS_CCPM, + ICNSS_QVIT, +}; + +struct icnss_soc_info { + void __iomem *v_addr; + phys_addr_t p_addr; + uint32_t chip_id; + uint32_t chip_family; + uint32_t board_id; + uint32_t soc_id; + uint32_t fw_version; + char fw_build_timestamp[ICNSS_MAX_TIMESTAMP_LEN + 1]; +}; + +#define icnss_register_driver(ops) \ + __icnss_register_driver(ops, THIS_MODULE, KBUILD_MODNAME) +extern int __icnss_register_driver(struct icnss_driver_ops *ops, + struct module *owner, const char *mod_name); + +extern int icnss_unregister_driver(struct icnss_driver_ops *ops); + +extern int icnss_wlan_enable(struct device *dev, + struct icnss_wlan_enable_cfg *config, + enum icnss_driver_mode mode, + const char *host_version); +extern int icnss_wlan_disable(struct device *dev, enum icnss_driver_mode mode); +extern void icnss_enable_irq(struct device *dev, unsigned int ce_id); +extern void icnss_disable_irq(struct device *dev, unsigned int ce_id); +extern int icnss_get_soc_info(struct device *dev, struct icnss_soc_info *info); +extern int icnss_ce_free_irq(struct device *dev, unsigned int ce_id, void *ctx); +extern int icnss_ce_request_irq(struct device *dev, unsigned int ce_id, + irqreturn_t (*handler)(int, void *), + unsigned long flags, const char *name, void *ctx); +extern int icnss_get_ce_id(struct device *dev, int irq); +extern int icnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode); +extern int icnss_athdiag_read(struct device *dev, uint32_t offset, + uint32_t mem_type, uint32_t data_len, + uint8_t *output); +extern int icnss_athdiag_write(struct device *dev, uint32_t offset, + uint32_t mem_type, uint32_t data_len, + uint8_t *input); +extern int icnss_get_irq(struct device *dev, int ce_id); +extern int icnss_power_on(struct device *dev); +extern int icnss_power_off(struct device *dev); +extern struct dma_iommu_mapping *icnss_smmu_get_mapping(struct device *dev); +extern int icnss_smmu_map(struct device *dev, phys_addr_t paddr, + uint32_t *iova_addr, size_t size); +extern unsigned int icnss_socinfo_get_serial_number(struct device *dev); +extern int icnss_set_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 ch_count); +extern int icnss_get_wlan_unsafe_channel(u16 *unsafe_ch_list, u16 *ch_count, + u16 buf_len); +extern int icnss_wlan_set_dfs_nol(const void *info, u16 info_len); +extern int icnss_wlan_get_dfs_nol(void *info, u16 info_len); +extern bool icnss_is_qmi_disable(struct device *dev); +extern bool icnss_is_fw_ready(void); +extern bool icnss_is_fw_down(void); +extern bool icnss_is_rejuvenate(void); +extern int icnss_set_wlan_mac_address(const u8 *in, const uint32_t len); +extern u8 *icnss_get_wlan_mac_address(struct device *dev, uint32_t *num); +extern int icnss_trigger_recovery(struct device *dev); +extern void icnss_block_shutdown(bool status); +extern bool icnss_is_pdr(void); +extern int icnss_idle_restart(struct device *dev); +extern int icnss_idle_shutdown(struct device *dev); +#endif /* _ICNSS_WLAN_H_ */ diff --git a/include/soc/qcom/irq-helper.h b/include/soc/qcom/irq-helper.h new file mode 100644 index 000000000000..d992fb6f470a --- /dev/null +++ b/include/soc/qcom/irq-helper.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2016, 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 __SOC_QCOM_IRQ_HELPER_H +#define __SOC_QCOM_IRQ_HELPER_H + +int irq_blacklist_on(void); +int irq_blacklist_off(void); + +#endif + diff --git a/include/soc/qcom/jtag.h b/include/soc/qcom/jtag.h new file mode 100644 index 000000000000..a5de362cdb8c --- /dev/null +++ b/include/soc/qcom/jtag.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2012-2015, 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 __MACH_JTAG_H +#define __MACH_JTAG_H + +#if defined(CONFIG_MSM_JTAG) || defined(CONFIG_MSM_JTAG_MM) || \ + defined(CONFIG_MSM_JTAGV8) +extern void msm_jtag_save_state(void); +extern void msm_jtag_restore_state(void); +extern void msm_jtag_etm_save_state(void); +extern void msm_jtag_etm_restore_state(void); +extern bool msm_jtag_fuse_apps_access_disabled(void); +#else +static inline void msm_jtag_save_state(void) {} +static inline void msm_jtag_restore_state(void) {} +static inline void msm_jtag_etm_save_state(void) {} +static inline void msm_jtag_etm_restore_state(void){} +static inline bool msm_jtag_fuse_apps_access_disabled(void) { return false; } +#endif +#ifdef CONFIG_MSM_JTAGV8 +extern int msm_jtag_save_register(struct notifier_block *nb); +extern int msm_jtag_save_unregister(struct notifier_block *nb); +extern int msm_jtag_restore_register(struct notifier_block *nb); +extern int msm_jtag_restore_unregister(struct notifier_block *nb); +#else +static inline int msm_jtag_save_register(struct notifier_block *nb) +{ + return 0; +} +static inline int msm_jtag_save_unregister(struct notifier_block *nb) +{ + return 0; +} +static inline int msm_jtag_restore_register(struct notifier_block *nb) +{ + return 0; +} +static inline int msm_jtag_restore_unregister(struct notifier_block *nb) +{ + return 0; +} +#endif + +#endif diff --git a/include/soc/qcom/kryo-l2-accessors.h b/include/soc/qcom/kryo-l2-accessors.h new file mode 100644 index 000000000000..5d8333e1b6cf --- /dev/null +++ b/include/soc/qcom/kryo-l2-accessors.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011-2014 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 __ASM_ARCH_MSM_MSM_KRYO_L2_ACCESSORS_H +#define __ASM_ARCH_MSM_MSM_KRYO_L2_ACCESSORS_H + +#ifdef CONFIG_ARCH_QCOM +void set_l2_indirect_reg(u64 reg_addr, u64 val); +u64 get_l2_indirect_reg(u64 reg_addr); +#else +static inline void set_l2_indirect_reg(u32 reg_addr, u32 val) {} +static inline u32 get_l2_indirect_reg(u32 reg_addr) +{ + return 0; +} +#endif +#endif diff --git a/include/soc/qcom/liquid_dock.h b/include/soc/qcom/liquid_dock.h new file mode 100644 index 000000000000..3668224f1938 --- /dev/null +++ b/include/soc/qcom/liquid_dock.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2014, 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/notifier.h> + +#if IS_ENABLED(CONFIG_QCOM_LIQUID_DOCK) +void register_liquid_dock_notify(struct notifier_block *nb); +void unregister_liquid_dock_notify(struct notifier_block *nb); +#else +static inline void register_liquid_dock_notify(struct notifier_block *nb) { } +static inline void unregister_liquid_dock_notify(struct notifier_block *nb) { } +#endif diff --git a/include/soc/qcom/lpm-stats.h b/include/soc/qcom/lpm-stats.h new file mode 100644 index 000000000000..d689d6a8d3db --- /dev/null +++ b/include/soc/qcom/lpm-stats.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2014-2015, 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 __ARCH_ARM_MACH_MSM_LPM_STATS_H +#define __ARCH_ARM_MACH_MSM_LPM_STATS_H + +struct lpm_stats; + +#define MAX_STR_LEN 256 + +struct lifo_stats { + uint32_t last_in; + uint32_t first_out; +}; + +struct lpm_stats { + char name[MAX_STR_LEN]; + struct level_stats *time_stats; + uint32_t num_levels; + struct lifo_stats lifo; + struct lpm_stats *parent; + struct list_head sibling; + struct list_head child; + struct cpumask mask; + struct dentry *directory; + int64_t sleep_time; + bool is_cpu; +}; + + + +#ifdef CONFIG_MSM_IDLE_STATS +struct lpm_stats *lpm_stats_config_level(const char *name, + const char **levels, int num_levels, struct lpm_stats *parent, + struct cpumask *mask); +void lpm_stats_cluster_enter(struct lpm_stats *stats, uint32_t index); +void lpm_stats_cluster_exit(struct lpm_stats *stats, uint32_t index, + bool success); +void lpm_stats_cpu_enter(uint32_t index, uint64_t time); +void lpm_stats_cpu_exit(uint32_t index, uint64_t time, bool success); +void lpm_stats_suspend_enter(void); +void lpm_stats_suspend_exit(void); +#else +static inline struct lpm_stats *lpm_stats_config_level(const char *name, + const char **levels, int num_levels, struct lpm_stats *parent, + struct cpumask *mask) +{ + return ERR_PTR(-ENODEV); +} + +static inline void lpm_stats_cluster_enter(struct lpm_stats *stats, + uint32_t index) +{ + return; +} + +static inline void lpm_stats_cluster_exit(struct lpm_stats *stats, + uint32_t index, bool success) +{ + return; +} + +static inline void lpm_stats_cpu_enter(uint32_t index, uint64_t time) +{ + return; +} + +static inline void lpm_stats_cpu_exit(uint32_t index, bool success, + uint64_t time) +{ + return; +} + +static inline void lpm_stats_suspend_enter(void) +{ + return; +} + +static inline void lpm_stats_suspend_exit(void) +{ + return; +} +#endif +#endif /* __ARCH_ARM_MACH_MSM_LPM_STATS_H */ diff --git a/include/soc/qcom/memory_dump.h b/include/soc/qcom/memory_dump.h new file mode 100644 index 000000000000..f1170dbb3569 --- /dev/null +++ b/include/soc/qcom/memory_dump.h @@ -0,0 +1,129 @@ +/* Copyright (c) 2012, 2014-2016, 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 __MSM_MEMORY_DUMP_H +#define __MSM_MEMORY_DUMP_H + +#include <linux/types.h> + +enum dump_client_type { + MSM_CPU_CTXT = 0, + MSM_L1_CACHE, + MSM_L2_CACHE, + MSM_OCMEM, + MSM_TMC_ETFETB, + MSM_ETM0_REG, + MSM_ETM1_REG, + MSM_ETM2_REG, + MSM_ETM3_REG, + MSM_TMC0_REG, /* TMC_ETR */ + MSM_TMC1_REG, /* TMC_ETF */ + MSM_LOG_BUF, + MSM_LOG_BUF_FIRST_IDX, + MAX_NUM_CLIENTS, +}; + +struct msm_client_dump { + enum dump_client_type id; + unsigned long start_addr; + unsigned long end_addr; +}; + +#ifdef CONFIG_QCOM_MEMORY_DUMP +extern int msm_dump_tbl_register(struct msm_client_dump *client_entry); +#else +static inline int msm_dump_tbl_register(struct msm_client_dump *entry) +{ + return -EIO; +} +#endif + + +#if defined(CONFIG_QCOM_MEMORY_DUMP) || defined(CONFIG_QCOM_MEMORY_DUMP_V2) +extern uint32_t msm_dump_table_version(void); +#else +static inline uint32_t msm_dump_table_version(void) +{ + return 0; +} +#endif + +#define MSM_DUMP_MAKE_VERSION(ma, mi) ((ma << 20) | mi) +#define MSM_DUMP_MAJOR(val) (val >> 20) +#define MSM_DUMP_MINOR(val) (val & 0xFFFFF) + + +#define MAX_NUM_ENTRIES 0x120 + +enum msm_dump_data_ids { + MSM_DUMP_DATA_CPU_CTX = 0x00, + MSM_DUMP_DATA_L1_INST_CACHE = 0x60, + MSM_DUMP_DATA_L1_DATA_CACHE = 0x80, + MSM_DUMP_DATA_ETM_REG = 0xA0, + MSM_DUMP_DATA_L2_CACHE = 0xC0, + MSM_DUMP_DATA_L3_CACHE = 0xD0, + MSM_DUMP_DATA_OCMEM = 0xE0, + MSM_DUMP_DATA_CNSS_WLAN = 0xE1, + MSM_DUMP_DATA_WIGIG = 0xE2, + MSM_DUMP_DATA_PMIC = 0xE4, + MSM_DUMP_DATA_DBGUI_REG = 0xE5, + MSM_DUMP_DATA_DCC_REG = 0xE6, + MSM_DUMP_DATA_DCC_SRAM = 0xE7, + MSM_DUMP_DATA_MISC = 0xE8, + MSM_DUMP_DATA_VSENSE = 0xE9, + MSM_DUMP_DATA_RPM = 0xEA, + MSM_DUMP_DATA_SCANDUMP = 0xEB, + MSM_DUMP_DATA_TMC_ETF = 0xF0, + MSM_DUMP_DATA_TMC_REG = 0x100, + MSM_DUMP_DATA_LOG_BUF = 0x110, + MSM_DUMP_DATA_LOG_BUF_FIRST_IDX = 0x111, + MSM_DUMP_DATA_MAX = MAX_NUM_ENTRIES, +}; + +enum msm_dump_table_ids { + MSM_DUMP_TABLE_APPS, + MSM_DUMP_TABLE_MAX = MAX_NUM_ENTRIES, +}; + +enum msm_dump_type { + MSM_DUMP_TYPE_DATA, + MSM_DUMP_TYPE_TABLE, +}; + +struct msm_dump_data { + uint32_t version; + uint32_t magic; + char name[32]; + uint64_t addr; + uint64_t len; + uint32_t reserved; +}; + +struct msm_dump_entry { + uint32_t id; + char name[32]; + uint32_t type; + uint64_t addr; +}; + +#ifdef CONFIG_QCOM_MEMORY_DUMP_V2 +extern int msm_dump_data_register(enum msm_dump_table_ids id, + struct msm_dump_entry *entry); +#else +static inline int msm_dump_data_register(enum msm_dump_table_ids id, + struct msm_dump_entry *entry) +{ + return -ENOSYS; +} +#endif + +#endif diff --git a/include/soc/qcom/minidump.h b/include/soc/qcom/minidump.h new file mode 100644 index 000000000000..d5970cfef643 --- /dev/null +++ b/include/soc/qcom/minidump.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2017 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 __MINIDUMP_H +#define __MINIDUMP_H + +#define MAX_NAME_LENGTH 16 +/* md_region - Minidump table entry + * @name: Entry name, Minidump will dump binary with this name. + * @id: Entry ID, used only for SDI dumps. + * @virt_addr: Address of the entry. + * @phys_addr: Physical address of the entry to dump. + * @size: Number of byte to dump from @address location + * it should be 4 byte aligned. + */ +struct md_region { + char name[MAX_NAME_LENGTH]; + u32 id; + u64 virt_addr; + u64 phys_addr; + u64 size; +}; + +/* Register an entry in Minidump table + * Returns: + * Zero: on successful addition + * Negetive error number on failures + */ +#ifdef CONFIG_QCOM_MINIDUMP +extern int msm_minidump_add_region(const struct md_region *entry); +/* Sets to true, if minidump table is initialized */ +extern bool minidump_enabled; +extern void dump_stack_minidump(u64 sp); +#else +static inline int msm_minidump_add_region(const struct md_region *entry) +{ + /* Return quietly, if minidump is not supported */ + return 0; +} + +static inline void dump_stack_minidump(u64 sp) {} +#endif + + +#endif diff --git a/include/soc/qcom/msm-clock-controller.h b/include/soc/qcom/msm-clock-controller.h new file mode 100644 index 000000000000..d6bd4e03af0d --- /dev/null +++ b/include/soc/qcom/msm-clock-controller.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2014, 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 __ARCH_ARM_MSM_CLOCK_CONTROLLER_H +#define __ARCH_ARM_MSM_CLOCK_CONTROLLER_H + +#include <linux/list.h> +#include <linux/clkdev.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +#define dt_err(np, fmt, ...) \ + pr_err("%s: " fmt, np->name, ##__VA_ARGS__) +#define dt_prop_err(np, str, fmt, ...) \ + dt_err(np, "%s: " fmt, str, ##__VA_ARGS__) + +/** + * struct msmclk_parser + * @compatible + * matches compatible property from devicetree + * @parsedt + * constructs & returns an instance of the appropriate obj based on + * the data from devicetree. + */ +struct msmclk_parser { + struct list_head list; + char *compatible; + void * (*parsedt)(struct device *dev, struct device_node *of); +}; + +#define MSMCLK_PARSER(fn, str, id) \ +static struct msmclk_parser _msmclk_##fn##id = { \ + .list = LIST_HEAD_INIT(_msmclk_##fn##id.list), \ + .compatible = str, \ + .parsedt = fn, \ +}; \ +static int __init _msmclk_init_##fn##id(void) \ +{ \ + msmclk_parser_register(&_msmclk_##fn##id); \ + return 0; \ +} \ +early_initcall(_msmclk_init_##fn##id) + +/* + * struct msmclk_data + * @base + * ioremapped region for sub_devices + * @list + * tracks all registered driver instances + * @htable + * tracks all registered child clocks + * @clk_tbl + * array of clk_lookup to be registered with the clock framework + */ +#define HASHTABLE_SIZE 200 +struct msmclk_data { + void __iomem *base; + struct device *dev; + struct list_head list; + struct hlist_head htable[HASHTABLE_SIZE]; + struct clk_lookup *clk_tbl; + int clk_tbl_size; + int max_clk_tbl_size; +}; + +#if defined(CONFIG_MSM_CLK_CONTROLLER_V2) + +/* Utility functions */ +int of_property_count_phandles(struct device_node *np, char *propname); +int of_property_read_phandle_index(struct device_node *np, char *propname, + int index, phandle *p); +void *msmclk_generic_clk_init(struct device *dev, struct device_node *np, + struct clk *c); + +/* + * msmclk_parser_register + * Registers a parser which will be matched with a node from dt + * according to the compatible string. + */ +void msmclk_parser_register(struct msmclk_parser *); + +/* + * msmclk_parse_phandle + * On hashtable miss, the corresponding entry will be retrieved from + * devicetree, and added to the hashtable. + */ +void *msmclk_parse_phandle(struct device *dev, phandle key); +/* + * msmclk_lookup_phandle + * Straightforward hashtable lookup + */ +void *msmclk_lookup_phandle(struct device *dev, phandle key); + +int __init msmclk_init(void); +#else + +static inline int of_property_count_phandles(struct device_node *np, + char *propname) +{ + return 0; +} + +static inline int of_property_read_phandle_index(struct device_node *np, + char *propname, int index, phandle *p) +{ + return 0; +} + +static inline void *msmclk_generic_clk_init(struct device *dev, + struct device_node *np, struct clk *c) +{ + return ERR_PTR(-EINVAL); +} + +static inline void msmclk_parser_register(struct msmclk_parser *p) {}; + +static inline void *msmclk_parse_phandle(struct device *dev, phandle key) +{ + return ERR_PTR(-EINVAL); +} + +static inline void *msmclk_lookup_phandle(struct device *dev, phandle key) +{ + return ERR_PTR(-EINVAL); +} + +static inline int __init msmclk_init(void) +{ + return 0; +} + +#endif /* CONFIG_MSM_CLK_CONTROLLER_V2 */ +#endif /* __ARCH_ARM_MSM_CLOCK_CONTROLLER_H */ diff --git a/include/soc/qcom/msm-core.h b/include/soc/qcom/msm-core.h new file mode 100644 index 000000000000..5e187183f07b --- /dev/null +++ b/include/soc/qcom/msm-core.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2014-2015, 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 __ARCH_ARM_MACH_MSM_CORE_H +#define __ARCH_ARM_MACH_MSM_CORE_H +#ifdef CONFIG_APSS_CORE_EA +void set_cpu_throttled(struct cpumask *mask, bool throttling); +struct blocking_notifier_head *get_power_update_notifier(void); +#else +static inline void set_cpu_throttled(struct cpumask *mask, bool throttling) {} +struct blocking_notifier_head *get_power_update_notifier(void) {return NULL; } +#endif +#endif + diff --git a/include/soc/qcom/msm_cpu_voltage.h b/include/soc/qcom/msm_cpu_voltage.h new file mode 100644 index 000000000000..79ac8f61813c --- /dev/null +++ b/include/soc/qcom/msm_cpu_voltage.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2016, 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. + */ + +unsigned int msm_match_cpu_voltage_btol(unsigned int input_freq); diff --git a/include/soc/qcom/msm_qmi_interface.h b/include/soc/qcom/msm_qmi_interface.h new file mode 100644 index 000000000000..38f390ee71b7 --- /dev/null +++ b/include/soc/qcom/msm_qmi_interface.h @@ -0,0 +1,502 @@ +/* Copyright (c) 2012-2015, 2017 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 _MSM_QMI_INTERFACE_H_ +#define _MSM_QMI_INTERFACE_H_ + +#include <linux/types.h> +#include <linux/errno.h> +#include <linux/mm.h> +#include <linux/list.h> +#include <linux/socket.h> +#include <linux/gfp.h> +#include <linux/qmi_encdec.h> +#include <linux/workqueue.h> + +#define QMI_COMMON_TLV_TYPE 0 + +enum qmi_event_type { + QMI_RECV_MSG = 1, + QMI_SERVER_ARRIVE, + QMI_SERVER_EXIT, +}; + +/** + * struct qmi_handle - QMI Handle Data Structure + * @handle_hash: Hash Table Node in which this handle is present. + * @src_port: Pointer to port used for message exchange. + * @ctl_port: Pointer to port used for out-of-band event exchange. + * @handle_type: Type of handle(Service/Client). + * @next_txn_id: Transaction ID of the next outgoing request. + * @handle_wq: Workqueue to handle any handle-specific events. + * @handle_lock: Lock to protect access to elements in the handle. + * @notify_lock: Lock to protect and generate notification atomically. + * @notify: Function to notify the handle owner of an event. + * @notify_priv: Private info to be passed during the notifcation. + * @handle_reset: Flag to hold the reset state of the handle. + * @reset_waitq: Wait queue to wait for any reset events. + * @ctl_work: Work to handle the out-of-band events for this handle. + * @dest_info: Destination to which this handle is connected to. + * @dest_service_id: service id of the service that client connected to. + * @txn_list: List of transactions waiting for the response. + * @ind_cb: Function to notify the handle owner of an indication message. + * @ind_cb_priv: Private info to be passed during an indication notification. + * @resume_tx_work: Work to resume the tx when the transport is not busy. + * @pending_txn_list: List of requests pending tx due to busy transport. + * @conn_list: List of connections handled by the service. + * @svc_ops_options: Service specific operations and options. + */ +struct qmi_handle { + struct hlist_node handle_hash; + void *src_port; + void *ctl_port; + unsigned handle_type; + uint16_t next_txn_id; + struct workqueue_struct *handle_wq; + struct mutex handle_lock; + spinlock_t notify_lock; + void (*notify)(struct qmi_handle *handle, enum qmi_event_type event, + void *notify_priv); + void *notify_priv; + int handle_reset; + wait_queue_head_t reset_waitq; + struct delayed_work ctl_work; + + /* Client specific elements */ + void *dest_info; + uint32_t dest_service_id; + struct list_head txn_list; + void (*ind_cb)(struct qmi_handle *handle, + unsigned int msg_id, void *msg, + unsigned int msg_len, void *ind_cb_priv); + void *ind_cb_priv; + struct delayed_work resume_tx_work; + struct list_head pending_txn_list; + + /* Service specific elements */ + struct list_head conn_list; + struct qmi_svc_ops_options *svc_ops_options; +}; + +enum qmi_result_type_v01 { + /* To force a 32 bit signed enum. Do not change or use*/ + QMI_RESULT_TYPE_MIN_ENUM_VAL_V01 = INT_MIN, + QMI_RESULT_SUCCESS_V01 = 0, + QMI_RESULT_FAILURE_V01 = 1, + QMI_RESULT_TYPE_MAX_ENUM_VAL_V01 = INT_MAX, +}; + +enum qmi_error_type_v01 { + /* To force a 32 bit signed enum. Do not change or use*/ + QMI_ERR_TYPE_MIN_ENUM_VAL_V01 = INT_MIN, + QMI_ERR_NONE_V01 = 0x0000, + QMI_ERR_MALFORMED_MSG_V01 = 0x0001, + QMI_ERR_NO_MEMORY_V01 = 0x0002, + QMI_ERR_INTERNAL_V01 = 0x0003, + QMI_ERR_CLIENT_IDS_EXHAUSTED_V01 = 0x0005, + QMI_ERR_INVALID_ID_V01 = 0x0029, + QMI_ERR_ENCODING_V01 = 0x003A, + QMI_ERR_DISABLED_V01 = 0x0045, + QMI_ERR_INCOMPATIBLE_STATE_V01 = 0x005A, + QMI_ERR_NOT_SUPPORTED_V01 = 0x005E, + QMI_ERR_TYPE_MAX_ENUM_VAL_V01 = INT_MAX, +}; + +struct qmi_response_type_v01 { + enum qmi_result_type_v01 result; + enum qmi_error_type_v01 error; +}; + +/** + * qmi_svc_ops_options - Operations and options to be specified when + * a service registers. + * @version: Version field to identify the ops_options structure. + * @service_id: Service ID of the service. + * @service_vers: Version to identify the client-service compatibility. + * @service_ins: Instance ID registered by the service. + * @connect_cb: Callback when a new client connects with the service. + * @disconnect_cb: Callback when the client exits the connection. + * @req_desc_cb: Callback to get request structure and its descriptor + * for a message id. + * @req_cb: Callback to process the request. + */ +struct qmi_svc_ops_options { + unsigned version; + uint32_t service_id; + uint32_t service_vers; + uint32_t service_ins; + int (*connect_cb)(struct qmi_handle *handle, + void *conn_handle); + int (*disconnect_cb)(struct qmi_handle *handle, + void *conn_handle); + int (*req_desc_cb)(unsigned int msg_id, + struct msg_desc **req_desc); + int (*req_cb)(struct qmi_handle *handle, + void *conn_handle, + void *req_handle, + unsigned int msg_id, + void *req); +}; + +#ifdef CONFIG_MSM_QMI_INTERFACE + +/* Element info array describing common qmi response structure */ +extern struct elem_info qmi_response_type_v01_ei[]; +#define get_qmi_response_type_v01_ei() qmi_response_type_v01_ei + +/** + * qmi_handle_create() - Create a QMI handle + * @notify: Callback to notify events on the handle created. + * @notify_priv: Private information to be passed along with the notification. + * + * @return: Valid QMI handle on success, NULL on error. + */ +struct qmi_handle *qmi_handle_create( + void (*notify)(struct qmi_handle *handle, + enum qmi_event_type event, void *notify_priv), + void *notify_priv); + +/** + * qmi_handle_destroy() - Destroy the QMI handle + * @handle: QMI handle to be destroyed. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_handle_destroy(struct qmi_handle *handle); + +/** + * qmi_register_ind_cb() - Register the indication callback function + * @handle: QMI handle with which the function is registered. + * @ind_cb: Callback function to be registered. + * @ind_cb_priv: Private data to be passed with the indication callback. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_register_ind_cb(struct qmi_handle *handle, + void (*ind_cb)(struct qmi_handle *handle, + unsigned int msg_id, void *msg, + unsigned int msg_len, void *ind_cb_priv), + void *ind_cb_priv); + +/** + * qmi_send_req_wait() - Send a synchronous QMI request + * @handle: QMI handle through which the QMI request is sent. + * @request_desc: Structure describing the request data structure. + * @req: Buffer containing the request data structure. + * @req_len: Length of the request data structure. + * @resp_desc: Structure describing the response data structure. + * @resp: Buffer to hold the response data structure. + * @resp_len: Length of the response data structure. + * @timeout_ms: Timeout before a response is received. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_send_req_wait(struct qmi_handle *handle, + struct msg_desc *req_desc, + void *req, unsigned int req_len, + struct msg_desc *resp_desc, + void *resp, unsigned int resp_len, + unsigned long timeout_ms); + +/** + * qmi_send_req_nowait() - Send an asynchronous QMI request + * @handle: QMI handle through which the QMI request is sent. + * @request_desc: Structure describing the request data structure. + * @req: Buffer containing the request data structure. + * @req_len: Length of the request data structure. + * @resp_desc: Structure describing the response data structure. + * @resp: Buffer to hold the response data structure. + * @resp_len: Length of the response data structure. + * @resp_cb: Callback function to be invoked when the response arrives. + * @resp_cb_data: Private information to be passed along with the callback. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_send_req_nowait(struct qmi_handle *handle, + struct msg_desc *req_desc, + void *req, unsigned int req_len, + struct msg_desc *resp_desc, + void *resp, unsigned int resp_len, + void (*resp_cb)(struct qmi_handle *handle, + unsigned int msg_id, void *msg, + void *resp_cb_data, + int stat), + void *resp_cb_data); + +/** + * qmi_recv_msg() - Receive the QMI message + * @handle: Handle for which the QMI message has to be received. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_recv_msg(struct qmi_handle *handle); + +/** + * qmi_connect_to_service() - Connect the QMI handle with a QMI service + * @handle: QMI handle to be connected with the QMI service. + * @service_id: Service id to identify the QMI service. + * @service_vers: Version to identify the compatibility. + * @service_ins: Instance id to identify the instance of the QMI service. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_connect_to_service(struct qmi_handle *handle, + uint32_t service_id, + uint32_t service_vers, + uint32_t service_ins); + +/** + * qmi_svc_event_notifier_register() - Register a notifier block to receive + * events regarding a QMI service + * @service_id: Service ID to identify the QMI service. + * @service_vers: Version to identify the compatibility. + * @service_ins: Instance ID to identify the instance of the QMI service. + * @nb: Notifier block used to receive the event. + * + * @return: 0 if successfully registered, < 0 on error. + */ +int qmi_svc_event_notifier_register(uint32_t service_id, + uint32_t service_vers, + uint32_t service_ins, + struct notifier_block *nb); + +/** + * qmi_svc_event_notifier_unregister() - Unregister service event + * notifier block + * @service_id: Service ID to identify the QMI service. + * @service_vers: Version to identify the compatibility. + * @service_ins: Instance ID to identify the instance of the QMI service. + * @nb: Notifier block registered to receive the events. + * + * @return: 0 if successfully registered, < 0 on error. + */ +int qmi_svc_event_notifier_unregister(uint32_t service_id, + uint32_t service_vers, + uint32_t service_ins, + struct notifier_block *nb); + +/** + * qmi_svc_register() - Register a QMI service with a QMI handle + * @handle: QMI handle on which the service has to be registered. + * @ops_options: Service specific operations and options. + * + * @return: 0 if successfully registered, < 0 on error. + */ +int qmi_svc_register(struct qmi_handle *handle, + void *ops_options); + +/** + * qmi_send_resp() - Send response to a request + * @handle: QMI handle from which the response is sent. + * @clnt: Client to which the response is sent. + * @req_handle: Request for which the response is sent. + * @resp_desc: Descriptor explaining the response structure. + * @resp: Pointer to the response structure. + * @resp_len: Length of the response structure. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_send_resp(struct qmi_handle *handle, + void *conn_handle, + void *req_handle, + struct msg_desc *resp_desc, + void *resp, + unsigned int resp_len); + +/** + * qmi_send_resp_from_cb() - Send response to a request from request_cb + * @handle: QMI handle from which the response is sent. + * @clnt: Client to which the response is sent. + * @req_handle: Request for which the response is sent. + * @resp_desc: Descriptor explaining the response structure. + * @resp: Pointer to the response structure. + * @resp_len: Length of the response structure. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_send_resp_from_cb(struct qmi_handle *handle, + void *conn_handle, + void *req_handle, + struct msg_desc *resp_desc, + void *resp, + unsigned int resp_len); + +/** + * qmi_send_ind() - Send unsolicited event/indication to a client + * @handle: QMI handle from which the indication is sent. + * @clnt: Client to which the indication is sent. + * @ind_desc: Descriptor explaining the indication structure. + * @ind: Pointer to the indication structure. + * @ind_len: Length of the indication structure. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_send_ind(struct qmi_handle *handle, + void *conn_handle, + struct msg_desc *ind_desc, + void *ind, + unsigned int ind_len); + +/** + * qmi_send_ind_from_cb() - Send indication to a client from registration_cb + * @handle: QMI handle from which the indication is sent. + * @clnt: Client to which the indication is sent. + * @ind_desc: Descriptor explaining the indication structure. + * @ind: Pointer to the indication structure. + * @ind_len: Length of the indication structure. + * + * @return: 0 on success, < 0 on error. + */ +int qmi_send_ind_from_cb(struct qmi_handle *handle, + void *conn_handle, + struct msg_desc *ind_desc, + void *ind, + unsigned int ind_len); + +/** + * qmi_svc_unregister() - Unregister the service from a QMI handle + * @handle: QMI handle from which the service has to be unregistered. + * + * return: 0 on success, < 0 on error. + */ +int qmi_svc_unregister(struct qmi_handle *handle); + +#else + +#define get_qmi_response_type_v01_ei() NULL + +static inline struct qmi_handle *qmi_handle_create( + void (*notify)(struct qmi_handle *handle, + enum qmi_event_type event, void *notify_priv), + void *notify_priv) +{ + return NULL; +} + +static inline int qmi_handle_destroy(struct qmi_handle *handle) +{ + return -ENODEV; +} + +static inline int qmi_register_ind_cb(struct qmi_handle *handle, + void (*ind_cb)(struct qmi_handle *handle, + unsigned int msg_id, void *msg, + unsigned int msg_len, void *ind_cb_priv), + void *ind_cb_priv) +{ + return -ENODEV; +} + +static inline int qmi_send_req_wait(struct qmi_handle *handle, + struct msg_desc *req_desc, + void *req, unsigned int req_len, + struct msg_desc *resp_desc, + void *resp, unsigned int resp_len, + unsigned long timeout_ms) +{ + return -ENODEV; +} + +static inline int qmi_send_req_nowait(struct qmi_handle *handle, + struct msg_desc *req_desc, + void *req, unsigned int req_len, + struct msg_desc *resp_desc, + void *resp, unsigned int resp_len, + void (*resp_cb)(struct qmi_handle *handle, + unsigned int msg_id, void *msg, + void *resp_cb_data), + void *resp_cb_data) +{ + return -ENODEV; +} + +static inline int qmi_recv_msg(struct qmi_handle *handle) +{ + return -ENODEV; +} + +static inline int qmi_connect_to_service(struct qmi_handle *handle, + uint32_t service_id, + uint32_t service_vers, + uint32_t service_ins) +{ + return -ENODEV; +} + +static inline int qmi_svc_event_notifier_register(uint32_t service_id, + uint32_t service_vers, + uint32_t service_ins, + struct notifier_block *nb) +{ + return -ENODEV; +} + +static inline int qmi_svc_event_notifier_unregister(uint32_t service_id, + uint32_t service_vers, + uint32_t service_ins, + struct notifier_block *nb) +{ + return -ENODEV; +} + +static inline int qmi_svc_register(struct qmi_handle *handle, + void *ops_options) +{ + return -ENODEV; +} + +static inline int qmi_send_resp(struct qmi_handle *handle, + void *conn_handle, + void *req_handle, + struct msg_desc *resp_desc, + void *resp, + unsigned int resp_len) +{ + return -ENODEV; +} + +static inline int qmi_send_resp_from_cb(struct qmi_handle *handle, + void *conn_handle, + void *req_handle, + struct msg_desc *resp_desc, + void *resp, + unsigned int resp_len) +{ + return -ENODEV; +} + +static inline int qmi_send_ind(struct qmi_handle *handle, + void *conn_handle, + struct msg_desc *ind_desc, + void *ind, + unsigned int ind_len) +{ + return -ENODEV; +} + +static inline int qmi_send_ind_from_cb(struct qmi_handle *handle, + void *conn_handle, + struct msg_desc *ind_desc, + void *ind, + unsigned int ind_len) +{ + return -ENODEV; +} + +static inline int qmi_svc_unregister(struct qmi_handle *handle) +{ + return -ENODEV; +} + +#endif + +#endif diff --git a/include/soc/qcom/msm_tz_smmu.h b/include/soc/qcom/msm_tz_smmu.h new file mode 100644 index 000000000000..4f4a64c09a8e --- /dev/null +++ b/include/soc/qcom/msm_tz_smmu.h @@ -0,0 +1,82 @@ +/* Copyright (c) 2015-2016, 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 __MSM_TZ_SMMU_H__ +#define __MSM_TZ_SMMU_H__ + +#include <linux/device.h> + +enum tz_smmu_device_id { + TZ_DEVICE_START = 0, + TZ_DEVICE_VIDEO = 0, + TZ_DEVICE_MDSS, + TZ_DEVICE_LPASS, + TZ_DEVICE_MDSS_BOOT, + TZ_DEVICE_USB1_HS, + TZ_DEVICE_OCMEM, + TZ_DEVICE_LPASS_CORE, + TZ_DEVICE_VPU, + TZ_DEVICE_COPSS_SMMU, + TZ_DEVICE_USB3_0, + TZ_DEVICE_USB3_1, + TZ_DEVICE_PCIE_0, + TZ_DEVICE_PCIE_1, + TZ_DEVICE_BCSS, + TZ_DEVICE_VCAP, + TZ_DEVICE_PCIE20, + TZ_DEVICE_IPA, + TZ_DEVICE_APPS, + TZ_DEVICE_GPU, + TZ_DEVICE_UFS, + TZ_DEVICE_ICE, + TZ_DEVICE_ROT, + TZ_DEVICE_VFE, + TZ_DEVICE_ANOC0, + TZ_DEVICE_ANOC1, + TZ_DEVICE_ANOC2, + TZ_DEVICE_CPP, + TZ_DEVICE_JPEG, + TZ_DEVICE_MAX, +}; + +#ifdef CONFIG_MSM_TZ_SMMU + +int msm_tz_smmu_atos_start(struct device *dev, int cb_num); +int msm_tz_smmu_atos_end(struct device *dev, int cb_num); +enum tz_smmu_device_id msm_dev_to_device_id(struct device *dev); +void msm_tz_set_cb_format(enum tz_smmu_device_id sec_id, int cbndx); + +#else + +static inline int msm_tz_smmu_atos_start(struct device *dev, int cb_num) +{ + return 0; +} + +static inline int msm_tz_smmu_atos_end(struct device *dev, int cb_num) +{ + return 0; +} + +static inline enum tz_smmu_device_id msm_dev_to_device_id(struct device *dev) +{ + return -EINVAL; +} + +static inline void msm_tz_set_cb_format(enum tz_smmu_device_id sec_id, + int cbndx) +{ +} + +#endif /* CONFIG_MSM_TZ_SMMU */ + +#endif /* __MSM_TZ_SMMU_H__ */ diff --git a/include/soc/qcom/perf_event_kryo.h b/include/soc/qcom/perf_event_kryo.h new file mode 100644 index 000000000000..e5b1aeac615f --- /dev/null +++ b/include/soc/qcom/perf_event_kryo.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 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 __PERF_EVENT_KRYO_H +#define __PERF_EVENT_KRYO_H + +#define pmactlr_el0 "S3_5_c11_c0_2" +#define pmresr0l_el0 "S3_5_c11_c3_0" +#define pmresr0h_el0 "S3_5_c11_c3_1" +#define pmresr1l_el0 "S3_5_c11_c3_2" +#define pmresr1h_el0 "S3_5_c11_c3_3" +#define pmresr2l_el0 "S3_5_c11_c3_4" +#define pmresr2h_el0 "S3_5_c11_c3_5" +#define pmxevcntcr_el0 "S3_5_c11_c0_3" + +#define RESR_L 0 +#define RESR_H 1 +#define RESR_ENABLE 0x80000000 + +#define ARMV8_PMCR_P 0x00000002 /* Reset counters */ +#define ARMV8_PMCR_C 0x00000004 /* Reset cycle counter */ + +#define PMACTLR_UEN 0x00000001 +#define PMUSERENR_UEN 0x00000001 + +/* + event encoding: NRCCG + n = prefix (1 for Kryo CPU) + r = register + cc = code + g = group +*/ +#define KRYO_EVT_PREFIX 1 +#define KRYO_EVT_MASK 0x000FFFFF +#define KRYO_EVT_PREFIX_MASK 0x000F0000 +#define KRYO_EVT_REG_MASK 0x0000F000 +#define KRYO_EVT_CODE_MASK 0x00000FF0 +#define KRYO_EVT_GROUP_MASK 0x0000000F +#define KRYO_EVT_PREFIX_SHIFT 16 +#define KRYO_EVT_REG_SHIFT 12 +#define KRYO_EVT_CODE_SHIFT 4 +#define KRYO_EVT_GROUP_SHIFT 0 +#define KRYO_MODE_EXCL_MASK 0xC0000000 + +#define KRYO_MAX_L1_REG 2 +#define KRYO_MAX_GROUP 7 + +#endif diff --git a/include/soc/qcom/pm.h b/include/soc/qcom/pm.h new file mode 100644 index 000000000000..ea19c2562f66 --- /dev/null +++ b/include/soc/qcom/pm.h @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2007 Google, Inc. + * Copyright (c) 2009-2016, The Linux Foundation. All rights reserved. + * Author: San Mehat <san@android.com> + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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 __ARCH_ARM_MACH_MSM_PM_H +#define __ARCH_ARM_MACH_MSM_PM_H + +#include <linux/types.h> +#include <linux/cpuidle.h> +#include <asm/smp_plat.h> +#include <asm/barrier.h> +#include <dt-bindings/msm/pm.h> + +#if !defined(CONFIG_SMP) +#define msm_secondary_startup NULL +#elif defined(CONFIG_CPU_V7) +#define msm_secondary_startup secondary_startup +#else +#define msm_secondary_startup secondary_holding_pen +#endif + +enum msm_pm_sleep_mode { + MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT, + MSM_PM_SLEEP_MODE_RETENTION, + MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE, + MSM_PM_SLEEP_MODE_POWER_COLLAPSE, + MSM_PM_SLEEP_MODE_FASTPC, + MSM_PM_SLEEP_MODE_POWER_COLLAPSE_SUSPEND, + MSM_PM_SLEEP_MODE_NR, + MSM_PM_SLEEP_MODE_NOT_SELECTED, +}; + +enum msm_pm_l2_scm_flag { + MSM_SCM_L2_ON = 0, + MSM_SCM_L2_OFF = 1, + MSM_SCM_L2_GDHS = 3, + MSM_SCM_L3_PC_OFF = 4, +}; + +#define MSM_PM_MODE(cpu, mode_nr) ((cpu) * MSM_PM_SLEEP_MODE_NR + (mode_nr)) + +struct msm_pm_time_params { + uint32_t latency_us; + uint32_t sleep_us; + uint32_t next_event_us; + uint32_t modified_time_us; +}; + +struct msm_pm_sleep_status_data { + void *base_addr; + uint32_t mask; +}; + +struct latency_level { + int affinity_level; + int reset_level; + const char *level_name; +}; + +/** + * lpm_cpu_pre_pc_cb(): API to get the L2 flag to pass to TZ + * + * @cpu: cpuid of the CPU going down. + * + * Returns the l2 flush flag enum that is passed down to TZ during power + * collaps + */ +enum msm_pm_l2_scm_flag lpm_cpu_pre_pc_cb(unsigned int cpu); + +/** + * msm_pm_sleep_mode_allow() - API to determine if sleep mode is allowed. + * @cpu: CPU on which to check for the sleep mode. + * @mode: Sleep Mode to check for. + * @idle: Idle or Suspend Sleep Mode. + * + * Helper function to determine if a Idle or Suspend + * Sleep mode is allowed for a specific CPU. + * + * Return: 1 for allowed; 0 if not allowed. + */ +int msm_pm_sleep_mode_allow(unsigned int, unsigned int, bool); + +/** + * msm_pm_sleep_mode_supported() - API to determine if sleep mode is + * supported. + * @cpu: CPU on which to check for the sleep mode. + * @mode: Sleep Mode to check for. + * @idle: Idle or Suspend Sleep Mode. + * + * Helper function to determine if a Idle or Suspend + * Sleep mode is allowed and enabled for a specific CPU. + * + * Return: 1 for supported; 0 if not supported. + */ +int msm_pm_sleep_mode_supported(unsigned int, unsigned int, bool); + +struct msm_pm_cpr_ops { + void (*cpr_suspend)(void); + void (*cpr_resume)(void); +}; + +void __init msm_pm_set_tz_retention_flag(unsigned int flag); +void msm_pm_enable_retention(bool enable); +bool msm_pm_retention_enabled(void); +bool msm_cpu_pm_enter_sleep(enum msm_pm_sleep_mode mode, bool from_idle); +static inline void msm_arch_idle(void) +{ + mb(); + wfi(); +} + +#ifdef CONFIG_MSM_PM + +void msm_pm_set_rpm_wakeup_irq(unsigned int irq); +int msm_pm_wait_cpu_shutdown(unsigned int cpu); +int __init msm_pm_sleep_status_init(void); +void lpm_cpu_hotplug_enter(unsigned int cpu); +s32 msm_cpuidle_get_deep_idle_latency(void); +int msm_pm_collapse(unsigned long unused); + +/** + * lpm_get_latency() - API to get latency for a low power mode + * @latency_level: pointer to structure with below elements + * affinity_level: The level (CPU/L2/CCI etc.) for which the + * latency is required. + * LPM_AFF_LVL_CPU : CPU level + * LPM_AFF_LVL_L2 : L2 level + * LPM_AFF_LVL_CCI : CCI level + * reset_level: Can be passed "LPM_RESET_LVL_GDHS" for + * low power mode with control logic power collapse or + * "LPM_RESET_LVL_PC" for low power mode with control and + * memory logic power collapse or "LPM_RESET_LVL_RET" for + * retention mode. + * level_name: Pointer to the cluster name for which the latency + * is required or NULL if the minimum value out of all the + * clusters is to be returned. For CPU level, the name of the + * L2 cluster to be passed. For CCI it has no effect. + * @latency: address to get the latency value. + * + * latency value will be for the particular cluster or the minimum + * value out of all the clusters at the particular affinity_level + * and reset_level. + * + * Return: 0 for success; Error number for failure. + */ +int lpm_get_latency(struct latency_level *level, uint32_t *latency); + +#else +static inline void msm_pm_set_rpm_wakeup_irq(unsigned int irq) {} +static inline int msm_pm_wait_cpu_shutdown(unsigned int cpu) { return 0; } +static inline int msm_pm_sleep_status_init(void) { return 0; }; + +static inline void lpm_cpu_hotplug_enter(unsigned int cpu) +{ + msm_arch_idle(); +}; + +static inline s32 msm_cpuidle_get_deep_idle_latency(void) { return 0; } +#define msm_pm_collapse NULL + +static inline int lpm_get_latency(struct latency_level *level, + uint32_t *latency) +{ + return 0; +} +#endif + +#ifdef CONFIG_HOTPLUG_CPU +int msm_platform_secondary_init(unsigned int cpu); +#else +static inline int msm_platform_secondary_init(unsigned int cpu) { return 0; } +#endif + +enum msm_pm_time_stats_id { + MSM_PM_STAT_REQUESTED_IDLE = 0, + MSM_PM_STAT_IDLE_SPIN, + MSM_PM_STAT_IDLE_WFI, + MSM_PM_STAT_RETENTION, + MSM_PM_STAT_IDLE_STANDALONE_POWER_COLLAPSE, + MSM_PM_STAT_IDLE_FAILED_STANDALONE_POWER_COLLAPSE, + MSM_PM_STAT_IDLE_POWER_COLLAPSE, + MSM_PM_STAT_IDLE_FAILED_POWER_COLLAPSE, + MSM_PM_STAT_SUSPEND, + MSM_PM_STAT_FAILED_SUSPEND, + MSM_PM_STAT_NOT_IDLE, + MSM_PM_STAT_COUNT +}; + +#ifdef CONFIG_MSM_IDLE_STATS +void msm_pm_add_stats(enum msm_pm_time_stats_id *enable_stats, int size); +void msm_pm_add_stat(enum msm_pm_time_stats_id id, int64_t t); +void msm_pm_l2_add_stat(uint32_t id, int64_t t); +#else +static inline void msm_pm_add_stats(enum msm_pm_time_stats_id *enable_stats, + int size) {} +static inline void msm_pm_add_stat(enum msm_pm_time_stats_id id, int64_t t) {} +static inline void msm_pm_l2_add_stat(uint32_t id, int64_t t) {} +#endif + +void msm_pm_set_cpr_ops(struct msm_pm_cpr_ops *ops); +extern dma_addr_t msm_pc_debug_counters_phys; +#endif /* __ARCH_ARM_MACH_MSM_PM_H */ diff --git a/include/soc/qcom/profiler.h b/include/soc/qcom/profiler.h new file mode 100644 index 000000000000..7ccea6f43228 --- /dev/null +++ b/include/soc/qcom/profiler.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2017 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 __PROFILER_H_ +#define __PROFILER_H_ + + +struct profiler_bw_cntrs_req { + uint32_t total; + uint32_t cpu; + uint32_t gpu; + uint32_t cmd; +}; + +struct compat_profiler_bw_cntrs_req { + compat_uint_t total; + compat_uint_t cpu; + compat_uint_t gpu; + compat_uint_t cmd; +}; + +/* Error types */ +enum tz_bw_svc_err { + E_BW_SUCCESS = 0, /* Operation successful */ + E_BW_FAILURE = 1, /* Operation failed due to unknown err */ + E_BW_NULL_PARAM = 2, /* Null Parameter */ + E_BW_INVALID_ARG = 3, /* Arg is not recognized */ + E_BW_BAD_ADDRESS = 4, /* Ptr arg is bad address */ + E_BW_INVALID_ARG_LEN = 5, /* Arg length is wrong */ + E_BW_NOT_SUPPORTED = 6, /* Operation not supported */ + E_BW_NOT_PERMITTED = 7, /* Operation not permitted on platform */ + E_BW_TIME_LOCKED = 8, /* Operation not permitted right now */ + E_BW_RESERVED = 0x7FFFFFFF +}; + +#define TZ_BW_SVC_VERSION (1) +#define PROFILER_IOC_MAGIC 0x98 + +#define PROFILER_IOCTL_GET_BW_INFO \ + _IOWR(PROFILER_IOC_MAGIC, 1, struct profiler_bw_cntrs_req) + +#define COMPAT_PROFILER_IOCTL_GET_BW_INFO \ + _IOWR(PROFILER_IOC_MAGIC, 1, struct compat_profiler_bw_cntrs_req) + +/* Command types */ +enum tz_bw_svc_cmd { + TZ_BW_SVC_START_ID = 0x00000001, + TZ_BW_SVC_GET_ID = 0x00000002, + TZ_BW_SVC_STOP_ID = 0x00000003, + TZ_BW_SVC_LAST_ID = 0x7FFFFFFF +}; +/* Start Request */ +struct tz_bw_svc_start_req { + enum tz_bw_svc_cmd cmd_id; + uint32_t version; +} __packed; + +/* Get Request */ +struct tz_bw_svc_get_req { + enum tz_bw_svc_cmd cmd_id; + uint64_t buf_ptr; + uint32_t buf_size; +} __packed; + +/* Stop Request */ +struct tz_bw_svc_stop_req { + enum tz_bw_svc_cmd cmd_id; +} __packed; + +struct tz_bw_svc_resp { + enum tz_bw_svc_cmd cmd_id; + enum tz_bw_svc_err status; +} __packed; + +union tz_bw_svc_req { + struct tz_bw_svc_start_req *start_req; + struct tz_bw_svc_get_req *get_req; + struct tz_bw_svc_stop_req *stop_req; +} __packed; + +struct tz_bw_svc_buf { + union tz_bw_svc_req bwreq; + struct tz_bw_svc_resp bwresp; + uint32_t req_size; +} __packed; + + +#define TZ_SVC_INFO 6 /* Misc. information services */ +#define TZ_SVC_BW_PROF_ID 0x07 + +#endif /* __PROFILER_H_ */ diff --git a/include/soc/qcom/qseecomi.h b/include/soc/qcom/qseecomi.h new file mode 100644 index 000000000000..46b1c5da4e90 --- /dev/null +++ b/include/soc/qcom/qseecomi.h @@ -0,0 +1,732 @@ +/* + * Copyright (c) 2013-2019, 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 __QSEECOMI_H_ +#define __QSEECOMI_H_ + +#include <linux/qseecom.h> + +#define QSEECOM_KEY_ID_SIZE 32 + +#define QSEOS_RESULT_FAIL_SEND_CMD_NO_THREAD -19 /*0xFFFFFFED*/ +#define QSEOS_RESULT_FAIL_APP_ALREADY_LOADED -38 /*0xFFFFFFDA*/ +#define QSEOS_RESULT_FAIL_UNSUPPORTED_CE_PIPE -63 +#define QSEOS_RESULT_FAIL_KS_OP -64 +#define QSEOS_RESULT_FAIL_KEY_ID_EXISTS -65 +#define QSEOS_RESULT_FAIL_MAX_KEYS -66 +#define QSEOS_RESULT_FAIL_SAVE_KS -67 +#define QSEOS_RESULT_FAIL_LOAD_KS -68 +#define QSEOS_RESULT_FAIL_KS_ALREADY_DONE -69 +#define QSEOS_RESULT_FAIL_KEY_ID_DNE -70 +#define QSEOS_RESULT_FAIL_INCORRECT_PSWD -71 +#define QSEOS_RESULT_FAIL_MAX_ATTEMPT -72 +#define QSEOS_RESULT_FAIL_PENDING_OPERATION -73 + +enum qseecom_command_scm_resp_type { + QSEOS_APP_ID = 0xEE01, + QSEOS_LISTENER_ID +}; + +enum qseecom_qceos_cmd_id { + QSEOS_APP_START_COMMAND = 0x01, + QSEOS_APP_SHUTDOWN_COMMAND, + QSEOS_APP_LOOKUP_COMMAND, + QSEOS_REGISTER_LISTENER, + QSEOS_DEREGISTER_LISTENER, + QSEOS_CLIENT_SEND_DATA_COMMAND, + QSEOS_LISTENER_DATA_RSP_COMMAND, + QSEOS_LOAD_EXTERNAL_ELF_COMMAND, + QSEOS_UNLOAD_EXTERNAL_ELF_COMMAND, + QSEOS_GET_APP_STATE_COMMAND, + QSEOS_LOAD_SERV_IMAGE_COMMAND, + QSEOS_UNLOAD_SERV_IMAGE_COMMAND, + QSEOS_APP_REGION_NOTIFICATION, + QSEOS_REGISTER_LOG_BUF_COMMAND, + QSEOS_RPMB_PROVISION_KEY_COMMAND, + QSEOS_RPMB_ERASE_COMMAND, + QSEOS_GENERATE_KEY = 0x11, + QSEOS_DELETE_KEY, + QSEOS_MAX_KEY_COUNT, + QSEOS_SET_KEY, + QSEOS_UPDATE_KEY_USERINFO, + QSEOS_TEE_OPEN_SESSION, + QSEOS_TEE_INVOKE_COMMAND, + QSEOS_TEE_INVOKE_MODFD_COMMAND = QSEOS_TEE_INVOKE_COMMAND, + QSEOS_TEE_CLOSE_SESSION, + QSEOS_TEE_REQUEST_CANCELLATION, + QSEOS_CONTINUE_BLOCKED_REQ_COMMAND, + QSEOS_RPMB_CHECK_PROV_STATUS_COMMAND = 0x1B, + QSEOS_CLIENT_SEND_DATA_COMMAND_WHITELIST = 0x1C, + QSEOS_TEE_OPEN_SESSION_WHITELIST = 0x1D, + QSEOS_TEE_INVOKE_COMMAND_WHITELIST = 0x1E, + QSEOS_LISTENER_DATA_RSP_COMMAND_WHITELIST = 0x1F, + QSEOS_FSM_LTEOTA_REQ_CMD = 0x109, + QSEOS_FSM_LTEOTA_REQ_RSP_CMD = 0x110, + QSEOS_FSM_IKE_REQ_CMD = 0x203, + QSEOS_FSM_IKE_REQ_RSP_CMD = 0x204, + QSEOS_FSM_OEM_FUSE_WRITE_ROW = 0x301, + QSEOS_FSM_OEM_FUSE_READ_ROW = 0x302, + QSEOS_FSM_ENCFS_REQ_CMD = 0x403, + QSEOS_FSM_ENCFS_REQ_RSP_CMD = 0x404, + + QSEOS_CMD_MAX = 0xEFFFFFFF +}; + +enum qseecom_qceos_cmd_status { + QSEOS_RESULT_SUCCESS = 0, + QSEOS_RESULT_INCOMPLETE, + QSEOS_RESULT_BLOCKED_ON_LISTENER, + QSEOS_RESULT_FAILURE = 0xFFFFFFFF +}; + +enum qseecom_pipe_type { + QSEOS_PIPE_ENC = 0x1, + QSEOS_PIPE_ENC_XTS = 0x2, + QSEOS_PIPE_AUTH = 0x4, + QSEOS_PIPE_ENUM_FILL = 0x7FFFFFFF +}; + +/* QSEE Reentrancy support phase */ +enum qseecom_qsee_reentrancy_phase { + QSEE_REENTRANCY_PHASE_0 = 0, + QSEE_REENTRANCY_PHASE_1, + QSEE_REENTRANCY_PHASE_2, + QSEE_REENTRANCY_PHASE_3, + QSEE_REENTRANCY_PHASE_MAX = 0xFF +}; + +struct qsee_apps_region_info_ireq { + uint32_t qsee_cmd_id; + uint32_t addr; + uint32_t size; +} __attribute__((__packed__)); + +struct qsee_apps_region_info_64bit_ireq { + uint32_t qsee_cmd_id; + uint64_t addr; + uint32_t size; +} __attribute__((__packed__)); + +struct qseecom_check_app_ireq { + uint32_t qsee_cmd_id; + char app_name[MAX_APP_NAME_SIZE]; +} __attribute__((__packed__)); + +struct qseecom_load_app_ireq { + uint32_t qsee_cmd_id; + uint32_t mdt_len; /* Length of the mdt file */ + uint32_t img_len; /* Length of .bxx and .mdt files */ + uint32_t phy_addr; /* phy addr of the start of image */ + char app_name[MAX_APP_NAME_SIZE]; /* application name*/ +} __attribute__((__packed__)); + +struct qseecom_load_app_64bit_ireq { + uint32_t qsee_cmd_id; + uint32_t mdt_len; + uint32_t img_len; + uint64_t phy_addr; + char app_name[MAX_APP_NAME_SIZE]; +} __attribute__((__packed__)); + +struct qseecom_unload_app_ireq { + uint32_t qsee_cmd_id; + uint32_t app_id; +} __attribute__((__packed__)); + +struct qseecom_load_lib_image_ireq { + uint32_t qsee_cmd_id; + uint32_t mdt_len; + uint32_t img_len; + uint32_t phy_addr; +} __attribute__((__packed__)); + +struct qseecom_load_lib_image_64bit_ireq { + uint32_t qsee_cmd_id; + uint32_t mdt_len; + uint32_t img_len; + uint64_t phy_addr; +} __attribute__((__packed__)); + +struct qseecom_unload_lib_image_ireq { + uint32_t qsee_cmd_id; +} __attribute__((__packed__)); + +struct qseecom_register_listener_ireq { + uint32_t qsee_cmd_id; + uint32_t listener_id; + uint32_t sb_ptr; + uint32_t sb_len; +} __attribute__((__packed__)); + +struct qseecom_register_listener_64bit_ireq { + uint32_t qsee_cmd_id; + uint32_t listener_id; + uint64_t sb_ptr; + uint32_t sb_len; +} __attribute__((__packed__)); + +struct qseecom_unregister_listener_ireq { + uint32_t qsee_cmd_id; + uint32_t listener_id; +} __attribute__((__packed__)); + +struct qseecom_client_send_data_ireq { + uint32_t qsee_cmd_id; + uint32_t app_id; + uint32_t req_ptr; + uint32_t req_len; + uint32_t rsp_ptr;/* First 4 bytes should be the return status */ + uint32_t rsp_len; + uint32_t sglistinfo_ptr; + uint32_t sglistinfo_len; +} __attribute__((__packed__)); + +struct qseecom_client_send_data_64bit_ireq { + uint32_t qsee_cmd_id; + uint32_t app_id; + uint64_t req_ptr; + uint32_t req_len; + uint64_t rsp_ptr; + uint32_t rsp_len; + uint64_t sglistinfo_ptr; + uint32_t sglistinfo_len; +} __attribute__((__packed__)); + +struct qseecom_reg_log_buf_ireq { + uint32_t qsee_cmd_id; + uint32_t phy_addr; + uint32_t len; +} __attribute__((__packed__)); + +struct qseecom_reg_log_buf_64bit_ireq { + uint32_t qsee_cmd_id; + uint64_t phy_addr; + uint32_t len; +} __attribute__((__packed__)); + +/* send_data resp */ +struct qseecom_client_listener_data_irsp { + uint32_t qsee_cmd_id; + uint32_t listener_id; + uint32_t status; + uint32_t sglistinfo_ptr; + uint32_t sglistinfo_len; +} __attribute__((__packed__)); + +struct qseecom_client_listener_data_64bit_irsp { + uint32_t qsee_cmd_id; + uint32_t listener_id; + uint32_t status; + uint64_t sglistinfo_ptr; + uint32_t sglistinfo_len; +} __attribute__((__packed__)); + +/* + * struct qseecom_command_scm_resp - qseecom response buffer + * @cmd_status: value from enum tz_sched_cmd_status + * @sb_in_rsp_addr: points to physical location of response + * buffer + * @sb_in_rsp_len: length of command response + */ +struct qseecom_command_scm_resp { + uint32_t result; + enum qseecom_command_scm_resp_type resp_type; + unsigned int data; +} __attribute__((__packed__)); + +struct qseecom_rpmb_provision_key { + uint32_t key_type; +}; + +struct qseecom_client_send_service_ireq { + uint32_t qsee_cmd_id; + uint32_t key_type; /* in */ + unsigned int req_len; /* in */ + uint32_t rsp_ptr; /* in/out */ + unsigned int rsp_len; /* in/out */ +} __attribute__((__packed__)); + +struct qseecom_client_send_service_64bit_ireq { + uint32_t qsee_cmd_id; + uint32_t key_type; + unsigned int req_len; + uint64_t rsp_ptr; + unsigned int rsp_len; +} __attribute__((__packed__)); + +struct qseecom_key_generate_ireq { + uint32_t qsee_command_id; + uint32_t flags; + uint8_t key_id[QSEECOM_KEY_ID_SIZE]; + uint8_t hash32[QSEECOM_HASH_SIZE]; +} __attribute__((__packed__)); + +struct qseecom_key_select_ireq { + uint32_t qsee_command_id; + uint32_t ce; + uint32_t pipe; + uint32_t pipe_type; + uint32_t flags; + uint8_t key_id[QSEECOM_KEY_ID_SIZE]; + uint8_t hash32[QSEECOM_HASH_SIZE]; +} __attribute__((__packed__)); + +struct qseecom_key_delete_ireq { + uint32_t qsee_command_id; + uint32_t flags; + uint8_t key_id[QSEECOM_KEY_ID_SIZE]; + uint8_t hash32[QSEECOM_HASH_SIZE]; + +} __attribute__((__packed__)); + +struct qseecom_key_userinfo_update_ireq { + uint32_t qsee_command_id; + uint32_t flags; + uint8_t key_id[QSEECOM_KEY_ID_SIZE]; + uint8_t current_hash32[QSEECOM_HASH_SIZE]; + uint8_t new_hash32[QSEECOM_HASH_SIZE]; +} __attribute__((__packed__)); + +struct qseecom_key_max_count_query_ireq { + uint32_t flags; +} __attribute__((__packed__)); + +struct qseecom_key_max_count_query_irsp { + uint32_t max_key_count; +} __attribute__((__packed__)); + +struct qseecom_qteec_ireq { + uint32_t qsee_cmd_id; + uint32_t app_id; + uint32_t req_ptr; + uint32_t req_len; + uint32_t resp_ptr; + uint32_t resp_len; + uint32_t sglistinfo_ptr; + uint32_t sglistinfo_len; +} __attribute__((__packed__)); + +struct qseecom_qteec_64bit_ireq { + uint32_t qsee_cmd_id; + uint32_t app_id; + uint64_t req_ptr; + uint32_t req_len; + uint64_t resp_ptr; + uint32_t resp_len; + uint64_t sglistinfo_ptr; + uint32_t sglistinfo_len; +} __attribute__((__packed__)); + +struct qseecom_client_send_fsm_key_req { + uint32_t qsee_cmd_id; + uint32_t req_ptr; + uint32_t req_len; + uint32_t rsp_ptr; + uint32_t rsp_len; +} __attribute__((__packed__)); + +struct qseecom_continue_blocked_request_ireq { + uint32_t qsee_cmd_id; + uint32_t app_or_session_id; /*legacy: app_id; smcinvoke: session_id*/ +} __attribute__((__packed__)); + +/********** ARMV8 SMC INTERFACE TZ MACRO *******************/ + +#define TZ_SVC_APP_MGR 1 /* Application management */ +#define TZ_SVC_LISTENER 2 /* Listener service management */ +#define TZ_SVC_EXTERNAL 3 /* External image loading */ +#define TZ_SVC_RPMB 4 /* RPMB */ +#define TZ_SVC_KEYSTORE 5 /* Keystore management */ +#define TZ_SVC_ES 16 /* Enterprise Security */ +#define TZ_SVC_MDTP 18 /* Mobile Device Theft */ + +/*---------------------------------------------------------------------------- + * Owning Entity IDs (defined by ARM SMC doc) + * --------------------------------------------------------------------------- + */ +#define TZ_OWNER_ARM 0 /** ARM Architecture call ID */ +#define TZ_OWNER_CPU 1 /** CPU service call ID */ +#define TZ_OWNER_SIP 2 /** SIP service call ID */ +#define TZ_OWNER_OEM 3 /** OEM service call ID */ +#define TZ_OWNER_STD 4 /** Standard service call ID */ + +/** Values 5-47 are reserved for future use */ + +/** Trusted Application call IDs */ +#define TZ_OWNER_TZ_APPS 48 +#define TZ_OWNER_TZ_APPS_RESERVED 49 +/** Trusted OS Call IDs */ +#define TZ_OWNER_QSEE_OS 50 +#define TZ_OWNER_MOBI_OS 51 +#define TZ_OWNER_OS_RESERVED_3 52 +#define TZ_OWNER_OS_RESERVED_4 53 +#define TZ_OWNER_OS_RESERVED_5 54 +#define TZ_OWNER_OS_RESERVED_6 55 +#define TZ_OWNER_OS_RESERVED_7 56 +#define TZ_OWNER_OS_RESERVED_8 57 +#define TZ_OWNER_OS_RESERVED_9 58 +#define TZ_OWNER_OS_RESERVED_10 59 +#define TZ_OWNER_OS_RESERVED_11 60 +#define TZ_OWNER_OS_RESERVED_12 61 +#define TZ_OWNER_OS_RESERVED_13 62 +#define TZ_OWNER_OS_RESERVED_14 63 + +#define TZ_SVC_INFO 6 /* Misc. information services */ + +/** Trusted Application call groups */ +#define TZ_SVC_APP_ID_PLACEHOLDER 0 /* SVC bits will contain App ID */ + +/** General helper macro to create a bitmask from bits low to high. */ +#define TZ_MASK_BITS(h, l) ((0xffffffff >> (32 - ((h - l) + 1))) << l) + +/* + * Macro used to define an SMC ID based on the owner ID, + * service ID, and function number. + */ +#define TZ_SYSCALL_CREATE_SMC_ID(o, s, f) \ + ((uint32_t)((((o & 0x3f) << 24) | (s & 0xff) << 8) | (f & 0xff))) + +#define TZ_SYSCALL_PARAM_NARGS_MASK TZ_MASK_BITS(3, 0) +#define TZ_SYSCALL_PARAM_TYPE_MASK TZ_MASK_BITS(1, 0) + +#define TZ_SYSCALL_CREATE_PARAM_ID(nargs, p1, p2, p3, \ + p4, p5, p6, p7, p8, p9, p10) \ + ((nargs&TZ_SYSCALL_PARAM_NARGS_MASK)+ \ + ((p1&TZ_SYSCALL_PARAM_TYPE_MASK)<<4)+ \ + ((p2&TZ_SYSCALL_PARAM_TYPE_MASK)<<6)+ \ + ((p3&TZ_SYSCALL_PARAM_TYPE_MASK)<<8)+ \ + ((p4&TZ_SYSCALL_PARAM_TYPE_MASK)<<10)+ \ + ((p5&TZ_SYSCALL_PARAM_TYPE_MASK)<<12)+ \ + ((p6&TZ_SYSCALL_PARAM_TYPE_MASK)<<14)+ \ + ((p7&TZ_SYSCALL_PARAM_TYPE_MASK)<<16)+ \ + ((p8&TZ_SYSCALL_PARAM_TYPE_MASK)<<18)+ \ + ((p9&TZ_SYSCALL_PARAM_TYPE_MASK)<<20)+ \ + ((p10&TZ_SYSCALL_PARAM_TYPE_MASK)<<22)) + +/* + * Macros used to create the Parameter ID associated with the syscall + */ +#define TZ_SYSCALL_CREATE_PARAM_ID_0 0 +#define TZ_SYSCALL_CREATE_PARAM_ID_1(p1) \ + TZ_SYSCALL_CREATE_PARAM_ID(1, p1, 0, 0, 0, 0, 0, 0, 0, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_2(p1, p2) \ + TZ_SYSCALL_CREATE_PARAM_ID(2, p1, p2, 0, 0, 0, 0, 0, 0, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_3(p1, p2, p3) \ + TZ_SYSCALL_CREATE_PARAM_ID(3, p1, p2, p3, 0, 0, 0, 0, 0, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_4(p1, p2, p3, p4) \ + TZ_SYSCALL_CREATE_PARAM_ID(4, p1, p2, p3, p4, 0, 0, 0, 0, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_5(p1, p2, p3, p4, p5) \ + TZ_SYSCALL_CREATE_PARAM_ID(5, p1, p2, p3, p4, p5, 0, 0, 0, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_6(p1, p2, p3, p4, p5, p6) \ + TZ_SYSCALL_CREATE_PARAM_ID(6, p1, p2, p3, p4, p5, p6, 0, 0, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_7(p1, p2, p3, p4, p5, p6, p7) \ + TZ_SYSCALL_CREATE_PARAM_ID(7, p1, p2, p3, p4, p5, p6, p7, 0, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_8(p1, p2, p3, p4, p5, p6, p7, p8) \ + TZ_SYSCALL_CREATE_PARAM_ID(8, p1, p2, p3, p4, p5, p6, p7, p8, 0, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \ + TZ_SYSCALL_CREATE_PARAM_ID(9, p1, p2, p3, p4, p5, p6, p7, p8, p9, 0) +#define TZ_SYSCALL_CREATE_PARAM_ID_10(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) \ + TZ_SYSCALL_CREATE_PARAM_ID(10, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + +/* + * Macro used to obtain the Parameter ID associated with the syscall + */ +#define TZ_SYSCALL_GET_PARAM_ID(CMD_ID) CMD_ID ## _PARAM_ID + +/** Helper macro to extract the owning entity from the SMC ID. */ +#define TZ_SYSCALL_OWNER_ID(r0) ((r0 & TZ_MASK_BITS(29, 24)) >> 24) + +/** Helper macro for checking whether an owning entity is of type trusted OS. */ +#define IS_OWNER_TRUSTED_OS(owner_id) \ + (((owner_id >= 50) && (owner_id <= 63)) ? 1:0) + +#define TZ_SYSCALL_PARAM_TYPE_VAL 0x0 /** type of value */ +#define TZ_SYSCALL_PARAM_TYPE_BUF_RO 0x1 /** type of buffer read-only */ +#define TZ_SYSCALL_PARAM_TYPE_BUF_RW 0x2 /** type of buffer read-write */ + +#define TZ_OS_APP_START_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x01) + +#define TZ_OS_APP_START_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_3( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_VAL, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_APP_SHUTDOWN_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x02) + +#define TZ_OS_APP_SHUTDOWN_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_APP_LOOKUP_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x03) + +#define TZ_OS_APP_LOOKUP_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_APP_GET_STATE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x04) + +#define TZ_OS_APP_GET_STATE_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_APP_REGION_NOTIFICATION_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x05) + +#define TZ_OS_APP_REGION_NOTIFICATION_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_REGISTER_LOG_BUFFER_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x06) + +#define TZ_OS_REGISTER_LOG_BUFFER_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_LOAD_SERVICES_IMAGE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x07) + +#define TZ_OS_LOAD_SERVICES_IMAGE_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_3( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_VAL, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_UNLOAD_SERVICES_IMAGE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_APP_MGR, 0x08) + +#define TZ_OS_UNLOAD_SERVICES_IMAGE_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_0 + +#define TZ_OS_REGISTER_LISTENER_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_LISTENER, 0x01) + +#define TZ_OS_REGISTER_LISTENER_SMCINVOKE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_LISTENER, 0x06) + +#define TZ_OS_REGISTER_LISTENER_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_3( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_DEREGISTER_LISTENER_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_LISTENER, 0x02) + +#define TZ_OS_DEREGISTER_LISTENER_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_LISTENER_RESPONSE_HANDLER_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_LISTENER, 0x03) + +#define TZ_OS_LISTENER_RESPONSE_HANDLER_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_LOAD_EXTERNAL_IMAGE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_EXTERNAL, 0x01) + +#define TZ_OS_LOAD_EXTERNAL_IMAGE_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_3( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_VAL, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_QSAPP_SEND_DATA_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x01) + + +#define TZ_APP_QSAPP_SEND_DATA_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_5( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_UNLOAD_EXTERNAL_IMAGE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_EXTERNAL, 0x02) + +#define TZ_OS_UNLOAD_EXTERNAL_IMAGE_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_0 + +#define TZ_INFO_IS_SVC_AVAILABLE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_SIP, TZ_SVC_INFO, 0x01) + +#define TZ_INFO_IS_SVC_AVAILABLE_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_INFO_GET_FEATURE_VERSION_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_SIP, TZ_SVC_INFO, 0x03) + +#define TZ_INFO_GET_FEATURE_VERSION_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_RPMB_PROVISION_KEY_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_RPMB, 0x01) + +#define TZ_OS_RPMB_PROVISION_KEY_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_RPMB_ERASE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_RPMB, 0x02) + +#define TZ_OS_RPMB_ERASE_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_0 + +#define TZ_OS_RPMB_CHECK_PROV_STATUS_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_RPMB, 0x03) + +#define TZ_OS_RPMB_CHECK_PROV_STATUS_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_0 + +#define TZ_OS_KS_GEN_KEY_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_KEYSTORE, 0x01) + +#define TZ_OS_KS_GEN_KEY_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_KS_DEL_KEY_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_KEYSTORE, 0x02) + +#define TZ_OS_KS_DEL_KEY_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_KS_GET_MAX_KEYS_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_KEYSTORE, 0x03) + +#define TZ_OS_KS_GET_MAX_KEYS_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_KS_SET_PIPE_KEY_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_KEYSTORE, 0x04) + +#define TZ_OS_KS_SET_PIPE_KEY_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_KS_UPDATE_KEY_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_KEYSTORE, 0x05) + +#define TZ_OS_KS_UPDATE_KEY_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_2( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_ES_SAVE_PARTITION_HASH_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_SIP, TZ_SVC_ES, 0x01) + +#define TZ_ES_SAVE_PARTITION_HASH_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_3( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_GPAPP_OPEN_SESSION_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x02) + +#define TZ_APP_GPAPP_OPEN_SESSION_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_5( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_GPAPP_CLOSE_SESSION_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x03) + +#define TZ_APP_GPAPP_CLOSE_SESSION_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_5( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_GPAPP_INVOKE_COMMAND_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x04) + +#define TZ_APP_GPAPP_INVOKE_COMMAND_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_5( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_GPAPP_REQUEST_CANCELLATION_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x05) + +#define TZ_APP_GPAPP_REQUEST_CANCELLATION_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_5( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_MDTP_CIPHER_DIP_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_SIP, TZ_SVC_MDTP, 0x1) + +#define TZ_MDTP_CIPHER_DIP_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_5( \ + TZ_SYSCALL_PARAM_TYPE_BUF_RO, TZ_SYSCALL_PARAM_TYPE_VAL, \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_CONTINUE_BLOCKED_REQUEST_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_LISTENER, 0x04) + +#define TZ_OS_CONTINUE_BLOCKED_REQUEST_SMCINVOKE_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_LISTENER, 0x07) + +#define TZ_OS_CONTINUE_BLOCKED_REQUEST_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_1(TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_QSAPP_SEND_DATA_WITH_WHITELIST_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x06) + +#define TZ_APP_QSAPP_SEND_DATA_WITH_WHITELIST_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_7( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_GPAPP_OPEN_SESSION_WITH_WHITELIST_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x07) + +#define TZ_APP_GPAPP_OPEN_SESSION_WITH_WHITELIST_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_7( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_APP_GPAPP_INVOKE_COMMAND_WITH_WHITELIST_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_TZ_APPS, \ + TZ_SVC_APP_ID_PLACEHOLDER, 0x09) + +#define TZ_APP_GPAPP_INVOKE_COMMAND_WITH_WHITELIST_ID_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_7( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ + TZ_SYSCALL_PARAM_TYPE_VAL) + +#define TZ_OS_LISTENER_RESPONSE_HANDLER_WITH_WHITELIST_ID \ + TZ_SYSCALL_CREATE_SMC_ID(TZ_OWNER_QSEE_OS, TZ_SVC_LISTENER, 0x05) + +#define TZ_OS_LISTENER_RESPONSE_HANDLER_WITH_WHITELIST_PARAM_ID \ + TZ_SYSCALL_CREATE_PARAM_ID_4( \ + TZ_SYSCALL_PARAM_TYPE_VAL, TZ_SYSCALL_PARAM_TYPE_VAL, \ + TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL) + +#endif /* __QSEECOMI_H_ */ diff --git a/include/soc/qcom/ramdump.h b/include/soc/qcom/ramdump.h new file mode 100644 index 000000000000..4e23ccf269a7 --- /dev/null +++ b/include/soc/qcom/ramdump.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2011-2014, 2017 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 _RAMDUMP_HEADER +#define _RAMDUMP_HEADER + +struct device; + +struct ramdump_segment { + char *name; + unsigned long address; + void *v_address; + unsigned long size; +}; + +#ifdef CONFIG_MSM_SUBSYSTEM_RESTART +extern void *create_ramdump_device(const char *dev_name, struct device *parent); +extern void destroy_ramdump_device(void *dev); +extern int do_ramdump(void *handle, struct ramdump_segment *segments, + int nsegments); +extern int do_elf_ramdump(void *handle, struct ramdump_segment *segments, + int nsegments); +extern int do_minidump(void *handle, struct ramdump_segment *segments, + int nsegments); + +#else +static inline void *create_ramdump_device(const char *dev_name, + struct device *parent) +{ + return NULL; +} + +static inline void destroy_ramdump_device(void *dev) +{ +} + +static inline int do_ramdump(void *handle, struct ramdump_segment *segments, + int nsegments) +{ + return -ENODEV; +} + +static inline int do_elf_ramdump(void *handle, struct ramdump_segment *segments, + int nsegments) +{ + return -ENODEV; +} +#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */ + +#endif diff --git a/include/soc/qcom/restart.h b/include/soc/qcom/restart.h new file mode 100644 index 000000000000..bd0f139b548a --- /dev/null +++ b/include/soc/qcom/restart.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2011-2014, 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 _ASM_ARCH_MSM_RESTART_H_ +#define _ASM_ARCH_MSM_RESTART_H_ + +#define RESTART_NORMAL 0x0 +#define RESTART_DLOAD 0x1 + +void msm_set_restart_mode(int mode); +extern int pmic_reset_irq; + +#endif + diff --git a/include/soc/qcom/rpm-notifier.h b/include/soc/qcom/rpm-notifier.h new file mode 100644 index 000000000000..ea6d95e313a8 --- /dev/null +++ b/include/soc/qcom/rpm-notifier.h @@ -0,0 +1,63 @@ +/* Copyright (c) 2012-2014, 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 __ARCH_ARM_MACH_MSM_RPM_NOTIF_H +#define __ARCH_ARM_MACH_MSM_RPM_NOTIF_H + +struct msm_rpm_notifier_data { + uint32_t rsc_type; + uint32_t rsc_id; + uint32_t key; + uint32_t size; + uint8_t *value; +}; +/** + * msm_rpm_register_notifier - Register for sleep set notifications + * + * @nb - notifier block to register + * + * return 0 on success, errno on failure. + */ +int msm_rpm_register_notifier(struct notifier_block *nb); + +/** + * msm_rpm_unregister_notifier - Unregister previously registered notifications + * + * @nb - notifier block to unregister + * + * return 0 on success, errno on failure. + */ +int msm_rpm_unregister_notifier(struct notifier_block *nb); + +/** + * msm_rpm_enter_sleep - Notify RPM driver to prepare for entering sleep + * + * @bool - flag to enable print contents of sleep buffer. + * @cpumask - cpumask of next wakeup cpu + * + * return 0 on success errno on failure. + */ +int msm_rpm_enter_sleep(bool print, const struct cpumask *cpumask); + +/** + * msm_rpm_exit_sleep - Notify RPM driver about resuming from power collapse + */ +void msm_rpm_exit_sleep(void); + +/** + * msm_rpm_waiting_for_ack - Indicate if there is RPM message + * pending acknowledgement. + * returns true for pending messages and false otherwise + */ +bool msm_rpm_waiting_for_ack(void); + +#endif /*__ARCH_ARM_MACH_MSM_RPM_NOTIF_H */ diff --git a/include/soc/qcom/rpm-smd.h b/include/soc/qcom/rpm-smd.h new file mode 100644 index 000000000000..020ffe308284 --- /dev/null +++ b/include/soc/qcom/rpm-smd.h @@ -0,0 +1,309 @@ +/* Copyright (c) 2012, 2014-2015, 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 __ARCH_ARM_MACH_MSM_RPM_SMD_H +#define __ARCH_ARM_MACH_MSM_RPM_SMD_H + +/** + * enum msm_rpm_set - RPM enumerations for sleep/active set + * %MSM_RPM_CTX_SET_0: Set resource parameters for active mode. + * %MSM_RPM_CTX_SET_SLEEP: Set resource parameters for sleep. + */ +enum msm_rpm_set { + MSM_RPM_CTX_ACTIVE_SET, + MSM_RPM_CTX_SLEEP_SET, +}; + +struct msm_rpm_request; + +struct msm_rpm_kvp { + uint32_t key; + uint32_t length; + uint8_t *data; +}; +#ifdef CONFIG_MSM_RPM_SMD +/** + * msm_rpm_request() - Creates a parent element to identify the + * resource on the RPM, that stores the KVPs for different fields modified + * for a hardware resource + * + * @set: if the device is setting the active/sleep set parameter + * for the resource + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type + * @num_elements: number of KVPs pairs associated with the resource + * + * returns pointer to a msm_rpm_request on success, NULL on error + */ +struct msm_rpm_request *msm_rpm_create_request( + enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, int num_elements); + +/** + * msm_rpm_request_noirq() - Creates a parent element to identify the + * resource on the RPM, that stores the KVPs for different fields modified + * for a hardware resource. This function is similar to msm_rpm_create_request + * except that it has to be called with interrupts masked. + * + * @set: if the device is setting the active/sleep set parameter + * for the resource + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type + * @num_elements: number of KVPs pairs associated with the resource + * + * returns pointer to a msm_rpm_request on success, NULL on error + */ +struct msm_rpm_request *msm_rpm_create_request_noirq( + enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, int num_elements); + +/** + * msm_rpm_add_kvp_data() - Adds a Key value pair to a existing RPM resource. + * + * @handle: RPM resource handle to which the data should be appended + * @key: unsigned integer identify the parameter modified + * @data: byte array that contains the value corresponding to key. + * @size: size of data in bytes. + * + * returns 0 on success or errno + */ +int msm_rpm_add_kvp_data(struct msm_rpm_request *handle, + uint32_t key, const uint8_t *data, int size); + +/** + * msm_rpm_add_kvp_data_noirq() - Adds a Key value pair to a existing RPM + * resource. This function is similar to msm_rpm_add_kvp_data except that it + * has to be called with interrupts masked. + * + * @handle: RPM resource handle to which the data should be appended + * @key: unsigned integer identify the parameter modified + * @data: byte array that contains the value corresponding to key. + * @size: size of data in bytes. + * + * returns 0 on success or errno + */ +int msm_rpm_add_kvp_data_noirq(struct msm_rpm_request *handle, + uint32_t key, const uint8_t *data, int size); + +/** msm_rpm_free_request() - clean up the RPM request handle created with + * msm_rpm_create_request + * + * @handle: RPM resource handle to be cleared. + */ + +void msm_rpm_free_request(struct msm_rpm_request *handle); + +/** + * msm_rpm_send_request() - Send the RPM messages using SMD. The function + * assigns a message id before sending the data out to the RPM. RPM hardware + * uses the message id to acknowledge the messages. + * + * @handle: pointer to the msm_rpm_request for the resource being modified. + * + * returns non-zero message id on success and zero on a failed transaction. + * The drivers use message id to wait for ACK from RPM. + */ +int msm_rpm_send_request(struct msm_rpm_request *handle); + +/** + * msm_rpm_send_request_noack() - Send the RPM messages using SMD. The function + * assigns a message id before sending the data out to the RPM. RPM hardware + * uses the message id to acknowledge the messages, but this API does not wait + * on the ACK for this message id and it does not add the message id to the wait + * list. + * + * @handle: pointer to the msm_rpm_request for the resource being modified. + * + * returns NULL on success and PTR_ERR on a failed transaction. + */ +void *msm_rpm_send_request_noack(struct msm_rpm_request *handle); + +/** + * msm_rpm_send_request_noirq() - Send the RPM messages using SMD. The + * function assigns a message id before sending the data out to the RPM. + * RPM hardware uses the message id to acknowledge the messages. This function + * is similar to msm_rpm_send_request except that it has to be called with + * interrupts masked. + * + * @handle: pointer to the msm_rpm_request for the resource being modified. + * + * returns non-zero message id on success and zero on a failed transaction. + * The drivers use message id to wait for ACK from RPM. + */ +int msm_rpm_send_request_noirq(struct msm_rpm_request *handle); + +/** + * msm_rpm_wait_for_ack() - A blocking call that waits for acknowledgment of + * a message from RPM. + * + * @msg_id: the return from msm_rpm_send_requests + * + * returns 0 on success or errno + */ +int msm_rpm_wait_for_ack(uint32_t msg_id); + +/** + * msm_rpm_wait_for_ack_noirq() - A blocking call that waits for acknowledgment + * of a message from RPM. This function is similar to msm_rpm_wait_for_ack + * except that it has to be called with interrupts masked. + * + * @msg_id: the return from msm_rpm_send_request + * + * returns 0 on success or errno + */ +int msm_rpm_wait_for_ack_noirq(uint32_t msg_id); + +/** + * msm_rpm_send_message() -Wrapper function for clients to send data given an + * array of key value pairs. + * + * @set: if the device is setting the active/sleep set parameter + * for the resource + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type + * @kvp: array of KVP data. + * @nelem: number of KVPs pairs associated with the message. + * + * returns 0 on success and errno on failure. + */ +int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems); + +/** + * msm_rpm_send_message_noack() -Wrapper function for clients to send data + * given an array of key value pairs without waiting for ack. + * + * @set: if the device is setting the active/sleep set parameter + * for the resource + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type + * @kvp: array of KVP data. + * @nelem: number of KVPs pairs associated with the message. + * + * returns NULL on success and PTR_ERR(errno) on failure. + */ +void *msm_rpm_send_message_noack(enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems); + +/** + * msm_rpm_send_message_noirq() -Wrapper function for clients to send data + * given an array of key value pairs. This function is similar to the + * msm_rpm_send_message() except that it has to be called with interrupts + * disabled. Clients should choose the irq version when possible for system + * performance. + * + * @set: if the device is setting the active/sleep set parameter + * for the resource + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type + * @kvp: array of KVP data. + * @nelem: number of KVPs pairs associated with the message. + * + * returns 0 on success and errno on failure. + */ +int msm_rpm_send_message_noirq(enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems); + +/** + * msm_rpm_driver_init() - Initialization function that registers for a + * rpm platform driver. + * + * returns 0 on success. + */ +int __init msm_rpm_driver_init(void); + +#else + +static inline struct msm_rpm_request *msm_rpm_create_request( + enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, int num_elements) +{ + return NULL; +} + +static inline struct msm_rpm_request *msm_rpm_create_request_noirq( + enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, int num_elements) +{ + return NULL; + +} +static inline uint32_t msm_rpm_add_kvp_data(struct msm_rpm_request *handle, + uint32_t key, const uint8_t *data, int count) +{ + return 0; +} +static inline uint32_t msm_rpm_add_kvp_data_noirq( + struct msm_rpm_request *handle, uint32_t key, + const uint8_t *data, int count) +{ + return 0; +} + +static inline void msm_rpm_free_request(struct msm_rpm_request *handle) +{ + return; +} + +static inline int msm_rpm_send_request(struct msm_rpm_request *handle) +{ + return 0; +} + +static inline int msm_rpm_send_request_noirq(struct msm_rpm_request *handle) +{ + return 0; + +} + +static inline void *msm_rpm_send_request_noack(struct msm_rpm_request *handle) +{ + return NULL; +} + +static inline int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type, + uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems) +{ + return 0; +} + +static inline int msm_rpm_send_message_noirq(enum msm_rpm_set set, + uint32_t rsc_type, uint32_t rsc_id, struct msm_rpm_kvp *kvp, + int nelems) +{ + return 0; +} + +static inline void *msm_rpm_send_message_noack(enum msm_rpm_set set, + uint32_t rsc_type, uint32_t rsc_id, struct msm_rpm_kvp *kvp, + int nelems) +{ + return NULL; +} + +static inline int msm_rpm_wait_for_ack(uint32_t msg_id) +{ + return 0; + +} +static inline int msm_rpm_wait_for_ack_noirq(uint32_t msg_id) +{ + return 0; +} + +static inline int __init msm_rpm_driver_init(void) +{ + return 0; +} +#endif +#endif /*__ARCH_ARM_MACH_MSM_RPM_SMD_H*/ diff --git a/include/soc/qcom/scm-boot.h b/include/soc/qcom/scm-boot.h new file mode 100644 index 000000000000..b986608c3227 --- /dev/null +++ b/include/soc/qcom/scm-boot.h @@ -0,0 +1,65 @@ +/* Copyright (c) 2010, 2012, 2014, 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 __MACH_SCM_BOOT_H +#define __MACH_SCM_BOOT_H + +#define SCM_BOOT_ADDR 0x1 +#define SCM_FLAG_COLDBOOT_CPU1 0x01 +#define SCM_FLAG_COLDBOOT_CPU2 0x08 +#define SCM_FLAG_COLDBOOT_CPU3 0x20 +#define SCM_FLAG_WARMBOOT_CPU1 0x02 +#define SCM_FLAG_WARMBOOT_CPU0 0x04 +#define SCM_FLAG_WARMBOOT_CPU2 0x10 +#define SCM_FLAG_WARMBOOT_CPU3 0x40 + +/* Multicluster Variants */ +#define SCM_BOOT_ADDR_MC 0x11 +#define SCM_FLAG_COLDBOOT_MC 0x02 +#define SCM_FLAG_WARMBOOT_MC 0x04 + +#ifdef CONFIG_ARM64 +#define SCM_FLAG_HLOS 0x01 +#else +#define SCM_FLAG_HLOS 0x0 +#endif + +#ifdef CONFIG_QCOM_SCM +int scm_set_boot_addr(phys_addr_t addr, unsigned int flags); +int scm_set_boot_addr_mc(phys_addr_t addr, u32 aff0, + u32 aff1, u32 aff2, u32 flags); +int scm_set_warm_boot_addr_mc_for_all(phys_addr_t addr); +int scm_is_mc_boot_available(void); +#else +static inline int scm_set_boot_addr(phys_addr_t addr, unsigned int flags) +{ + WARN_ONCE(1, "CONFIG_QCOM_SCM disabled, SCM call will fail silently\n"); + return 0; +} +static inline int scm_set_boot_addr_mc(phys_addr_t addr, u32 aff0, + u32 aff1, u32 aff2, u32 flags) +{ + WARN_ONCE(1, "CONFIG_QCOM_SCM disabled, SCM call will fail silently\n"); + return 0; +} +static inline int scm_set_warm_boot_addr_mc_for_all(phys_addr_t addr) +{ + WARN_ONCE(1, "CONFIG_QCOM_SCM disabled, SCM call will fail silently\n"); + return 0; +} +static inline int scm_is_mc_boot_available(void) +{ + WARN_ONCE(1, "CONFIG_QCOM_SCM disabled, SCM call will fail silently\n"); + return 0; +} +#endif + +#endif diff --git a/include/soc/qcom/scm.h b/include/soc/qcom/scm.h new file mode 100644 index 000000000000..e741d540a8d6 --- /dev/null +++ b/include/soc/qcom/scm.h @@ -0,0 +1,245 @@ +/* Copyright (c) 2010-2018, 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 __MACH_SCM_H +#define __MACH_SCM_H + +#define SCM_SVC_BOOT 0x1 +#define SCM_SVC_PIL 0x2 +#define SCM_SVC_UTIL 0x3 +#define SCM_SVC_TZ 0x4 +#define SCM_SVC_IO 0x5 +#define SCM_SVC_INFO 0x6 +#define SCM_SVC_SSD 0x7 +#define SCM_SVC_FUSE 0x8 +#define SCM_SVC_PWR 0x9 +#define SCM_SVC_MP 0xC +#define SCM_SVC_DCVS 0xD +#define SCM_SVC_ES 0x10 +#define SCM_SVC_HDCP 0x11 +#define SCM_SVC_MDTP 0x12 +#define SCM_SVC_LMH 0x13 +#define SCM_SVC_SMMU_PROGRAM 0x15 +#define SCM_SVC_QDSS 0x16 +#define SCM_SVC_TZSCHEDULER 0xFC +#define SCM_SVC_BW 0xFD + +#define SCM_FUSE_READ 0x7 +#define SCM_CMD_HDCP 0x01 + +/* SCM Features */ +#define SCM_SVC_SEC_CAMERA 0xD + +#define DEFINE_SCM_BUFFER(__n) \ +static char __n[PAGE_SIZE] __aligned(PAGE_SIZE); + +#define SCM_BUFFER_SIZE(__buf) sizeof(__buf) + +#define SCM_BUFFER_PHYS(__buf) virt_to_phys(__buf) + +#define SCM_SIP_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) | 0x02000000) +#define SCM_QSEEOS_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) | \ + 0x32000000) +#define SCM_SVC_ID(s) (((s) & 0xFF00) >> 8) + +#define MAX_SCM_ARGS 10 +#define MAX_SCM_RETS 3 + +enum scm_arg_types { + SCM_VAL, + SCM_RO, + SCM_RW, + SCM_BUFVAL, +}; + +#define SCM_ARGS_IMPL(num, a, b, c, d, e, f, g, h, i, j, ...) (\ + (((a) & 0xff) << 4) | \ + (((b) & 0xff) << 6) | \ + (((c) & 0xff) << 8) | \ + (((d) & 0xff) << 10) | \ + (((e) & 0xff) << 12) | \ + (((f) & 0xff) << 14) | \ + (((g) & 0xff) << 16) | \ + (((h) & 0xff) << 18) | \ + (((i) & 0xff) << 20) | \ + (((j) & 0xff) << 22) | \ + (num & 0xffff)) + +#define SCM_ARGS(...) SCM_ARGS_IMPL(__VA_ARGS__, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + +/** + * struct scm_desc + * @arginfo: Metadata describing the arguments in args[] + * @args: The array of arguments for the secure syscall + * @ret: The values returned by the secure syscall + * @extra_arg_buf: The buffer containing extra arguments + (that don't fit in available registers) + * @x5: The 4rd argument to the secure syscall or physical address of + extra_arg_buf + */ +struct scm_desc { + u32 arginfo; + u64 args[MAX_SCM_ARGS]; + u64 ret[MAX_SCM_RETS]; + + /* private */ + void *extra_arg_buf; + u64 x5; +}; + +#if defined(CONFIG_QCOM_SCM) || defined(CONFIG_QCOM_SCM_QCPE) +extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len, + void *resp_buf, size_t resp_len); + +extern int scm_call2(u32 cmd_id, struct scm_desc *desc); + +extern int scm_call2_noretry(u32 cmd_id, struct scm_desc *desc); + +extern int scm_call2_atomic(u32 cmd_id, struct scm_desc *desc); + +extern int scm_call_noalloc(u32 svc_id, u32 cmd_id, const void *cmd_buf, + size_t cmd_len, void *resp_buf, size_t resp_len, + void *scm_buf, size_t scm_buf_size); + + +extern s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1); +extern s32 scm_call_atomic1_1(u32 svc, u32 cmd, u32 arg1, u32 *ret1); +extern s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2); +extern s32 scm_call_atomic3(u32 svc, u32 cmd, u32 arg1, u32 arg2, u32 arg3); +extern s32 scm_call_atomic4_3(u32 svc, u32 cmd, u32 arg1, u32 arg2, u32 arg3, + u32 arg4, u32 *ret1, u32 *ret2); +extern s32 scm_call_atomic5_3(u32 svc, u32 cmd, u32 arg1, u32 arg2, u32 arg3, + u32 arg4, u32 arg5, u32 *ret1, u32 *ret2, u32 *ret3); + +#define SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) + +extern u32 scm_get_version(void); +extern int scm_is_call_available(u32 svc_id, u32 cmd_id); +extern int scm_get_feat_version(u32 feat, u64 *scm_ret); +extern bool is_scm_armv8(void); +extern int scm_restore_sec_cfg(u32 device_id, u32 spare, u64 *scm_ret); +extern u32 scm_io_read(phys_addr_t address); +extern int scm_io_write(phys_addr_t address, u32 val); +extern bool scm_is_secure_device(void); + +#define SCM_HDCP_MAX_REG 5 + +struct scm_hdcp_req { + u32 addr; + u32 val; +}; + +extern struct mutex scm_lmh_lock; + +#else + +static inline int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, + size_t cmd_len, void *resp_buf, size_t resp_len) +{ + return 0; +} + +static inline int scm_call2(u32 cmd_id, struct scm_desc *desc) +{ + return 0; +} + +static inline int scm_call2_noretry(u32 cmd_id, struct scm_desc *desc) +{ + return 0; +} + +static inline int scm_call2_atomic(u32 cmd_id, struct scm_desc *desc) +{ + return 0; +} + +static inline int scm_call_noalloc(u32 svc_id, u32 cmd_id, + const void *cmd_buf, size_t cmd_len, void *resp_buf, + size_t resp_len, void *scm_buf, size_t scm_buf_size) +{ + return 0; +} + +static inline s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1) +{ + return 0; +} + +static inline s32 scm_call_atomic1_1(u32 svc, u32 cmd, u32 arg1, u32 *ret1) +{ + return 0; +} + +static inline s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2) +{ + return 0; +} + +static inline s32 scm_call_atomic3(u32 svc, u32 cmd, u32 arg1, u32 arg2, + u32 arg3) +{ + return 0; +} + +static inline s32 scm_call_atomic4_3(u32 svc, u32 cmd, u32 arg1, u32 arg2, + u32 arg3, u32 arg4, u32 *ret1, u32 *ret2) +{ + return 0; +} + +static inline s32 scm_call_atomic5_3(u32 svc, u32 cmd, u32 arg1, u32 arg2, + u32 arg3, u32 arg4, u32 arg5, u32 *ret1, u32 *ret2, u32 *ret3) +{ + return 0; +} + +static inline u32 scm_get_version(void) +{ + return 0; +} + +static inline int scm_is_call_available(u32 svc_id, u32 cmd_id) +{ + return 0; +} + +static inline int scm_get_feat_version(u32 feat, u64 *scm_ret) +{ + return 0; +} + +static inline bool is_scm_armv8(void) +{ + return true; +} + +static inline int scm_restore_sec_cfg(u32 device_id, u32 spare, u64 *scm_ret) +{ + return 0; +} + +static inline u32 scm_io_read(phys_addr_t address) +{ + return 0; +} + +static inline int scm_io_write(phys_addr_t address, u32 val) +{ + return 0; +} + +static inline bool scm_is_secure_device(void) +{ + return false; +} +#endif +#endif diff --git a/include/soc/qcom/secure_buffer.h b/include/soc/qcom/secure_buffer.h new file mode 100644 index 000000000000..1e22937b61bb --- /dev/null +++ b/include/soc/qcom/secure_buffer.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2015-2017, 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 __MSM_SECURE_BUFFER_H__ +#define __MSM_SECURE_BUFFER_H__ + +#include <linux/scatterlist.h> + +/* + * if you add a secure VMID here make sure you update + * msm_secure_vmid_to_string. + * Make sure to keep the VMID_LAST as the last entry in the enum. + * This is needed in ion to create a list and it's sized using VMID_LAST. + */ +enum vmid { + VMID_HLOS = 0x3, + VMID_CP_TOUCH = 0x8, + VMID_CP_BITSTREAM = 0x9, + VMID_CP_PIXEL = 0xA, + VMID_CP_NON_PIXEL = 0xB, + VMID_CP_CAMERA = 0xD, + VMID_HLOS_FREE = 0xE, + VMID_MSS_MSA = 0xF, + VMID_MSS_NONMSA = 0x10, + VMID_CP_SEC_DISPLAY = 0x11, + VMID_CP_APP = 0x12, + VMID_WLAN = 0x18, + VMID_WLAN_CE = 0x19, + VMID_CP_CAMERA_PREVIEW = 0x1D, + VMID_CP_SPSS_SP_SHARED = 0x22, + VMID_LAST, + VMID_INVAL = -1 +}; + +#define PERM_READ 0x4 +#define PERM_WRITE 0x2 +#define PERM_EXEC 0x1 + +#ifdef CONFIG_MSM_SECURE_BUFFER +int msm_secure_table(struct sg_table *table); +int msm_unsecure_table(struct sg_table *table); +int hyp_assign_table(struct sg_table *table, + u32 *source_vm_list, int source_nelems, + int *dest_vmids, int *dest_perms, + int dest_nelems); +extern int hyp_assign_phys(phys_addr_t addr, u64 size, + u32 *source_vmlist, int source_nelems, + int *dest_vmids, int *dest_perms, int dest_nelems); +bool msm_secure_v2_is_supported(void); +const char *msm_secure_vmid_to_string(int secure_vmid); +#else +static inline int msm_secure_table(struct sg_table *table) +{ + return -ENOSYS; +} +static inline int msm_unsecure_table(struct sg_table *table) +{ + return -ENOSYS; +} +static inline int hyp_assign_table(struct sg_table *table, + u32 *source_vm_list, int source_nelems, + int *dest_vmids, int *dest_perms, + int dest_nelems) +{ + return -ENOSYS; +} +static inline int hyp_assign_phys(phys_addr_t addr, u64 size, + u32 *source_vmlist, int source_nelems, + int *dest_vmids, int *dest_perms, int dest_nelems) +{ + return -ENOSYS; +} + +static inline bool msm_secure_v2_is_supported(void) +{ + return false; +} +static inline const char *msm_secure_vmid_to_string(int secure_vmid) +{ + return "N/A"; +} +#endif +#endif diff --git a/include/soc/qcom/service-locator.h b/include/soc/qcom/service-locator.h new file mode 100644 index 000000000000..7fa25b90fc12 --- /dev/null +++ b/include/soc/qcom/service-locator.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2015-2016, 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. + * + * Process Domain Service Locator API header + */ + +#ifndef _SERVICE_LOCATOR_H +#define _SERVICE_LOCATOR_H + +#define QMI_SERVREG_LOC_NAME_LENGTH_V01 64 +#define QMI_SERVREG_LOC_LIST_LENGTH_V01 32 + +/* + * @name: The full process domain path for a process domain which provides + * a particular service + * @instance_id: The QMI instance id corresponding to the root process + * domain which is responsible for notifications for this + * process domain + * @service_data_valid: Indicates if service_data field has valid data + * @service_data: Optional service data provided by the service locator + */ +struct servreg_loc_entry_v01 { + char name[QMI_SERVREG_LOC_NAME_LENGTH_V01 + 1]; + uint32_t instance_id; + uint8_t service_data_valid; + uint32_t service_data; +}; + +/* + * @client_name: Name of the client calling the api + * @service_name: Name of the service for which the list of process domains + * is requested + * @total_domains: Length of the process domain list + * @db_rev_count: Process domain list database revision number + * @domain_list: List of process domains providing the service + */ +struct pd_qmi_client_data { + char client_name[QMI_SERVREG_LOC_NAME_LENGTH_V01 + 1]; + char service_name[QMI_SERVREG_LOC_NAME_LENGTH_V01 + 1]; + int total_domains; + int db_rev_count; + struct servreg_loc_entry_v01 *domain_list; +}; + +enum service_locator_state { + LOCATOR_DOWN = 0x0F, + LOCATOR_UP = 0x1F, +}; + +#if defined(CONFIG_MSM_SERVICE_LOCATOR) +/* + * Use this api to request information regarding the process domains on + * which a particular service runs. The client name, the service name + * and notifier block pointer need to be provided by client calling the api. + * The total domains, db revision and the domain list will be filled in + * by the service locator. + * Returns 0 on success; otherwise a value < 0 if no valid subsystem is found. + */ +int get_service_location(char *client_name, char *service_name, + struct notifier_block *locator_nb); + +/* + * Use this api to request information regarding the subsystem the process + * domain runs on. + * @pd_path: The name field from inside the servreg_loc_entry that one + * gets back using the get_processdomains api. + * Returns 0 on success; otherwise a value < 0 if no valid subsystem is found. + */ +int find_subsys(const char *pd_path, char *subsys); + +#else + +static inline int get_service_location(char *client_name, + char *service_name, struct notifier_block *locator_nb) +{ + return -ENODEV; +} + +static inline int find_subsys(const char *pd_path, const char *subsys) +{ + return 0; +} + +#endif /* CONFIG_MSM_SERVICE_LOCATOR */ + +#endif diff --git a/include/soc/qcom/service-notifier.h b/include/soc/qcom/service-notifier.h new file mode 100644 index 000000000000..740f7f644a02 --- /dev/null +++ b/include/soc/qcom/service-notifier.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2015-2017, 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. + * + * Process Domain Service Notifier API header + */ + +#ifndef _SERVICE_NOTIFIER_H +#define _SERVICE_NOTIFIER_H + +enum qmi_servreg_notif_service_state_enum_type_v01 { + QMI_SERVREG_NOTIF_SERVICE_STATE_ENUM_TYPE_MIN_VAL_V01 = INT_MIN, + QMI_SERVREG_NOTIF_SERVICE_STATE_ENUM_TYPE_MAX_VAL_V01 = INT_MAX, + SERVREG_NOTIF_SERVICE_STATE_DOWN_V01 = 0x0FFFFFFF, + SERVREG_NOTIF_SERVICE_STATE_UP_V01 = 0x1FFFFFFF, + SERVREG_NOTIF_SERVICE_STATE_UNINIT_V01 = 0x7FFFFFFF, +}; + +enum pd_subsys_state { + ROOT_PD_DOWN, + ROOT_PD_UP, + ROOT_PD_ERR_FATAL, + ROOT_PD_WDOG_BITE, + ROOT_PD_SHUTDOWN, + USER_PD_STATE_CHANGE, +}; +#if defined(CONFIG_MSM_SERVICE_NOTIFIER) + +/* service_notif_register_notifier() - Register a notifier for a service + * On success, it returns back a handle. It takes the following arguments: + * service_path: Individual service identifier path for which a client + * registers for notifications. + * instance_id: Instance id specific to a subsystem. + * current_state: Current state of service returned by the registration + * process. + * notifier block: notifier callback for service events. + */ +void *service_notif_register_notifier(const char *service_path, int instance_id, + struct notifier_block *nb, int *curr_state); + +/* service_notif_unregister_notifier() - Unregister a notifier for a service. + * service_notif_handle - The notifier handler that was provided by the + * service_notif_register_notifier function when the + * client registered for notifications. + * nb - The notifier block that was previously used during the registration. + */ +int service_notif_unregister_notifier(void *service_notif_handle, + struct notifier_block *nb); + +int service_notif_pd_restart(const char *service_path, int instance_id); + +#else + +static inline void *service_notif_register_notifier(const char *service_path, + int instance_id, struct notifier_block *nb, + int *curr_state) +{ + return ERR_PTR(-ENODEV); +} + +static inline int service_notif_unregister_notifier(void *service_notif_handle, + struct notifier_block *nb) +{ + return -ENODEV; +} + +static inline int service_notif_pd_restart(const char *service_path, + int instance_id) +{ + return -ENODEV; +} + +#endif /* CONFIG_MSM_SERVICE_NOTIFIER */ + +#endif diff --git a/include/soc/qcom/smd.h b/include/soc/qcom/smd.h new file mode 100644 index 000000000000..50c32d191055 --- /dev/null +++ b/include/soc/qcom/smd.h @@ -0,0 +1,381 @@ +/* include/soc/qcom/smd.h + * + * Copyright (C) 2007 Google, Inc. + * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * Author: Brian Swetland <swetland@google.com> + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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 __ASM_ARCH_MSM_SMD_H +#define __ASM_ARCH_MSM_SMD_H + +#include <linux/io.h> + +#include <soc/qcom/smem.h> + +typedef struct smd_channel smd_channel_t; +struct cpumask; + +#define SMD_MAX_CH_NAME_LEN 20 /* includes null char at end */ + +#define SMD_EVENT_DATA 1 +#define SMD_EVENT_OPEN 2 +#define SMD_EVENT_CLOSE 3 +#define SMD_EVENT_STATUS 4 +#define SMD_EVENT_REOPEN_READY 5 + +/* + * SMD Processor ID's. + * + * For all processors that have both SMSM and SMD clients, + * the SMSM Processor ID and the SMD Processor ID will + * be the same. In cases where a processor only supports + * SMD, the entry will only exist in this enum. + */ +enum { + SMD_APPS = SMEM_APPS, + SMD_MODEM = SMEM_MODEM, + SMD_Q6 = SMEM_Q6, + SMD_DSPS = SMEM_DSPS, + SMD_TZ = SMEM_DSPS, + SMD_WCNSS = SMEM_WCNSS, + SMD_MODEM_Q6_FW = SMEM_MODEM_Q6_FW, + SMD_RPM = SMEM_RPM, + NUM_SMD_SUBSYSTEMS, +}; + +enum { + SMD_APPS_MODEM = 0, + SMD_APPS_QDSP, + SMD_MODEM_QDSP, + SMD_APPS_DSPS, + SMD_MODEM_DSPS, + SMD_QDSP_DSPS, + SMD_APPS_WCNSS, + SMD_MODEM_WCNSS, + SMD_QDSP_WCNSS, + SMD_DSPS_WCNSS, + SMD_APPS_Q6FW, + SMD_MODEM_Q6FW, + SMD_QDSP_Q6FW, + SMD_DSPS_Q6FW, + SMD_WCNSS_Q6FW, + SMD_APPS_RPM, + SMD_MODEM_RPM, + SMD_QDSP_RPM, + SMD_WCNSS_RPM, + SMD_TZ_RPM, + SMD_NUM_TYPE, + +}; + +#ifdef CONFIG_MSM_SMD +int smd_close(smd_channel_t *ch); + +/* passing a null pointer for data reads and discards */ +int smd_read(smd_channel_t *ch, void *data, int len); +int smd_read_from_cb(smd_channel_t *ch, void *data, int len); + +/* Write to stream channels may do a partial write and return +** the length actually written. +** Write to packet channels will never do a partial write -- +** it will return the requested length written or an error. +*/ +int smd_write(smd_channel_t *ch, const void *data, int len); + +int smd_write_avail(smd_channel_t *ch); +int smd_read_avail(smd_channel_t *ch); + +/* Returns the total size of the current packet being read. +** Returns 0 if no packets available or a stream channel. +*/ +int smd_cur_packet_size(smd_channel_t *ch); + +/* these are used to get and set the IF sigs of a channel. + * DTR and RTS can be set; DSR, CTS, CD and RI can be read. + */ +int smd_tiocmget(smd_channel_t *ch); +int smd_tiocmset(smd_channel_t *ch, unsigned int set, unsigned int clear); +int +smd_tiocmset_from_cb(smd_channel_t *ch, unsigned int set, unsigned int clear); +int smd_named_open_on_edge(const char *name, uint32_t edge, smd_channel_t **_ch, + void *priv, void (*notify)(void *, unsigned)); + +/* Tells the other end of the smd channel that this end wants to recieve + * interrupts when the written data is read. Read interrupts should only + * enabled when there is no space left in the buffer to write to, thus the + * interrupt acts as notification that space may be avaliable. If the + * other side does not support enabling/disabling interrupts on demand, + * then this function has no effect if called. + */ +void smd_enable_read_intr(smd_channel_t *ch); + +/* Tells the other end of the smd channel that this end does not want + * interrupts when written data is read. The interrupts should be + * disabled by default. If the other side does not support enabling/ + * disabling interrupts on demand, then this function has no effect if + * called. + */ +void smd_disable_read_intr(smd_channel_t *ch); + +/** + * Enable/disable receive interrupts for the remote processor used by a + * particular channel. + * @ch: open channel handle to use for the edge + * @mask: 1 = mask interrupts; 0 = unmask interrupts + * @cpumask cpumask for the next cpu scheduled to be woken up + * @returns: 0 for success; < 0 for failure + * + * Note that this enables/disables all interrupts from the remote subsystem for + * all channels. As such, it should be used with care and only for specific + * use cases such as power-collapse sequencing. + */ +int smd_mask_receive_interrupt(smd_channel_t *ch, bool mask, + const struct cpumask *cpumask); + +/* Starts a packet transaction. The size of the packet may exceed the total + * size of the smd ring buffer. + * + * @ch: channel to write the packet to + * @len: total length of the packet + * + * Returns: + * 0 - success + * -ENODEV - invalid smd channel + * -EACCES - non-packet channel specified + * -EINVAL - invalid length + * -EBUSY - transaction already in progress + * -EAGAIN - no enough memory in ring buffer to start transaction + * -EPERM - unable to sucessfully start transaction due to write error + */ +int smd_write_start(smd_channel_t *ch, int len); + +/* Writes a segment of the packet for a packet transaction. + * + * @ch: channel to write packet to + * @data: buffer of data to write + * @len: length of data buffer + * + * Returns: + * number of bytes written + * -ENODEV - invalid smd channel + * -EINVAL - invalid length + * -ENOEXEC - transaction not started + */ +int smd_write_segment(smd_channel_t *ch, const void *data, int len); + +/* Completes a packet transaction. Do not call from interrupt context. + * + * @ch: channel to complete transaction on + * + * Returns: + * 0 - success + * -ENODEV - invalid smd channel + * -E2BIG - some ammount of packet is not yet written + */ +int smd_write_end(smd_channel_t *ch); + +/** + * smd_write_segment_avail() - available write space for packet transactions + * @ch: channel to write packet to + * @returns: number of bytes available to write to, or -ENODEV for invalid ch + * + * This is a version of smd_write_avail() intended for use with packet + * transactions. This version correctly accounts for any internal reserved + * space at all stages of the transaction. + */ +int smd_write_segment_avail(smd_channel_t *ch); + +/* + * Returns a pointer to the subsystem name or NULL if no + * subsystem name is available. + * + * @type - Edge definition + */ +const char *smd_edge_to_subsystem(uint32_t type); + +/* + * Returns a pointer to the subsystem name given the + * remote processor ID. + * + * @pid Remote processor ID + * @returns Pointer to subsystem name or NULL if not found + */ +const char *smd_pid_to_subsystem(uint32_t pid); + +/* + * Checks to see if a new packet has arrived on the channel. Only to be + * called with interrupts disabled. + * + * @ch: channel to check if a packet has arrived + * + * Returns: + * 0 - packet not available + * 1 - packet available + * -EINVAL - NULL parameter or non-packet based channel provided + */ +int smd_is_pkt_avail(smd_channel_t *ch); + +/* + * SMD initialization function that registers for a SMD platform driver. + * + * returns success on successful driver registration. + */ +int __init msm_smd_init(void); + +/** + * smd_remote_ss_to_edge() - return edge type from remote ss type + * @name: remote subsystem name + * + * Returns the edge type connected between the local subsystem(APPS) + * and remote subsystem @name. + */ +int smd_remote_ss_to_edge(const char *name); + +/** + * smd_edge_to_pil_str - Returns the PIL string used to load the remote side of + * the indicated edge. + * + * @type - Edge definition + * @returns - The PIL string to load the remove side of @type or NULL if the + * PIL string does not exist. + */ +const char *smd_edge_to_pil_str(uint32_t type); + +#else + +static inline int smd_close(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline int smd_read(smd_channel_t *ch, void *data, int len) +{ + return -ENODEV; +} + +static inline int smd_read_from_cb(smd_channel_t *ch, void *data, int len) +{ + return -ENODEV; +} + +static inline int smd_write(smd_channel_t *ch, const void *data, int len) +{ + return -ENODEV; +} + +static inline int smd_write_avail(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline int smd_read_avail(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline int smd_cur_packet_size(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline int smd_tiocmget(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline int +smd_tiocmset(smd_channel_t *ch, unsigned int set, unsigned int clear) +{ + return -ENODEV; +} + +static inline int +smd_tiocmset_from_cb(smd_channel_t *ch, unsigned int set, unsigned int clear) +{ + return -ENODEV; +} + +static inline int +smd_named_open_on_edge(const char *name, uint32_t edge, smd_channel_t **_ch, + void *priv, void (*notify)(void *, unsigned)) +{ + return -ENODEV; +} + +static inline void smd_enable_read_intr(smd_channel_t *ch) +{ +} + +static inline void smd_disable_read_intr(smd_channel_t *ch) +{ +} + +static inline int smd_mask_receive_interrupt(smd_channel_t *ch, bool mask, + const struct cpumask *cpumask) +{ + return -ENODEV; +} + +static inline int smd_write_start(smd_channel_t *ch, int len) +{ + return -ENODEV; +} + +static inline int +smd_write_segment(smd_channel_t *ch, const void *data, int len) +{ + return -ENODEV; +} + +static inline int smd_write_end(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline int smd_write_segment_avail(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline const char *smd_edge_to_subsystem(uint32_t type) +{ + return NULL; +} + +static inline const char *smd_pid_to_subsystem(uint32_t pid) +{ + return NULL; +} + +static inline int smd_is_pkt_avail(smd_channel_t *ch) +{ + return -ENODEV; +} + +static inline int __init msm_smd_init(void) +{ + return 0; +} + +static inline int smd_remote_ss_to_edge(const char *name) +{ + return -EINVAL; +} + +static inline const char *smd_edge_to_pil_str(uint32_t type) +{ + return NULL; +} +#endif + +#endif diff --git a/include/soc/qcom/smem.h b/include/soc/qcom/smem.h new file mode 100644 index 000000000000..4117b0d47b0d --- /dev/null +++ b/include/soc/qcom/smem.h @@ -0,0 +1,248 @@ +/* Copyright (c) 2013-2016, 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 _ARCH_ARM_MACH_MSM_SMEM_H_ +#define _ARCH_ARM_MACH_MSM_SMEM_H_ + +#include <linux/types.h> + +enum { + SMEM_APPS, + SMEM_MODEM, + SMEM_Q6, + SMEM_DSPS, + SMEM_WCNSS, + SMEM_MODEM_Q6_FW, + SMEM_CDSP = SMEM_MODEM_Q6_FW, + SMEM_RPM, + SMEM_TZ, + SMEM_SPSS, + SMEM_HYP, + NUM_SMEM_SUBSYSTEMS, +}; + +/* + * Flag options for the XXX_to_proc() API + * + * SMEM_ITEM_CACHED_FLAG - Indicates this operation should use cachable smem + * + * SMEM_ANY_HOST_FLAG - Indicates this operation should not apply to smem items + * which are limited to a specific host pairing. Will + * cause this operation to ignore the to_proc parameter. + */ +#define SMEM_ITEM_CACHED_FLAG 1 +#define SMEM_ANY_HOST_FLAG 2 + +#define SMEM_NUM_SMD_STREAM_CHANNELS 64 + +/** + * OVERFLOW_ADD_UNSIGNED() - check for unsigned overflow + * + * @type: type to check for overflow + * @a: left value to use + * @b: right value to use + * @returns: true if a + b will result in overflow; false otherwise + */ +#define OVERFLOW_ADD_UNSIGNED(type, a, b) \ + (((type)~0 - (a)) < (b) ? true : false) + +enum { + /* fixed items */ + SMEM_PROC_COMM = 0, + SMEM_HEAP_INFO, + SMEM_ALLOCATION_TABLE, + SMEM_VERSION_INFO, + SMEM_HW_RESET_DETECT, + SMEM_AARM_WARM_BOOT, + SMEM_DIAG_ERR_MESSAGE, + SMEM_SPINLOCK_ARRAY, + SMEM_MEMORY_BARRIER_LOCATION, + SMEM_FIXED_ITEM_LAST = SMEM_MEMORY_BARRIER_LOCATION, + + /* dynamic items */ + SMEM_AARM_PARTITION_TABLE, + SMEM_AARM_BAD_BLOCK_TABLE, + SMEM_ERR_CRASH_LOG_ADSP, + SMEM_WM_UUID, + SMEM_CHANNEL_ALLOC_TBL, + SMEM_SMD_BASE_ID, + SMEM_SMEM_LOG_IDX = SMEM_SMD_BASE_ID + SMEM_NUM_SMD_STREAM_CHANNELS, + SMEM_SMEM_LOG_EVENTS, + SMEM_XBL_LOADER_CORE_INFO, + SMEM_SMEM_STATIC_LOG_EVENTS, + SMEM_CHARGER_BATTERY_INFO = SMEM_SMEM_STATIC_LOG_EVENTS, + SMEM_SMEM_SLOW_CLOCK_SYNC, + SMEM_WLAN_CONFIG = SMEM_SMEM_SLOW_CLOCK_SYNC, + SMEM_SMEM_SLOW_CLOCK_VALUE, + SMEM_BIO_LED_BUF, + SMEM_SMSM_SHARED_STATE, + SMEM_SMSM_INT_INFO, + SMEM_SMSM_SLEEP_DELAY, + SMEM_SMSM_LIMIT_SLEEP, + SMEM_SLEEP_POWER_COLLAPSE_DISABLED, + SMEM_KEYPAD_KEYS_PRESSED, + SMEM_KEYPAD_STATE_UPDATED, + SMEM_KEYPAD_STATE_IDX, + SMEM_GPIO_INT, + SMEM_SMP2P_CDSP_BASE, + SMEM_SMD_PROFILES = SMEM_SMP2P_CDSP_BASE + 8, + SMEM_TSSC_BUSY, + SMEM_HS_SUSPEND_FILTER_INFO, + SMEM_BATT_INFO, + SMEM_APPS_BOOT_MODE, + SMEM_VERSION_FIRST, + SMEM_VERSION_SMD = SMEM_VERSION_FIRST, + SMEM_VERSION_LAST = SMEM_VERSION_FIRST + 24, + SMEM_OSS_RRCASN1_BUF1, + SMEM_OSS_RRCASN1_BUF2, + SMEM_ID_VENDOR0, + SMEM_ID_VENDOR1, + SMEM_ID_VENDOR2, + SMEM_HW_SW_BUILD_ID, + SMEM_SMD_BASE_ID_2, + SMEM_SMD_FIFO_BASE_ID_2 = SMEM_SMD_BASE_ID_2 + + SMEM_NUM_SMD_STREAM_CHANNELS, + SMEM_CHANNEL_ALLOC_TBL_2 = SMEM_SMD_FIFO_BASE_ID_2 + + SMEM_NUM_SMD_STREAM_CHANNELS, + SMEM_I2C_MUTEX = SMEM_CHANNEL_ALLOC_TBL_2 + + SMEM_NUM_SMD_STREAM_CHANNELS, + SMEM_SCLK_CONVERSION, + SMEM_SMD_SMSM_INTR_MUX, + SMEM_SMSM_CPU_INTR_MASK, + SMEM_APPS_DEM_SLAVE_DATA, + SMEM_QDSP6_DEM_SLAVE_DATA, + SMEM_VSENSE_DATA, + SMEM_CLKREGIM_SOURCES, + SMEM_SMD_FIFO_BASE_ID, + SMEM_USABLE_RAM_PARTITION_TABLE = SMEM_SMD_FIFO_BASE_ID + + SMEM_NUM_SMD_STREAM_CHANNELS, + SMEM_POWER_ON_STATUS_INFO, + SMEM_DAL_AREA, + SMEM_SMEM_LOG_POWER_IDX, + SMEM_SMEM_LOG_POWER_WRAP, + SMEM_SMEM_LOG_POWER_EVENTS, + SMEM_ERR_CRASH_LOG, + SMEM_ERR_F3_TRACE_LOG, + SMEM_SMD_BRIDGE_ALLOC_TABLE, + SMEM_SMDLITE_TABLE, + SMEM_SD_IMG_UPGRADE_STATUS, + SMEM_SEFS_INFO, + SMEM_RESET_LOG, + SMEM_RESET_LOG_SYMBOLS, + SMEM_MODEM_SW_BUILD_ID, + SMEM_SMEM_LOG_MPROC_WRAP, + SMEM_BOOT_INFO_FOR_APPS, + SMEM_SMSM_SIZE_INFO, + SMEM_SMD_LOOPBACK_REGISTER, + SMEM_SSR_REASON_MSS0, + SMEM_SSR_REASON_WCNSS0, + SMEM_SSR_REASON_LPASS0, + SMEM_SSR_REASON_DSPS0, + SMEM_SSR_REASON_VCODEC0, + SMEM_SMP2P_APPS_BASE = 427, + SMEM_SMP2P_MODEM_BASE = SMEM_SMP2P_APPS_BASE + 8, /* 435 */ + SMEM_SMP2P_AUDIO_BASE = SMEM_SMP2P_MODEM_BASE + 8, /* 443 */ + SMEM_SMP2P_WIRLESS_BASE = SMEM_SMP2P_AUDIO_BASE + 8, /* 451 */ + SMEM_SMP2P_POWER_BASE = SMEM_SMP2P_WIRLESS_BASE + 8, /* 459 */ + SMEM_FLASH_DEVICE_INFO = SMEM_SMP2P_POWER_BASE + 8, /* 467 */ + SMEM_BAM_PIPE_MEMORY, /* 468 */ + SMEM_IMAGE_VERSION_TABLE, /* 469 */ + SMEM_LC_DEBUGGER, /* 470 */ + SMEM_FLASH_NAND_DEV_INFO, /* 471 */ + SMEM_A2_BAM_DESCRIPTOR_FIFO, /* 472 */ + SMEM_CPR_CONFIG, /* 473 */ + SMEM_CLOCK_INFO, /* 474 */ + SMEM_IPC_FIFO, /* 475 */ + SMEM_RF_EEPROM_DATA, /* 476 */ + SMEM_COEX_MDM_WCN, /* 477 */ + SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, /* 478 */ + SMEM_GLINK_NATIVE_XPRT_FIFO_0, /* 479 */ + SMEM_GLINK_NATIVE_XPRT_FIFO_1, /* 480 */ + SMEM_SMP2P_SENSOR_BASE, /* 481 */ + SMEM_SMP2P_TZ_BASE = SMEM_SMP2P_SENSOR_BASE + 8, /* 489 */ + SMEM_IPA_FILTER_TABLE = SMEM_SMP2P_TZ_BASE + 8, /* 497 */ + SMEM_NUM_ITEMS, /* 498 */ +}; + +#ifdef CONFIG_MSM_SMEM +void *smem_alloc(unsigned id, unsigned size_in, unsigned to_proc, + unsigned flags); +void *smem_find(unsigned id, unsigned size_in, unsigned to_proc, + unsigned flags); +void *smem_get_entry(unsigned id, unsigned *size, unsigned to_proc, + unsigned flags); + +/** + * smem_get_entry_no_rlock - Get existing item without using remote spinlock + * + * @id: ID of SMEM item + * @size_out: Pointer to size variable for storing the result + * @to_proc: SMEM host that shares the item with apps + * @flags: Item attribute flags + * @returns: Pointer to SMEM item or NULL if it doesn't exist + * + * This function does not lock the remote spinlock and should only be used in + * failure-recover cases such as retrieving the subsystem failure reason during + * subsystem restart. + */ +void *smem_get_entry_no_rlock(unsigned id, unsigned *size_out, unsigned to_proc, + unsigned flags); + +/** + * smem_virt_to_phys() - Convert SMEM address to physical address. + * + * @smem_address: Virtual address returned by smem_alloc() + * @returns: Physical address (or NULL if there is a failure) + * + * This function should only be used if an SMEM item needs to be handed + * off to a DMA engine. + */ +phys_addr_t smem_virt_to_phys(void *smem_address); + +/** + * SMEM initialization function that registers for a SMEM platform driver. + * + * @returns: success on successful driver registration. + */ +int __init msm_smem_init(void); + +#else +static inline void *smem_alloc(unsigned id, unsigned size_in, unsigned to_proc, + unsigned flags) +{ + return NULL; +} +static inline void *smem_find(unsigned id, unsigned size_in, + unsigned to_proc, unsigned flags) +{ + return NULL; +} +static inline void *smem_get_entry(unsigned id, unsigned *size, + unsigned to_proc, unsigned flags) +{ + return NULL; +} +static inline void *smem_get_entry_no_rlock(unsigned id, unsigned *size_out, + unsigned to_proc, unsigned flags) +{ + return NULL; +} +static inline phys_addr_t smem_virt_to_phys(void *smem_address) +{ + return (phys_addr_t) NULL; +} +static inline int __init msm_smem_init(void) +{ + return 0; +} +#endif /* CONFIG_MSM_SMEM */ +#endif /* _ARCH_ARM_MACH_MSM_SMEM_H_ */ diff --git a/include/soc/qcom/smem_log.h b/include/soc/qcom/smem_log.h new file mode 100644 index 000000000000..85b8bfd6d514 --- /dev/null +++ b/include/soc/qcom/smem_log.h @@ -0,0 +1,72 @@ +/* Copyright (c) 2008-2009, 2012-2014, 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/types.h> + +/* Event indentifier format: + * bit 31-28 is processor ID 8 => apps, 4 => Q6, 0 => modem + * bits 27-16 are subsystem id (event base) + * bits 15-0 are event id + */ + +#define PROC 0xF0000000 +#define SUB 0x0FFF0000 +#define ID 0x0000FFFF + +#define SMEM_LOG_PROC_ID_MODEM 0x00000000 +#define SMEM_LOG_PROC_ID_Q6 0x40000000 +#define SMEM_LOG_PROC_ID_APPS 0x80000000 +#define SMEM_LOG_PROC_ID_WCNSS 0xC0000000 + +#define SMEM_LOG_CONT 0x10000000 + +#define SMEM_LOG_SMEM_EVENT_BASE 0x00020000 +#define SMEM_LOG_ERROR_EVENT_BASE 0x00060000 +#define SMEM_LOG_IPC_ROUTER_EVENT_BASE 0x000D0000 +#define SMEM_LOG_QMI_CCI_EVENT_BASE 0x000E0000 +#define SMEM_LOG_QMI_CSI_EVENT_BASE 0x000F0000 +#define ERR_ERROR_FATAL (SMEM_LOG_ERROR_EVENT_BASE + 1) +#define ERR_ERROR_FATAL_TASK (SMEM_LOG_ERROR_EVENT_BASE + 2) +#define SMEM_LOG_EVENT_CB (SMEM_LOG_SMEM_EVENT_BASE + 0) +#define SMEM_LOG_EVENT_START (SMEM_LOG_SMEM_EVENT_BASE + 1) +#define SMEM_LOG_EVENT_INIT (SMEM_LOG_SMEM_EVENT_BASE + 2) +#define SMEM_LOG_EVENT_RUNNING (SMEM_LOG_SMEM_EVENT_BASE + 3) +#define SMEM_LOG_EVENT_STOP (SMEM_LOG_SMEM_EVENT_BASE + 4) +#define SMEM_LOG_EVENT_RESTART (SMEM_LOG_SMEM_EVENT_BASE + 5) +#define SMEM_LOG_EVENT_SS (SMEM_LOG_SMEM_EVENT_BASE + 6) +#define SMEM_LOG_EVENT_READ (SMEM_LOG_SMEM_EVENT_BASE + 7) +#define SMEM_LOG_EVENT_WRITE (SMEM_LOG_SMEM_EVENT_BASE + 8) +#define SMEM_LOG_EVENT_SIGS1 (SMEM_LOG_SMEM_EVENT_BASE + 9) +#define SMEM_LOG_EVENT_SIGS2 (SMEM_LOG_SMEM_EVENT_BASE + 10) +#define SMEM_LOG_EVENT_WRITE_DM (SMEM_LOG_SMEM_EVENT_BASE + 11) +#define SMEM_LOG_EVENT_READ_DM (SMEM_LOG_SMEM_EVENT_BASE + 12) +#define SMEM_LOG_EVENT_SKIP_DM (SMEM_LOG_SMEM_EVENT_BASE + 13) +#define SMEM_LOG_EVENT_STOP_DM (SMEM_LOG_SMEM_EVENT_BASE + 14) +#define SMEM_LOG_EVENT_ISR (SMEM_LOG_SMEM_EVENT_BASE + 15) +#define SMEM_LOG_EVENT_TASK (SMEM_LOG_SMEM_EVENT_BASE + 16) +#define SMEM_LOG_EVENT_RS (SMEM_LOG_SMEM_EVENT_BASE + 17) + +#ifdef CONFIG_MSM_SMEM_LOGGING +void smem_log_event(uint32_t id, uint32_t data1, uint32_t data2, + uint32_t data3); +void smem_log_event6(uint32_t id, uint32_t data1, uint32_t data2, + uint32_t data3, uint32_t data4, uint32_t data5, + uint32_t data6); +#else +void smem_log_event(uint32_t id, uint32_t data1, uint32_t data2, + uint32_t data3) { } +void smem_log_event6(uint32_t id, uint32_t data1, uint32_t data2, + uint32_t data3, uint32_t data4, uint32_t data5, + uint32_t data6) { } +#endif + diff --git a/include/soc/qcom/smsm.h b/include/soc/qcom/smsm.h new file mode 100644 index 000000000000..96ca0c86912c --- /dev/null +++ b/include/soc/qcom/smsm.h @@ -0,0 +1,147 @@ +/* Copyright (c) 2011-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. + */ + +#ifndef _ARCH_ARM_MACH_MSM_SMSM_H_ +#define _ARCH_ARM_MACH_MSM_SMSM_H_ + +#include <soc/qcom/smem.h> + +enum { + SMSM_APPS_STATE, + SMSM_MODEM_STATE, + SMSM_Q6_STATE, + SMSM_APPS_DEM, + SMSM_WCNSS_STATE = SMSM_APPS_DEM, + SMSM_MODEM_DEM, + SMSM_DSPS_STATE = SMSM_MODEM_DEM, + SMSM_Q6_DEM, + SMSM_POWER_MASTER_DEM, + SMSM_TIME_MASTER_DEM, +}; +extern uint32_t SMSM_NUM_ENTRIES; + +/* + * Ordered by when processors adopted the SMSM protocol. May not be 1-to-1 + * with SMEM PIDs, despite initial expectations. + */ +enum { + SMSM_APPS = SMEM_APPS, + SMSM_MODEM = SMEM_MODEM, + SMSM_Q6 = SMEM_Q6, + SMSM_WCNSS, + SMSM_DSPS, +}; +extern uint32_t SMSM_NUM_HOSTS; + +#define SMSM_INIT 0x00000001 +#define SMSM_SMDINIT 0x00000008 +#define SMSM_RPCINIT 0x00000020 +#define SMSM_RESET 0x00000040 +#define SMSM_TIMEWAIT 0x00000400 +#define SMSM_TIMEINIT 0x00000800 +#define SMSM_PROC_AWAKE 0x00001000 +#define SMSM_SMD_LOOPBACK 0x00800000 + +#define SMSM_USB_PLUG_UNPLUG 0x00002000 + +#define SMSM_A2_POWER_CONTROL 0x00000002 +#define SMSM_A2_POWER_CONTROL_ACK 0x00000800 + +#ifdef CONFIG_MSM_SMD +int smsm_change_state(uint32_t smsm_entry, + uint32_t clear_mask, uint32_t set_mask); + +/* + * Changes the global interrupt mask. The set and clear masks are re-applied + * every time the global interrupt mask is updated for callback registration + * and de-registration. + * + * The clear mask is applied first, so if a bit is set to 1 in both the clear + * mask and the set mask, the result will be that the interrupt is set. + * + * @smsm_entry SMSM entry to change + * @clear_mask 1 = clear bit, 0 = no-op + * @set_mask 1 = set bit, 0 = no-op + * + * @returns 0 for success, < 0 for error + */ +int smsm_change_intr_mask(uint32_t smsm_entry, + uint32_t clear_mask, uint32_t set_mask); +int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask); +uint32_t smsm_get_state(uint32_t smsm_entry); +int smsm_state_cb_register(uint32_t smsm_entry, uint32_t mask, + void (*notify)(void *, uint32_t old_state, uint32_t new_state), + void *data); +int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask, + void (*notify)(void *, uint32_t, uint32_t), void *data); + +#else +static inline int smsm_change_state(uint32_t smsm_entry, + uint32_t clear_mask, uint32_t set_mask) +{ + return -ENODEV; +} + +/* + * Changes the global interrupt mask. The set and clear masks are re-applied + * every time the global interrupt mask is updated for callback registration + * and de-registration. + * + * The clear mask is applied first, so if a bit is set to 1 in both the clear + * mask and the set mask, the result will be that the interrupt is set. + * + * @smsm_entry SMSM entry to change + * @clear_mask 1 = clear bit, 0 = no-op + * @set_mask 1 = set bit, 0 = no-op + * + * @returns 0 for success, < 0 for error + */ +static inline int smsm_change_intr_mask(uint32_t smsm_entry, + uint32_t clear_mask, uint32_t set_mask) +{ + return -ENODEV; +} + +static inline int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask) +{ + return -ENODEV; +} +static inline uint32_t smsm_get_state(uint32_t smsm_entry) +{ + return 0; +} +static inline int smsm_state_cb_register(uint32_t smsm_entry, uint32_t mask, + void (*notify)(void *, uint32_t old_state, uint32_t new_state), + void *data) +{ + return -ENODEV; +} +static inline int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask, + void (*notify)(void *, uint32_t, uint32_t), void *data) +{ + return -ENODEV; +} +static inline void smsm_reset_modem(unsigned mode) +{ +} +static inline void smsm_reset_modem_cont(void) +{ +} +static inline void smd_sleep_exit(void) +{ +} +static inline int smsm_check_for_modem_crash(void) +{ + return -ENODEV; +} +#endif +#endif diff --git a/include/soc/qcom/socinfo.h b/include/soc/qcom/socinfo.h new file mode 100644 index 000000000000..6b11533685a5 --- /dev/null +++ b/include/soc/qcom/socinfo.h @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2009-2018, 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 _ARCH_ARM_MACH_MSM_SOCINFO_H_ +#define _ARCH_ARM_MACH_MSM_SOCINFO_H_ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/errno.h> +#include <linux/of_fdt.h> +#include <linux/of.h> + +#include <asm/cputype.h> +/* + * SOC version type with major number in the upper 16 bits and minor + * number in the lower 16 bits. For example: + * 1.0 -> 0x00010000 + * 2.3 -> 0x00020003 + */ +#define SOCINFO_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) +#define SOCINFO_VERSION_MINOR(ver) ((ver) & 0x0000ffff) +#define SOCINFO_VERSION(maj, min) ((((maj) & 0xffff) << 16)|((min) & 0xffff)) + +#ifdef CONFIG_OF +#define of_board_is_cdp() of_machine_is_compatible("qcom,cdp") +#define of_board_is_sim() of_machine_is_compatible("qcom,sim") +#define of_board_is_rumi() of_machine_is_compatible("qcom,rumi") +#define of_board_is_fluid() of_machine_is_compatible("qcom,fluid") +#define of_board_is_liquid() of_machine_is_compatible("qcom,liquid") +#define of_board_is_dragonboard() \ + of_machine_is_compatible("qcom,dragonboard") +#define of_board_is_cdp() of_machine_is_compatible("qcom,cdp") +#define of_board_is_mtp() of_machine_is_compatible("qcom,mtp") +#define of_board_is_qrd() of_machine_is_compatible("qcom,qrd") +#define of_board_is_xpm() of_machine_is_compatible("qcom,xpm") +#define of_board_is_skuf() of_machine_is_compatible("qcom,skuf") +#define of_board_is_sbc() of_machine_is_compatible("qcom,sbc") + +#define machine_is_msm8974() of_machine_is_compatible("qcom,msm8974") +#define machine_is_msm9625() of_machine_is_compatible("qcom,msm9625") +#define machine_is_msm8610() of_machine_is_compatible("qcom,msm8610") +#define machine_is_msm8226() of_machine_is_compatible("qcom,msm8226") +#define machine_is_apq8074() of_machine_is_compatible("qcom,apq8074") +#define machine_is_msm8926() of_machine_is_compatible("qcom,msm8926") + +#define early_machine_is_msm8610() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8610") +#define early_machine_is_msm8909() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8909") +#define early_machine_is_msm8916() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8916") +#define early_machine_is_msm8936() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8936") +#define early_machine_is_msm8939() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8939") +#define early_machine_is_apq8084() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,apq8084") +#define early_machine_is_mdm9630() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,mdm9630") +#define early_machine_is_msmzirc() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msmzirc") +#define early_machine_is_fsm9900() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,fsm9900") +#define early_machine_is_msm8994() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8994") +#define early_machine_is_msm8992() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8992") +#define early_machine_is_fsm9010() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,fsm9010") +#define early_machine_is_msm8976() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8976") +#define early_machine_is_msmtellurium() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msmtellurium") +#define early_machine_is_msm8996() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8996") +#define early_machine_is_msm8929() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8929") +#define early_machine_is_msm8998() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8998") +#define early_machine_is_apq8098() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,apq8098") +#define early_machine_is_msmhamster() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msmhamster") +#define early_machine_is_sdm660() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sdm660") +#define early_machine_is_sda660() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sda660") +#define early_machine_is_sdm455() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sdm455") +#define early_machine_is_sdm636() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sdm636") +#define early_machine_is_sda636() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sda636") +#define early_machine_is_sdm658() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sdm658") +#define early_machine_is_sda658() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sda658") +#define early_machine_is_sdm630() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sdm630") +#define early_machine_is_sda630() \ + of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,sda630") +#else +#define of_board_is_sim() 0 +#define of_board_is_rumi() 0 +#define of_board_is_fluid() 0 +#define of_board_is_liquid() 0 +#define of_board_is_dragonboard() 0 +#define of_board_is_cdp() 0 +#define of_board_is_mtp() 0 +#define of_board_is_qrd() 0 +#define of_board_is_xpm() 0 +#define of_board_is_skuf() 0 +#define of_board_is_sbc() 0 + +#define machine_is_msm8974() 0 +#define machine_is_msm9625() 0 +#define machine_is_msm8610() 0 +#define machine_is_msm8226() 0 +#define machine_is_apq8074() 0 +#define machine_is_msm8926() 0 + +#define early_machine_is_msm8610() 0 +#define early_machine_is_msm8909() 0 +#define early_machine_is_msm8916() 0 +#define early_machine_is_msm8936() 0 +#define early_machine_is_msm8939() 0 +#define early_machine_is_apq8084() 0 +#define early_machine_is_mdm9630() 0 +#define early_machine_is_fsm9900() 0 +#define early_machine_is_fsm9010() 0 +#define early_machine_is_msmtellurium() 0 +#define early_machine_is_msm8996() 0 +#define early_machine_is_msm8976() 0 +#define early_machine_is_msm8929() 0 +#define early_machine_is_msm8998() 0 +#define early_machine_is_apq8098() 0 +#define early_machine_is_msmhamster() 0 +#define early_machine_is_sdm660() 0 +#define early_machine_is_sda660() 0 +#define early_machine_is_sdm455() 0 +#define early_machine_is_sdm636() 0 +#define early_machine_is_sda636() 0 +#define early_machine_is_sdm658() 0 +#define early_machine_is_sda658() 0 +#define early_machine_is_sdm630() 0 +#define early_machine_is_sda630() 0 +#endif + +#define PLATFORM_SUBTYPE_MDM 1 +#define PLATFORM_SUBTYPE_INTERPOSERV3 2 +#define PLATFORM_SUBTYPE_SGLTE 6 + +enum msm_cpu { + MSM_CPU_UNKNOWN = 0, + MSM_CPU_7X01, + MSM_CPU_7X25, + MSM_CPU_7X27, + MSM_CPU_8X50, + MSM_CPU_8X50A, + MSM_CPU_7X30, + MSM_CPU_8X55, + MSM_CPU_8X60, + MSM_CPU_8960, + MSM_CPU_8960AB, + MSM_CPU_7X27A, + FSM_CPU_9XXX, + MSM_CPU_7X25A, + MSM_CPU_7X25AA, + MSM_CPU_7X25AB, + MSM_CPU_8064, + MSM_CPU_8064AB, + MSM_CPU_8064AA, + MSM_CPU_8930, + MSM_CPU_8930AA, + MSM_CPU_8930AB, + MSM_CPU_7X27AA, + MSM_CPU_9615, + MSM_CPU_8974, + MSM_CPU_8974PRO_AA, + MSM_CPU_8974PRO_AB, + MSM_CPU_8974PRO_AC, + MSM_CPU_8627, + MSM_CPU_8625, + MSM_CPU_9625, + MSM_CPU_8909, + MSM_CPU_8916, + MSM_CPU_8936, + MSM_CPU_8939, + MSM_CPU_8226, + MSM_CPU_8610, + MSM_CPU_8625Q, + MSM_CPU_8084, + MSM_CPU_9630, + FSM_CPU_9900, + MSM_CPU_ZIRC, + MSM_CPU_8994, + MSM_CPU_8992, + FSM_CPU_9010, + MSM_CPU_TELLURIUM, + MSM_CPU_8996, + MSM_CPU_8976, + MSM_CPU_8929, + MSM_CPU_8998, + MSM_CPU_HAMSTER, + MSM_CPU_660, + MSM_CPU_455, + MSM_CPU_630, + MSM_CPU_636, +}; + +struct msm_soc_info { + enum msm_cpu generic_soc_type; + char *soc_id_string; +}; + +enum pmic_model { + PMIC_MODEL_PM8058 = 13, + PMIC_MODEL_PM8028 = 14, + PMIC_MODEL_PM8901 = 15, + PMIC_MODEL_PM8027 = 16, + PMIC_MODEL_ISL_9519 = 17, + PMIC_MODEL_PM8921 = 18, + PMIC_MODEL_PM8018 = 19, + PMIC_MODEL_PM8015 = 20, + PMIC_MODEL_PM8014 = 21, + PMIC_MODEL_PM8821 = 22, + PMIC_MODEL_PM8038 = 23, + PMIC_MODEL_PM8922 = 24, + PMIC_MODEL_PM8917 = 25, + PMIC_MODEL_UNKNOWN = 0xFFFFFFFF +}; + +enum msm_cpu socinfo_get_msm_cpu(void); +uint32_t socinfo_get_id(void); +uint32_t socinfo_get_version(void); +uint32_t socinfo_get_raw_id(void); +char *socinfo_get_build_id(void); +uint32_t socinfo_get_platform_type(void); +uint32_t socinfo_get_platform_subtype(void); +uint32_t socinfo_get_platform_version(void); +uint32_t socinfo_get_serial_number(void); +enum pmic_model socinfo_get_pmic_model(void); +uint32_t socinfo_get_pmic_die_revision(void); +int __init socinfo_init(void) __must_check; + +#endif diff --git a/include/soc/qcom/spcom.h b/include/soc/qcom/spcom.h new file mode 100644 index 000000000000..f234591ed8dd --- /dev/null +++ b/include/soc/qcom/spcom.h @@ -0,0 +1,223 @@ +/* Copyright (c) 2015-2016, 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 _SPCOM_H_ +#define _SPCOM_H_ + +#include <linux/types.h> /* uint32_t ,bool */ + +/** + * @brief - Secure Processor Communication API + * + * This API should be used by Linux Kernel drivers, + * similar API is provided to user space applications + * via spcomlib.h API file. + * Sending Request and receiving Response is synchronous, only one at a time. + * The API is based on Client/Server model. + * The API resemble the trustzone QSEECOM API. + * In most cases, the Secure Processor side has servers and the HLOS + * side has clients. Request is initiated by the client and responded by the + * server. + */ + +/*===========================================================================*/ +/* defines, enums , types */ +/*===========================================================================*/ + +/* Maximum size (including null) for channel names - match glink */ +#define SPCOM_CHANNEL_NAME_SIZE 32 + +/** + * Request buffer size. + * Any large data (multiply of 4KB) is provided by temp buffer in DDR. + * Request shall provide the temp buffer physical address (align to 4KB). + * Maximum request/response size of 268 is used to accommodate APDU size. + * From kernel spcom driver perspective a PAGE_SIZE of 4K + * is the actual maximum size for a single read/write file operation. + */ +#define SPCOM_MAX_REQUEST_SIZE 268 +#define SPCOM_MAX_RESPONSE_SIZE 268 + +/** + * Abstract spcom handle. + * The actual struct definition is internal to the spcom driver. + */ +struct spcom_client; /* Forward declaration */ +struct spcom_server; /* Forward declaration */ + +/** + * Client registration info + * + * @ch_name: glink logical channel name + * @notify_ssr_cb: callback when the remote SP side reset (power down). + * This is likely to happen due to remote subsystem restart (SSR). + * NULL callback means no notification required. + * Upon ssr callback, the user should unregister, + * Poll for link up and then register again. + */ +struct spcom_client_info { + const char *ch_name; + void (*notify_ssr_cb)(void); +}; + +/** + * Server registration info + * + * @ch_name: glink logical channel name + * @notify_ssr_cb: callback when the remote SP side reset (power down). + * This is likely to happen due to remote subsystem restart (SSR). + * NULL callback means no notification required. + * Upon ssr callback, the user should unregister, + * Poll for link up and then register again. + */ +struct spcom_service_info { + const char *ch_name; + void (*notify_ssr_cb)(void); +}; + +/*===========================================================================*/ +/* General API */ +/*===========================================================================*/ + +/** + * spcom_is_sp_subsystem_link_up() - check if SPSS link is up. + * + * return: true if link is up, false if link is down. + */ +bool spcom_is_sp_subsystem_link_up(void); + +/*===========================================================================*/ +/* Client Send Message */ +/*===========================================================================*/ +/** + * spcom_register_client() - register client for channel + * + * Only one client/Server can register on each side of a channel. + * Server on remote side is expected to be running and connected, + * therefore connection expected within the provided timeout. + * Handle is returned even if timeout expired. + * use spcom_client_is_server_connected() to check fully connected. + * + * @info: Client configuration info (input). + * + * return: client handle on success, NULL on failure. + */ +struct spcom_client *spcom_register_client(struct spcom_client_info *info); + +/** + * spcom_unregister_client() - unregister client for channel + * + * @client: Client Handle. + * + * return: 0 on success, negative error code on failure (see errno.h) + */ +int spcom_unregister_client(struct spcom_client *client); + +/** + * spcom_client_send_message_sync() - Send a synchronous request and response + * + * @client: a pointer to spcom client + * @req_ptr: a pointer to the request C struct representation + * @req_size: size of the request C struct + * @resp_ptr: a pointer to the response C struct representation + * @resp_size: size of the response C struct + * @timeout_msec: Timeout in msec between command and response, 0=no timeout. + * + * return: number of rx bytes on success, negative value on failure. + */ +int spcom_client_send_message_sync(struct spcom_client *client, + void *req_ptr, + uint32_t req_size, + void *resp_ptr, + uint32_t resp_size, + uint32_t timeout_msec); + +/** + * spcom_client_is_server_connected() - Check if remote server connected. + * + * This API checks that the logical channel is fully connected between + * the client and the server. + * Normally, the server should be up first and connect first. + * + * @client: a pointer to spcom client + * + * return: true if server connected, false otherwise. + */ +bool spcom_client_is_server_connected(struct spcom_client *client); + +/*===========================================================================*/ +/* Service */ +/*===========================================================================*/ + +/** + * spcom_register_service() - register server for channel + * + * Only one client/Server can register on each side of a channel. + * + * @info: Server configuration info (input). + * + * return: server handle on success, NULL on failure. + */ +struct spcom_server *spcom_register_service(struct spcom_service_info *info); + +/** + * spcom_unregister_service() - unregister server for channel + * + * @server: server Handle. + * + * return: 0 on success, negative error code on failure (see errno.h) + */ +int spcom_unregister_service(struct spcom_server *server); + +/** + * spcom_server_get_next_request_size() - get the size of the + * next request + * + * This API MUST be called before calling spcom_server_wait_for_request(). + * The server should allocate the relevant buffer size. + * + * @server: a pointer to spcom server + * + * return: size of request in bytes on success, negative value on failure. + */ +int spcom_server_get_next_request_size(struct spcom_server *server); + +/** + * spcom_server_wait_for_request() - server wait for request + * + * @server: a pointer to spcom server + * @req_ptr: a pointer to the request buffer + * @req_size: size of the buffer provided. + * The server should provide a buffer of at least the size + * returned by spcom_server_get_next_request_size() and up to + * SPCOM_MAX_REQUEST_SIZE. + * + * return: size of request on success, negative value on failure (see errno.h) + */ +int spcom_server_wait_for_request(struct spcom_server *server, + void *req_ptr, + uint32_t req_size); + +/** + * spcom_server_send_response() - Send a the response to request + * + * @server: a pointer to spcom server + * @resp_ptr: a pointer to the response C struct representation + * @resp_size: size of the response C struct + * + * return: sent data size on success, negative value on failure (see errno.h) + */ +int spcom_server_send_response(struct spcom_server *server, + void *resp_ptr, + uint32_t resp_size); + +#endif /* _SPCOM_H_ */ diff --git a/include/soc/qcom/spm.h b/include/soc/qcom/spm.h new file mode 100644 index 000000000000..0d199d027258 --- /dev/null +++ b/include/soc/qcom/spm.h @@ -0,0 +1,148 @@ +/* Copyright (c) 2010-2016, 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 __ARCH_ARM_MACH_MSM_SPM_H +#define __ARCH_ARM_MACH_MSM_SPM_H + +enum { + MSM_SPM_MODE_DISABLED, + MSM_SPM_MODE_CLOCK_GATING, + MSM_SPM_MODE_RETENTION, + MSM_SPM_MODE_GDHS, + MSM_SPM_MODE_POWER_COLLAPSE, + MSM_SPM_MODE_STANDALONE_POWER_COLLAPSE, + MSM_SPM_MODE_FASTPC, + MSM_SPM_MODE_NR +}; + +enum msm_spm_avs_irq { + MSM_SPM_AVS_IRQ_MIN, + MSM_SPM_AVS_IRQ_MAX, +}; + +struct msm_spm_device; +struct device_node; + +#if defined(CONFIG_MSM_SPM) + +int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm); +int msm_spm_probe_done(void); +int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel); +int msm_spm_get_vdd(unsigned int cpu); +int msm_spm_turn_on_cpu_rail(struct device_node *l2ccc_node, + unsigned int val, int cpu, int vctl_offset); +struct msm_spm_device *msm_spm_get_device_by_name(const char *name); +int msm_spm_config_low_power_mode(struct msm_spm_device *dev, + unsigned int mode, bool notify_rpm); +int msm_spm_device_init(void); +bool msm_spm_is_mode_avail(unsigned int mode); +void msm_spm_dump_regs(unsigned int cpu); +int msm_spm_is_avs_enabled(unsigned int cpu); +int msm_spm_avs_enable(unsigned int cpu); +int msm_spm_avs_disable(unsigned int cpu); +int msm_spm_avs_set_limit(unsigned int cpu, uint32_t min_lvl, + uint32_t max_lvl); +int msm_spm_avs_enable_irq(unsigned int cpu, enum msm_spm_avs_irq irq); +int msm_spm_avs_disable_irq(unsigned int cpu, enum msm_spm_avs_irq irq); +int msm_spm_avs_clear_irq(unsigned int cpu, enum msm_spm_avs_irq irq); + +#if defined(CONFIG_MSM_L2_SPM) + +/* Public functions */ + +int msm_spm_apcs_set_phase(int cpu, unsigned int phase_cnt); +int msm_spm_enable_fts_lpm(int cpu, uint32_t mode); + +#else + +static inline int msm_spm_apcs_set_phase(int cpu, unsigned int phase_cnt) +{ + return -ENOSYS; +} + +static inline int msm_spm_enable_fts_lpm(int cpu, uint32_t mode) +{ + return -ENOSYS; +} +#endif /* defined(CONFIG_MSM_L2_SPM) */ +#else /* defined(CONFIG_MSM_SPM) */ +static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm) +{ + return -ENOSYS; +} + +static inline int msm_spm_probe_done(void) +{ + return -ENOSYS; +} + +static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel) +{ + return -ENOSYS; +} + +static inline int msm_spm_get_vdd(unsigned int cpu) +{ + return 0; +} + +static inline int msm_spm_turn_on_cpu_rail(struct device_node *l2ccc_node, + unsigned int val, int cpu, int vctl_offset) +{ + return -ENOSYS; +} + +static inline int msm_spm_device_init(void) +{ + return -ENOSYS; +} + +static inline void msm_spm_dump_regs(unsigned int cpu) +{ + return; +} + +static inline int msm_spm_config_low_power_mode(struct msm_spm_device *dev, + unsigned int mode, bool notify_rpm) +{ + return -ENODEV; +} +static inline struct msm_spm_device *msm_spm_get_device_by_name(const char *name) +{ + return NULL; +} + +static inline bool msm_spm_is_mode_avail(unsigned int mode) +{ + return false; +} + +static inline int msm_spm_avs_enable_irq(unsigned int cpu, + enum msm_spm_avs_irq irq) +{ + return -ENOSYS; +} + +static inline int msm_spm_avs_disable_irq(unsigned int cpu, + enum msm_spm_avs_irq irq) +{ + return -ENOSYS; +} + +static inline int msm_spm_avs_clear_irq(unsigned int cpu, + enum msm_spm_avs_irq irq) +{ + return -ENOSYS; +} + +#endif /* defined (CONFIG_MSM_SPM) */ +#endif /* __ARCH_ARM_MACH_MSM_SPM_H */ diff --git a/include/soc/qcom/subsystem_notif.h b/include/soc/qcom/subsystem_notif.h new file mode 100644 index 000000000000..db421ca6e54a --- /dev/null +++ b/include/soc/qcom/subsystem_notif.h @@ -0,0 +1,87 @@ +/* Copyright (c) 2011, 2013 - 2014, 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. + * + * + * Subsystem restart notifier API header + * + */ + +#ifndef _SUBSYS_NOTIFIER_H +#define _SUBSYS_NOTIFIER_H + +#include <linux/notifier.h> + +enum subsys_notif_type { + SUBSYS_BEFORE_SHUTDOWN, + SUBSYS_AFTER_SHUTDOWN, + SUBSYS_BEFORE_POWERUP, + SUBSYS_AFTER_POWERUP, + SUBSYS_RAMDUMP_NOTIFICATION, + SUBSYS_POWERUP_FAILURE, + SUBSYS_PROXY_VOTE, + SUBSYS_PROXY_UNVOTE, + SUBSYS_SOC_RESET, + SUBSYS_NOTIF_TYPE_COUNT +}; + +#if defined(CONFIG_MSM_SUBSYSTEM_RESTART) +/* Use the subsys_notif_register_notifier API to register for notifications for + * a particular subsystem. This API will return a handle that can be used to + * un-reg for notifications using the subsys_notif_unregister_notifier API by + * passing in that handle as an argument. + * + * On receiving a notification, the second (unsigned long) argument of the + * notifier callback will contain the notification type, and the third (void *) + * argument will contain the handle that was returned by + * subsys_notif_register_notifier. + */ +void *subsys_notif_register_notifier( + const char *subsys_name, struct notifier_block *nb); +int subsys_notif_unregister_notifier(void *subsys_handle, + struct notifier_block *nb); + +/* Use the subsys_notif_init_subsys API to initialize the notifier chains form + * a particular subsystem. This API will return a handle that can be used to + * queue notifications using the subsys_notif_queue_notification API by passing + * in that handle as an argument. + */ +void *subsys_notif_add_subsys(const char *); +int subsys_notif_queue_notification(void *subsys_handle, + enum subsys_notif_type notif_type, + void *data); +#else + +static inline void *subsys_notif_register_notifier( + const char *subsys_name, struct notifier_block *nb) +{ + return NULL; +} + +static inline int subsys_notif_unregister_notifier(void *subsys_handle, + struct notifier_block *nb) +{ + return 0; +} + +static inline void *subsys_notif_add_subsys(const char *subsys_name) +{ + return NULL; +} + +static inline int subsys_notif_queue_notification(void *subsys_handle, + enum subsys_notif_type notif_type, + void *data) +{ + return 0; +} +#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */ + +#endif diff --git a/include/soc/qcom/subsystem_restart.h b/include/soc/qcom/subsystem_restart.h new file mode 100644 index 000000000000..9a4d013b363c --- /dev/null +++ b/include/soc/qcom/subsystem_restart.h @@ -0,0 +1,204 @@ +/* Copyright (c) 2014-2017, 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 __SUBSYS_RESTART_H +#define __SUBSYS_RESTART_H + +#include <linux/spinlock.h> +#include <linux/interrupt.h> + +struct subsys_device; +extern struct bus_type subsys_bus_type; + +enum { + RESET_SOC = 0, + RESET_SUBSYS_COUPLED, + RESET_LEVEL_MAX +}; + +enum crash_status { + CRASH_STATUS_NO_CRASH = 0, + CRASH_STATUS_ERR_FATAL, + CRASH_STATUS_WDOG_BITE, +}; + +struct device; +struct module; + +/** + * struct subsys_desc - subsystem descriptor + * @name: name of subsystem + * @fw_name: firmware name + * @depends_on: subsystem this subsystem depends on to operate + * @dev: parent device + * @owner: module the descriptor belongs to + * @shutdown: Stop a subsystem + * @powerup: Start a subsystem + * @crash_shutdown: Shutdown a subsystem when the system crashes (can't sleep) + * @ramdump: Collect a ramdump of the subsystem + * @free_memory: Free the memory associated with this subsystem + * @is_not_loadable: Indicate if subsystem firmware is not loadable via pil + * framework + * @no_auth: Set if subsystem does not rely on PIL to authenticate and bring + * it out of reset + * @ssctl_instance_id: Instance id used to connect with SSCTL service + * @sysmon_pid: pdev id that sysmon is probed with for the subsystem + * @sysmon_shutdown_ret: Return value for the call to sysmon_send_shutdown + * @system_debug: If "set", triggers a device restart when the + * subsystem's wdog bite handler is invoked. + * @ignore_ssr_failure: SSR failures are usually fatal and results in panic. If + * set will ignore failure. + * @edge: GLINK logical name of the subsystem + */ +struct subsys_desc { + const char *name; + char fw_name[256]; + const char *depends_on; + struct device *dev; + struct module *owner; + + int (*shutdown)(const struct subsys_desc *desc, bool force_stop); + int (*powerup)(const struct subsys_desc *desc); + void (*crash_shutdown)(const struct subsys_desc *desc); + int (*ramdump)(int, const struct subsys_desc *desc); + void (*free_memory)(const struct subsys_desc *desc); + irqreturn_t (*err_fatal_handler) (int irq, void *dev_id); + irqreturn_t (*stop_ack_handler) (int irq, void *dev_id); + irqreturn_t (*wdog_bite_handler) (int irq, void *dev_id); + irqreturn_t (*generic_handler)(int irq, void *dev_id); + int is_not_loadable; + int err_fatal_gpio; + unsigned int err_fatal_irq; + unsigned int err_ready_irq; + unsigned int stop_ack_irq; + unsigned int wdog_bite_irq; + unsigned int generic_irq; + int force_stop_gpio; + int ramdump_disable_gpio; + int shutdown_ack_gpio; + int ramdump_disable; + bool no_auth; + bool pil_mss_memsetup; + int ssctl_instance_id; + u32 sysmon_pid; + int sysmon_shutdown_ret; + bool system_debug; + bool ignore_ssr_failure; + const char *edge; +}; + +/** + * struct notif_data - additional notif information + * @crashed: indicates if subsystem has crashed due to wdog bite or err fatal + * @enable_ramdump: ramdumps disabled if set to 0 + * @enable_mini_ramdumps: enable flag for minimized critical-memory-only + * ramdumps + * @no_auth: set if subsystem does not use PIL to bring it out of reset + * @pdev: subsystem platform device pointer + */ +struct notif_data { + enum crash_status crashed; + int enable_ramdump; + int enable_mini_ramdumps; + bool no_auth; + struct platform_device *pdev; +}; + +#if defined(CONFIG_MSM_SUBSYSTEM_RESTART) + +extern int subsys_get_restart_level(struct subsys_device *dev); +extern int subsystem_restart_dev(struct subsys_device *dev); +extern int subsystem_restart(const char *name); +extern int subsystem_crashed(const char *name); + +extern void *subsystem_get(const char *name); +extern void *subsystem_get_with_fwname(const char *name, const char *fw_name); +extern int subsystem_set_fwname(const char *name, const char *fw_name); +extern void subsystem_put(void *subsystem); + +extern struct subsys_device *subsys_register(struct subsys_desc *desc); +extern void subsys_unregister(struct subsys_device *dev); + +extern void subsys_default_online(struct subsys_device *dev); +extern void subsys_set_crash_status(struct subsys_device *dev, + enum crash_status crashed); +extern enum crash_status subsys_get_crash_status(struct subsys_device *dev); +extern void subsys_set_error(struct subsys_device *dev, const char *error_msg); +void notify_proxy_vote(struct device *device); +void notify_proxy_unvote(struct device *device); +void complete_err_ready(struct subsys_device *subsys); +extern int wait_for_shutdown_ack(struct subsys_desc *desc); +#else + +static inline int subsys_get_restart_level(struct subsys_device *dev) +{ + return 0; +} + +static inline int subsystem_restart_dev(struct subsys_device *dev) +{ + return 0; +} + +static inline int subsystem_restart(const char *name) +{ + return 0; +} + +static inline int subsystem_crashed(const char *name) +{ + return 0; +} + +static inline void *subsystem_get(const char *name) +{ + return NULL; +} + +static inline void *subsystem_get_with_fwname(const char *name, + const char *fw_name) { + return NULL; +} + +static inline int subsystem_set_fwname(const char *name, + const char *fw_name) { + return 0; +} + +static inline void subsystem_put(void *subsystem) { } + +static inline +struct subsys_device *subsys_register(struct subsys_desc *desc) +{ + return NULL; +} + +static inline void subsys_unregister(struct subsys_device *dev) { } + +static inline void subsys_default_online(struct subsys_device *dev) { } +static inline void subsys_set_crash_status(struct subsys_device *dev, + enum crash_status crashed) { } +static inline +enum crash_status subsys_get_crash_status(struct subsys_device *dev) +{ + return false; +} +static inline void notify_proxy_vote(struct device *device) { } +static inline void notify_proxy_unvote(struct device *device) { } +static inline int wait_for_shutdown_ack(struct subsys_desc *desc) +{ + return -ENOSYS; +} +#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */ + +#endif diff --git a/include/soc/qcom/sysmon.h b/include/soc/qcom/sysmon.h new file mode 100644 index 000000000000..9c9500a671de --- /dev/null +++ b/include/soc/qcom/sysmon.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2011-2016, 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 __MSM_SYSMON_H +#define __MSM_SYSMON_H + +#include <soc/qcom/smd.h> +#include <soc/qcom/subsystem_notif.h> +#include <soc/qcom/subsystem_restart.h> + +/** + * enum subsys_id - Destination subsystems for events. + */ +enum subsys_id { + /* SMD subsystems */ + SYSMON_SS_MODEM = SMD_APPS_MODEM, + SYSMON_SS_LPASS = SMD_APPS_QDSP, + SYSMON_SS_WCNSS = SMD_APPS_WCNSS, + SYSMON_SS_DSPS = SMD_APPS_DSPS, + SYSMON_SS_Q6FW = SMD_APPS_Q6FW, + + /* Non-SMD subsystems */ + SYSMON_SS_EXT_MODEM = SMD_NUM_TYPE, + SYSMON_NUM_SS +}; + +/** + * enum ssctl_ssr_event_enum_type - Subsystem notification type. + */ +enum ssctl_ssr_event_enum_type { + SSCTL_SSR_EVENT_ENUM_TYPE_MIN_ENUM_VAL = -2147483647, + SSCTL_SSR_EVENT_BEFORE_POWERUP = 0, + SSCTL_SSR_EVENT_AFTER_POWERUP = 1, + SSCTL_SSR_EVENT_BEFORE_SHUTDOWN = 2, + SSCTL_SSR_EVENT_AFTER_SHUTDOWN = 3, + SSCTL_SSR_EVENT_ENUM_TYPE_MAX_ENUM_VAL = 2147483647 +}; + +/** + * enum ssctl_ssr_event_driven_enum_type - Subsystem shutdown type. + */ +enum ssctl_ssr_event_driven_enum_type { + SSCTL_SSR_EVENT_DRIVEN_ENUM_TYPE_MIN_ENUM_VAL = -2147483647, + SSCTL_SSR_EVENT_FORCED = 0, + SSCTL_SSR_EVENT_GRACEFUL = 1, + SSCTL_SSR_EVENT_DRIVEN_ENUM_TYPE_MAX_ENUM_VAL = 2147483647 +}; + +#if defined(CONFIG_MSM_SYSMON_COMM) || defined(CONFIG_MSM_SYSMON_GLINK_COMM) +extern int sysmon_send_event(struct subsys_desc *dest_desc, + struct subsys_desc *event_desc, + enum subsys_notif_type notif); +extern int sysmon_send_event_no_qmi(struct subsys_desc *dest_desc, + struct subsys_desc *event_desc, + enum subsys_notif_type notif); +extern int sysmon_get_reason(struct subsys_desc *dest_desc, char *buf, + size_t len); +extern int sysmon_get_reason_no_qmi(struct subsys_desc *dest_desc, + char *buf, size_t len); +extern int sysmon_send_shutdown(struct subsys_desc *dest_desc); +extern int sysmon_send_shutdown_no_qmi(struct subsys_desc *dest_desc); +extern int sysmon_notifier_register(struct subsys_desc *desc); +extern void sysmon_notifier_unregister(struct subsys_desc *desc); +#else +static inline int sysmon_send_event(struct subsys_desc *dest_desc, + struct subsys_desc *event_desc, + enum subsys_notif_type notif) +{ + return 0; +} +static inline int sysmon_send_event_no_qmi(struct subsys_desc *dest_desc, + struct subsys_desc *event_desc, + enum subsys_notif_type notif) +{ + return 0; +} +static inline int sysmon_get_reason(struct subsys_desc *dest_desc, + char *buf, size_t len) +{ + return 0; +} +static inline int sysmon_get_reason_no_qmi(struct subsys_desc *dest_desc, + char *buf, size_t len) +{ + return 0; +} +static inline int sysmon_send_shutdown(struct subsys_desc *dest_desc) +{ + return 0; +} +static inline int sysmon_send_shutdown_no_qmi(struct subsys_desc *dest_desc) +{ + return 0; +} +static inline int sysmon_notifier_register(struct subsys_desc *desc) +{ + return 0; +} +static inline void sysmon_notifier_unregister(struct subsys_desc *desc) +{ +} +#endif + +#if defined(CONFIG_MSM_SYSMON_GLINK_COMM) +extern int sysmon_glink_register(struct subsys_desc *desc); +extern void sysmon_glink_unregister(struct subsys_desc *desc); +#else +static inline int sysmon_glink_register(struct subsys_desc *desc) +{ + return 0; +} +static inline void sysmon_glink_unregister(struct subsys_desc *desc) +{ +} +#endif +#endif diff --git a/include/soc/qcom/system_health_monitor.h b/include/soc/qcom/system_health_monitor.h new file mode 100644 index 000000000000..5ce027cc4ae9 --- /dev/null +++ b/include/soc/qcom/system_health_monitor.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2014, 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 SYSTEM_HEALTH_MONITOR_H +#define SYSTEM_HEALTH_MONITOR_H + +#ifdef CONFIG_SYSTEM_HEALTH_MONITOR +/** + * kern_check_system_health() - Check the system health + * + * This function is used by the kernel drivers to initiate the + * system health check. This function in turn trigger SHM to send + * QMI message to all the HMAs connected to it. + * + * Return: 0 on success, standard Linux error codes on failure. + */ +int kern_check_system_health(void); +#else +static inline int kern_check_system_health(void) +{ + return -ENODEV; +} +#endif /* CONFIG_SYSTEM_HEALTH_MONITOR */ + +#endif /* SYSTEM_HEALTH_MONITOR_H */ diff --git a/include/soc/qcom/tracer_pkt.h b/include/soc/qcom/tracer_pkt.h new file mode 100644 index 000000000000..2657b79b1ed6 --- /dev/null +++ b/include/soc/qcom/tracer_pkt.h @@ -0,0 +1,130 @@ +/* Copyright (c) 2015, 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 _TRACER_PKT_H_ +#define _TRACER_PKT_H_ + +#include <linux/err.h> +#include <linux/types.h> + +#ifdef CONFIG_TRACER_PKT + +/** + * tracer_pkt_init() - initialize the tracer packet + * @data: Pointer to the buffer to be initialized with a tracer + * packet. + * @data_len: Length of the buffer. + * @client_event_cfg: Client-specific event configuration mask. + * @glink_event_cfg: G-Link-specific event configuration mask. + * @pkt_priv: Private/Cookie information to be added to the tracer + * packet. + * @pkt_priv_len: Length of the private data. + * + * This function is used to initialize a buffer with the tracer packet header. + * The tracer packet header includes the data as passed by the elements in the + * parameters. + * + * Return: 0 on success, standard Linux error codes on failure. + */ +int tracer_pkt_init(void *data, size_t data_len, + uint16_t client_event_cfg, uint32_t glink_event_cfg, + void *pkt_priv, size_t pkt_priv_len); + +/** + * tracer_pkt_set_event_cfg() - set the event configuration mask in the tracer + * packet + * @data: Pointer to the buffer to be initialized with event + * configuration mask. + * @client_event_cfg: Client-specific event configuration mask. + * @glink_event_cfg: G-Link-specific event configuration mask. + * + * This function is used to initialize a buffer with the event configuration + * mask as passed by the elements in the parameters. + * + * Return: 0 on success, standard Linux error codes on failure. + */ +int tracer_pkt_set_event_cfg(void *data, uint16_t client_event_cfg, + uint32_t glink_event_cfg); + +/** + * tracer_pkt_log_event() - log an event specific to the tracer packet + * @data: Pointer to the buffer containing tracer packet. + * @event_id: Event ID to be logged. + * + * This function is used to log an event specific to the tracer packet. + * The event is logged either into the tracer packet itself or a different + * tracing mechanism as configured. + * + * Return: 0 on success, standard Linux error codes on failure. + */ +int tracer_pkt_log_event(void *data, uint32_t event_id); + +/** + * tracer_pkt_calc_hex_dump_size() - calculate the hex dump size of a tracer + * packet + * @data: Pointer to the buffer containing tracer packet. + * @data_len: Length of the tracer packet buffer. + * + * This function is used to calculate the length of the buffer required to + * hold the hex dump of the tracer packet. + * + * Return: 0 on success, standard Linux error codes on failure. + */ +size_t tracer_pkt_calc_hex_dump_size(void *data, size_t data_len); + +/** + * tracer_pkt_hex_dump() - hex dump the tracer packet into a buffer + * @buf: Buffer to contain the hex dump of the tracer packet. + * @buf_len: Length of the hex dump buffer. + * @data: Buffer containing the tracer packet. + * @data_len: Length of the buffer containing the tracer packet. + * + * This function is used to dump the contents of the tracer packet into + * a buffer in a specific hexadecimal format. The hex dump buffer can then + * be dumped through debugfs. + * + * Return: 0 on success, standard Linux error codes on failure. + */ +int tracer_pkt_hex_dump(void *buf, size_t buf_len, void *data, size_t data_len); + +#else + +static inline int tracer_pkt_init(void *data, size_t data_len, + uint16_t client_event_cfg, uint32_t glink_event_cfg, + void *pkt_priv, size_t pkt_priv_len) +{ + return -EOPNOTSUPP; +} + +static inline int tracer_pkt_set_event_cfg(uint16_t client_event_cfg, + uint32_t glink_event_cfg) +{ + return -EOPNOTSUPP; +} + +static inline int tracer_pkt_log_event(void *data, uint32_t event_id) +{ + return -EOPNOTSUPP; +} + +static inline size_t tracer_pkt_calc_hex_dump_size(void *data, size_t data_len) +{ + return -EOPNOTSUPP; +} + +static inline int tracer_pkt_hex_dump(void *buf, size_t buf_len, void *data, + size_t data_len) +{ + return -EOPNOTSUPP; +} + +#endif /* CONFIG_TRACER_PKT */ +#endif /* _TRACER_PKT_H_ */ diff --git a/include/soc/qcom/watchdog.h b/include/soc/qcom/watchdog.h new file mode 100644 index 000000000000..dc0e1c8b3700 --- /dev/null +++ b/include/soc/qcom/watchdog.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2014, 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 _ASM_ARCH_MSM_WATCHDOG_H_ +#define _ASM_ARCH_MSM_WATCHDOG_H_ + +#ifdef CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC +#define WDOG_BITE_ON_PANIC 1 +#else +#define WDOG_BITE_ON_PANIC 0 +#endif + +#ifdef CONFIG_QCOM_WATCHDOG_V2 +void msm_trigger_wdog_bite(void); +#else +static inline void msm_trigger_wdog_bite(void) { } +#endif + +#endif |
