summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
Commit message (Collapse)AuthorAgeFilesLines
* spi: Extend the core to ease integration of SPI memory controllersSteffen Trumtrar2019-05-081-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sync with Linux v5.1-rc1. This is the barebox adoption of the commit commit c36ff266dc82f4ae797a6f3513c6ffa344f7f1c7 Author: Boris Brezillon <boris.brezillon@bootlin.com> Date: Thu Apr 26 18:18:14 2018 +0200 spi: Extend the core to ease integration of SPI memory controllers Some controllers are exposing high-level interfaces to access various kind of SPI memories. Unfortunately they do not fit in the current spi_controller model and usually have drivers placed in drivers/mtd/spi-nor which are only supporting SPI NORs and not SPI memories in general. This is an attempt at defining a SPI memory interface which works for all kinds of SPI memories (NORs, NANDs, SRAMs). Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Frieder Schrempf <frieder.schrempf@exceet.de> Tested-by: Frieder Schrempf <frieder.schrempf@exceet.de> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: Generalize SPI "master" to "controller"Steffen Trumtrar2019-05-081-35/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sync with Linux v5.1-rc1. This is the barebox adoption of the commit commit 8caab75fd2c2a92667cbb1cd315720bede3feaa9 Author: Geert Uytterhoeven <geert+renesas@glider.be> Date: Tue Jun 13 13:23:52 2017 +0200 spi: Generalize SPI "master" to "controller" Now struct spi_master is used for both SPI master and slave controllers, it makes sense to rename it to struct spi_controller, and replace "master" by "controller" where appropriate. For now this conversion is done for SPI core infrastructure only. Wrappers are provided for backwards compatibility, until all SPI drivers have been converted. Noteworthy details: - SPI_MASTER_GPIO_SS is retained, as it only makes sense for SPI master controllers, - spi_busnum_to_master() is retained, as it looks up masters only, - A new field spi_device.controller is added, but spi_device.master is retained for compatibility (both are always initialized by spi_alloc_device()), - spi_flash_read() is used by SPI masters only. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: use of_property_read_bool where appropriateSascha Hauer2017-04-121-4/+4
| | | | | | Use of_property_read_bool where boolean properties are read. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: only register enabled child nodesJan Luebbe2015-07-091-1/+1
| | | | | Signed-off-by: Jan Luebbe <jluebbe@debian.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Call remove function only when availableSascha Hauer2015-03-171-1/+2
| | | | | | | | The bus implementations currently call the drivers remove hook unconditionally, but this hook is seldomly populated. Only call it when it's actually populated. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c/spi: match of_modaliasesSascha Hauer2014-02-071-1/+1
| | | | | | | | i2c/spi devices in the devicetree often come with a "vendor,device" comaptible string. These do not match in barebox, so add a device_match_of_modalias function which does exactly that. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: Get bus_num from devicetreeSascha Hauer2013-10-311-0/+3
| | | | | | Get the bus_num from devicetree if a "spi" alias exists. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: support dynamic bus idsSascha Hauer2013-10-311-0/+5
| | | | | | | | | When probing spi bus masters from devicetree they got a bus_num of -1. This works with a single bus master only since all bus masters had the same bus_num. Detect this and dynamically assign a valid bus_num. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: Call spi_of_register_slaves from coreSascha Hauer2013-10-311-3/+10
| | | | | | Makes individual handling of OF spi slaves unnecessary in the bus drivers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: Reuse "driver_match" for SPI busAlexander Shiyan2013-07-151-10/+1
| | | | | | | This will allow to use device_ids and make code a bit smaller. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* OF: base: convert and remove device_node_for_nach_childSebastian Hesselbarth2013-06-201-1/+1
| | | | | | | | Remove device_node_for_nach_child and convert users to corresponding imported OF API functions. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* OF: base: sync of_find_property with linux OF APISebastian Hesselbarth2013-06-201-5/+5
| | | | | | | | To start synchronizing OF API of barebox with linux OF API, this adds a length pointer to of_find_property. Also all current users of that function are updated to reflect the API change. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
* spi: improve devicetree supportSascha Hauer2013-05-211-2/+13
| | | | | | | | | - zero spi_board_info structure to not accidently pass unitilialized fields - parse spi-max-frequency property from devicetree - parse mode flags from devicetree Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/base: fix corrupt device treeSascha Hauer2012-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_add_child is a very unsafe function. If called multiple times it allows setting the same device to different parents thus corrupting the siblings list. This happens regularly since: | commit c2e568d19c5c34a05a1002d25280bf113b72b752 | Author: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | Date: Sat Nov 3 16:11:05 2012 +0100 | | bus: add bus device | | automatically add it as parent of any bus device if none already specified | | we have now a nice output per bus If for example a FATfs is mounted this nice output per bus often ends with: > `---- fat0 > `---- 0 > `---- 0x86f0000087020031-0x86f000410df27124: /dev/<NULL> > `---- sram00 > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > unable to handle NULL pointer dereference at address 0x0000000c > pc : [<87f08a20>] lr : [<87f08a04>] > sp : 86eff8c0 ip : 87f3fbde fp : ffffffff > r10: ffffffff r9 : 00000000 r8 : 00000003 > r7 : 86f075b8 r6 : 00000002 r5 : ffffffec r4 : 86f07544 > r3 : 00000000 r2 : 43f900b4 r1 : 00000020 r0 : 00000005 > Flags: Nzcv IRQs off FIQs off Mode SVC_32 > [<87f08a20>] (do_devinfo_subtree+0x90/0x130) from [<87f08a90>] (do_devinfo_subtree+0x100/0x130) > > [<87f3e070>] (unwind_backtrace+0x0/0x90) from [<87f28514>] (panic+0x28/0x3c) > [<87f28514>] (panic+0x28/0x3c) from [<87f3e4b8>] (do_exception+0x10/0x14) > [<87f3e4b8>] (do_exception+0x10/0x14) from [<87f3e544>] (do_data_abort+0x2c/0x38) > [<87f3e544>] (do_data_abort+0x2c/0x38) from [<87f3e268>] (data_abort+0x48/0x60) This patch fixes this by adding a device to its parents children list in register_device so that dev_add_child is no longer needed. This function is removed from the tree. Now callers of register_device have to clearly set the parent *before* registering a device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Jan Lübbe <jlu@pengutronix.de>
* spi: introduce spi_get_masterJean-Christophe PLAGNIOL-VILLARD2012-11-121-0/+12
| | | | | | | so we can request a master usefull for the spi command Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/remove-fsf-address'Sascha Hauer2012-10-031-4/+0
|\ | | | | | | | | | | Conflicts: drivers/net/miidev.c include/miidev.h
| * Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | | | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | spi: switch from printf back to debugJan Luebbe2012-09-271-1/+1
| | | | | | | | | | | | | | | | Commit 5888a3b5c96cf8381431486416ef2667993c85fc accidentally changed this to printf. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: register busJean-Christophe PLAGNIOL-VILLARD2012-09-231-0/+6
| | | | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | spi: add oftree supportSascha Hauer2012-09-141-1/+32
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | SPI: Put SPI devices on their own busSascha Hauer2012-09-141-0/+24
|/ | | | | | | | | This patch adds a SPI bus on which the SPI devices and drivers register. This makes it cleaner as SPI devices won't accidently end up probed by a platform_device driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* drivers/spi/spi.c: use DEVICE_ID_DYNAMIC when allocating a struct device_dJan Luebbe2012-05-141-0/+2
| | | | | | | | This causes allocation of a free id and avoids conflicts if multiple identical SPI devices are attached. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: enfore default bits_per_word valuePaul Fertser2011-09-291-1/+1
| | | | | | | | Documentation says it should default to 8 when not specified explicitly by the device data. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: let master a chance to setup device before registering itPaul Fertser2011-09-291-3/+2
| | | | | | | | | Call setup() before registering the device because registering leads to a probe routine of the slave device and that requires an initialised master. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: make the spi devices children of the parent busSascha Hauer2011-08-171-0/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: unregister dev if master->setup failsFranck Jullien2011-07-061-0/+1
| | | | | | | | If the device setup executed by the spi master fails, unregister the created device. Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: add bits_per_word to proxy structureFranck Jullien2011-07-061-0/+1
| | | | | | | | | | | | | During the creation of a new spi device, we need to have the possiblility to give the bits_per_word value to master->setup. As a matter of fact, spi master could check the spi device bits_per_word and compare this value against its capabilities. Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: add more spi transfer functionsHubert Feurstein2011-06-211-0/+41
| | | | | | | | | | | | | This commit adds the following spi transfer functions: - spi_write - spi_read - spi_write_then_read - spi_w8r8 The code has been ported from the linux kernel. Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: add platform_data pointer to spi_board_infoHubert Feurstein2011-06-211-0/+1
| | | | | | | | | In the spi layer this pointer will be assigned to the platform_data pointer of the new spi device, thus it can be accessed in the drivers 'probe' handler. Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: dev->id is an int, not a string, fix debug outputMarc Kleine-Budde2009-11-241-1/+1
| | | | | | Also convert __FUNCTION__ -> __func__ Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* spi: remove bogus setup of proxy deviceSascha Hauer2009-07-211-3/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* first (partly) running spi supportSascha Hauer2008-03-141-4/+187
|
* beginning of SPI supportSascha Hauer2008-03-111-0/+14