Merge pull request #1450 from MISL-EBU-System-SW/marvell-support-v6
authordanh-arm <dan.handley@arm.com>
Thu, 19 Jul 2018 16:11:32 +0000 (17:11 +0100)
committerGitHub <noreply@github.com>
Thu, 19 Jul 2018 16:11:32 +0000 (17:11 +0100)
Marvell support for Armada 8K SoC family

1  2 
drivers/io/io_fip.c
maintainers.rst

diff --combined drivers/io/io_fip.c
index 6e7103dbee9374aad685a5de8da2c70f481ba8d3,c5ee6a4df59af7058c73a4e337ee35659e901e16..9d6c763e8969bb92597a6c59fba4c25d76c05050
  #include <utils.h>
  #include <uuid.h>
  
 +#ifndef MAX_FIP_DEVICES
 +#define MAX_FIP_DEVICES               1
 +#endif
 +
  /* Useful for printing UUIDs when debugging.*/
  #define PRINT_UUID2(x)                                                                \
        "%08x-%04hx-%04hx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",   \
@@@ -36,33 -32,11 +36,33 @@@ typedef struct 
        fip_toc_entry_t entry;
  } file_state_t;
  
 +/*
 + * Maintain dev_spec per FIP Device
 + * TODO - Add backend handles and file state
 + * per FIP device here once backends like io_memmap
 + * can support multiple open files
 + */
 +typedef struct {
 +      uintptr_t dev_spec;
 +} fip_dev_state_t;
 +
  static const uuid_t uuid_null = { {0} };
 +/*
 + * Only one file can be open across all FIP device
 + * as backends like io_memmap don't support
 + * multiple open files. The file state and
 + * backend handle should be maintained per FIP device
 + * if the same support is available in the backend
 + */
  static file_state_t current_file = {0};
  static uintptr_t backend_dev_handle;
  static uintptr_t backend_image_spec;
  
 +static fip_dev_state_t state_pool[MAX_FIP_DEVICES];
 +static io_dev_info_t dev_info_pool[MAX_FIP_DEVICES];
 +
 +/* Track number of allocated fip devices */
 +static unsigned int fip_dev_count;
  
  /* Firmware Image Package driver functions */
  static int fip_dev_open(const uintptr_t dev_spec, io_dev_info_t **dev_info);
