[{"id":1770936,"web_url":"http://patchwork.ozlabs.org/comment/1770936/","msgid":"<472ff629-39bd-9fe2-c1f8-a08ba6997b53@amsat.org>","list_archive_url":null,"date":"2017-09-19T12:12:20","subject":"Re: [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices","submitter":{"id":70924,"url":"http://patchwork.ozlabs.org/api/people/70924/","name":"Philippe Mathieu-Daudé","email":"f4bug@amsat.org"},"content":"Hi Cédric,\n\nOn 09/19/2017 08:26 AM, Cédric Le Goater wrote:\n> The Aspeed boards have at least one EEPROM to hold the Vital Product\n> Data (VPD).\n> \n> Signed-off-by: Cédric Le Goater <clg@kaod.org>\n> ---\n>   hw/arm/aspeed.c | 20 ++++++++++++++++++++\n>   1 file changed, 20 insertions(+)\n> \n> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c\n> index 362b683e9021..3e74970d7ad2 100644\n> --- a/hw/arm/aspeed.c\n> +++ b/hw/arm/aspeed.c\n> @@ -251,6 +251,17 @@ static void aspeed_board_init(MachineState *machine,\n>       arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo);\n>   }\n>   \n> +static void aspeed_i2c_add_eeprom(I2CBus *bus, uint8_t address, size_t size)\n> +{\n> +    uint8_t *eeprom_buf = g_malloc0(size);\n> +    DeviceState *dev;\n> +\n> +    dev = qdev_create((BusState *) bus, \"smbus-eeprom\");\n> +    qdev_prop_set_uint8(dev, \"address\", address);\n> +    qdev_prop_set_ptr(dev, \"data\", eeprom_buf);\n> +    qdev_init_nofail(dev);\n\nCan you merge this with smbus_eeprom_init() ?\nI think the cleaner way would be add \"include/hw/i2c/eeprom.h\" defining \nSMB_EEPROM_TYPE \"smbus-eeprom\" and declare smbus_eeprom_init() there or \nas inlined.\n\n> +}\n> +\n>   static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)\n>   {\n>       AspeedSoCState *soc = &bmc->soc;\n> @@ -260,6 +271,9 @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)\n>        * enough to provide basic RTC features. Alarms will be missing */\n>       i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), \"ds1338\", 0x68);\n>   \n> +    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,\n> +                          256 * 1024);\n> +\n>       /* add a TMP423 temperature sensor */\n>       dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),\n>                              \"tmp423\", 0x4c);\n> @@ -298,6 +312,9 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)\n>   {\n>       AspeedSoCState *soc = &bmc->soc;\n>   \n> +    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,\n> +                          8 * 1024);\n> +\n>       /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */\n>       i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), \"tmp105\", 0x4d);\n>   \n> @@ -377,6 +394,9 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)\n>       /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is\n>        * good enough */\n>       i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), \"ds1338\", 0x32);\n> +\n> +    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,\n> +                          8 * 1024);\n>   }\n>   \n>   static void witherspoon_bmc_init(MachineState *machine)\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Q3EjlWB4\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxMHk5BZKz9s4q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 22:14:26 +1000 (AEST)","from localhost ([::1]:42508 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duHQ0-00076m-RD\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 08:14:24 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:49964)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1duHOB-00067q-AC\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 08:12:33 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1duHO4-0002zC-Tl\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 08:12:31 -0400","from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:35945)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1duHO4-0002xr-PZ; Tue, 19 Sep 2017 08:12:24 -0400","by mail-qk0-x241.google.com with SMTP id i14so2113569qke.3;\n\tTue, 19 Sep 2017 05:12:24 -0700 (PDT)","from [192.168.1.10] ([181.93.89.178])\n\tby smtp.gmail.com with ESMTPSA id\n\tr1sm6895516qtc.90.2017.09.19.05.12.21\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 19 Sep 2017 05:12:23 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=LIfrsyEkEY/+b7Cs9rchpqdmj9VrMy3goK+JiL3LDW8=;\n\tb=Q3EjlWB4vWnkMDkRP8sqxDgZZ2ubcokBiAG8xpLVyqEG1mGnKoeaA8p5TA7Fkzig6K\n\tUt5P7qk1ZWKFJ3zRK5e612+vmJvcqmTqdhMhOIotNZ/odotHkRcllMuwIFJHANDQqvnr\n\tEN0UIWULmHiOLRevUSE+jaUznS2F1kajEki0Z10QxKL6iRNLfx0cpDzWsoN1D3BlZNkS\n\tXpu1fBUDQSyRKd8HELyubqq5FMT/+mKJ3K9elSR8CZCh9rYEvVSiX4WL0B6eeNAdhExf\n\tw4Z5+U3MaMvrOjtNipoF72jyRnLTJEXY8bzlqGTp7gGA0gOtSk1LTp/DBrHbsaytS3jo\n\tPRzA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:subject:to:cc:references:from:message-id\n\t:date:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=LIfrsyEkEY/+b7Cs9rchpqdmj9VrMy3goK+JiL3LDW8=;\n\tb=slHXXDhSEIPNGJ65/1QuAfjpUwGDuDYkQefuyNl5z8tZIrjUog33SzeDMNQ/N9xRCx\n\tNRfzeV+PHhTQ3aGw9n53hWNWd4aMwVY1uQutLpPeSuc/tbegyAr7+nxgyXVd3/gDM1Cc\n\t07rqYm9rJciQkLPBGBbwiKIGK4Bmzd2Vy11xW/WJ4PxW5h0wJbpWpNtqhUykNEWbDlYR\n\tIS1UtUEGGjUwA+NYjELu3/8pXvgMSq8+QQheOee2gYK9aixRXdRdlurtbW+ADzUAhZKj\n\txgS6P5tjuyNyfiR/2sTyLpHFSn6VKAjqdeqCybbVlVId7x9We6kWGksif4cke8j5DOR2\n\tgvRA==","X-Gm-Message-State":"AHPjjUg9g9fOJtRHGSjkoljIX3je/+9LK/KInvl0yLcj6yI/eL75SA+g\n\t40Gee9WGr3Xv6WJfZxWZO4s=","X-Google-Smtp-Source":"AOwi7QDeK8YXh7+k/+7G034GWbU3qIzz9k/AOpolC/KxMQKwCiuBydFb91BJtX0i89sVH8gmxx2xbQ==","X-Received":"by 10.55.137.66 with SMTP id l63mr1528647qkd.249.1505823144092; \n\tTue, 19 Sep 2017 05:12:24 -0700 (PDT)","To":"=?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@kaod.org>","References":"<20170919112645.8574-1-clg@kaod.org>\n\t<20170919112645.8574-4-clg@kaod.org>","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","Message-ID":"<472ff629-39bd-9fe2-c1f8-a08ba6997b53@amsat.org>","Date":"Tue, 19 Sep 2017 09:12:20 -0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170919112645.8574-4-clg@kaod.org>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","Content-Transfer-Encoding":"8bit","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400d:c09::241","Subject":"Re: [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Andrew Jeffery <andrew@aj.id.au>,\n\tPeter Maydell <peter.maydell@linaro.org>, \n\tqemu-arm@nongnu.org, qemu-devel@nongnu.org, Joel Stanley <joel@jms.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1770997,"web_url":"http://patchwork.ozlabs.org/comment/1770997/","msgid":"<f510d607-b328-90e6-3727-c6f554864e2f@kaod.org>","list_archive_url":null,"date":"2017-09-19T12:42:08","subject":"Re: [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices","submitter":{"id":68548,"url":"http://patchwork.ozlabs.org/api/people/68548/","name":"Cédric Le Goater","email":"clg@kaod.org"},"content":"On 09/19/2017 02:12 PM, Philippe Mathieu-Daudé wrote:\n> Hi Cédric,\n> \n> On 09/19/2017 08:26 AM, Cédric Le Goater wrote:\n>> The Aspeed boards have at least one EEPROM to hold the Vital Product\n>> Data (VPD).\n>>\n>> Signed-off-by: Cédric Le Goater <clg@kaod.org>\n>> ---\n>>   hw/arm/aspeed.c | 20 ++++++++++++++++++++\n>>   1 file changed, 20 insertions(+)\n>>\n>> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c\n>> index 362b683e9021..3e74970d7ad2 100644\n>> --- a/hw/arm/aspeed.c\n>> +++ b/hw/arm/aspeed.c\n>> @@ -251,6 +251,17 @@ static void aspeed_board_init(MachineState *machine,\n>>       arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo);\n>>   }\n>>   +static void aspeed_i2c_add_eeprom(I2CBus *bus, uint8_t address, size_t size)\n>> +{\n>> +    uint8_t *eeprom_buf = g_malloc0(size);\n>> +    DeviceState *dev;\n>> +\n>> +    dev = qdev_create((BusState *) bus, \"smbus-eeprom\");\n>> +    qdev_prop_set_uint8(dev, \"address\", address);\n>> +    qdev_prop_set_ptr(dev, \"data\", eeprom_buf);\n>> +    qdev_init_nofail(dev);\n> \n> Can you merge this with smbus_eeprom_init() ?\n> I think the cleaner way would be add \"include/hw/i2c/eeprom.h\" defining SMB_EEPROM_TYPE \"smbus-eeprom\" and declare smbus_eeprom_init() there or as inlined.\n\nyes. That would remove some duplicated code.\n\nI will wait for some feedback before doing a resend or a followup.\n\nThanks,\n\nC.\n\n\n> \n>> +}\n>> +\n>>   static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)\n>>   {\n>>       AspeedSoCState *soc = &bmc->soc;\n>> @@ -260,6 +271,9 @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)\n>>        * enough to provide basic RTC features. Alarms will be missing */\n>>       i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), \"ds1338\", 0x68);\n>>   +    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,\n>> +                          256 * 1024);\n>> +\n>>       /* add a TMP423 temperature sensor */\n>>       dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),\n>>                              \"tmp423\", 0x4c);\n>> @@ -298,6 +312,9 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)\n>>   {\n>>       AspeedSoCState *soc = &bmc->soc;\n>>   +    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,\n>> +                          8 * 1024);\n>> +\n>>       /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */\n>>       i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), \"tmp105\", 0x4d);\n>>   @@ -377,6 +394,9 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)\n>>       /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is\n>>        * good enough */\n>>       i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), \"ds1338\", 0x32);\n>> +\n>> +    aspeed_i2c_add_eeprom(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,\n>> +                          8 * 1024);\n>>   }\n>>     static void witherspoon_bmc_init(MachineState *machine)\n>>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxNq3493Pz9sMN\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 23:23:11 +1000 (AEST)","from localhost ([::1]:42843 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duIUX-0006Vl-Mt\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 09:23:09 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:40172)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <clg@kaod.org>) id 1duHr6-0005vT-DM\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 08:42:29 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <clg@kaod.org>) id 1duHr0-0005Wp-M1\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 08:42:24 -0400","from 19.mo3.mail-out.ovh.net ([178.32.98.231]:35687)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <clg@kaod.org>) id 1duHr0-0005Vu-FU\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 08:42:18 -0400","from player797.ha.ovh.net (b9.ovh.net [213.186.33.59])\n\tby mo3.mail-out.ovh.net (Postfix) with ESMTP id E844A1595E1\n\tfor <qemu-devel@nongnu.org>; Tue, 19 Sep 2017 14:42:16 +0200 (CEST)","from zorba.kaod.org (deibp9eh1--blueice1n4.emea.ibm.com\n\t[195.212.29.166]) (Authenticated sender: postmaster@kaod.org)\n\tby player797.ha.ovh.net (Postfix) with ESMTPSA id E25CC2E0098;\n\tTue, 19 Sep 2017 14:42:08 +0200 (CEST)"],"To":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","References":"<20170919112645.8574-1-clg@kaod.org>\n\t<20170919112645.8574-4-clg@kaod.org>\n\t<472ff629-39bd-9fe2-c1f8-a08ba6997b53@amsat.org>","From":"=?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@kaod.org>","Message-ID":"<f510d607-b328-90e6-3727-c6f554864e2f@kaod.org>","Date":"Tue, 19 Sep 2017 14:42:08 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<472ff629-39bd-9fe2-c1f8-a08ba6997b53@amsat.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","X-Ovh-Tracer-Id":"1199927829588315091","X-VR-SPAMSTATE":"OK","X-VR-SPAMSCORE":"-100","X-VR-SPAMCAUSE":"gggruggvucftvghtrhhoucdtuddrfeelledrheejgdehhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"178.32.98.231","Subject":"Re: [Qemu-devel] [PATCH 3/5] aspeed: Add EEPROM I2C devices","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Andrew Jeffery <andrew@aj.id.au>,\n\tPeter Maydell <peter.maydell@linaro.org>, \n\tqemu-arm@nongnu.org, qemu-devel@nongnu.org, Joel Stanley <joel@jms.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]