Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1153253/?format=api
{ "id": 1153253, "url": "http://patchwork.ozlabs.org/api/patches/1153253/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20190826152834.1239404-1-hs@denx.de/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20190826152834.1239404-1-hs@denx.de>", "list_archive_url": null, "date": "2019-08-26T15:28:34", "name": "[U-Boot,v2] ddr, fsl: add DM_I2C support", "commit_ref": "09aa70ffada679c28cea603db9578d8b1c65907b", "pull_url": null, "state": "accepted", "archived": false, "hash": "c27b2fe174a5bbd889de1968ea5da08c8c35da14", "submitter": { "id": 99, "url": "http://patchwork.ozlabs.org/api/people/99/?format=api", "name": "Heiko Schocher", "email": "hs@denx.de" }, "delegate": { "id": 2467, "url": "http://patchwork.ozlabs.org/api/users/2467/?format=api", "username": "prabhu_kush", "first_name": "Prabhakar", "last_name": "Kushwaha", "email": "prabhakar@freescale.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20190826152834.1239404-1-hs@denx.de/mbox/", "series": [ { "id": 127336, "url": "http://patchwork.ozlabs.org/api/series/127336/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=127336", "date": "2019-08-26T15:28:34", "name": "[U-Boot,v2] ddr, fsl: add DM_I2C support", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/127336/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1153253/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1153253/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=none (p=none dis=none) header.from=denx.de" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 46HGBF6lfTz9sBF\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 27 Aug 2019 01:28:53 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid 85DD2C221E1; Mon, 26 Aug 2019 15:28:48 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 500ECC21FEA;\n\tMon, 26 Aug 2019 15:28:46 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid EF1B3C21FBE; Mon, 26 Aug 2019 15:28:44 +0000 (UTC)", "from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10])\n\tby lists.denx.de (Postfix) with ESMTPS id 3C689C21FBE\n\tfor <u-boot@lists.denx.de>; Mon, 26 Aug 2019 15:28:44 +0000 (UTC)", "from frontend01.mail.m-online.net (unknown [192.168.8.182])\n\tby mail-out.m-online.net (Postfix) with ESMTP id 46HGB40P9Lz1rVw9;\n\tMon, 26 Aug 2019 17:28:44 +0200 (CEST)", "from localhost (dynscan1.mnet-online.de [192.168.6.70])\n\tby mail.m-online.net (Postfix) with ESMTP id 46HGB406Cwz1qqkq;\n\tMon, 26 Aug 2019 17:28:44 +0200 (CEST)", "from mail.mnet-online.de ([192.168.8.182])\n\tby localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id 5qQvhAM-x0jz; Mon, 26 Aug 2019 17:28:42 +0200 (CEST)", "from mail-internal.denx.de (p578adb1c.dip0.t-ipconnect.de\n\t[87.138.219.28])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby mail.mnet-online.de (Postfix) with ESMTPSA;\n\tMon, 26 Aug 2019 17:28:42 +0200 (CEST)", "from pollux.denx.de (pollux [192.168.1.1])\n\tby mail-internal.denx.de (Postfix) with ESMTP id 2FA3E180778;\n\tMon, 26 Aug 2019 17:28:41 +0200 (CEST)", "by pollux.denx.de (Postfix, from userid 515)\n\tid 1270D1A009F; Mon, 26 Aug 2019 17:28:41 +0200 (CEST)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=0.0 required=5.0 tests=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0", "X-Virus-Scanned": "amavisd-new at mnet-online.de", "X-Auth-Info": "7uPIv/o1Wwst9iwD2k6CJqz8SXIdEdZgIcCsi7AFH1I=", "From": "Heiko Schocher <hs@denx.de>", "To": "u-boot@lists.denx.de", "Date": "Mon, 26 Aug 2019 17:28:34 +0200", "Message-Id": "<20190826152834.1239404-1-hs@denx.de>", "X-Mailer": "git-send-email 2.21.0", "MIME-Version": "1.0", "Cc": "York Sun <york.sun@nxp.com>, Chuanhua Han <chuanhua.han@nxp.com>", "Subject": "[U-Boot] [PATCH v2] ddr, fsl: add DM_I2C support", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.18", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>" }, "content": "add DM_I2C support for this driver.\n\nSigned-off-by: Heiko Schocher <hs@denx.de>\n\n---\n\nDid not fixed checkpatch warning:\n\nCHECK: Prefer kernel type 'u8' over 'uint8_t'\n+ uint8_t buf = 0;\n\nTravis build, see:\nhttps://travis-ci.org/hsdenx/u-boot-test/builds/576762771\n\nChanges in v2:\n- rebased against\n 50b4b80f59 Merge tag 'u-boot-rockchip-20190823' of https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip\n\n drivers/ddr/fsl/main.c | 119 ++++++++++++++++++++++++++---------------\n 1 file changed, 76 insertions(+), 43 deletions(-)", "diff": "diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c\nindex ac0783b428..0aa6aedae7 100644\n--- a/drivers/ddr/fsl/main.c\n+++ b/drivers/ddr/fsl/main.c\n@@ -10,6 +10,7 @@\n */\n \n #include <common.h>\n+#include <dm.h>\n #include <i2c.h>\n #include <fsl_ddr_sdram.h>\n #include <fsl_ddr.h>\n@@ -82,20 +83,82 @@ u8 spd_i2c_addr[CONFIG_SYS_NUM_DDR_CTLRS][CONFIG_DIMM_SLOTS_PER_CTLR] = {\n \n #endif\n \n+#if defined(CONFIG_DM_I2C)\n+#define DEV_TYPE struct udevice\n+#else\n+/* Local udevice */\n+struct ludevice {\n+\tu8 chip;\n+};\n+\n+#define DEV_TYPE struct ludevice\n+\n+#endif\n+\n #define SPD_SPA0_ADDRESS\t0x36\n #define SPD_SPA1_ADDRESS\t0x37\n \n-static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)\n+static int ddr_i2c_read(DEV_TYPE *dev, unsigned int addr,\n+\t\t\tint alen, uint8_t *buf, int len)\n {\n \tint ret;\n+\n+#ifdef CONFIG_DM_I2C\n+\tret = dm_i2c_read(dev, 0, buf, len);\n+#else\n+\tret = i2c_read(dev->chip, addr, alen, buf, len);\n+#endif\n+\n+\treturn ret;\n+}\n+\n #ifdef CONFIG_SYS_FSL_DDR4\n-\tuint8_t dummy = 0;\n+static int ddr_i2c_dummy_write(unsigned int chip_addr)\n+{\n+\tuint8_t buf = 0;\n+\n+#ifdef CONFIG_DM_I2C\n+\tstruct udevice *dev;\n+\tint ret;\n+\n+\tret = i2c_get_chip_for_busnum(CONFIG_SYS_SPD_BUS_NUM, chip_addr,\n+\t\t\t\t 1, &dev);\n+\tif (ret) {\n+\t\tprintf(\"%s: Cannot find udev for a bus %d\\n\", __func__,\n+\t\t CONFIG_SYS_SPD_BUS_NUM);\n+\t\treturn ret;\n+\t}\n+\n+\treturn dm_i2c_write(dev, 0, &buf, 1);\n+#else\n+\treturn i2c_write(chip_addr, 0, 1, &buf, 1);\n #endif\n \n-#ifndef CONFIG_DM_I2C\n-\ti2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);\n+\treturn 0;\n+}\n #endif\n \n+static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)\n+{\n+\tint ret;\n+\tDEV_TYPE *dev;\n+\n+#if defined(CONFIG_DM_I2C)\n+\tret = i2c_get_chip_for_busnum(CONFIG_SYS_SPD_BUS_NUM, i2c_address,\n+\t\t\t\t 1, &dev);\n+\tif (ret) {\n+\t\tprintf(\"%s: Cannot find udev for a bus %d\\n\", __func__,\n+\t\t CONFIG_SYS_SPD_BUS_NUM);\n+\t\treturn;\n+\t}\n+#else /* Non DM I2C support - will be removed */\n+\tstruct ludevice ldev = {\n+\t\t.chip = i2c_address,\n+\t};\n+\tdev = &ldev;\n+\n+\ti2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);\n+#endif\n \n #ifdef CONFIG_SYS_FSL_DDR4\n \t/*\n@@ -104,49 +167,19 @@ static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)\n \t * To access the upper 256 bytes, we need to set EE page address to 1\n \t * See Jedec standar No. 21-C for detail\n \t */\n-#ifndef CONFIG_DM_I2C\n-\ti2c_write(SPD_SPA0_ADDRESS, 0, 1, &dummy, 1);\n-\tret = i2c_read(i2c_address, 0, 1, (uchar *)spd, 256);\n+\tddr_i2c_dummy_write(SPD_SPA0_ADDRESS);\n+\tret = ddr_i2c_read(dev, 0, 1, (uchar *)spd, 256);\n \tif (!ret) {\n-\t\ti2c_write(SPD_SPA1_ADDRESS, 0, 1, &dummy, 1);\n-\t\tret = i2c_read(i2c_address, 0, 1,\n-\t\t\t (uchar *)((ulong)spd + 256),\n-\t\t\t min(256,\n-\t\t\t\t (int)sizeof(generic_spd_eeprom_t) - 256));\n+\t\tddr_i2c_dummy_write(SPD_SPA1_ADDRESS);\n+\t\tret = ddr_i2c_read(dev, 0, 1, (uchar *)((ulong)spd + 256),\n+\t\t\t\t min(256,\n+\t\t\t\t (int)sizeof(generic_spd_eeprom_t)\n+\t\t\t\t - 256));\n \t}\n-#else\n-\tstruct udevice *dev;\n-\tint read_len = min(256, (int)sizeof(generic_spd_eeprom_t) - 256);\n \n-\tret = i2c_get_chip_for_busnum(0, SPD_SPA0_ADDRESS, 1, &dev);\n-\tif (!ret)\n-\t\tdm_i2c_write(dev, 0, &dummy, 1);\n-\tret = i2c_get_chip_for_busnum(0, i2c_address, 1, &dev);\n-\tif (!ret) {\n-\t\tif (!dm_i2c_read(dev, 0, (uchar *)spd, 256)) {\n-\t\t\tif (!i2c_get_chip_for_busnum(0, SPD_SPA1_ADDRESS,\n-\t\t\t\t\t\t 1, &dev))\n-\t\t\t\tdm_i2c_write(dev, 0, &dummy, 1);\n-\t\t\tif (!i2c_get_chip_for_busnum(0, i2c_address, 1, &dev))\n-\t\t\t\tret = dm_i2c_read(dev, 0,\n-\t\t\t\t\t\t (uchar *)((ulong)spd + 256),\n-\t\t\t\t\t\t read_len);\n-\t\t}\n-\t}\n-#endif\n-\n-#else\n-\n-#ifndef CONFIG_DM_I2C\n-\tret = i2c_read(i2c_address, 0, 1, (uchar *)spd,\n-\t\t\tsizeof(generic_spd_eeprom_t));\n #else\n-\tret = i2c_get_chip_for_busnum(0, i2c_address, 1, &dev);\n-\tif (!ret)\n-\t\tret = dm_i2c_read(dev, 0, (uchar *)spd,\n-\t\t\t\t sizeof(generic_spd_eeprom_t));\n-#endif\n-\n+\tret = ddr_i2c_read(dev, 0, 1, (uchar *)spd,\n+\t\t\t sizeof(generic_spd_eeprom_t));\n #endif\n \n \tif (ret) {\n", "prefixes": [ "U-Boot", "v2" ] }