162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2022 MediaTek Inc. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __DRV_CLK_MTK_RESET_H 762306a36Sopenharmony_ci#define __DRV_CLK_MTK_RESET_H 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/reset-controller.h> 1062306a36Sopenharmony_ci#include <linux/types.h> 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define RST_NR_PER_BANK 32 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* Infra global controller reset set register */ 1562306a36Sopenharmony_ci#define INFRA_RST0_SET_OFFSET 0x120 1662306a36Sopenharmony_ci#define INFRA_RST1_SET_OFFSET 0x130 1762306a36Sopenharmony_ci#define INFRA_RST2_SET_OFFSET 0x140 1862306a36Sopenharmony_ci#define INFRA_RST3_SET_OFFSET 0x150 1962306a36Sopenharmony_ci#define INFRA_RST4_SET_OFFSET 0x730 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/** 2262306a36Sopenharmony_ci * enum mtk_reset_version - Version of MediaTek clock reset controller. 2362306a36Sopenharmony_ci * @MTK_RST_SIMPLE: Use the same registers for bit set and clear. 2462306a36Sopenharmony_ci * @MTK_RST_SET_CLR: Use separate registers for bit set and clear. 2562306a36Sopenharmony_ci * @MTK_RST_MAX: Total quantity of version for MediaTek clock reset controller. 2662306a36Sopenharmony_ci */ 2762306a36Sopenharmony_cienum mtk_reset_version { 2862306a36Sopenharmony_ci MTK_RST_SIMPLE = 0, 2962306a36Sopenharmony_ci MTK_RST_SET_CLR, 3062306a36Sopenharmony_ci MTK_RST_MAX, 3162306a36Sopenharmony_ci}; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/** 3462306a36Sopenharmony_ci * struct mtk_clk_rst_desc - Description of MediaTek clock reset. 3562306a36Sopenharmony_ci * @version: Reset version which is defined in enum mtk_reset_version. 3662306a36Sopenharmony_ci * @rst_bank_ofs: Pointer to an array containing base offsets of the reset register. 3762306a36Sopenharmony_ci * @rst_bank_nr: Quantity of reset bank. 3862306a36Sopenharmony_ci * @rst_idx_map:Pointer to an array containing ids if input argument is index. 3962306a36Sopenharmony_ci * This array is not necessary if our input argument does not mean index. 4062306a36Sopenharmony_ci * @rst_idx_map_nr: Quantity of reset index map. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_cistruct mtk_clk_rst_desc { 4362306a36Sopenharmony_ci enum mtk_reset_version version; 4462306a36Sopenharmony_ci u16 *rst_bank_ofs; 4562306a36Sopenharmony_ci u32 rst_bank_nr; 4662306a36Sopenharmony_ci u16 *rst_idx_map; 4762306a36Sopenharmony_ci u32 rst_idx_map_nr; 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci/** 5162306a36Sopenharmony_ci * struct mtk_clk_rst_data - Data of MediaTek clock reset controller. 5262306a36Sopenharmony_ci * @regmap: Pointer to base address of reset register address. 5362306a36Sopenharmony_ci * @rcdev: Reset controller device. 5462306a36Sopenharmony_ci * @desc: Pointer to description of the reset controller. 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_cistruct mtk_clk_rst_data { 5762306a36Sopenharmony_ci struct regmap *regmap; 5862306a36Sopenharmony_ci struct reset_controller_dev rcdev; 5962306a36Sopenharmony_ci const struct mtk_clk_rst_desc *desc; 6062306a36Sopenharmony_ci}; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/** 6362306a36Sopenharmony_ci * mtk_register_reset_controller - Register MediaTek clock reset controller 6462306a36Sopenharmony_ci * @np: Pointer to device node. 6562306a36Sopenharmony_ci * @desc: Constant pointer to description of clock reset. 6662306a36Sopenharmony_ci * 6762306a36Sopenharmony_ci * Return: 0 on success and errorno otherwise. 6862306a36Sopenharmony_ci */ 6962306a36Sopenharmony_ciint mtk_register_reset_controller(struct device_node *np, 7062306a36Sopenharmony_ci const struct mtk_clk_rst_desc *desc); 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/** 7362306a36Sopenharmony_ci * mtk_register_reset_controller - Register mediatek clock reset controller with device 7462306a36Sopenharmony_ci * @np: Pointer to device. 7562306a36Sopenharmony_ci * @desc: Constant pointer to description of clock reset. 7662306a36Sopenharmony_ci * 7762306a36Sopenharmony_ci * Return: 0 on success and errorno otherwise. 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ciint mtk_register_reset_controller_with_dev(struct device *dev, 8062306a36Sopenharmony_ci const struct mtk_clk_rst_desc *desc); 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci#endif /* __DRV_CLK_MTK_RESET_H */ 83