@@@ -118,94 -92,20 +118,94 @@@ static const io_dev_funcs_t fip_dev_fun
        .dev_close = fip_dev_close,
  };
  
 +/* Locate a file state in the pool, specified by address */
 +static int find_first_fip_state(const uintptr_t dev_spec,
 +                                unsigned int *index_out)
 +{
 +      int result = -ENOENT;
 +      unsigned int index;
 +
 +      for (index = 0; index < (unsigned int)MAX_FIP_DEVICES; ++index) {
 +              /* dev_spec is used as identifier since it's unique */
 +              if (state_pool[index].dev_spec == dev_spec) {
 +                      result = 0;
 +                      *index_out = index;
 +                      break;
 +              }
 +      }
 +      return result;
 +}
 +
  
 -/* No state associated with this device so structure can be const */
 -static const io_dev_info_t fip_dev_info = {
 -      .funcs = &fip_dev_funcs,
 -      .info = (uintptr_t)NULL
 -};
 +/* Allocate a device info from the pool and return a pointer to it */
 +static int allocate_dev_info(io_dev_info_t **dev_info)
 +{
 +      int result = -ENOMEM;
  
 +      assert(dev_info != NULL);
 +
 +      if (fip_dev_count < (unsigned int)MAX_FIP_DEVICES) {
 +              unsigned int index = 0;
 +
 +              result = find_first_fip_state(0, &index);
 +              assert(result == 0);
 +              /* initialize dev_info */
 +              dev_info_pool[index].funcs = &fip_dev_funcs;
 +              dev_info_pool[index].info =
 +                              (uintptr_t)&state_pool[index];
 +              *dev_info = &dev_info_pool[index];
 +              ++fip_dev_count;
 +      }
 +
 +      return result;
 +}
  
 -/* Open a connection to the FIP device */
 -static int fip_dev_open(const uintptr_t dev_spec __unused,
 +/* Release a device info to the pool */
 +static int free_dev_info(io_dev_info_t *dev_info)
 +{
 +      int result;
 +      unsigned int index = 0;
 +      fip_dev_state_t *state;
 +
 +      assert(dev_info != NULL);
 +
 +      state = (fip_dev_state_t *)dev_info->info;
 +      result = find_first_fip_state(state->dev_spec, &index);
 +      if (result ==  0) {
 +              /* free if device info is valid */
 +              zeromem(state, sizeof(fip_dev_state_t));
 +              --fip_dev_count;
 +      }
 +
 +      return result;
 +}
 +
 +/*
 + * Multiple FIP devices can be opened depending on the value of
 + * MAX_FIP_DEVICES. Given that there is only one backend, only a
 + * single file can be open at a time by any FIP device.
 + */
 +static int fip_dev_open(const uintptr_t dev_spec,
                         io_dev_info_t **dev_info)
  {
 +      int result;
 +      io_dev_info_t *info;
 +      fip_dev_state_t *state;
 +
        assert(dev_info != NULL);
 -      *dev_info = (io_dev_info_t *)&fip_dev_info; /* cast away const */
 +#if MAX_FIP_DEVICES > 1
 +      assert(dev_spec != (uintptr_t)NULL);
 +#endif
 +
 +      result = allocate_dev_info(&info);
 +      if (result != 0)
 +              return -ENOMEM;
 +
 +      state = (fip_dev_state_t *)info->info;
 +
 +      state->dev_spec = dev_spec;
 +
 +      *dev_info = info;
  
        return 0;
  }
@@@ -265,7 -165,7 +265,7 @@@ static int fip_dev_close(io_dev_info_t 
        backend_dev_handle = (uintptr_t)NULL;
        backend_image_spec = (uintptr_t)NULL;
  
 -      return 0;
 +      return free_dev_info(dev_info);
  }
  
  
@@@ -372,7 -272,6 +372,6 @@@ static int fip_file_read(io_entity_t *e
        uintptr_t backend_handle;
  
        assert(entity != NULL);
-       assert(buffer != (uintptr_t)NULL);
        assert(length_read != NULL);
        assert(entity->info != (uintptr_t)NULL);
  
@@@ -441,11 -340,7 +440,11 @@@ int register_io_dev_fip(const io_dev_co
        int result;
        assert(dev_con != NULL);
  
 -      result = io_register_device(&fip_dev_info);
 +      /*
 +       * Since dev_info isn't really used in io_register_device, always
 +       * use the same device info at here instead.
 +       */
 +      result = io_register_device(&dev_info_pool[0]);
        if (result == 0)
                *dev_con = &fip_dev_connector;
  
diff --combined maintainers.rst
index 638f66a7ce9d95ccfd3cbb23dcbddbb3a4f7aae9,702bbad55066f59f2eacc596617d4c792c11e70f..76fede821dd82efce3cb41a4d23f0e47551b560a
@@@ -20,8 -20,6 +20,8 @@@ Allwinner ARMv8 platform por
  -----------------------------
  :M: Andre Przywara <andre.przywara@arm.com>
  :G: `Andre-ARM`_
 +:M: Samuel Holland <samuel@sholland.org>
 +:G: `smaeul`_
  :F: docs/plat/allwinner.rst
  :F: plat/allwinner/
  
@@@ -66,6 -64,14 +66,14 @@@ MediaTek platform port
  :G: `mtk09422`_
  :F: plat/mediatek/
  
+ Marvell platform ports and SoC drivers
+ --------------------------------------
+ :M: Konstantin Porotchkin <kostap@marvell.com>
+ :G: `kostapr`_
+ :F: docs/plat/marvell/
+ :F: plat/marvell/
+ :F: drivers/marvell/
  NVidia platform ports
  ---------------------
  :M: Varun Wadekar <vwadekar@nvidia.com>
@@@ -165,13 -171,13 +173,14 @@@ Xilinx platform por
  .. _glneo: https://github.com/glneo
  .. _hzhuang1: https://github.com/hzhuang1
  .. _jenswi-linaro: https://github.com/jenswi-linaro
+ .. _kostapr: https://github.com/kostapr
  .. _masahir0y: https://github.com/masahir0y
  .. _mtk09422: https://github.com/mtk09422
  .. _qoriq-open-source: https://github.com/qoriq-open-source
  .. _rockchip-linux: https://github.com/rockchip-linux
  .. _shawnguo2: https://github.com/shawnguo2
  .. _sivadur: https://github.com/sivadur
 +.. _smaeul: https://github.com/smaeul
  .. _soby-mathew: https://github.com/soby-mathew
  .. _TonyXie06: https://github.com/TonyXie06
  .. _vwadekar: https://github.com/vwadekar