芯片手册:http://m4udit.dinauz.org/P2020RM_rev0.pdf
PowerPC体系结构Freescale架构系列芯片可以将l2_cache配置成l2_cache与sram结合的策略来使用,在内核中是以设备的方式来驱动l2cache_sram。驱动定义在arch/powerpc/platforms/85xx/Kconfig中,配置项FSL_85XX_CACHE_SRAM,核心代码为fsl_85xx_l2ctlr.c和fsl_85xx_cache_sram.c,均在arch/powerpc/sysdev路径下,主要结构定义在头文件arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h中。
模块注册:
static __init int mpc85xx_l2ctlr_of_init(void)
{
return platform_driver_register(&mpc85xx_l2ctlr_of_platform_driver);
}
static void __exit mpc85xx_l2ctlr_of_exit(void)
{
platform_driver_unregister(&mpc85xx_l2ctlr_of_platform_driver);
}
/* 模块出口和入口 */
subsys_initcall(mpc85xx_l2ctlr_of_init);
module_exit(mpc85xx_l2ctlr_of_exit);
L2-Cache Sram驱动的注册过程如下:
mpc85xx_l2ctlr_of_probe
platform_drv_probe
driver_probe_device
__driver_attach
bus_for_each_dev
bus_add_driver
driver_register
do_one_initcall
kernel_init_freeable
kernel_init
ret_from_kernel_thread
实际上为Linux内核中驱动通用的注册逻辑,此处为platform设备驱动注册。
驱动定义:
static struct platform_driver mpc85xx_l2ctlr_of_platform_driver = {
.driver = {
.name = "fsl-l2ctlr",
.of_match_table = mpc85xx_l2ctlr_of_match,
},
.probe = mpc85xx_l2ctlr_of_probe,
.remove = mpc85xx_l2ctlr_of_remove,
};
其中有一项为兼容性列表,其定义如下:
static const struct of_device_i