Implement a simple wrapper for platform module to build komeda to module, Also add a very simple D71 layer code to show how to discover a product. Komeda driver direct bind the product ENTRY function xxx_identity to DT compatible name like: d71_product = { .product_id = MALIDP_D71_PRODUCT_ID, .identify = d71_identify, }, const struct of_device_id komeda_of_match[] = { { .compatible = "arm,mali-d71", .data = &d71_product, }, {}, }; Then when linux found a matched DT node and call driver to probe, we can easily get the of data, and call into the product to do the identify: komeda_bind() { ... product = of_device_get_match_data(dev); product->identify(); ... } Changes in v4: - Replaced kzalloc with devm_kzalloc Changes in v3: - Fixed style problem found by checkpatch.pl --strict. Signed-off-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com> Acked-by: Liviu Dudau <liviu.dudau@arm.com> Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
42 lines
844 B
C
42 lines
844 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
|
|
* Author: James.Qian.Wang <james.qian.wang@arm.com>
|
|
*
|
|
*/
|
|
#ifndef _MALIDP_IO_H_
|
|
#define _MALIDP_IO_H_
|
|
|
|
#include <linux/io.h>
|
|
|
|
static inline u32
|
|
malidp_read32(u32 __iomem *base, u32 offset)
|
|
{
|
|
return readl((base + (offset >> 2)));
|
|
}
|
|
|
|
static inline void
|
|
malidp_write32(u32 __iomem *base, u32 offset, u32 v)
|
|
{
|
|
writel(v, (base + (offset >> 2)));
|
|
}
|
|
|
|
static inline void
|
|
malidp_write32_mask(u32 __iomem *base, u32 offset, u32 m, u32 v)
|
|
{
|
|
u32 tmp = malidp_read32(base, offset);
|
|
|
|
tmp &= (~m);
|
|
malidp_write32(base, offset, v | tmp);
|
|
}
|
|
|
|
static inline void
|
|
malidp_write_group(u32 __iomem *base, u32 offset, int num, const u32 *values)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < num; i++)
|
|
malidp_write32(base, offset + i * 4, values[i]);
|
|
}
|
|
|
|
#endif /*_MALIDP_IO_H_*/
|