| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2024 SpacemiT Technology Co. Ltd |
| 4 |
* Copyright (c) 2024-2025 Haylen Chu <[email protected]> |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef _CCU_COMMON_H_ |
| 8 |
#define _CCU_COMMON_H_ |
| 9 |
|
| 10 |
#include <linux/clk-provider.h> |
| 11 |
#include <linux/platform_device.h> |
| 12 |
#include <linux/regmap.h> |
| 13 |
|
| 14 |
struct ccu_common { |
| 15 |
struct regmap *regmap; |
| 16 |
struct regmap *lock_regmap; |
| 17 |
|
| 18 |
union { |
| 19 |
/* For DDN and MIX */ |
| 20 |
struct { |
| 21 |
u32 reg_ctrl; |
| 22 |
u32 reg_fc; |
| 23 |
u32 mask_fc; |
| 24 |
}; |
| 25 |
|
| 26 |
/* For PLL */ |
| 27 |
struct { |
| 28 |
u32 reg_swcr1; |
| 29 |
u32 reg_swcr2; |
| 30 |
u32 reg_swcr3; |
| 31 |
}; |
| 32 |
}; |
| 33 |
|
| 34 |
struct clk_hw hw; |
| 35 |
}; |
| 36 |
|
| 37 |
static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) |
| 38 |
{ |
| 39 |
return container_of(hw, struct ccu_common, hw); |
| 40 |
} |
| 41 |
|
| 42 |
struct spacemit_ccu_data { |
| 43 |
const char *reset_name; |
| 44 |
struct clk_hw **hws; |
| 45 |
size_t num; |
| 46 |
}; |
| 47 |
|
| 48 |
#define ccu_read(c, reg) \ |
| 49 |
({ \ |
| 50 |
u32 tmp; \ |
| 51 |
regmap_read((c)->regmap, (c)->reg_##reg, &tmp); \ |
| 52 |
tmp; \ |
| 53 |
}) |
| 54 |
#define ccu_update(c, reg, mask, val) \ |
| 55 |
regmap_update_bits((c)->regmap, (c)->reg_##reg, mask, val) |
| 56 |
|
| 57 |
int spacemit_ccu_probe(struct platform_device *pdev, const char *compat); |
| 58 |
|
| 59 |
#endif /* _CCU_COMMON_H_ */ |