23 Apr, 2015

4 commits

  • We must not clear global_data even in tests, since the ram_buffer (which
    is used by malloc()) will also be lost, and subsequent tests will fail.

    Zero only the global_data fields that are required for the test to function.

    Signed-off-by: Simon Glass
    Reviewed-by: Joe Hershberger
    Tested-by: Joe Hershberger

    Simon Glass
     
  • This commit introduces simple tests for functions:
    - uclass_find_device_by_name()
    - uclass_get_device_by_name()

    Tests added by this commit:
    - Test: dm_test_uclass_devices_find_by_name: for uclass id: UCLASS_TEST_FDT
    * get uclass's devices by uclass_find_first/next_device() each as 'testdev',
    * for each returned device, call: uclass_find_device_by_name(),
    with previously returned device's name as an argument ('testdev->name').
    * for the found device ('founddev') check if:
    * founddev != NULL
    * testdev == founddev
    * testdev->name == founddev->name (by strcmp)

    - Test: dm_test_uclass_devices_get_by_name: for uclass id: UCLASS_TEST_FDT
    * get uclass's devices by uclass_get_first/next_device() each as 'testdev',
    * for each returned device, call: uclass_get_device_by_name(),
    with previously returned device's name as an argument ('testdev->name').
    * for the found device ('founddev') check if:
    * founddev != NULL
    * founddev is active
    * testdev == founddev
    * testdev->name == founddev->name (by strcmp)

    Signed-off-by: Przemyslaw Marczak
    Cc: Simon Glass
    Acked-by: Simon Glass

    Przemyslaw Marczak
     
  • This commit introduces simple tests for functions:
    - uclass_find_first_device()
    - uclass_find_next_device()
    - uclass_first_device()
    - uclass_next_device()

    Tests added by this commit:
    - Test: dm_test_uclass_devices_find:
    * call uclass_find_first_device(), then check if: (dev != NULL), (ret == 0)
    * for the rest devices, call uclass_find_next_device() and do the same check

    - Test: dm_test_uclass_devices_get:
    * call uclass_first_device(), then check if:
    -- (dev != NULL), (ret == 0), device_active()
    * for the rest devices, call uclass_next_device() and do the same check

    Signed-off-by: Przemyslaw Marczak
    Cc: Simon Glass
    Acked-by: Simon Glass

    Przemyslaw Marczak
     
  • This test introduces new test structure type:dm_test_perdev_uc_pdata.
    The structure consists of three int values only. For the test purposes,
    three pattern values are defined by enum, starting with TEST_UC_PDATA_INTVAL1.

    This commit adds two test cases for uclass platform data:
    - Test: dm_test_autobind_uclass_pdata_alloc - this tests if:
    * uclass driver sets: .per_device_platdata_auto_alloc_size field
    * the devices's: dev->uclass_platdata is non-NULL

    - Test: dm_test_autobind_uclass_pdata_valid - this tests:
    * if the devices's: dev->uclass_platdata is non-NULL
    * the structure of type 'dm_test_perdev_uc_pdata' allocated at address
    pointed by dev->uclass_platdata. Each structure field, should be equal
    to proper pattern data, starting from .intval1 == TEST_UC_PDATA_INTVAL1.

    Signed-off-by: Przemyslaw Marczak
    Cc: Simon Glass
    Acked-by: Simon Glass

    Przemyslaw Marczak
     

19 Apr, 2015

16 commits


17 Apr, 2015

3 commits


13 Feb, 2015

2 commits


30 Jan, 2015

