On 11/30/2016 06:36 AM, Alastair D'Silva wrote:
> From: Alastair D'Silva <[email protected]>
>
> Connect an RX8900 RTC to i2c12 of the AST2500 SOC at address 0x32
>
> Signed-off-by: Alastair D'Silva <[email protected]>
> ---
> hw/arm/aspeed.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index c7206fd..8de95f2 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -166,7 +166,19 @@ static const TypeInfo palmetto_bmc_type = {
>
> static void ast2500_evb_init(MachineState *machine)
> {
> + AspeedSoCState *soc;
> + I2CBus *i2c12;
> + DeviceState *rx8900;
> +
> aspeed_board_init(machine, &aspeed_boards[AST2500_EVB]);
> +
> + soc = ASPEED_SOC(object_resolve_path_component(OBJECT(machine), "soc"));
> +
> + i2c12 = aspeed_i2c_get_bus((DeviceState *)&soc->i2c, 11);
> + rx8900 = i2c_create_slave(i2c12, "rx8900", 0x32);
> +
> + qdev_connect_gpio_out_named(rx8900, "rx8900-interrupt-out", 0,
> + qdev_get_gpio_in(DEVICE(&soc->vic), 22));
> }
>
> static void ast2500_evb_class_init(ObjectClass *oc, void *data)
>
I think it would be nicer to define a handler under AspeedBoardConfig,
something like :
int (*i2c_init)(AspeedBoardState *bmc);
when a board needs I2C devices. The handler would be called
from aspeed_board_init() directly. This is similar to what
we do for the flash modules but we didn't have to add a
specific handler for the flash.
Thoughts ?
C.