diff mbox

[4/4] arm: Add an RX8900 RTC to the ASpeed board

Message ID 1479357400-17441-5-git-send-email-alastair@au1.ibm.com
State New
Headers show

Commit Message

Alastair D'Silva Nov. 17, 2016, 4:36 a.m. UTC
From: Alastair D'Silva <alastair@d-silva.org>

Connect an RX8900 RTC to i2c12 of the AST2500 SOC at address 0x32

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
 hw/arm/aspeed.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Cédric Le Goater Nov. 22, 2016, 4:56 p.m. UTC | #1
On 11/17/2016 05:36 AM, Alastair D'Silva wrote:
> From: Alastair D'Silva <alastair@d-silva.org>
> 
> Connect an RX8900 RTC to i2c12 of the AST2500 SOC at address 0x32

If this is a board device, we should include it under a machine routine.

Is that for the palmetto ? The ast2500 does not have a RTC.

Thanks,

C. 

> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> ---
>  hw/arm/aspeed.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index c7206fd..554ae20 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -100,6 +100,8 @@ static void aspeed_board_init(MachineState *machine,
>  {
>
>      AspeedBoardState *bmc;
>      AspeedSoCClass *sc;
> +    I2CBus *i2c12;
> +    DeviceState *rx8900;
>  
>      bmc = g_new0(AspeedBoardState, 1);
>      object_initialize(&bmc->soc, (sizeof(bmc->soc)), cfg->soc_name);
> @@ -137,6 +139,12 @@ static void aspeed_board_init(MachineState *machine,
>      aspeed_board_binfo.ram_size = ram_size;
>      aspeed_board_binfo.loader_start = sc->info->sdram_base;
>  
> +    i2c12 = aspeed_i2c_get_bus((DeviceState *)&bmc->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(&bmc->soc.vic), 22));
> +
>      arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo);
>  }
>  
>
Alastair D'Silva Nov. 23, 2016, 12:46 a.m. UTC | #2
On Tue, 2016-11-22 at 17:56 +0100, Cédric Le Goater wrote:
> On 11/17/2016 05:36 AM, Alastair D'Silva wrote:
> > 
> > From: Alastair D'Silva <alastair@d-silva.org>
> > 
> > Connect an RX8900 RTC to i2c12 of the AST2500 SOC at address 0x32
> 
> If this is a board device, we should include it under a machine
> routine.
> 
> Is that for the palmetto ? The ast2500 does not have a RTC.
> 
> Thanks,
> 
> C. 

Ok
Cédric Le Goater Nov. 23, 2016, 8:48 a.m. UTC | #3
On 11/23/2016 01:46 AM, Alastair D'Silva wrote:
> On Tue, 2016-11-22 at 17:56 +0100, Cédric Le Goater wrote:
>> On 11/17/2016 05:36 AM, Alastair D'Silva wrote:
>>>
>>> From: Alastair D'Silva <alastair@d-silva.org>
>>>
>>> Connect an RX8900 RTC to i2c12 of the AST2500 SOC at address 0x32
>>
>> If this is a board device, we should include it under a machine
>> routine.
>>
>> Is that for the palmetto ? The ast2500 does not have a RTC.
>>
>> Thanks,
>>
>> C. 
> 
> Ok
 
I suppose we could change aspeed_board_init() to return 
a AspeedSoCState* and use the soc object in the specific 
<machine>_init routines to add devices. 

Andrew, what is your opinion on that ? 

Thanks,

C.
Andrew Jeffery Nov. 24, 2016, 12:15 a.m. UTC | #4
On Wed, 2016-11-23 at 09:48 +0100, Cédric Le Goater wrote:
> On 11/23/2016 01:46 AM, Alastair D'Silva wrote:
> > On Tue, 2016-11-22 at 17:56 +0100, Cédric Le Goater wrote:
> > > On 11/17/2016 05:36 AM, Alastair D'Silva wrote:
> > > > 
> > > > > > > > From: Alastair D'Silva <alastair@d-silva.org>
> > > > 
> > > > Connect an RX8900 RTC to i2c12 of the AST2500 SOC at address 0x32
> > > 
> > > If this is a board device, we should include it under a machine
> > > routine.
> > > 
> > > Is that for the palmetto ? The ast2500 does not have a RTC.
> > > 
> > > Thanks,
> > > 
> > > C. 
> > 
> > Ok
> 
>  
> I suppose we could change aspeed_board_init() to return 
> a AspeedSoCState* and use the soc object in the specific 
> <machine>_init routines to add devices. 
> 
> Andrew, what is your opinion on that ? 

I see the I2C bus configuration as a declarative problem. In a similar
vein we already have AspeedBoardConfig, so I think we should try to
describe the buses and attached devices there. That way we can have a
generic aspeed_i2c_bus_init() routine that we call inside
aspeed_board_init().

This would avoid encoding the buses and their slaves in the board-
specific init code.

Is that a reasonable alternative? I agree that we need to use a
different approach to that which the current patch is using.

Andrew
diff mbox

Patch

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index c7206fd..554ae20 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -100,6 +100,8 @@  static void aspeed_board_init(MachineState *machine,
 {
     AspeedBoardState *bmc;
     AspeedSoCClass *sc;
+    I2CBus *i2c12;
+    DeviceState *rx8900;
 
     bmc = g_new0(AspeedBoardState, 1);
     object_initialize(&bmc->soc, (sizeof(bmc->soc)), cfg->soc_name);
@@ -137,6 +139,12 @@  static void aspeed_board_init(MachineState *machine,
     aspeed_board_binfo.ram_size = ram_size;
     aspeed_board_binfo.loader_start = sc->info->sdram_base;
 
+    i2c12 = aspeed_i2c_get_bus((DeviceState *)&bmc->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(&bmc->soc.vic), 22));
+
     arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo);
 }