mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-12-19 18:23:07 +00:00
dart: add dart_init_fdt()
Used to intialize by FDT phandle. Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
parent
3c5b0fdd52
commit
233264cda2
2 changed files with 49 additions and 0 deletions
48
src/dart.c
48
src/dart.c
|
@ -8,6 +8,8 @@
|
|||
#include "string.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "libfdt/libfdt.h"
|
||||
|
||||
#define DART_T8020_CONFIG 0x60
|
||||
#define DART_T8020_CONFIG_LOCK BIT(15)
|
||||
|
||||
|
@ -318,6 +320,52 @@ dart_dev_t *dart_init_adt(const char *path, int instance, int device, bool keep_
|
|||
return dart;
|
||||
}
|
||||
|
||||
dart_dev_t *dart_init_fdt(void *dt, u32 phandle, int device, bool keep_pts)
|
||||
{
|
||||
int node = fdt_node_offset_by_phandle(dt, phandle);
|
||||
if (node < 0) {
|
||||
printf("FDT: node for phandle %u not found\n", phandle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int len;
|
||||
const void *prop = fdt_getprop(dt, node, "reg", &len);
|
||||
if (!prop || len < 8) {
|
||||
return NULL;
|
||||
}
|
||||
uintptr_t base = fdt64_ld((const fdt64_t *)prop);
|
||||
if (!base)
|
||||
return NULL;
|
||||
|
||||
enum dart_type_t type;
|
||||
const char *type_s;
|
||||
const char *name = fdt_get_name(dt, node, NULL);
|
||||
|
||||
if (fdt_node_check_compatible(dt, node, "apple,t8103-dart") == 0) {
|
||||
type = DART_T8020;
|
||||
type_s = "t8020";
|
||||
} else if (fdt_node_check_compatible(dt, node, "apple,t6000-dart") == 0) {
|
||||
type = DART_T6000;
|
||||
type_s = "t6000";
|
||||
} else if (fdt_node_check_compatible(dt, node, "apple,t8110-dart") == 0) {
|
||||
type = DART_T8110;
|
||||
type_s = "t8110";
|
||||
} else {
|
||||
printf("dart: dart %s at 0x%lx is of an unknown type\n", name, base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dart_dev_t *dart = dart_init(base, device, keep_pts, type);
|
||||
|
||||
if (!dart)
|
||||
return NULL;
|
||||
|
||||
printf("dart: dart %s at 0x%lx is a %s%s\n", name, base, type_s,
|
||||
dart->locked ? " (locked)" : "");
|
||||
|
||||
return dart;
|
||||
}
|
||||
|
||||
int dart_setup_pt_region(dart_dev_t *dart, const char *path, int device)
|
||||
{
|
||||
/* only device 0 of dart-dcp and dart-disp0 are of interest */
|
||||
|
|
|
@ -18,6 +18,7 @@ enum dart_type_t {
|
|||
|
||||
dart_dev_t *dart_init(uintptr_t base, u8 device, bool keep_pts, enum dart_type_t type);
|
||||
dart_dev_t *dart_init_adt(const char *path, int instance, int device, bool keep_pts);
|
||||
dart_dev_t *dart_init_fdt(void *dt, u32 phandle, int device, bool keep_pts);
|
||||
int dart_setup_pt_region(dart_dev_t *dart, const char *path, int device);
|
||||
int dart_map(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len);
|
||||
void dart_unmap(dart_dev_t *dart, uintptr_t iova, size_t len);
|
||||
|
|
Loading…
Reference in a new issue