2 * Copyright (c) 2014 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
11 DECLARE_GLOBAL_DATA_PTR
;
13 struct simple_bus_plat
{
19 fdt_addr_t
simple_bus_translate(struct udevice
*dev
, fdt_addr_t addr
)
21 struct simple_bus_plat
*plat
= dev_get_uclass_platdata(dev
);
23 if (addr
>= plat
->base
&& addr
< plat
->base
+ plat
->size
)
24 addr
= (addr
- plat
->base
) + plat
->target
;
29 static int simple_bus_post_bind(struct udevice
*dev
)
34 ret
= fdtdec_get_int_array(gd
->fdt_blob
, dev
->of_offset
, "ranges",
35 cell
, ARRAY_SIZE(cell
));
37 struct simple_bus_plat
*plat
= dev_get_uclass_platdata(dev
);
40 plat
->target
= cell
[1];
44 return dm_scan_fdt_node(dev
, gd
->fdt_blob
, dev
->of_offset
, false);
47 UCLASS_DRIVER(simple_bus
) = {
48 .id
= UCLASS_SIMPLE_BUS
,
50 .post_bind
= simple_bus_post_bind
,
51 .per_device_platdata_auto_alloc_size
= sizeof(struct simple_bus_plat
),
54 static const struct udevice_id generic_simple_bus_ids
[] = {
55 { .compatible
= "simple-bus" },
59 U_BOOT_DRIVER(simple_bus_drv
) = {
60 .name
= "generic_simple_bus",
61 .id
= UCLASS_SIMPLE_BUS
,
62 .of_match
= generic_simple_bus_ids
,