aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/fsi/fsi-core.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-07-03Merge tag 'fsi-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi into char-misc-nextGreg Kroah-Hartman1-12/+20
Joel writes: FSI changes for 5.3 - Add MAINTAINERS entry. There is now a git tree and a mailing list/patchwork for collecting FSI patches - Bug fix for error driver registration error paths - Correction for the OCC hwmon driver to meet the spec * tag 'fsi-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi: fsi/core: Fix error paths on CFAM init OCC: FSI and hwmon: Add sequence numbering MAINTAINERS: Add FSI subsystem
2019-07-03fsi/core: Fix error paths on CFAM initJeremy Kerr1-12/+20
Change d1dcd67825 re-worked the struct fsi_slave initialisation in fsi_slave_init, but introduced a few inconsitencies: the slave->dev is now registered through cdev_device_add, but we may kfree() the device out from underneath the cdev registration. We may also leave an IDA allocated. This change fixes the error paths, so that we kfree() only before the device is registered with the core code. We also move the smode write to before we start creating proper devices, as it's the most likely to fail. We also remove the IDA-allocated minor on error, and properly clean up the of_node. Fixes: d1dcd6782576 ("fsi: Add cfam char devices") Reported-by: Lei YU <mine260309@gmail.com> Tested-by: John Wang <wangzqbj@inspur.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174Thomas Gleixner1-9/+1
Based on 1 normalized pattern(s): 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 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 655 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-27fsi: Prevent multiple concurrent rescansBenjamin Herrenschmidt1-2/+14
The bus scanning process isn't terribly good at parallel attempts at rescanning the same bus. Let's have a per-master mutex protecting the scanning process. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2018-07-27fsi: Add cfam char devicesBenjamin Herrenschmidt1-51/+213
This aims to deprecate the "raw" sysfs file used for directly accessing the CFAM and instead use a char device like the other sub drivers. Since it reworks the slave creation code and adds a cfam device type, we also use the opportunity to convert the attributes to attribute groups and add a couple more. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2018-07-27fsi: Add new central chardev supportBenjamin Herrenschmidt1-2/+93
The various FSI devices (sbefifo, occ, scom, more to come) currently use misc devices. This is problematic as the minor device space for misc is limited and there can be a lot of them. Also it limits our ability to move them to a dedicated /dev/fsi directory or to be smart about device naming and numbering. It also means we have IDAs on every single of these drivers This creates a common fsi "device_type" for the optional /dev/fsi grouping and a dev_t allocator for all FSI devices. "Legacy" devices get to use a backward compatible numbering scheme (as long as chip id <16 and there's only one copy of a given unit type per chip). A single major number and a single IDA are shared for all FSI devices. This doesn't convert the FSI device drivers to use the new scheme yet, they will be converted individually. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2018-07-23fsi: Add support for device-tree provided chip IDsBenjamin Herrenschmidt1-0/+24
They get retrieved from the device-tree and exposed as an attribute in sysfs Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2018-07-12fsi: Don't use device_unregister() in fsi_master_register()Benjamin Herrenschmidt1-5/+2
In the error path of fsi_master_register(), we currently use device_unregister(). This will cause the last reference to the structure to be dropped, thus freeing the enclosing structure, which isn't what the callers want. Use device_del() instead so that we return to the caller with a refcount of 1. The caller can then assume that it must use put_device() after a call to fsi_master_register() regardless of whether the latter suceeded or failed. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2018-07-12fsi: Add mechanism to set the tSendDelay and tEchoDelay valuesBenjamin Herrenschmidt1-18/+91
Those values control the amount of "dummy" clocks between commands and between a command and its response. This adds a way to configure them from sysfs (to be later extended to defaults in the device-tree). The default remains 16 (the HW default). This is only supported if the backend supports the new link_config() callback to configure the generation of those delays. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Joel Stanley <joel@jms.id.au> ---
2018-07-12fsi: Move code around to avoid forward declarationBenjamin Herrenschmidt1-48/+46
Move fsi_slave_set_smode() and its helpers to before it's first user and remove the corresponding forward declaration. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Joel Stanley <joel@jms.id.au>
2018-06-18fsi: core: Fix sparse warningsJoel Stanley1-10/+13
fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:210:9: warning: cast to restricted __be32 fsi-core.c:606:15: warning: incorrect type in assignment (different base types) fsi-core.c:606:15: expected unsigned int [unsigned] [assigned] [usertype] smode fsi-core.c:606:15: got restricted __be32 [usertype] <noident> fsi-core.c:492:28: warning: expression using sizeof(void) fsi-core.c:520:29: warning: expression using sizeof(void) fsi-core.c:682:19: warning: cast to restricted __be32 fsi-core.c:682:19: warning: cast to restricted __be32 fsi-core.c:682:19: warning: cast to restricted __be32 fsi-core.c:682:19: warning: cast to restricted __be32 fsi-core.c:682:19: warning: cast to restricted __be32 fsi-core.c:682:19: warning: cast to restricted __be32 fsi-core.c:706:24: warning: incorrect type in assignment (different base types) fsi-core.c:706:24: expected unsigned int [unsigned] [usertype] llmode fsi-core.c:706:24: got restricted __be32 [usertype] <noident> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2018-03-14fsi: core: Add check for master property no-scan-on-initChristopher Bostic1-1/+4
Prior to scanning a master check if the optional property no-scan-on-init is present. If it is then avoid scanning. This is necessary in cases where a master scan could interfere with another FSI master on the same bus. Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14fsi: core: Reduce console output during normal scanChristopher Bostic1-2/+2
To reduce amount of console output during boot / power up make all normal path scan related messages debug type. Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14fsi: Match fsi slaves and engines to available dt nodesJeremy Kerr1-0/+99
This change populates device tree nodes for scanned FSI slaves and engines. If the master populates ->of_node of the FSI master device, we'll look for matching slaves, and under those slaves we'll look for matching engines. This means that FSI drivers will have their ->of_node pointer populated if there's a corresponding DT node, which they can use for further device discover. Presence of device tree nodes is optional, and only required for fsi device drivers that need extra properties, or subordinate devices, to be enumerated. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14fsi: Fix one and two byte bus reads/writesEddie James1-4/+7
Address checker fixed to allow one and two byte reads/writes. Address alignments for each size verified. Signed-off-by: Edward James <eajames@us.ibm.com> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14fsi: Add fsi_master_rescan()Jeremy Kerr1-2/+8
We'll want non-core fsi code to trigger a rescan, so introduce a non-static fsi_master_rescan() function. Use this for the existing unscan/scan behaviour too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Christopher Bostic <clbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-04drivers/fsi: make a couple of functions staticColin Ian King1-3/+3
The functions fsi_slave_report_and_clear_errors and fsi_slave_handle_error are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnings: symbol 'fsi_slave_report_and_clear_errors' was not declared. Should it be static? symbol 'fsi_slave_handle_error' was not declared. Should it be static? Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-28drivers/fsi: add const to bin_attribute structuresBhumika Goyal1-2/+2
Declare bin_attribute structures as const as they are only passed as an argument to the function device_create_bin_file. This argument is of type const, so declare the structure as const. Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-17drivers/fsi: fix fsi_slave_mode prototypeArnd Bergmann1-1/+1
gcc warns about the return type of this function: drivers/fsi/fsi-core.c:535:8: error: type qualifiers ignored on function return type [-Werror=ignored-qualifiers] This removes the 'const' attribute, as suggested by the warning. Fixes: 2b37c3e285f9 ("drivers/fsi: Set slave SMODE to init communication") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-17fsi: core: register with postcore_initcallJoel Stanley1-3/+2
When testing an i2c driver that is a fsi bus driver, I saw the following oops: kernel BUG at drivers/base/driver.c:153! Internal error: Oops - BUG: 0 [#1] ARM [<8027cb1c>] (driver_register) from [<80344e88>] (fsi_driver_register+0x2c/0x38) [<80344e88>] (fsi_driver_register) from [<805f5ebc>] (fsi_i2c_driver_init+0x1c/0x24) [<805f5ebc>] (fsi_i2c_driver_init) from [<805d1f14>] (do_one_initcall+0xb4/0x170) [<805d1f14>] (do_one_initcall) from [<805d20f0>] (kernel_init_freeable+0x120/0x1dc) [<805d20f0>] (kernel_init_freeable) from [<8043f4a8>] (kernel_init+0x18/0x104) [<8043f4a8>] (kernel_init) from [<8000a5e8>] (ret_from_fork+0x14/0x2c) This is because the fsi bus had not been registered. This fix registers the bus with postcore_initcall instead, to ensure it is registered earlier on. When the fsi core is used as a module this should not be a problem as the fsi driver will depend on the fsi bus type symbol, and will therefore load the core before the driver. Fixes: 0508ad1fff11 ("drivers/fsi: Add empty fsi bus definitions") Signed-off-by: Joel Stanley <joel@jms.id.au> Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add module license to core driverChristopher Bostic1-0/+1
Add missing MODULE_LICENSE("GPL") to the core FSI driver. Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Use asynchronous slave modeJeremy Kerr1-1/+21
For slaves that are behind a software-clocked master, we want FSI CFAMs to run asynchronously to the FSI clock, so set up our slaves to be in async mode. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add error handling for slaveJeremy Kerr1-7/+114
This change implements error handling in the FSI core, by cleaining up and retrying failed operations, using the SISC, TERM and BREAK facilities. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add tracepoints for low-level operationsJeremy Kerr1-6/+21
Trace low level read and write FSI bus operations. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: expose direct-access slave APIJeremy Kerr1-6/+24
Allow drivers to access the slave address ranges. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add sysfs files for FSI master & slave accessesJeremy Kerr1-0/+116
This change adds a 'raw' file for reads & writes, and a 'term' file for the TERM command, and a 'break' file for issuing a BREAK. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add client driver register utilitiesChristopher Bostic1-0/+17
Add driver_register and driver_unregister wrappers for FSI. Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add master unscanChristopher Bostic1-0/+44
Allow a master to undo a previous scan. Should a master scan a bus twice it will need to ensure it doesn't double register any previously detected device. Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> ---- v7 - Unscan when unregistering master - Remove leading '__'s from function names - Return fail state for sysfs rescan file Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add device read/write/peek APIJeremy Kerr1-1/+49
This change introduces the fsi device API: simple read, write and peek accessors for the devices' address spaces. Includes contributions from Christopher Bostic <cbostic@linux.vnet.ibm.com> and Edward A. James <eajames@us.ibm.com>. Signed-off-by: Edward A. James <eajames@us.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: scan slaves & register devicesJeremy Kerr1-1/+127
Now that we have fsi_slave devices, scan each for endpoints, and register them on the fsi bus. Includes contributions from Christopher Bostic <cbostic@linux.vnet.ibm.com>. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Set slave SMODE to init communicationChristopher Bostic1-0/+75
Set CFAM to appropriate ID so that the controlling master can manage link memory ranges. Add slave engine register definitions. Includes changes from Jeremy Kerr <jk@ozlabs.org>. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Implement slave initialisationJeremy Kerr1-2/+65
Implement fsi_slave_init: if we can read a chip ID, create fsi_slave devices and register with the driver core. Includes changes from Christopher Bostic <cbostic@linux.vnet.ibm.com>. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Set up links for slave communicationChristopher Bostic1-2/+35
Enable each link and send a break command, and try to detect a slave by reading from the SMODE register. Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add slave & master read/write APIsJeremy Kerr1-0/+92
Introduce functions to perform reads/writes on the slave address space; these simply pass the request on the slave's master with the correct link and slave ID. We implement these on top of similar helpers for the master. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add empty master scanJeremy Kerr1-2/+23
When a new fsi master is added, we will need to scan its links, and slaves attached to those links. This change introduces a little shell to iterate the links, which we will populate with the actual slave scan in a later change. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add slave definitionJeremy Kerr1-0/+10
Add the initial fsi slave device, which is private to the core code. This will be a child of the master, and parent to endpoint devices. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-09drivers/fsi: Add fsi master definitionJeremy Kerr1-0/+35
Add a `struct fsi_master` to represent a FSI master controller. FSI master drivers register one of these structs to provide device-specific of the standard operations: read/write/term/break and link control. Includes changes from Edward A. James <eajames@us.ibm.com> & Jeremy Kerr <jk@ozlabs.org>. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-10drivers/fsi: add driver to device matchesJeremy Kerr1-0/+21
Driver bind to devices based on the engine types & (optional) versions. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Chris Bostic <cbostic@us.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-10drivers/fsi: Add empty fsi bus definitionsJeremy Kerr1-0/+38
This change adds the initial (empty) fsi bus definition, and introduces drivers/fsi/. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Chris Bostic <cbostic@us.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>