Return-Path: Received: from mail-oi0-x244.google.com (mail-oi0-x244.google.com [IPv6:2607:f8b0:4003:c06::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3str4s5FqhzDsrT for ; Wed, 12 Oct 2016 08:40:13 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=r0WWr1ls; dkim-atps=neutral Received: by mail-oi0-x244.google.com with SMTP id d132so2259848oib.2 for ; Tue, 11 Oct 2016 14:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rOayd6yqQEjURZInnL08jFgLHqOngbsNasG/b6YyVuo=; b=r0WWr1lskO+7P+SebsmHVq3ZmyaCY33OhbhLdIeCJnst4AKq+3iEJxgNUq64o8+x+A 5yHYhWeb3B21YmiLauKvMdEpM6DG2A5X+IeaPhKNUXydQib3WRjEQIEKYsTiuZPrLatG Dd3MOj15aoQj+MUe5gqkE3rZ/McdE2mtcGE2sWz5hZ4gxkUmcWqfFC4h/HwBMyeCUY/d BPxNx+Khj+31tYVrYhFFUIotjND0SimXvR+1VppiyYwEvgws+OkLF0rU3ZgbUJeBwLaa sx9577molibZSX8OgLiFd12yEYs0EyMhX2ErpfeRANd6oqSCJptxOSsk+kGDFzFDVAMe iAIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rOayd6yqQEjURZInnL08jFgLHqOngbsNasG/b6YyVuo=; b=YBhuYLsh0kXNmnPK8797MB5z8qWRUUI4B05PtKtzED6FZCh9ZET9YwQbHJbGfaMluw 2tcJcyLZ56TOQ6xTxAj16DtXKQc0HYI40GIfx8349b436Su5cbXFiBI5y6llEAFbSVCM ddb+blgYpZy3SuV1NYLQLCgSzP9OMcWKH6l06D2oUlgd105/DLBGSeblTU9cagek6S4o 46ntqK0DxzfA0WLbUo9IsIwLfvxo1v28W9IiT5EPXXhyLI7iB5eRGaKMbfnGzPd4gbiS Gwo8G+S4MoFSoKJghb3VYdufRpWVhFARSYaVop3aPT6BEz53X5sKJbPOssMkgPCWpBDB yk5A== X-Gm-Message-State: AA6/9RnDOPsZxGOZBDpASmHYDzpgM9j3qQ4eMWQlgo/QUJBxtrl3S95C+KUH3/F+8yzZHA== X-Received: by 10.202.51.137 with SMTP id z131mr4450598oiz.184.1476222012026; Tue, 11 Oct 2016 14:40:12 -0700 (PDT) Received: from Christophers-MacBook-Pro.local.com (45-20-192-79.lightspeed.austtx.sbcglobal.net. [45.20.192.79]) by smtp.gmail.com with ESMTPSA id h91sm1811153oth.40.2016.10.11.14.40.11 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 11 Oct 2016 14:40:11 -0700 (PDT) From: christopher.lee.bostic@gmail.com To: openbmc@lists.ozlabs.org Cc: joel@jms.id.au, zahrens@us.ibm.com, xxpetri@de.ibm.com, Jeremy Kerr Subject: [PATCH linux v3 05/18] fsi: Add fake master driver Date: Tue, 11 Oct 2016 16:39:50 -0500 Message-Id: <1476222003-99697-6-git-send-email-christopher.lee.bostic@gmail.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1476222003-99697-1-git-send-email-christopher.lee.bostic@gmail.com> References: <1476222003-99697-1-git-send-email-christopher.lee.bostic@gmail.com> X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 21:40:14 -0000 From: Jeremy Kerr For debugging, add a fake master driver, that only supports reads, returning a fixed set of data. Signed-off-by: Jeremy Kerr --- drivers/fsi/Kconfig | 10 +++++ drivers/fsi/Makefile | 1 + drivers/fsi/fsi-master-fake.c | 96 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 drivers/fsi/fsi-master-fake.c diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig index 04c1a0e..f065dbe 100644 --- a/drivers/fsi/Kconfig +++ b/drivers/fsi/Kconfig @@ -9,4 +9,14 @@ config FSI ---help--- FSI - the FRU Support Interface - is a simple bus for low-level access to POWER-based hardware. + +if FSI + +config FSI_MASTER_FAKE + tristate "Fake FSI master" + depends on FSI + ---help--- + This option enables a fake FSI master driver for debugging. +endif + endmenu diff --git a/drivers/fsi/Makefile b/drivers/fsi/Makefile index db0e5e7..847c00c 100644 --- a/drivers/fsi/Makefile +++ b/drivers/fsi/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_FSI) += fsi-core.o +obj-$(CONFIG_FSI_MASTER_FAKE) += fsi-master-fake.o diff --git a/drivers/fsi/fsi-master-fake.c b/drivers/fsi/fsi-master-fake.c new file mode 100644 index 0000000..50aac0b --- /dev/null +++ b/drivers/fsi/fsi-master-fake.c @@ -0,0 +1,96 @@ +/* + * Fake FSI master driver for FSI development + * + * Copyright (C) IBM Corporation 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include + +#include "fsi-master.h" + +const uint8_t data[] = { + 0xc0, 0x02, 0x08, 0x03, /* chip id */ + 0x80, 0x01, 0x11, 0x00, /* peek */ + 0x80, 0x01, 0x20, 0x3e, /* slave */ + 0x00, 0x01, 0x10, 0xa5, /* i2c */ +}; + + +static int fsi_master_fake_read(struct fsi_master *_master, int link, + uint8_t slave, uint32_t addr, void *val, size_t size) +{ + if (link != 0) + return -ENODEV; + + if (addr + size > sizeof(data)) + memset(val, 0, size); + else + memcpy(val, data + addr, size); + + return 0; +} + +static int fsi_master_fake_write(struct fsi_master *_master, int link, + uint8_t slave, uint32_t addr, const void *val, size_t size) +{ + if (link != 0) + return -ENODEV; + + return -EACCES; +} + +static int fsi_master_fake_probe(struct platform_device *pdev) +{ + struct fsi_master *master; + + master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL); + if (!master) + return -ENOMEM; + + master->dev = &pdev->dev; + master->n_links = 1; + master->read = fsi_master_fake_read; + master->write = fsi_master_fake_write; + + return fsi_master_register(master); +} + +static const struct of_device_id fsi_master_fake_match[] = { + { .compatible = "ibm,fsi-master-fake" }, + { }, +}; + +static struct platform_driver fsi_master_fake_driver = { + .driver = { + .name = "fsi-master-fake", + .of_match_table = fsi_master_fake_match, + }, + .probe = fsi_master_fake_probe, +}; + +static int __init fsi_master_fake_init(void) +{ + struct device_node *np; + + platform_driver_register(&fsi_master_fake_driver); + + for_each_compatible_node(np, NULL, "ibm,fsi-master-fake") + of_platform_device_create(np, NULL, NULL); + + return 0; +} + +module_init(fsi_master_fake_init); + -- 1.8.2.2