9
0
Fork 0
Commit Graph

28 Commits

Author SHA1 Message Date
Sascha Hauer 394edf6377 i2c/spi: match of_modaliases
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>
2014-02-07 09:28:02 +01:00
Sascha Hauer 2fa5f06958 spi: Get bus_num from devicetree
Get the bus_num from devicetree if a "spi" alias exists.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-10-31 12:53:08 +01:00
Sascha Hauer fb40dd5157 spi: support dynamic bus ids
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>
2013-10-31 12:53:08 +01:00
Sascha Hauer fd5b82e640 spi: Call spi_of_register_slaves from core
Makes individual handling of OF spi slaves unnecessary in the bus drivers.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-10-31 12:53:05 +01:00
Alexander Shiyan 4802ed1489 spi: Reuse "driver_match" for SPI bus
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>
2013-07-15 10:08:11 +02:00
Sebastian Hesselbarth 2e2265bfd4 OF: base: convert and remove device_node_for_nach_child
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>
2013-06-20 21:22:19 +02:00
Sebastian Hesselbarth 905f3ee7fb OF: base: sync of_find_property with linux OF API
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>
2013-06-20 17:18:01 +02:00
Sascha Hauer 56dd3c6c2a spi: improve devicetree support
- 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>
2013-05-21 09:35:19 +02:00
Sascha Hauer 1a9e93cc81 drivers/base: fix corrupt device tree
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 c2e568d19c
| 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>
2012-12-12 15:04:27 +01:00
Jean-Christophe PLAGNIOL-VILLARD 968d444cdd spi: introduce spi_get_master
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>
2012-11-12 08:32:16 +01:00
Sascha Hauer d1e65d2a7b Merge branch 'for-next/remove-fsf-address'
Conflicts:
	drivers/net/miidev.c
	include/miidev.h
2012-10-03 21:12:48 +02:00
Jan Luebbe 0f77ca3c49 spi: switch from printf back to debug
Commit 5888a3b5c9 accidentally changed
this to printf.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-27 07:17:52 +02:00
Jean-Christophe PLAGNIOL-VILLARD 72b0a6503f driver: register bus
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-23 21:15:13 +02:00
Sascha Hauer 77322aa896 Treewide: remove address of the Free Software Foundation
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>
2012-09-17 10:57:41 +02:00
Sascha Hauer 5888a3b5c9 spi: add oftree support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-14 13:35:47 +02:00
Sascha Hauer 617bfbcbeb SPI: Put SPI devices on their own bus
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>
2012-09-14 11:47:24 +02:00
Jan Luebbe 7b5817e58d drivers/spi/spi.c: use DEVICE_ID_DYNAMIC when allocating a struct device_d
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>
2012-05-14 19:47:13 +02:00
Paul Fertser 686bd976a6 spi: enfore default bits_per_word value
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>
2011-09-29 12:27:32 +02:00
Paul Fertser 67f2dcc0d7 spi: let master a chance to setup device before registering it
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>
2011-09-29 12:27:32 +02:00
Sascha Hauer c574a0d1f1 spi: make the spi devices children of the parent bus
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-08-17 09:36:35 +02:00
Franck Jullien 07b2cff207 spi: unregister dev if master->setup fails
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>
2011-07-06 10:25:39 +02:00
Franck Jullien 4c35079c1c spi: add bits_per_word to proxy structure
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>
2011-07-06 10:25:39 +02:00
Hubert Feurstein c0b9629867 spi: add more spi transfer functions
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>
2011-06-21 13:56:49 +02:00
Hubert Feurstein 76f46b5619 spi: add platform_data pointer to spi_board_info
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>
2011-06-21 13:56:49 +02:00
Marc Kleine-Budde 7ee5aa3329 spi: dev->id is an int, not a string, fix debug output
Also convert __FUNCTION__ -> __func__

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2009-11-24 10:01:07 +01:00
Sascha Hauer 56139274fd spi: remove bogus setup of proxy device
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:46 +02:00
Sascha Hauer a14a5c02f0 first (partly) running spi support 2008-03-14 12:59:55 +01:00
Sascha Hauer 906eea397a beginning of SPI support 2008-03-11 22:13:06 +01:00