2 * Copyright (c) 2014 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
10 DECLARE_GLOBAL_DATA_PTR
;
12 struct simple_bus_plat
{
18 fdt_addr_t
simple_bus_translate(struct udevice
*dev
, fdt_addr_t addr
)
20 struct simple_bus_plat
*plat
= dev_get_uclass_platdata(dev
);
22 if (addr
>= plat
->base
&& addr
< plat
->base
+ plat
->size
)
23 addr
= (addr
- plat
->base
) + plat
->target
;
28 static int simple_bus_post_bind(struct udevice
*dev
)
30 #if CONFIG_IS_ENABLED(OF_PLATDATA)
36 ret
= dev_read_u32_array(dev
, "ranges", cell
, ARRAY_SIZE(cell
));
38 struct simple_bus_plat
*plat
= dev_get_uclass_platdata(dev
);
41 plat
->target
= cell
[1];
45 return dm_scan_fdt_dev(dev
);
49 UCLASS_DRIVER(simple_bus
) = {
50 .id
= UCLASS_SIMPLE_BUS
,
52 .post_bind
= simple_bus_post_bind
,
53 .per_device_platdata_auto_alloc_size
= sizeof(struct simple_bus_plat
),
56 static const struct udevice_id generic_simple_bus_ids
[] = {
57 { .compatible
= "simple-bus" },
58 { .compatible
= "simple-mfd" },
62 U_BOOT_DRIVER(simple_bus_drv
) = {
63 .name
= "generic_simple_bus",
64 .id
= UCLASS_SIMPLE_BUS
,
65 .of_match
= generic_simple_bus_ids
,