soc: mediatek: Make mtk-infracfg modular
cover soc: mediatek: Make mtk-infracfg modular
This series converts mtk-infracfg to be buildable as a loadable module, allowing for more flexible kernel configurations and reduced memory footprint on systems that don't require this functionality built-in.
Justin Yeh (2):
soc: mediatek: Allow MTK_INFRACFG to be built as module
soc: mediatek: mtk-infracfg: Export symbols for module support
drivers/soc/mediatek/Kconfig | 2 +- drivers/soc/mediatek/mtk-infracfg.c | 9 +++++++-- include/linux/soc/mediatek/infracfg.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/2 soc: mediatek: Allow MTK_INFRACFG to be built as module
Change MTK_INFRACFG from bool to tristate to support building it as a loadable kernel module (.ko) instead of being built into the kernel. This is required for DDK (Driver Development Kit) module build, where mtk-infracfg needs to be loaded dynamically along with other SoC infrastructure modules.
--- drivers/soc/mediatek/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/mediatek/Kconfig +1 -1
@@ -38,7 +38,7 @@ config MTK_DVFSRC best achievable performance-per-watt. config MTK_INFRACFG - bool "MediaTek INFRACFG Support" + tristate "MediaTek INFRACFG Support" select REGMAP help Say yes here to add support for the MediaTek INFRACFG controller. The
Signature · 1 line
2.45.2
PATCH 2/2 soc: mediatek: mtk-infracfg: Export symbols for DDK modules
In reply to Justin YehExport mtk_infracfg functions to allow other DDK modules (like mtk-scpsys) to use bus protection APIs.
Changes:
- Add EXPORT_SYMBOL_GPL for set/clear bus_protection and init functions
- Remove static and __init qualifiers from mtk_infracfg_init
- Add mtk_infracfg_init() declaration to header
- Remove postcore_initcall, let dependent modules call init explicitly
- Add #include <linux/module.h> for export macros
- Add MODULE_LICENSE("GPL") metadata
This allows mtk-infracfg to be built as a DDK module (.ko) and its functions to be used by other modules like mtk-scpsys for power domain management.
--- drivers/soc/mediatek/mtk-infracfg.c | 9 +++++++-- include/linux/soc/mediatek/infracfg.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/soc/mediatek/mtk-infracfg.c +7 -2
@@ -7,6 +7,7 @@#include <linux/jiffies.h> #include <linux/regmap.h> #include <linux/mfd/syscon.h> +#include <linux/module.h> #include <linux/soc/mediatek/infracfg.h> #include <asm/processor.h>
@@ -43,6 +44,7 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,return ret; } +EXPORT_SYMBOL_GPL (mtk_infracfg_set_bus_protection);/** * mtk_infracfg_clear_bus_protection - disable bus protection
@@ -73,8 +75,9 @@ int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,return ret; } +EXPORT_SYMBOL_GPL (mtk_infracfg_clear_bus_protection); -static int __init mtk_infracfg_init (void ) +int mtk_infracfg_init (void ) {struct regmap *infracfg;
@@ -90,4 +93,6 @@ static int __init mtk_infracfg_init(void) MT8192_INFRA_CTRL_DISABLE_MFG2ACP);return 0 ; } -postcore_initcall (mtk_infracfg_init); +EXPORT_SYMBOL_GPL (mtk_infracfg_init); + +MODULE_LICENSE ("GPL" );
include/linux/soc/mediatek/infracfg.h +1 -0
@@ -454,4 +454,5 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, bool reg_update);int mtk_infracfg_clear_bus_protection (struct regmap *infracfg,u32 mask,bool reg_update); +int mtk_infracfg_init (void );#endif /* __SOC_MEDIATEK_INFRACFG_H */
Signature · 1 line
2.45.2
AngeloGioacchino Del Regno
maintainerRe: [PATCH 2/2] soc: mediatek: mtk-infracfg: Export symbols for DDK modules
Quoted 42 lines · Justin Yeh
Export
mtk_infracfgfunctions to allow other DDK modules (like mtk-scpsys) to use bus protection APIs.Changes:
- AddEXPORT_SYMBOL_GPLfor set/clearbus_protectionand init functions
- Remove static and__initqualifiers frommtk_infracfg_init
- Addmtk_infracfg_init()declaration to header
- Removepostcore_initcall, let dependent modules call init explicitly
- Add #include <linux/module.h> for export macros
- AddMODULE_LICENSE("GPL")metadataThis allows mtk-infracfg to be built as a DDK module (.ko) and its functions to be used by other modules like mtk-scpsys for power domain management.
Signed-off-by Justin Yeh <[email protected]>--- drivers/soc/mediatek/mtk-infracfg.c | 9 +++++++-- include/linux/soc/mediatek/infracfg.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-)drivers/soc/mediatek/mtk-infracfg.c +2
-0@@ -7,6 +7,7 @@#include <linux/jiffies.h> #include <linux/regmap.h> #include <linux/mfd/syscon.h> +#include <linux/module.h> #include <linux/soc/mediatek/infracfg.h> #include <asm/processor.h> @@ -43,6 +44,7 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,return ret; } +EXPORT_SYMBOL_GPL (mtk_infracfg_set_bus_protection);/** * mtk_infracfg_clear_bus_protection - disable bus protection
drivers/soc/mediatek/mtk-infracfg.c int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask, · line 78
Quoted 4 lines
drivers/soc/mediatek/mtk-infracfg.c +1
-0@@ -73,8 +75,9 @@ int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,return ret; } +EXPORT_SYMBOL_GPL (mtk_infracfg_clear_bus_protection);
Those two are ok, but I'd prefer to use namespaces (EXPORT_SYMBOL_NS_GPL) and to import the namespace in the relevant drivers.
drivers/soc/mediatek/mtk-infracfg.c static int __init mtk_infracfg_init(void) · line 96
Quoted 12 lines
drivers/soc/mediatek/mtk-infracfg.c +2
-2-static int __init mtk_infracfg_init (void ) +int mtk_infracfg_init (void ) {struct regmap *infracfg;@@ -90,4 +93,6 @@ static int __init mtk_infracfg_init(void) MT8192_INFRA_CTRL_DISABLE_MFG2ACP);return 0 ; } -postcore_initcall (mtk_infracfg_init); +EXPORT_SYMBOL_GPL (mtk_infracfg_init);
Sorry, but that makes little sense.
Check the mtk_infracfg_init() function: if you avoid the postcore_initcall() there, what's going to happen with MT8192?! :-)
Cheers,
Angelo
Quoted 12 lines
drivers/soc/mediatek/mtk-infracfg.c +2
-0+ +MODULE_LICENSE ("GPL" );include/linux/soc/mediatek/infracfg.h +1
-0@@ -454,4 +454,5 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, bool reg_update);int mtk_infracfg_clear_bus_protection (struct regmap *infracfg,u32 mask,bool reg_update); +int mtk_infracfg_init (void );#endif /* __SOC_MEDIATEK_INFRACFG_H */