9
0
Fork 0
Commit Graph

77 Commits

Author SHA1 Message Date
Michel Stam 4d94f56c6c common: Allow for I/O mapped I/O
Rework the current framework so that I/O mapped I/O resources are
also possible.

Signed-off-by: Michel Stam <michel@reverze.net>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-08 08:17:55 +02:00
Sascha Hauer e358922a74 Merge branch 'for-next/mtd'
Conflicts:
	drivers/mtd/core.c
	net/eth.c
2014-03-07 09:25:18 +01:00
Sascha Hauer d23af7a0a0 device: remove parameters when unregistering a device
Otherwise we loose memory on each device_unregister. The ethernet
code used to do this before calling unregister_device. This can
now be removed.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-13 19:39:11 +01:00
Sascha Hauer f0bd826abe device: init bus list
bus_list is only initialized when the device has a bus, but it
needs to be initialized in unregister_device, so initialize the
list unconditionally.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-13 19:39:11 +01:00
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 1c9668a3cc net: dm9k: Fix resource sizes in add_dm9000_device
The dm9000 needs a resource for an index register and one for
the data register. Both should have a size of the access width,
and not two times the access width. The current code is probably
a leftover when the dm9000 had only one resource.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-12-18 16:52:14 +01:00
Sascha Hauer ed039cd72b Merge branch 'for-next/omap-drivers' 2013-12-06 08:23:27 +01:00
Sascha Hauer f92f309c54 device: Add functions to add resources
We currently have functions to add a device based on function parameters.
This adds the corresponding functions to add resources to a device without
registering the device itself. This is useful to manipulate devices before
registering them.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-11-27 10:42:54 +01:00
Sascha Hauer b67b2671c2 treewide: Add missing includes
A lot of files rely on include/driver.h including include/of.h (and
this including include/errno.h. include the files explicitly so we can
eventually get rid of including of.h from driver.h

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-11-08 15:42:04 +01:00
Sascha Hauer 33c56e21eb Merge branch 'for-next/misc'
Conflicts:
	commands/Makefile
2013-10-07 08:00:25 +02:00
Sascha Hauer 666f12e0c1 introduce runtime loglevel
With this the verbosity of barebox can be controlled during runtime
using the 'loglevel' globalvar.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-09-29 12:15:40 +02:00
Sascha Hauer 4a22305307 move devinfo command to its own file
Just like nearly all other commands are in individual files.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-09-27 11:14:32 +02:00
Alexander Shiyan 7bc400d14c base: Transform "platform_match" into "device_match" and make this function public
This change will allow reuse this function for other buses.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-07-15 10:08:10 +02:00
Sascha Hauer 8d2762ff56 driver: implement device_detect_by_name function
It becomes a common pattern for boards to find a device and
call device_detect on it. Add a convenience wrapper for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-06-26 18:17:12 +02:00
Sascha Hauer 95e7982f99 devices: add detect mechanism
We often encounter the situation where slow devices should not be
probed during startup since probing is slow and maybe unnecessary
for unused devices. With MMC we have the 'probe' device parameter,
for ata we have the same, for USB we have the 'usb' command. Overall
this is not very consistent.
With MMC there is the additional problem that the probe parameter
is attached to the logical device when we often have the information
which physical device we want to probe.
This patch adds a 'detect' callback for devices and adds a command
to detect devices and to list the devices which are actually detecable.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-31 12:32:05 +02:00
Sascha Hauer 73b0d228e5 driver: Attach info callback to device, not to driver
Since the info is device specific and not driver specific, attach
the callback to the device. This makes it possible to have a info
callback for a device which does not have a driver attached.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-30 12:18:27 +02:00
Sascha Hauer c5fa299862 param: Add info function
Some parameters may wish to provide some information about their
meaning or possible values. Provide an info callback for parameters.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-23 15:40:22 +02:00
Sascha Hauer 7f63c0a246 Add initial pinctrl support
This is a massively stripped down pinctrl support. The upper API
consists of only of:

int pinctrl_select_state(struct device_d *dev, const char *state);

This is used to setup the pinmux for a device to a certain state.
This function normally does not need to be called manually. The
device core will setup the default state before probing a device.

The pinctrl core has the job of handling the devicetree. It parses
the pinctrl phandles for a device from devicetree, finds the correct
pinctrl device and calls its set_state callback with the pinctrl
setup device node.

The simplicity of this pinctrl framework comes from the fact that
we:

- Limit usage to devicetree only for now. For non devicetree use the
  old legacy SoC specific APIs still can be used.
- Do not parse the devicetree into internal data structures which
  are used by the drivers later. This adds the overhead that we
  may parse the devicetree multiple times for more dynamic setups,
  but on the other hand we do not need to parse devices from the
  devicetree we don't use in barebox
- Do not detect resource conflicts. Since the framework mainly is
  a devicetree parser this would be hard to implement. It should
  be easy for board maintainers to avoid resource conflicts though.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-23 09:36:13 +02:00
Sascha Hauer 1a66a77567 bus: Make struct device a pointer
struct bus_type contains an embedded struct device_d which is quite
a big structure. Dynamically allocate this instead to save the space
in the binary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-14 08:42:24 +01:00
Alexander Shiyan 927eb75795 Make "dev_get_resource" publicly available
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-18 09:22:17 +01: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
Sascha Hauer 8f32824c6e Merge branch 'for-next/phylib'
Conflicts:
	drivers/net/phy/phy.c
2012-12-07 16:43:21 +01:00
Sascha Hauer a0643f615d Merge branch 'for-next/driver' 2012-12-07 16:42:04 +01:00
Robert P. J. Day a912f55a6c correct simple typo, "plarform_init"
Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-12-03 11:13:50 +01:00
Jean-Christophe PLAGNIOL-VILLARD f777b3b13f driver: introduce device_probe to manully probe a device
This will expect a driver to be specified
This is needed by the phylib the probe the generic phy if not driver found

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-11-20 09:38:25 +01:00
Jean-Christophe PLAGNIOL-VILLARD c2e568d19c 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

barebox@Atmel at91sam9x5-ek:/
devices:
`---- platform
     `---- atmel_usart0
          `---- cs0
     `---- atmel_usart1
          `---- cs1
     `---- mem0
          `---- 0x00000000-0x07ffffff: /dev/ram0
     `---- mem1
          `---- 0x00000000-0x00007fff: /dev/sram0
     `---- mem2
          `---- 0x00000000-0x000037bf: /dev/defaultenv
     `---- mem3
          `---- 0x00000000-0xfffffffe: /dev/mem
     `---- cs2
     `---- w1-gpio
          `---- w1_bus0
               `---- w1-2d-0
                    `---- 0x00000000-0x0000007f: /dev/ds24310
               `---- w1-2d-1
                    `---- 0x00000000-0x0000007f: /dev/ds24311
               `---- w1-23-0
                    `---- 0x00000000-0x000001ff: /dev/ds24330
     `---- at91sam9x5cm
     `---- at91sam9x5ek
     `---- at91sam9x5dm
     `---- atmel_nand0
          `---- nand0
               `---- 0x00000000-0x1fffffff: /dev/nand0
               `---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
               `---- 0x00040000-0x0009ffff: /dev/self_raw
               `---- 0x000a0000-0x000bffff: /dev/env_raw
               `---- 0x000c0000-0x000dffff: /dev/env_raw1
               `---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
               `---- 0x00040000-0x0009ffff: /dev/nand0.barebox
               `---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
               `---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
               `---- 0x000e0000-0x000fffff: /dev/nand0.oftree
               `---- 0x00100000-0x001fffff: /dev/nand0.free
               `---- 0x00200000-0x007fffff: /dev/nand0.kernel
               `---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
               `---- 0x08000000-0x1fffffff: /dev/nand0.data
     `---- macb0
          `---- miibus0
          `---- eth0
     `---- atmel_spi0
          `---- mtd_dataflash0
               `---- dataflash0
                    `---- 0x00000000-0x0041ffff: /dev/dataflash0
     `---- atmel_mci0
          `---- mci0
               `---- 0x00000000-0x1d9bfffff: /dev/disk0
               `---- 0x00100000-0x064fffff: /dev/disk0.0
               `---- 0x06500000-0x1d9bfffff: /dev/disk0.1
     `---- i2c-gpio0
          `---- i2c0
               `---- qt10700
                    `---- cs3
`---- mdio_bus
`---- spi
`---- i2c
`---- w1_bus
`---- fs
     `---- ramfs0
     `---- devfs0
`---- net
`---- global

drivers:
atmel_usart
ramfs
devfs
fat
macb
Generic PHY
atmel_nand
mtd_dataflash
m25p80
atmel_spi
i2c-gpio
mci
atmel_mci
qt1070
w1-gpio
ds2431
ds2433
mem

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-11-19 11:36:33 +01:00
Sascha Hauer 856f60dbd1 Merge branch 'for-next/misc'
Conflicts:
	commands/Makefile

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-11-16 14:01:34 +01:00
Jean-Christophe PLAGNIOL-VILLARD d54f5b1b48 driver: add support for requesting resource by name
this will allow to avoid issue with resource order

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-30 10:24:12 +01:00
Franck Jullien 8579905314 cosmetic: remove right alignment on driver list
In order to avoid misalignment, just remove the right alignment while
printing the drivers list.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-17 22:17:12 +02:00
Sascha Hauer 501ca464e2 platform driver: Drop check for resource conflicts
The check is wrong since it would have to check whether the
new iomem region overlaps with an existing region. Checking
for the base address only is not enough.
Currently this is not possible because every device conflicts
with the top iomem region which covers the whole address space.

This at least fixes the regression that devices whose memory region
begins at 0x0 can no longer be succesfully registered.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-10-13 14:19:35 +02:00
Sascha Hauer 52df7b6184 Merge branch 'pu/misc-fixes' 2012-10-07 18:45:56 +02:00
Sascha Hauer 54763e2c17 driver: print error message when probe fails
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-07 12:58:02 +02:00
Sascha Hauer 27c64eaacd driver: make get_bus_by_name static
We have no prototype for it, so it should be static.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-04 15:34:47 +02:00
Jean-Christophe PLAGNIOL-VILLARD ddba7e606b devinfo: display device bus name
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-10-04 15:19:12 +02:00
Jean-Christophe PLAGNIOL-VILLARD 3c5327e660 switch all platform_bus device/driver registering to platform_driver/device_register
now register_driver and register_device are for bus only usage.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-10-04 15:19:12 +02:00
Sascha Hauer 50c075ba43 driver: move dev_get_drvdata out of CONFIG_CMD_DEVINFO
dev_get_drvdata accidently is inside #ifdef CONFIG_CMD_DEVINFO.
Move it out of there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-04 10:56:24 +02: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
Jean-Christophe PLAGNIOL-VILLARD ed942bc085 driver: search device and driver based on the bus instead of all
This will allow reduce the number of driver and device to search on.

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
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 58f3457f4f of: add devicetree probing support
This adds code to probe devices from a devicetree. Most helper
functions are directly imported from Linux.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-14 11:47:42 +02:00
Sascha Hauer b2a13798a6 driver: add dev_get_drvdata function
Drivers need to get their driver data either from devicetree or the platform
information. It should matter for the driver where this data comes from, so
introduce a common function for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-14 11:47:42 +02:00
Sascha Hauer 420815465e driver: Add platform_device_id mechanism
It is common for drivers to handle multiple similar devices. On
Linux the driver can distinguish between the devices using the
platform_device_id mechanism. Introduce the same for barebox.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-14 11:47:42 +02:00
Sascha Hauer 08a7d5a625 driver: rewrite dev_printf as a function
Printing device context normally should be "driver instance:",
but instead we printed the device name twice. This patch fixes
this and as a bonus makes the binary a bit smaller. Instead of
a '@' between driver and instance this function now prints a
whitespace which is a bit more like Linux.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-14 11:47:42 +02:00
Sascha Hauer 1510c57e93 Merge branch 'for-next/resource-size'
Conflicts:
	drivers/base/resource.c
	fs/fs.c
2012-07-02 11:05:57 +02:00
Sascha Hauer f22d4e2778 Merge branch 'for-next/sparse' 2012-07-02 10:59:37 +02:00
Sascha Hauer a3251562db Merge branch 'for-next/64bit' 2012-07-02 10:58:32 +02:00
Sascha Hauer 1c136767a2 ehci: Fix resource size
We now have a resource size for the ehci hccr register space. This
was assumed to be 0x40 in size. On OMAP though it is only 0x10 and
then the hccr resource conflicts with the hcor resource which results
in a non working ehci port on beagle and panda boards. This patch
adds a nonintrusive workaround, it limits the hccr resource to 0x10,
which then also works on OMAP.

Later we should drop the multiple resources for the ehci port and
make the resource as specified in the datasheets.

This is broken since:

commit 08845e41fb
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Wed May 23 12:54:24 2012 +0200

    usb ehci: Add resource sizes

    add_usb_ehci_device registers resources with size 0. Fix this.

    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-07-02 10:11:05 +02:00
Sascha Hauer 5f03074ea9 resource: store 'end' instead of 'size' in struct resource
Storing the size instead of the resource end in struct resource was
a mistake. 'size' ranges from 0 to UINT[32|64]_MAX + 1 which obviously
leads to problems. 'end' on the other hand will never exceed
UINT[32|64]_MAX. Also this way we can express a iomem region covering
the whole address space.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-07-01 08:18:53 +02:00
Sascha Hauer 6f5ea13f28 Do not use iomem space for dev_get_mem_region
It is mostly used for mmapping sdram which is no iomem.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 22:34:54 +02:00