9
0
Fork 0
Commit Graph

52 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 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 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
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
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 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
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
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 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 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
Sascha Hauer be573120fe make cdev 64bit capable
Next step to 64bit support: Make cdev size a 64bit type.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:24 +02:00
Sascha Hauer a6e358b2f5 drivers/base: bail out if request_iomem_region fails
When request_iomem_region fails we have to bail out instead of
dereferencing res->start.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-27 18:31:34 +02:00
Sascha Hauer 2ca512e592 print out resource_size_t correctly
resource_size_t can be 32bit or 64bit depending on the architecture.
Add a define for it to be able to printf a resource_size_t correctly

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-25 14:45:43 +02:00
Jean-Christophe PLAGNIOL-VILLARD 1fa17ad5d4 complete: add device name complete support for devinfo
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-04-30 20:37:34 +08:00
Sascha Hauer 2893952c28 devinfo: use accessor function for parameters
Instead of directly accessing the struct member of struct param_d
use the provided getter function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-24 11:18:32 +02:00
Sascha Hauer dbd4e1166e device: make singular devices possible
Currently all devices have an id meaning that all devicenames
end with a number. This patch adds a DEVICE_ID_SINGLE to make
it ppossible to register a device without an id assigned to
it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-15 16:11:26 +02:00
Sascha Hauer 33d1cc4bf2 commands: remove struct command pointer from commands
This is unused in all commands and thus can be removed.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-27 20:28:07 +01:00
Sascha Hauer 491cc29b0a devices: unregister children when unregistering a device
We currently do not allow to unregister a device when it
has children. However, the return value is seldomly checked.
Also this breaks for hot pluggable devices like USB which we have
to unregister when they disappear. The best way to fix this is to
unregister our children and also the partitions on the unregistered
device.
We unregister the device first and then afterwards the children.
We do this because for example network devices have a miidev as
child which they unregister themselves. So we only have to
unregister the children which are not cleaned up by the drivers,
namely fs devices.
Also, unregister all partitions on a disappearing device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-17 10:27:15 +01:00
Sascha Hauer 18e845efd9 implement resource management for platform devices
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-04 22:26:12 +01:00
Sascha Hauer 79884012c6 devinfo: beautify output
Files associated to a device showed up in a long list. Instead,
print them in seperate lines and also show offset/size information

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-08-17 09:36:35 +02:00
Sascha Hauer 35191f24cc drivers/base: initialize active list
Otherwise, when a non active device is unregistered, we call
list_del on an unitialized list which oopses.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-08-15 09:45:34 +02:00
Jean-Christophe PLAGNIOL-VILLARD ad7590ee64 driver: remove map_base
as now all the drivers and board have been switch to resource whe can drop
map_base and size from device_d

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2011-08-01 16:33:44 +08:00
Jean-Christophe PLAGNIOL-VILLARD aaefaddde3 devinfo: switch to resource
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2011-07-29 14:04:24 +08:00
Jean-Christophe PLAGNIOL-VILLARD 7a68c0fac7 generic_memmap_ro/rw: switch to resource
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2011-07-29 14:04:24 +08:00