15 commits

  • Tom Rini
     
  • At present we go through various contortions to store the SPI slave's chip
    select in its private data. This only exists when the slave is active so
    must be set up when it is probed. Until the device is probed we don't
    actually know what chip select it will appear on.

    However, now that we can support per-child platform data, we can use that
    instead. This allows us to set up the chip select when the child is bound,
    and avoid the messy contortions.

    Unfortunately this is a fairly large change and it seems to be difficult to
    break it down further.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • Some buses need to set up their devices before they can be used. This setup
    may well be common to all buses in a particular uclass. Support a common
    pre-probe method for the uclass, called before any bus devices are probed.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • For buses, after a child is bound, allow the uclass to perform some
    processing. This can be used to figure out the address of the child (e.g.
    the chip select for SPI slaves) so that it is ready to be probed.

    This avoids bus drivers having to repeat the same process, which really
    should be done by the uclass, since it is common.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • In many cases the per-child private data for a device's children is defined
    by the uclass rather than the individual driver. For example, a SPI bus
    needs to store information about each of its children, but all SPI drivers
    store the same information. It makes sense to allow the uclass to define
    this data.

    If the driver provides a size value for its per-child private data, then use
    it. Failng that, fall back to that provided by the uclass.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • At present we try to use the 'reg' property and device tree aliases to give
    devices a sequence number. The 'reg' property is often actually a memory
    address, so the sequence numbers thus-obtained are not useful. It would be
    better if the devices were just sequentially numbered in that case. In fact
    neither I2C nor SPI use this feature, so drop it.

    Some devices need us to look up an alias to number them within the uclass.
    Add a flag to control this, so it is not done unless it is needed.

    Adjust the tests to test this new behaviour.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • This is useful to check which uclass a device is in.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • Allow parent drivers to be called when a new child is bound to them. This
    allows a bus to set up information it needs for that child.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • In many cases the child platform data for a device's children is defined by
    the uclass rather than the individual devices. For example, a SPI bus needs
    to know the chip select and speed for each of its children. It makes sense
    to allow this information to be defined the SPI uclass rather than each
    individual driver.

    If the device provides a size value for its child platdata, then use it.
    Failng that, fall back to that provided by the uclass.

    Reviewed-by: Masahiro Yamada
    Signed-off-by: Simon Glass

    Simon Glass
     
  • For buses it is common for parents to need to know the address of the child
    on the bus, the bus speed to use for that child, and other information. This
    can be provided in platform data attached to each child.

    Add driver model support for this, including auto-allocation which can be
    requested using a new property to specify the size of the data.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • When using allocated platform data, allocate it when we bind the device.
    This makes it possible to fill in this information before the device is
    probed.

    This fits with the platform data model (when not using device tree),
    since platform data exists at bind-time.

    Signed-off-by: Simon Glass
    Reviewed-by: Masahiro Yamada

    Simon Glass
     
  • There is no point in running the tests if U-Boot cannot be built. Abort in
    this case.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • Rather than assuming that the chip offset length is 1, allow it to be
    provided. This allows chips that don't use the default offset length to
    be used (at present they are only supported by the command line 'i2c'
    command which sets the offset length explicitly).

    Signed-off-by: Simon Glass
    Acked-by: Heiko Schocher

    Simon Glass
     
  • Add a dm_ prefix to driver model I2C functions so that we can keep the old
    ones around.

    This is a little unfortunate, but on reflection it is too difficult to
    change the API. We can undo this rename when most boards and drivers are
    converted to use driver model for I2C.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • At present U-Boot sort-of supports the standard way of reading GPIOs from
    device tree nodes, but the support is incomplete, a bit clunky and only
    works for GPIO bindings where #gpio-cells is 2.

    Add new functions to request GPIOs, taking full account of the device
    tree binding. These permit requesting a GPIO with a simple call like:

    gpio_request_by_name(dev, "cd-gpios", 0, &desc, GPIOD_IS_IN);

    This will request the GPIO, looking at the device's node which might be
    this, for example:

    cd-gpios = ;

    The GPIO will be set to input mode in this case and polarity will be
    honoured by the GPIO calls.

    It is also possible to request and free a list of GPIOs.

    Signed-off-by: Simon Glass

    Simon Glass